tool-shed 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +3 -1
- data/Gemfile.lock +82 -0
- data/README.md +7 -5
- data/bin/as-asset-detector +0 -0
- data/lib/shed/asdoc_package.rb +1 -1
- data/lib/shed/manifest.rb +12 -4
- data/lib/shed/opts/manifest_opts.rb +11 -4
- data/lib/shed/opts/tool_opts.rb +8 -5
- data/lib/shed/opts/unused_asset_opts.rb +1 -1
- data/lib/shed/opts/unused_class_opts.rb +16 -1
- data/lib/shed/opts/unused_style_opts.rb +1 -1
- data/lib/shed/search.rb +6 -5
- data/lib/shed/tool.rb +16 -3
- data/lib/shed/unused_asset.rb +37 -12
- data/lib/shed/unused_class.rb +4 -4
- data/lib/shed/version.rb +1 -1
- data/rakefile.rb +20 -84
- data/test/fixtures/unused-asset/src/org/helvector/ToolBox.mxml +4 -0
- data/test/test_helper.rb +13 -0
- data/test/unit/test_manifest.rb +23 -2
- data/test/unit/test_manifest_opts.rb +15 -0
- data/test/unit/test_search.rb +16 -4
- data/test/unit/test_unused_asset.rb +24 -14
- data/test/unit/test_unused_class_opts.rb +28 -1
- metadata +41 -69
- data/coverage/unit/index.html +0 -330
- data/coverage/unit/jquery-1.3.2.min.js +0 -19
- data/coverage/unit/jquery.tablesorter.min.js +0 -15
- data/coverage/unit/lib-hel-asdoc_package_rb.html +0 -447
- data/coverage/unit/lib-hel-manifest_rb.html +0 -555
- data/coverage/unit/lib-hel-opts-asdoc_package_opts_rb.html +0 -195
- data/coverage/unit/lib-hel-opts-manifest_opts_rb.html +0 -195
- data/coverage/unit/lib-hel-opts-tool_opts_rb.html +0 -531
- data/coverage/unit/lib-hel-opts-unused_class_opts_rb.html +0 -207
- data/coverage/unit/lib-hel-opts-unused_style_opts_rb.html +0 -201
- data/coverage/unit/lib-hel-project_tools_rb.html +0 -423
- data/coverage/unit/lib-hel-search_rb.html +0 -363
- data/coverage/unit/lib-hel-stripper_rb.html +0 -357
- data/coverage/unit/lib-hel-tool_rb.html +0 -423
- data/coverage/unit/lib-hel-unused_class_rb.html +0 -675
- data/coverage/unit/lib-hel-unused_style_rb.html +0 -747
- data/coverage/unit/lib-hel-version_rb.html +0 -135
- data/coverage/unit/lib-hel_tools_rb.html +0 -165
- data/coverage/unit/print.css +0 -12
- data/coverage/unit/rcov.js +0 -42
- data/coverage/unit/screen.css +0 -270
- data/coverage.data +0 -0
- data/rdoc/classes/ASDocPackage.html +0 -281
- data/rdoc/classes/ASDocPackageOpts.html +0 -204
- data/rdoc/classes/Manifest.html +0 -323
- data/rdoc/classes/ManifestOpts.html +0 -205
- data/rdoc/classes/ProjectTools.html +0 -302
- data/rdoc/classes/Search.html +0 -203
- data/rdoc/classes/Stripper.html +0 -223
- data/rdoc/classes/Tool.html +0 -313
- data/rdoc/classes/ToolOpts.html +0 -297
- data/rdoc/classes/UnusedClass.html +0 -258
- data/rdoc/classes/UnusedClassOpts.html +0 -206
- data/rdoc/classes/UnusedStyle.html +0 -277
- data/rdoc/classes/UnusedStyleOpts.html +0 -205
- data/rdoc/created.rid +0 -1
- data/rdoc/files/LICENSE.html +0 -129
- data/rdoc/files/README_md.html +0 -138
- data/rdoc/files/lib/hel/asdoc_package_rb.html +0 -107
- data/rdoc/files/lib/hel/manifest_rb.html +0 -107
- data/rdoc/files/lib/hel/opts/asdoc_package_opts_rb.html +0 -107
- data/rdoc/files/lib/hel/opts/manifest_opts_rb.html +0 -107
- data/rdoc/files/lib/hel/opts/tool_opts_rb.html +0 -114
- data/rdoc/files/lib/hel/opts/unused_class_opts_rb.html +0 -107
- data/rdoc/files/lib/hel/opts/unused_style_opts_rb.html +0 -107
- data/rdoc/files/lib/hel/project_tools_rb.html +0 -107
- data/rdoc/files/lib/hel/search_rb.html +0 -114
- data/rdoc/files/lib/hel/stripper_rb.html +0 -107
- data/rdoc/files/lib/hel/tool_rb.html +0 -107
- data/rdoc/files/lib/hel/unused_class_rb.html +0 -107
- data/rdoc/files/lib/hel/unused_style_rb.html +0 -107
- data/rdoc/files/lib/hel/version_rb.html +0 -107
- data/rdoc/files/lib/hel_tools_rb.html +0 -127
- data/rdoc/fr_class_index.html +0 -39
- data/rdoc/fr_file_index.html +0 -43
- data/rdoc/fr_method_index.html +0 -75
- data/rdoc/index.html +0 -24
- data/rdoc/rdoc-style.css +0 -208
- data/tool-shed-0.0.3.gem +0 -0
- data/tool-shed.gemspec +0 -41
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: http://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
Saikuro (1.1.0)
|
|
5
|
+
activesupport (3.0.3)
|
|
6
|
+
arrayfields (4.7.4)
|
|
7
|
+
builder (3.0.0)
|
|
8
|
+
chronic (0.2.3)
|
|
9
|
+
hoe (>= 1.2.1)
|
|
10
|
+
churn (0.0.12)
|
|
11
|
+
chronic (~> 0.2.3)
|
|
12
|
+
hirb
|
|
13
|
+
json_pure
|
|
14
|
+
main
|
|
15
|
+
ruby_parser (~> 2.0.4)
|
|
16
|
+
sexp_processor (~> 3.0.3)
|
|
17
|
+
ci_reporter (1.6.3)
|
|
18
|
+
builder (>= 2.1.2)
|
|
19
|
+
colored (1.2)
|
|
20
|
+
fattr (2.2.0)
|
|
21
|
+
flay (1.4.1)
|
|
22
|
+
ruby_parser (~> 2.0)
|
|
23
|
+
sexp_processor (~> 3.0)
|
|
24
|
+
flog (2.5.0)
|
|
25
|
+
ruby_parser (~> 2.0)
|
|
26
|
+
sexp_processor (~> 3.0)
|
|
27
|
+
hirb (0.3.5)
|
|
28
|
+
hoe (2.7.0)
|
|
29
|
+
rake (>= 0.8.7)
|
|
30
|
+
rubyforge (>= 2.0.4)
|
|
31
|
+
i18n (0.4.2)
|
|
32
|
+
json_pure (1.4.6)
|
|
33
|
+
main (4.3.0)
|
|
34
|
+
arrayfields (>= 4.7.4)
|
|
35
|
+
fattr (>= 2.1.0)
|
|
36
|
+
metric_fu (2.0.1)
|
|
37
|
+
Saikuro (>= 1.1.0)
|
|
38
|
+
activesupport (>= 2.0.0)
|
|
39
|
+
chronic (~> 0.2.3)
|
|
40
|
+
churn (>= 0.0.7)
|
|
41
|
+
flay (>= 1.2.1)
|
|
42
|
+
flog (>= 2.2.0)
|
|
43
|
+
rails_best_practices (>= 0.3.16)
|
|
44
|
+
rcov (>= 0.8.3.3)
|
|
45
|
+
reek (>= 1.2.6)
|
|
46
|
+
roodi (>= 2.1.0)
|
|
47
|
+
mocha (0.9.9)
|
|
48
|
+
rake
|
|
49
|
+
progressbar (0.9.0)
|
|
50
|
+
rails_best_practices (0.5.0)
|
|
51
|
+
activesupport
|
|
52
|
+
colored (~> 1.2)
|
|
53
|
+
progressbar (~> 0.9.0)
|
|
54
|
+
ruby_parser (~> 2.0.4)
|
|
55
|
+
rake (0.8.7)
|
|
56
|
+
rcov (0.9.9)
|
|
57
|
+
reek (1.2.8)
|
|
58
|
+
ruby2ruby (~> 1.2)
|
|
59
|
+
ruby_parser (~> 2.0)
|
|
60
|
+
sexp_processor (~> 3.0)
|
|
61
|
+
roodi (2.1.0)
|
|
62
|
+
ruby_parser
|
|
63
|
+
ruby2ruby (1.2.5)
|
|
64
|
+
ruby_parser (~> 2.0)
|
|
65
|
+
sexp_processor (~> 3.0)
|
|
66
|
+
ruby_parser (2.0.5)
|
|
67
|
+
sexp_processor (~> 3.0)
|
|
68
|
+
rubyforge (2.0.4)
|
|
69
|
+
json_pure (>= 1.1.7)
|
|
70
|
+
sexp_processor (3.0.5)
|
|
71
|
+
shoulda (2.11.3)
|
|
72
|
+
|
|
73
|
+
PLATFORMS
|
|
74
|
+
ruby
|
|
75
|
+
|
|
76
|
+
DEPENDENCIES
|
|
77
|
+
ci_reporter
|
|
78
|
+
i18n
|
|
79
|
+
metric_fu
|
|
80
|
+
mocha
|
|
81
|
+
rake
|
|
82
|
+
shoulda
|
data/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Tool Shed
|
|
2
2
|
|
|
3
|
-
A collection of utility scripts
|
|
3
|
+
A collection of utility scripts to help working with ActionScript and Flex
|
|
4
|
+
projects. These scripts are under development, so **don't** expect reliability.
|
|
4
5
|
|
|
5
6
|
### as-docp
|
|
6
7
|
|
|
@@ -40,13 +41,14 @@ tree but are no longer referenced by the application.
|
|
|
40
41
|
|
|
41
42
|
## Using
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
Examples will follow once the tools are in a stable state.
|
|
45
|
+
|
|
45
46
|
## Authors
|
|
46
47
|
|
|
47
48
|
[Simon Gregory](http://simongregory.com)
|
|
48
49
|
|
|
49
50
|
## License
|
|
50
51
|
|
|
51
|
-
Released under the MIT License. Please see the accompanying LICENSE document for
|
|
52
|
+
Released under the MIT License. Please see the accompanying [LICENSE](LICENSE) document for
|
|
52
53
|
details.
|
|
54
|
+
|
data/bin/as-asset-detector
CHANGED
|
File without changes
|
data/lib/shed/asdoc_package.rb
CHANGED
|
@@ -13,7 +13,7 @@ class ASDocPackage < Tool
|
|
|
13
13
|
|
|
14
14
|
@asdoc = /\.asdoc$/
|
|
15
15
|
|
|
16
|
-
@header = "<?xml version='1.0' encoding='utf-8'?>\n<flex-config>\n\t<packages
|
|
16
|
+
@header = "<?xml version='1.0' encoding='utf-8'?>\n<flex-config>\n\t<packages>\n"
|
|
17
17
|
@package = "\t\t<package>\n\t\t\t<string>%s</string>\n\t\t\t<string><![CDATA[%s]]></string>\n\t\t</package>\n"
|
|
18
18
|
@footer = "\t</packages>\n</flex-config>"
|
|
19
19
|
|
data/lib/shed/manifest.rb
CHANGED
|
@@ -13,6 +13,7 @@ class Manifest < Tool
|
|
|
13
13
|
super(opt,out)
|
|
14
14
|
|
|
15
15
|
@filetypes = /\.(as|mxml)$/
|
|
16
|
+
@filter = opt[:filter] || ''
|
|
16
17
|
|
|
17
18
|
build
|
|
18
19
|
end
|
|
@@ -45,11 +46,21 @@ class Manifest < Tool
|
|
|
45
46
|
found << add(p, cn) if cn =~ /^[A-Z]/
|
|
46
47
|
end
|
|
47
48
|
|
|
48
|
-
found
|
|
49
|
+
found = process(found) unless found.empty?
|
|
49
50
|
|
|
50
51
|
found
|
|
51
52
|
end
|
|
52
53
|
|
|
54
|
+
#
|
|
55
|
+
# Proccesses the list to remove duplicates, sort alphabetically and reject any
|
|
56
|
+
# items that do not match the filter.
|
|
57
|
+
#
|
|
58
|
+
def process(list)
|
|
59
|
+
list.uniq!
|
|
60
|
+
list.sort! {|a,b| a[:xml] <=> b[:xml] }
|
|
61
|
+
list.select { |e| e[:xml].include?(@filter) }
|
|
62
|
+
end
|
|
63
|
+
|
|
53
64
|
#
|
|
54
65
|
# Build the manifest file and save it to disk.
|
|
55
66
|
#
|
|
@@ -59,9 +70,6 @@ class Manifest < Tool
|
|
|
59
70
|
if @components.empty?
|
|
60
71
|
puts "No ActionScript or Mxml files found."
|
|
61
72
|
else
|
|
62
|
-
|
|
63
|
-
@components.sort! {|a,b| a[:xml] <=> b[:xml] }
|
|
64
|
-
|
|
65
73
|
@xml = create_xml(@components)
|
|
66
74
|
|
|
67
75
|
#Open/Create the manifest file and write the output to it.
|
|
@@ -5,18 +5,25 @@
|
|
|
5
5
|
#
|
|
6
6
|
class ManifestOpts < ToolOpts
|
|
7
7
|
|
|
8
|
-
def self.description
|
|
9
|
-
"ActionScript Manifest Generator Tool"
|
|
10
|
-
end
|
|
11
|
-
|
|
12
8
|
def self.name
|
|
13
9
|
"as-manifest"
|
|
14
10
|
end
|
|
15
11
|
|
|
12
|
+
def self.description
|
|
13
|
+
"ActionScript Manifest Generator Tool"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
16
|
def self.default_config
|
|
17
17
|
dc = superclass.default_config
|
|
18
18
|
dc[:output] = "manifest.xml"
|
|
19
19
|
dc
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def self.add_optional(op,config)
|
|
23
|
+
superclass.add_optional(op,config)
|
|
24
|
+
op.on("-f", "--filter [STRING]", String, "Package filter, in the form of 'org.helvector', to include in the generated manifest.") do |v|
|
|
25
|
+
config[:filter] = v
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
22
29
|
end
|
data/lib/shed/opts/tool_opts.rb
CHANGED
|
@@ -19,7 +19,7 @@ class ToolOpts
|
|
|
19
19
|
# A basic description of the tools use.
|
|
20
20
|
#
|
|
21
21
|
def self.description
|
|
22
|
-
'
|
|
22
|
+
'Abstract tool from the tool shed.'
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
#
|
|
@@ -68,11 +68,11 @@ class ToolOpts
|
|
|
68
68
|
config[:src] = v
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
op.on("-o", "--output [FILE
|
|
71
|
+
op.on("-o", "--output [FILE]", String, "Path to output file, defaults to #{config[:output]}.") do |v|
|
|
72
72
|
config[:output] = v
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
op.on("-v", "--verbose", "Run verbosely") do |v|
|
|
75
|
+
op.on("-v", "--verbose", "Run verbosely.") do |v|
|
|
76
76
|
config[:verbose] = v
|
|
77
77
|
end
|
|
78
78
|
|
|
@@ -81,13 +81,16 @@ class ToolOpts
|
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
+
#
|
|
85
|
+
# Add tail arguments to the options parser.
|
|
86
|
+
#
|
|
84
87
|
def self.add_tail(op,out)
|
|
85
|
-
op.on_tail("-h", "--help", "Show this help message") do
|
|
88
|
+
op.on_tail("-h", "--help", "Show this help message.") do
|
|
86
89
|
out.puts op
|
|
87
90
|
exit
|
|
88
91
|
end
|
|
89
92
|
|
|
90
|
-
op.on_tail("--version", "Show version") do
|
|
93
|
+
op.on_tail("--version", "Show version.") do
|
|
91
94
|
out.puts "#{description} version #{version}"
|
|
92
95
|
exit
|
|
93
96
|
end
|
|
@@ -15,10 +15,25 @@ class UnusedClassOpts < ToolOpts
|
|
|
15
15
|
|
|
16
16
|
def self.default_config
|
|
17
17
|
dc = superclass.default_config
|
|
18
|
-
dc[:output] = '
|
|
18
|
+
dc[:output] = 'class-vaccum.txt'
|
|
19
19
|
dc[:manifest] = 'manifest.xml'
|
|
20
20
|
dc[:link_report] = 'link-report.xml'
|
|
21
21
|
dc
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
#
|
|
25
|
+
# Add all mandatory arguments to the options parser.
|
|
26
|
+
#
|
|
27
|
+
def self.add_mandatory(op,config)
|
|
28
|
+
superclass.add_mandatory(op,config)
|
|
29
|
+
|
|
30
|
+
op.on("-m", "--manifest FILE", "Path to the source manifest file.") do |v|
|
|
31
|
+
config[:manifest] = v
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
op.on("-l", "--link-report FILE", "Path to the compiler link-report file.") do |v|
|
|
35
|
+
config[:link_report] = v
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
24
39
|
end
|
data/lib/shed/search.rb
CHANGED
|
@@ -31,20 +31,21 @@ module Search
|
|
|
31
31
|
#
|
|
32
32
|
# Scans the path and its children for empty directories.
|
|
33
33
|
#
|
|
34
|
-
def self.for_empties(
|
|
34
|
+
def self.for_empties(dir,excluding=['.svn','.git'])
|
|
35
35
|
|
|
36
|
-
Find.find(
|
|
36
|
+
Find.find(dir) do |path|
|
|
37
37
|
|
|
38
|
-
if FileTest.directory?(
|
|
39
|
-
if excluding.include?(File.basename(
|
|
38
|
+
if FileTest.directory?(path)
|
|
39
|
+
if excluding.include?(File.basename(path))
|
|
40
40
|
Find.prune
|
|
41
41
|
else
|
|
42
42
|
# Any dir that only contains ., .., and .svn or .git are empty.
|
|
43
|
-
yield
|
|
43
|
+
yield path if Dir.entries(path).join =~ /^\.\.\.(\.(svn|git))?$/
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
end
|
|
50
|
+
|
|
50
51
|
end
|
data/lib/shed/tool.rb
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
#
|
|
4
|
-
# Abstract base class for tools. Provides basic default settings,
|
|
5
|
-
# control over the level of logging to standard out
|
|
4
|
+
# Abstract base class for tools. Provides basic default settings, allows
|
|
5
|
+
# control over the level of logging to standard out, and installs a sig int
|
|
6
|
+
# handler.
|
|
6
7
|
#
|
|
7
8
|
class Tool
|
|
8
9
|
|
|
9
|
-
INVALID_OPTS = "
|
|
10
|
+
INVALID_OPTS = "Invalid options:"
|
|
10
11
|
|
|
11
12
|
def initialize(opt,out=STDOUT)
|
|
12
13
|
@src = opt[:src] || '.'
|
|
@@ -15,6 +16,8 @@ class Tool
|
|
|
15
16
|
@silent = opt[:silent] || false
|
|
16
17
|
@excludes = opt[:excludes] || ['.svn','.git']
|
|
17
18
|
@out = out
|
|
19
|
+
|
|
20
|
+
add_sigint_handler
|
|
18
21
|
end
|
|
19
22
|
|
|
20
23
|
#
|
|
@@ -57,4 +60,14 @@ class Tool
|
|
|
57
60
|
"Generated at" + Time.now.strftime(" [%m/%d/%Y %H:%M:%S] ")
|
|
58
61
|
end
|
|
59
62
|
|
|
63
|
+
#
|
|
64
|
+
# Installs a sigint handler.
|
|
65
|
+
#
|
|
66
|
+
def add_sigint_handler
|
|
67
|
+
trap 'INT' do
|
|
68
|
+
puts '\nCancelled. Bye Bye!'
|
|
69
|
+
exit!
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
60
73
|
end
|
data/lib/shed/unused_asset.rb
CHANGED
|
@@ -6,46 +6,71 @@
|
|
|
6
6
|
# no longer used by the application.
|
|
7
7
|
#
|
|
8
8
|
class UnusedAsset < Tool
|
|
9
|
+
attr_reader :assets, :src_files, :declared, :unused
|
|
10
|
+
|
|
9
11
|
def initialize(opt,out=STDOUT)
|
|
10
12
|
super(opt,out)
|
|
11
13
|
|
|
12
|
-
@
|
|
13
|
-
@
|
|
14
|
+
@project_dir = opt[:project_dir]
|
|
15
|
+
@assets = []
|
|
16
|
+
@src_files = []
|
|
17
|
+
@declared = []
|
|
14
18
|
|
|
15
19
|
unless valid_opts
|
|
16
|
-
@out.puts "#{INVALID_OPTS} One or all of specified
|
|
20
|
+
@out.puts "#{INVALID_OPTS} One or all of specified asset and source directories does not exist."
|
|
17
21
|
return
|
|
18
22
|
end
|
|
19
23
|
|
|
20
|
-
@declared_regex =
|
|
24
|
+
@declared_regex = /Embed\(source='([\w.\/]+)'/
|
|
21
25
|
|
|
22
26
|
detect
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
#@report = describe
|
|
25
29
|
|
|
26
|
-
to_disk(@report)
|
|
30
|
+
#to_disk(@report)
|
|
27
31
|
end
|
|
28
32
|
|
|
29
33
|
def valid_opts
|
|
30
|
-
File.exist?(@
|
|
34
|
+
File.exist?(@project_dir) rescue false
|
|
31
35
|
end
|
|
32
36
|
|
|
37
|
+
private
|
|
38
|
+
|
|
33
39
|
def detect
|
|
34
|
-
|
|
40
|
+
Search.find_all(/\.(jpg|jpeg|png|otf)$/,@project_dir,@excludes) do |path|
|
|
41
|
+
@assets << path
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
@declared = scan_dirs(/\.(css|as|mxml)$/, @project_dir, @declared_regex)
|
|
45
|
+
|
|
46
|
+
@unused = []
|
|
47
|
+
|
|
48
|
+
@assets.each { |a|
|
|
49
|
+
@unused << a unless is_used(a)
|
|
50
|
+
}
|
|
35
51
|
end
|
|
36
52
|
|
|
37
|
-
|
|
53
|
+
def is_used(file)
|
|
54
|
+
used = false
|
|
55
|
+
@declared.each { |f|
|
|
56
|
+
if File.basename(f) == File.basename(file)
|
|
57
|
+
used = true
|
|
58
|
+
end
|
|
59
|
+
}
|
|
60
|
+
used
|
|
61
|
+
end
|
|
38
62
|
|
|
39
63
|
#
|
|
40
64
|
# Scans directories for all files that match the file extension regex, and
|
|
41
65
|
# for each match goes on to scan that document for items matching the syntax
|
|
42
66
|
# regex.
|
|
43
67
|
#
|
|
44
|
-
def scan_dirs(
|
|
68
|
+
def scan_dirs(file_ext_regex,path,syntax_regex)
|
|
45
69
|
d = []
|
|
46
70
|
|
|
47
|
-
Search.find_all(
|
|
48
|
-
|
|
71
|
+
Search.find_all(file_ext_regex,path,@excludes) do |p|
|
|
72
|
+
@src_files << p
|
|
73
|
+
d << scan_doc(p,syntax_regex)
|
|
49
74
|
end
|
|
50
75
|
|
|
51
76
|
d.flatten!.sort!.uniq! unless d.empty?
|
data/lib/shed/unused_class.rb
CHANGED
|
@@ -65,9 +65,9 @@ class UnusedClass < Tool
|
|
|
65
65
|
# Returns a string detailing the findings of the unused class detection.
|
|
66
66
|
#
|
|
67
67
|
def describe
|
|
68
|
-
d = generated_at
|
|
69
|
-
d << add_desc("
|
|
70
|
-
d << add_desc("
|
|
68
|
+
d = "as-class-vaccum Report. #{generated_at}\n\n"
|
|
69
|
+
d << add_desc("classes are in the manifest but not in the link report:", @unused_classes)
|
|
70
|
+
d << add_desc("packages appear to be empty:", @empty_packages)
|
|
71
71
|
d
|
|
72
72
|
end
|
|
73
73
|
|
|
@@ -76,7 +76,7 @@ class UnusedClass < Tool
|
|
|
76
76
|
#
|
|
77
77
|
def add_desc(txt,list)
|
|
78
78
|
l = list.empty? ? '' : list.join("\n")
|
|
79
|
-
"#{list.length} #{txt}\n#{l}"
|
|
79
|
+
"#{list.length} #{txt}\n#{l}\n\n"
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
#
|
data/lib/shed/version.rb
CHANGED
data/rakefile.rb
CHANGED
|
@@ -3,12 +3,26 @@ require 'bundler'
|
|
|
3
3
|
|
|
4
4
|
Bundler.require
|
|
5
5
|
|
|
6
|
+
require 'metric_fu'
|
|
7
|
+
|
|
6
8
|
require 'rake/clean'
|
|
7
9
|
require 'rake/testtask'
|
|
8
10
|
require 'rake/rdoctask'
|
|
9
11
|
|
|
12
|
+
ENV['CI_REPORTS'] = 'tmp/reports' #Hide these here for now...
|
|
13
|
+
require 'ci/reporter/rake/test_unit'
|
|
14
|
+
|
|
10
15
|
require File.dirname(__FILE__) + '/lib/shed/version'
|
|
11
16
|
|
|
17
|
+
MetricFu::Configuration.run do |config|
|
|
18
|
+
config.rcov[:test_files] = ['test/unit/**/test_*.rb']
|
|
19
|
+
config.flay ={:dirs_to_flay => ['lib'],
|
|
20
|
+
:minimum_score => 10,
|
|
21
|
+
:filetypes => ['rb'] }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
CLEAN.add('tmp')
|
|
25
|
+
|
|
12
26
|
Rake::RDocTask.new do |rdoc|
|
|
13
27
|
rdoc.title = " ActionScript Tools v.#{ToolShed::VERSION::STRING}"
|
|
14
28
|
rdoc.rdoc_dir = 'rdoc'
|
|
@@ -16,94 +30,16 @@ Rake::RDocTask.new do |rdoc|
|
|
|
16
30
|
rdoc.rdoc_files.include("README.md", "LICENSE", "lib/**/*.rb")
|
|
17
31
|
end
|
|
18
32
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
test.libs << "test"
|
|
24
|
-
test.test_files = Dir["test/unit/test_*.rb"]
|
|
25
|
-
test.verbose = true
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Thanks to Project Sprouts and Luke Bayes for the coverage, flog
|
|
29
|
-
# and flay tasks below.
|
|
30
|
-
#
|
|
31
|
-
namespace :coverage do
|
|
32
|
-
desc "Delete aggregate coverage data."
|
|
33
|
-
task(:clean) { rm_f "coverage.data" }
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Apparently, rcov does not work on Windows or Ubuntu?
|
|
37
|
-
# Hide these tasks so that we can at least
|
|
38
|
-
# run the others...
|
|
39
|
-
if(RUBY_PLATFORM =~ /darwin/i)
|
|
40
|
-
require 'rcov/rcovtask'
|
|
41
|
-
|
|
42
|
-
CLEAN.add('coverage.data')
|
|
43
|
-
CLEAN.add('coverage')
|
|
44
|
-
|
|
45
|
-
# Hold collection in case we need it:
|
|
46
|
-
#%w[unit functional integration].each do |target|
|
|
47
|
-
%w[unit].each do |target|
|
|
48
|
-
namespace :coverage do
|
|
49
|
-
Rcov::RcovTask.new(target) do |t|
|
|
50
|
-
t.libs = ["lib", "test"]
|
|
51
|
-
t.test_files = FileList["test/#{target}/**/test_*.rb"]
|
|
52
|
-
t.output_dir = "coverage/#{target}"
|
|
53
|
-
t.verbose = true
|
|
54
|
-
t.rcov_opts = ["--sort coverage",
|
|
55
|
-
"--aggregate coverage.data",
|
|
56
|
-
"--exclude .bundle",
|
|
57
|
-
"--exclude .gem",
|
|
58
|
-
"--exclude errors.rb",
|
|
59
|
-
"--exclude progress_bar.rb"]
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
task :coverage => "test:coverage:#{target}"
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
namespace :torture do
|
|
67
|
-
desc "Flog the Sprouts"
|
|
68
|
-
task :flog do
|
|
69
|
-
puts "--------------------------"
|
|
70
|
-
puts "Flog Report:"
|
|
71
|
-
message =<<EOM
|
|
72
|
-
According to Jake Scruggs at http://bit.ly/3QrvW a
|
|
73
|
-
method average score of:
|
|
74
|
-
|
|
75
|
-
Score Means
|
|
76
|
-
0-10 Awesome
|
|
77
|
-
11-20 Good enough
|
|
78
|
-
21-40 Might need refactoring
|
|
79
|
-
41-60 Possible to justify
|
|
80
|
-
61-100 Danger
|
|
81
|
-
100-200 Whoop, whoop, whoop
|
|
82
|
-
200 + Someone please think of the children
|
|
83
|
-
EOM
|
|
84
|
-
puts message
|
|
85
|
-
puts ""
|
|
86
|
-
|
|
87
|
-
sh "find lib -name '*.rb' | xargs flog"
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
desc "Flay the Sprouts"
|
|
91
|
-
task :flay do
|
|
92
|
-
puts "--------------------------"
|
|
93
|
-
puts "Flay Report:"
|
|
94
|
-
sh "flay lib/**/*.rb"
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
desc "Run all tortuous reports"
|
|
99
|
-
task :torture => ['torture:flog', 'torture:flay']
|
|
100
|
-
|
|
33
|
+
Rake::TestTask.new(:test) do |test|
|
|
34
|
+
test.libs << "test"
|
|
35
|
+
test.test_files = Dir["test/unit/test_*.rb"]
|
|
36
|
+
test.verbose = true
|
|
101
37
|
end
|
|
102
38
|
|
|
103
|
-
|
|
39
|
+
CLEAN.add('rdoc')
|
|
104
40
|
|
|
105
41
|
desc "Default"
|
|
106
42
|
task :default => [:test]
|
|
107
43
|
|
|
108
44
|
desc "Run all tests and reports"
|
|
109
|
-
task :
|
|
45
|
+
task :hudson => ['ci:setup:testunit', :test, 'metrics:all']
|
data/test/test_helper.rb
CHANGED
|
@@ -7,3 +7,16 @@ require 'tool_shed'
|
|
|
7
7
|
require 'bundler'
|
|
8
8
|
|
|
9
9
|
Bundler.require :development
|
|
10
|
+
|
|
11
|
+
#Create empty directories for the unit tests, as Git ignores empty directories.
|
|
12
|
+
empties = ['test/fixtures/empty/borg',
|
|
13
|
+
'test/fixtures/empty/org',
|
|
14
|
+
'test/fixtures/empty/xorg',
|
|
15
|
+
'test/fixtures/empty/zorg',
|
|
16
|
+
'test/fixtures/unused-cla/src/org',
|
|
17
|
+
'test/fixtures/empty/sorg/.svn/sub/verted',
|
|
18
|
+
'test/fixtures/empty/gorg/.git/head']
|
|
19
|
+
|
|
20
|
+
empties.each { |f|
|
|
21
|
+
`mkdir -p #{f}` unless File.exists?("#{f}")
|
|
22
|
+
}
|
data/test/unit/test_manifest.rb
CHANGED
|
@@ -18,7 +18,6 @@ class ManifestTest < Test::Unit::TestCase
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
should "find all actionscript and .mxml files in src tree" do
|
|
21
|
-
|
|
22
21
|
assert_equal(false, @manf.xml.empty?)
|
|
23
22
|
assert((@manf.components.length > 1))
|
|
24
23
|
assert((@manf.components.length == 5))
|
|
@@ -27,7 +26,6 @@ class ManifestTest < Test::Unit::TestCase
|
|
|
27
26
|
assert_match(/org\.helvector\.one\.HelOne/, @manf.xml)
|
|
28
27
|
assert_match(/org\.helvector\.three\.HelThree/, @manf.xml)
|
|
29
28
|
assert_match(/org\.helvector\.Helvector/, @manf.xml)
|
|
30
|
-
|
|
31
29
|
end
|
|
32
30
|
|
|
33
31
|
should "write the results to disk" do
|
|
@@ -50,4 +48,27 @@ class ManifestTest < Test::Unit::TestCase
|
|
|
50
48
|
end
|
|
51
49
|
end
|
|
52
50
|
|
|
51
|
+
context "A manifest builder invoked with a filter" do
|
|
52
|
+
setup do
|
|
53
|
+
@output = '/tmp/as-manifest-tool-test.xml'
|
|
54
|
+
src = File.expand_path(File.dirname(__FILE__)+ "/../fixtures/src")
|
|
55
|
+
opts = ManifestOpts.parse ['-s', src,'-o', @output, '-f', 'org.helvector.one', '--silent']
|
|
56
|
+
@manf = Manifest.new(opts)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
teardown do
|
|
60
|
+
File.delete @output if File.exist?(@output)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
should "only include files in the filter" do
|
|
64
|
+
assert_equal(false, @manf.xml.empty?)
|
|
65
|
+
assert((@manf.components.length > 1))
|
|
66
|
+
assert((@manf.components.length == 2))
|
|
67
|
+
|
|
68
|
+
assert_match(/org\.helvector\.one\.HelOneTwo/, @manf.xml)
|
|
69
|
+
assert_match(/org\.helvector\.one\.HelOne/, @manf.xml)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
|
|
53
74
|
end
|