-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from cybersonic/develop
Keeping master up to date
- Loading branch information
Showing
16 changed files
with
444 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: java | ||
install: ant | ||
script: ant build | ||
deploy: | ||
provider: releases | ||
api_key: | ||
secure: VCztWP2Y9QQfbhXZvB/4GQ5yNVBLhm6Wm8fchfoFSWlEHk/CE1EcUFe2lcZRnp9kQ17aYXYpE5igrGoC/xq6iwwx+TFsFkBDLAoOuudAD41uxY1x4Lb/hlW8ex+BpRuBadgAc83xr3bfR7pSn8/0Y7WW9w4+Tj2nuotydMlLDmC78Zho1AeDpTwRwPKCzHd/uz7B/VN7MgUgOHuvHVjLL9OKbCX1BBaZN/5MY2rk5cG8uVsHYISDaraADUGxfXeiFe2GmScWt2vuCHQ+MB46WokUwwOdDbBZgr9Z6rOF2PQMNSYmPLxSEvWNFk/5v0LCjYpHpvPrqzz4TsTZ+FbUjzNPQk1DGlTkhJKWJvWi4KsBiQqjPcjZFuC9oD7ht92fYjbTge+88Wdhr3T+lwx5Yvu4VnUrGTPbpWrhhf8PbMUKh1FYyXByByj/k0BJEw7Su0JHGOZyVqQmvkx8MPX9Grxw16ohFrawJo97kKw1k/kGSeXr5ns9rW/e/yzTqqLJr+bW0H47lr5r/zxSGu8V6emVGf0D6JgZuCU/cpiPrnmcUmBdVKXsxNi83IaIc6kV1xZQ7ewuRgGkt39kd068LiJD9kJMVMOnxvYTTQy/wdaKeUbzvu/5tkddcQZfY+T1yTxaHUXj7D7INoFvlIXNO5H0k0XVE/dFOHZpa4AtrR8= | ||
file: dist/filecoverage-extension.lex | ||
on: | ||
repo: cybersonic/lucee-filecoverage-extension | ||
branch: develop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#Build Number for ANT. Do not edit! | ||
#Sat Jun 16 12:38:21 BST 2018 | ||
build.number=9 | ||
#Sat Jun 16 13:10:23 BST 2018 | ||
build.number=11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
<cfscript> | ||
Person = new Person(name="Mark", age=44); | ||
Person.called(); | ||
</cfscript><cfoutput>Hello #Person.getName()# #Person.getAge()# #Person.getName()#</cfoutput> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
component { | ||
this.name = "FileCoverage_" & Hash(getCurrentTemplatePath()); | ||
this.datasource = "codecoverage"; | ||
|
||
|
||
|
||
function onRequestStart(targetPage){ | ||
request.basePath = contractPath(getDirectoryFromPath(getCurrentTemplatePath())); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
component { | ||
|
||
variables.tablename = "lucee_filecoverage_extension"; | ||
variables.extensionfilter = "*.cf*"; | ||
|
||
//TODO: Add ignored foldders etc. | ||
|
||
public any function getCoverageForDirectory(String path, boolean recurse=false){ | ||
|
||
var delimiter = Right(Path,1) EQ "/"? "" : "/"; | ||
|
||
|
||
|
||
var files = DirectoryList(path,recurse,"query",variables.extensionfilter,"Name"); | ||
|
||
|
||
|
||
var results = { | ||
total: files.recordcount, | ||
accessed: 0 | ||
} | ||
|
||
|
||
loop query="files"{ | ||
//See if any of these have hits! | ||
var hitsForThisScript = getTotalHits(directory & "/" & name); | ||
|
||
if(hitsForThisScript){ | ||
results.accessed++; | ||
} | ||
|
||
} | ||
return results; | ||
} | ||
|
||
|
||
public any function getReportForDirectory(String path, boolean recurse=false){ | ||
|
||
|
||
//Directories need to be calculated differently, as we get a roll up of all files accesed underneath them rather than an exact match. | ||
|
||
var ret_files = []; | ||
var ret_dirs = []; | ||
|
||
var files = DirectoryList(path,recurse,"query",variables.extensionfilter,"name","all") | ||
|
||
for(file in files){ | ||
|
||
|
||
file["hits"] = getTotalHits(file.directory & "/" & file.name); | ||
ret_files.append(file); | ||
} | ||
|
||
|
||
|
||
var directories = DirectoryList(path,recurse, "query", "*","name", "dir"); | ||
|
||
for(dir in directories){ | ||
|
||
dir["hits"] = findTotalHits(dir.directory & "/" & dir.name); | ||
ret_dirs.append(dir); | ||
} | ||
|
||
|
||
|
||
return { | ||
files:ret_files, | ||
directories:ret_dirs | ||
} | ||
} | ||
|
||
function getInfoForFile(PathToFind){ | ||
var raw = queryExecute(sql:"SELECT * FROM #variables.tablename# WHERE FILEPATH = '#PathToFind#'"); | ||
|
||
var type = ListLast(PathToFind,".") EQ "cfc" ? "Component" : "Script"; | ||
|
||
var methods = {}; | ||
//Get metadata | ||
if(type EQ "Component"){ | ||
|
||
var dotPath = getDotPathFromPath(PathToFind); | ||
var componentMetaData = getComponentMetadata(dotPath); | ||
|
||
for(func in componentMetaData.functions){ | ||
methods[func.name] = 0; | ||
} | ||
|
||
raw.each(function(item, index, query){ | ||
|
||
if(Len(Trim(item.method))){ | ||
methods[item.method] = methods[item.method]+item.count; | ||
} | ||
|
||
}); | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
var count = raw.reduce(function(hits=0,cols,index,query){ | ||
return hits + cols.count; | ||
}); | ||
|
||
|
||
|
||
return { | ||
raw: raw, | ||
summary: { | ||
name: getFileFromPath(PathToFind), | ||
directory: getDirectoryFromPath(PathToFind), | ||
type: type, | ||
methods: methods, | ||
hits: count, | ||
source: FileRead(PathToFind) | ||
} | ||
} | ||
} | ||
|
||
|
||
function getDotPathFromPath(PathToFind){ | ||
var dotPath = contractPath(PathToFind); | ||
dotPath = listDeleteAt(dotPath, ListLen(dotPath, "."),"."); | ||
dotPath = listTrim(dotPath,"/"); | ||
dotPath = Replace(dotPath, "/", ".", "all"); | ||
|
||
return dotPath; | ||
} | ||
|
||
//Exact match for a file search | ||
function getTotalHits(PathToFind){ | ||
|
||
var found = queryExecute(sql:"SELECT SUM(count) AS hits FROM #variables.tablename# WHERE FILEPATH = '#PathToFind#'"); | ||
|
||
|
||
if(!isNumeric(found.hits)){ | ||
return 0; | ||
} | ||
return found.hits; | ||
} | ||
|
||
//Finds all the matches of path% rather than an exact match | ||
function findTotalHits(PathToFind){ | ||
|
||
var found = queryExecute(sql:"SELECT SUM(count) AS hits FROM #variables.tablename# WHERE FILEPATH LIKE '#PathToFind#%'"); | ||
|
||
if(!isNumeric(found.hits)){ | ||
return 0; | ||
} | ||
return found.hits; | ||
} | ||
|
||
function deleteCoverage(){ | ||
var found = queryExecute(sql:"DELETE FROM #variables.tablename#"); | ||
writeDump(getAll()); | ||
|
||
} | ||
|
||
function createCoverageTable(){ | ||
var createDBTable = queryExecute( | ||
sql:"DROP TABLE IF EXISTS PUBLIC.#variables.tablename#" | ||
); | ||
|
||
var createDBTable = queryExecute( | ||
sql:"CREATE CACHED TABLE IF NOT EXISTS PUBLIC.#variables.tablename#( | ||
ID BIGINT auto_increment, | ||
SRC VARCHAR(500), | ||
FILEPATH VARCHAR(500), | ||
METHOD VARCHAR(255), | ||
COUNT INT, | ||
MIN INT, | ||
MAX INT, | ||
AVG INT, | ||
APP INT, | ||
LOAD INT, | ||
QUERY INT, | ||
TOTAL INT, | ||
HASH VARCHAR(100) | ||
) | ||
" | ||
); | ||
} | ||
|
||
function getAll(){ | ||
return queryExecute(sql:"SELECT * FROM #variables.tablename#"); | ||
} | ||
|
||
} |
Oops, something went wrong.