tool-shed 0.0.5 → 0.0.7
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/README.md +45 -22
- data/bin/{as-asset-detector → as-asset-vacuum} +2 -2
- data/bin/{as-class-detector → as-class-vacuum} +2 -2
- data/bin/{as-style-detector → as-style-vacuum} +2 -2
- data/bin/as-vacuum +16 -0
- data/lib/shed/asdoc_package.rb +11 -11
- data/lib/shed/asset_vacuum.rb +85 -0
- data/lib/shed/{unused_class.rb → class_vacuum.rb} +18 -19
- data/lib/shed/manifest.rb +11 -12
- data/lib/shed/opts/asdoc_package_opts.rb +1 -1
- data/lib/shed/opts/asset_vacuum_opts.rb +22 -0
- data/lib/shed/opts/{unused_class_opts.rb → class_vacuum_opts.rb} +9 -12
- data/lib/shed/opts/manifest_opts.rb +2 -2
- data/lib/shed/opts/style_vacuum_opts.rb +31 -0
- data/lib/shed/opts/tool_opts.rb +8 -8
- data/lib/shed/style_vacuum.rb +92 -0
- data/lib/shed/tool.rb +43 -6
- data/lib/shed/version.rb +1 -1
- data/lib/tool_shed.rb +6 -6
- data/test/fixtures/unused-asset/assets/audio/referenced.mp3 +0 -0
- data/test/fixtures/unused-asset/assets/audio/un-referenced.mp3 +0 -0
- data/test/fixtures/unused-asset/assets/css/referenced-in-mxml.css +0 -0
- data/test/fixtures/unused-asset/assets/css/referenced.css +12 -0
- data/test/fixtures/unused-asset/assets/css/un-referenced.css +7 -0
- data/test/fixtures/unused-asset/assets/fonts/referenced-in-css.ttf +0 -0
- data/test/fixtures/unused-asset/assets/fonts/referenced-in-unused-css.ttf +0 -0
- data/test/fixtures/unused-asset/assets/img/referenced.gif +0 -0
- data/test/fixtures/unused-asset/assets/img/referenced.svg +0 -0
- data/test/fixtures/unused-asset/assets/img/un-referenced.gif +0 -0
- data/test/fixtures/unused-asset/assets/img/un-referenced.svg +0 -0
- data/test/fixtures/unused-asset/assets/swf/referenced-in-css.swf +0 -0
- data/test/fixtures/unused-asset/assets/swf/referenced.swf +0 -0
- data/test/fixtures/unused-asset/assets/swf/un-referenced.swf +0 -0
- data/test/fixtures/unused-asset/src/org/helvector/ToolBox.mxml +5 -0
- data/test/fixtures/unused-asset/src/org/helvector/ToolShed.as +7 -2
- data/test/unit/test_asdoc_package_opts.rb +1 -1
- data/test/unit/test_asset_vacuum.rb +77 -0
- data/test/unit/{test_unused_asset_opts.rb → test_asset_vacuum_opts.rb} +5 -7
- data/test/unit/{test_unused_class.rb → test_class_vacuum.rb} +7 -7
- data/test/unit/test_class_vacuum_opts.rb +51 -0
- data/test/unit/{test_unused_style.rb → test_style_vacuum.rb} +21 -15
- data/test/unit/test_style_vacuum_opts.rb +46 -0
- metadata +36 -22
- data/lib/shed/opts/unused_asset_opts.rb +0 -24
- data/lib/shed/opts/unused_style_opts.rb +0 -23
- data/lib/shed/unused_asset.rb +0 -93
- data/lib/shed/unused_style.rb +0 -114
- data/test/unit/test_unused_asset.rb +0 -69
- data/test/unit/test_unused_class_opts.rb +0 -59
- data/test/unit/test_unused_style_opts.rb +0 -31
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tool-shed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Simon Gregory
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-27 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -109,36 +109,38 @@ email: tool-shed@helvector.org
|
|
109
109
|
executables:
|
110
110
|
- as-docp
|
111
111
|
- as-manifest
|
112
|
-
- as-class-
|
113
|
-
- as-style-
|
112
|
+
- as-class-vacuum
|
113
|
+
- as-style-vacuum
|
114
|
+
- as-asset-vacuum
|
114
115
|
extensions: []
|
115
116
|
|
116
117
|
extra_rdoc_files:
|
117
118
|
- LICENSE
|
118
119
|
- README.md
|
119
120
|
files:
|
120
|
-
- bin/as-asset-
|
121
|
-
- bin/as-class-
|
121
|
+
- bin/as-asset-vacuum
|
122
|
+
- bin/as-class-vacuum
|
122
123
|
- bin/as-docp
|
123
124
|
- bin/as-manifest
|
124
|
-
- bin/as-style-
|
125
|
+
- bin/as-style-vacuum
|
126
|
+
- bin/as-vacuum
|
125
127
|
- Gemfile
|
126
128
|
- Gemfile.lock
|
127
129
|
- lib/shed/asdoc_package.rb
|
130
|
+
- lib/shed/asset_vacuum.rb
|
131
|
+
- lib/shed/class_vacuum.rb
|
128
132
|
- lib/shed/manifest.rb
|
129
133
|
- lib/shed/opts/asdoc_package_opts.rb
|
134
|
+
- lib/shed/opts/asset_vacuum_opts.rb
|
135
|
+
- lib/shed/opts/class_vacuum_opts.rb
|
130
136
|
- lib/shed/opts/manifest_opts.rb
|
137
|
+
- lib/shed/opts/style_vacuum_opts.rb
|
131
138
|
- lib/shed/opts/tool_opts.rb
|
132
|
-
- lib/shed/opts/unused_asset_opts.rb
|
133
|
-
- lib/shed/opts/unused_class_opts.rb
|
134
|
-
- lib/shed/opts/unused_style_opts.rb
|
135
139
|
- lib/shed/project_tools.rb
|
136
140
|
- lib/shed/search.rb
|
137
141
|
- lib/shed/stripper.rb
|
142
|
+
- lib/shed/style_vacuum.rb
|
138
143
|
- lib/shed/tool.rb
|
139
|
-
- lib/shed/unused_asset.rb
|
140
|
-
- lib/shed/unused_class.rb
|
141
|
-
- lib/shed/unused_style.rb
|
142
144
|
- lib/shed/version.rb
|
143
145
|
- lib/tool_shed.rb
|
144
146
|
- LICENSE
|
@@ -156,14 +158,26 @@ files:
|
|
156
158
|
- test/fixtures/src/org/helvector/three/package.asdoc
|
157
159
|
- test/fixtures/src/org/helvector/two/HelTwo.as
|
158
160
|
- test/fixtures/src/org/helvector/two/package.asdoc
|
161
|
+
- test/fixtures/unused-asset/assets/audio/referenced.mp3
|
162
|
+
- test/fixtures/unused-asset/assets/audio/un-referenced.mp3
|
163
|
+
- test/fixtures/unused-asset/assets/css/referenced-in-mxml.css
|
159
164
|
- test/fixtures/unused-asset/assets/css/referenced.css
|
160
165
|
- test/fixtures/unused-asset/assets/css/un-referenced.css
|
166
|
+
- test/fixtures/unused-asset/assets/fonts/referenced-in-css.ttf
|
167
|
+
- test/fixtures/unused-asset/assets/fonts/referenced-in-unused-css.ttf
|
161
168
|
- test/fixtures/unused-asset/assets/fonts/referenced.otf
|
162
169
|
- test/fixtures/unused-asset/assets/fonts/un-referenced.otf
|
170
|
+
- test/fixtures/unused-asset/assets/img/referenced.gif
|
163
171
|
- test/fixtures/unused-asset/assets/img/referenced.jpg
|
164
172
|
- test/fixtures/unused-asset/assets/img/referenced.png
|
173
|
+
- test/fixtures/unused-asset/assets/img/referenced.svg
|
174
|
+
- test/fixtures/unused-asset/assets/img/un-referenced.gif
|
165
175
|
- test/fixtures/unused-asset/assets/img/un-referenced.jpg
|
166
176
|
- test/fixtures/unused-asset/assets/img/un-referenced.png
|
177
|
+
- test/fixtures/unused-asset/assets/img/un-referenced.svg
|
178
|
+
- test/fixtures/unused-asset/assets/swf/referenced-in-css.swf
|
179
|
+
- test/fixtures/unused-asset/assets/swf/referenced.swf
|
180
|
+
- test/fixtures/unused-asset/assets/swf/un-referenced.swf
|
167
181
|
- test/fixtures/unused-asset/src/org/helvector/ToolBox.mxml
|
168
182
|
- test/fixtures/unused-asset/src/org/helvector/ToolShed.as
|
169
183
|
- test/fixtures/unused-cla/link-report.xml
|
@@ -178,19 +192,19 @@ files:
|
|
178
192
|
- test/test_helper.rb
|
179
193
|
- test/unit/test_asdoc_package.rb
|
180
194
|
- test/unit/test_asdoc_package_opts.rb
|
195
|
+
- test/unit/test_asset_vacuum.rb
|
196
|
+
- test/unit/test_asset_vacuum_opts.rb
|
197
|
+
- test/unit/test_class_vacuum.rb
|
198
|
+
- test/unit/test_class_vacuum_opts.rb
|
181
199
|
- test/unit/test_manifest.rb
|
182
200
|
- test/unit/test_manifest_opts.rb
|
183
201
|
- test/unit/test_search.rb
|
184
202
|
- test/unit/test_source_tools.rb
|
185
203
|
- test/unit/test_stripper.rb
|
204
|
+
- test/unit/test_style_vacuum.rb
|
205
|
+
- test/unit/test_style_vacuum_opts.rb
|
186
206
|
- test/unit/test_tool.rb
|
187
207
|
- test/unit/test_tool_opts.rb
|
188
|
-
- test/unit/test_unused_asset.rb
|
189
|
-
- test/unit/test_unused_asset_opts.rb
|
190
|
-
- test/unit/test_unused_class.rb
|
191
|
-
- test/unit/test_unused_class_opts.rb
|
192
|
-
- test/unit/test_unused_style.rb
|
193
|
-
- test/unit/test_unused_style_opts.rb
|
194
208
|
has_rdoc: true
|
195
209
|
homepage: http://github.com/simongregory/tool-shed
|
196
210
|
licenses: []
|
@@ -198,7 +212,7 @@ licenses: []
|
|
198
212
|
post_install_message: |+
|
199
213
|
Welcome to the Tool-Shed
|
200
214
|
========================
|
201
|
-
Get Tooled Up 0.0.
|
215
|
+
Get Tooled Up 0.0.7. Kick off.
|
202
216
|
|
203
217
|
Thanks for installing, the tools are under development. Don't expect reliability.
|
204
218
|
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
#
|
4
|
-
# Manages the command line interface for the unused assets detection tool.
|
5
|
-
#
|
6
|
-
class UnusedAssetOpts < ToolOpts
|
7
|
-
|
8
|
-
def self.name
|
9
|
-
"as-asset-detector"
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.description
|
13
|
-
"ActionScript Unused Asset Detection Tool"
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.default_config
|
17
|
-
dc = superclass.default_config
|
18
|
-
dc[:output] = 'assets.txt'
|
19
|
-
dc[:manifest] = 'manifest.xml'
|
20
|
-
dc[:link_report] = 'link-report.xml'
|
21
|
-
dc
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
#
|
4
|
-
# Manages the command line interface for the unused style detection tool.
|
5
|
-
#
|
6
|
-
class UnusedStyleOpts < ToolOpts
|
7
|
-
|
8
|
-
def self.name
|
9
|
-
"as-style-detector"
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.description
|
13
|
-
"ActionScript Unused Style Detection Tool"
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.default_config
|
17
|
-
dc = superclass.default_config
|
18
|
-
dc[:output] = 'styles.txt'
|
19
|
-
dc[:css_dir] = 'style'
|
20
|
-
dc
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
data/lib/shed/unused_asset.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
#
|
4
|
-
# This script scans all Actionscript classes and CSS files in a project to
|
5
|
-
# identify assets, like PNG files, that are in the project source tree but are
|
6
|
-
# no longer used by the application.
|
7
|
-
#
|
8
|
-
class UnusedAsset < Tool
|
9
|
-
attr_reader :assets, :src_files, :declared, :unused
|
10
|
-
|
11
|
-
def initialize(opt,out=STDOUT)
|
12
|
-
super(opt,out)
|
13
|
-
|
14
|
-
@project_dir = opt[:project_dir]
|
15
|
-
@assets = []
|
16
|
-
@src_files = []
|
17
|
-
@declared = []
|
18
|
-
|
19
|
-
unless valid_opts
|
20
|
-
@out.puts "#{INVALID_OPTS} One or all of specified asset and source directories does not exist."
|
21
|
-
return
|
22
|
-
end
|
23
|
-
|
24
|
-
@declared_regex = /Embed\(source='([\w.\/]+)'/
|
25
|
-
|
26
|
-
detect
|
27
|
-
|
28
|
-
#@report = describe
|
29
|
-
|
30
|
-
#to_disk(@report)
|
31
|
-
end
|
32
|
-
|
33
|
-
def valid_opts
|
34
|
-
File.exist?(@project_dir) rescue false
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def detect
|
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
|
-
}
|
51
|
-
end
|
52
|
-
|
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
|
62
|
-
|
63
|
-
#
|
64
|
-
# Scans directories for all files that match the file extension regex, and
|
65
|
-
# for each match goes on to scan that document for items matching the syntax
|
66
|
-
# regex.
|
67
|
-
#
|
68
|
-
def scan_dirs(file_ext_regex,path,syntax_regex)
|
69
|
-
d = []
|
70
|
-
|
71
|
-
Search.find_all(file_ext_regex,path,@excludes) do |p|
|
72
|
-
@src_files << p
|
73
|
-
d << scan_doc(p,syntax_regex)
|
74
|
-
end
|
75
|
-
|
76
|
-
d.flatten!.sort!.uniq! unless d.empty?
|
77
|
-
d
|
78
|
-
end
|
79
|
-
|
80
|
-
#
|
81
|
-
# Opens the document specified by path and returns a list of all first capture
|
82
|
-
# group matches, after stripping comments.
|
83
|
-
#
|
84
|
-
def scan_doc(path,regex)
|
85
|
-
n = []
|
86
|
-
f = File.open(path,"r").read.strip
|
87
|
-
f = Stripper.comments(f)
|
88
|
-
f.scan(regex) do |style_name|
|
89
|
-
n << $1
|
90
|
-
end
|
91
|
-
n
|
92
|
-
end
|
93
|
-
end
|
data/lib/shed/unused_style.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
#
|
4
|
-
# Detects styles that are not used in a Flex application.
|
5
|
-
#
|
6
|
-
# This needs to be provided with a source directory to search for used styles,
|
7
|
-
# and a directory containing css files which will be loaded and parsed for
|
8
|
-
# style definitions.
|
9
|
-
#
|
10
|
-
# NOTE: This tool needs further work before it can be considerd to cover all
|
11
|
-
# use cases.
|
12
|
-
#
|
13
|
-
class UnusedStyle < Tool
|
14
|
-
attr_reader :report,
|
15
|
-
:declared,
|
16
|
-
:used,
|
17
|
-
:unused,
|
18
|
-
:undeclared
|
19
|
-
|
20
|
-
def initialize(opt,out=STDOUT)
|
21
|
-
super(opt,out)
|
22
|
-
|
23
|
-
@css_dir = opt[:css_dir]
|
24
|
-
|
25
|
-
@style_regex = /styleName\s*=\s*["']\s*\{?\s*([\w.]+)\s*\}?\s*["']/
|
26
|
-
@declared_regex = /^\.(\w+)/
|
27
|
-
|
28
|
-
@declared, @used, @unused, @undeclared = []
|
29
|
-
|
30
|
-
unless valid_opts
|
31
|
-
@out.puts "#{INVALID_OPTS} The directory specified as containging css files does not exist, or does not contain css files."
|
32
|
-
return
|
33
|
-
end
|
34
|
-
|
35
|
-
detect
|
36
|
-
|
37
|
-
@report = describe
|
38
|
-
end
|
39
|
-
|
40
|
-
def valid_opts
|
41
|
-
return false unless File.exist?(@css_dir)
|
42
|
-
|
43
|
-
found = Dir.chdir("#{@css_dir}") do |d|
|
44
|
-
Dir.glob('*.css')
|
45
|
-
end
|
46
|
-
|
47
|
-
found.length > 0
|
48
|
-
end
|
49
|
-
|
50
|
-
def detect
|
51
|
-
@declared = scan_dirs(/\.(css)/, @css_dir, @declared_regex)
|
52
|
-
@used = scan_dirs(/\.(as|mxml)/, @src, @style_regex)
|
53
|
-
|
54
|
-
#Find any style names used in the source which haven't been declared.
|
55
|
-
@undeclared = @used-@declared
|
56
|
-
|
57
|
-
#Find any style names declared in the css but not used in the src.
|
58
|
-
@unused = @declared-@used
|
59
|
-
end
|
60
|
-
|
61
|
-
private
|
62
|
-
|
63
|
-
#
|
64
|
-
# Returns a string detailing the findings of the style detection.
|
65
|
-
#
|
66
|
-
def describe
|
67
|
-
desc = "#{generated_at}"
|
68
|
-
desc << add_desc("declared in CSS", @declared)
|
69
|
-
desc << add_desc("used in MXML",@used)
|
70
|
-
desc << add_desc("declared but not used (in a styleName property)",@unused)
|
71
|
-
desc << add_desc("used but not declared",@undeclared)
|
72
|
-
desc
|
73
|
-
end
|
74
|
-
|
75
|
-
#
|
76
|
-
# Prints a description category.
|
77
|
-
#
|
78
|
-
def add_desc(txt,list)
|
79
|
-
d = "\nStyles #{txt}: #{list.length.to_s}\n"
|
80
|
-
d << list.join("\n") unless list.empty?
|
81
|
-
d
|
82
|
-
end
|
83
|
-
|
84
|
-
#
|
85
|
-
# Scans directories for all files that match the file extension regex, and
|
86
|
-
# for each match goes on to scan that document for items matching the syntax
|
87
|
-
# regex.
|
88
|
-
#
|
89
|
-
def scan_dirs(extension_regex,path,syntax_regex)
|
90
|
-
d = []
|
91
|
-
|
92
|
-
Search.find_all(extension_regex,path,@excludes) do |path|
|
93
|
-
d << scan_doc(path,syntax_regex)
|
94
|
-
end
|
95
|
-
|
96
|
-
d.flatten!.sort!.uniq! unless d.empty?
|
97
|
-
d
|
98
|
-
end
|
99
|
-
|
100
|
-
#
|
101
|
-
# Opens the document specified by path and returns a list of all first capture
|
102
|
-
# group matches, after stripping comments.
|
103
|
-
#
|
104
|
-
def scan_doc(path,regex)
|
105
|
-
n = []
|
106
|
-
f = File.open(path,"r").read.strip
|
107
|
-
f = Stripper.comments(f)
|
108
|
-
f.scan(regex) do |style_name|
|
109
|
-
n << $1
|
110
|
-
end
|
111
|
-
n
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), "/../test_helper")
|
4
|
-
|
5
|
-
class TestUnusedAsset < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def fix
|
8
|
-
File.expand_path(File.dirname(__FILE__)+ "/../fixtures/unused-asset")
|
9
|
-
end
|
10
|
-
|
11
|
-
context "A unused asset detector" do
|
12
|
-
|
13
|
-
context "with correct arguments" do
|
14
|
-
setup do
|
15
|
-
opt = { :project_dir => "#{fix}" }
|
16
|
-
|
17
|
-
@out = StringIO.new
|
18
|
-
@tool = UnusedAsset.new(opt,@out)
|
19
|
-
end
|
20
|
-
|
21
|
-
should "find all assets in the project" do
|
22
|
-
assert_equal(6, @tool.assets.length)
|
23
|
-
assert_match(/\.jpg/, @tool.assets.to_s)
|
24
|
-
assert_match(/\.png/, @tool.assets.to_s)
|
25
|
-
assert_match(/\.otf/, @tool.assets.to_s)
|
26
|
-
end
|
27
|
-
|
28
|
-
should "locate all src files in the project" do
|
29
|
-
assert_equal(4, @tool.src_files.length)
|
30
|
-
assert_match(/\.mxml/, @tool.src_files.to_s)
|
31
|
-
assert_match(/\.as/, @tool.src_files.to_s)
|
32
|
-
assert_match(/\.css/, @tool.src_files.to_s)
|
33
|
-
end
|
34
|
-
|
35
|
-
should "search all loaded src files for asset references and store them in a list" do
|
36
|
-
assert_equal(3, @tool.declared.length)
|
37
|
-
assert_match('referenced.otf', @tool.declared.to_s)
|
38
|
-
assert_match('referenced.jpg', @tool.declared.to_s)
|
39
|
-
assert_match('referenced.png', @tool.declared.to_s)
|
40
|
-
end
|
41
|
-
|
42
|
-
should "produce a list of assets found in the project directory which are not referenced in the project src" do
|
43
|
-
assert_equal(3, @tool.unused.length)
|
44
|
-
assert_match('un-referenced.otf', @tool.unused.to_s)
|
45
|
-
assert_match('un-referenced.jpg', @tool.unused.to_s)
|
46
|
-
assert_match('un-referenced.png', @tool.unused.to_s)
|
47
|
-
end
|
48
|
-
|
49
|
-
should "load the project link report and look for assets compiled into the application" do
|
50
|
-
#TODO
|
51
|
-
#flunk
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
context "with incorrect arguments" do
|
57
|
-
setup do
|
58
|
-
opt = {:project_dir => "INVALID"}
|
59
|
-
@out = StringIO.new
|
60
|
-
@tool = UnusedAsset.new(opt,@out)
|
61
|
-
end
|
62
|
-
|
63
|
-
should "fail with a warning message" do
|
64
|
-
assert_match(/#{UnusedAsset::INVALID_OPTS}/, @out.string)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), "/../test_helper")
|
4
|
-
|
5
|
-
class UnusedClassOptsTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
context "A Unused Class Tool Options Parser" do
|
8
|
-
|
9
|
-
should "return default hash if no arguments are specified" do
|
10
|
-
|
11
|
-
args = []
|
12
|
-
opts = UnusedClassOpts.parse(args)
|
13
|
-
|
14
|
-
assert_equal 'class-vaccum.txt', opts[:output]
|
15
|
-
assert_equal 'manifest.xml', opts[:manifest]
|
16
|
-
assert_equal 'link-report.xml', opts[:link_report]
|
17
|
-
assert_equal '.', opts[:src]
|
18
|
-
assert_equal false, opts[:verbose]
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
should "display a name" do
|
23
|
-
assert_match(/\w+/, UnusedClassOpts.name)
|
24
|
-
end
|
25
|
-
|
26
|
-
should "describe itself" do
|
27
|
-
assert_match(/\w+/, UnusedClassOpts.description)
|
28
|
-
end
|
29
|
-
|
30
|
-
should "raise an exception if mandatory arguments are missing" do
|
31
|
-
#TODO assert_raise(Exception) { UnusedClassOpts.parse([]) }
|
32
|
-
end
|
33
|
-
|
34
|
-
should "exit with a useage message if mandatory options are not specified" do
|
35
|
-
#TODO: This is failing as the rescue is never entered.
|
36
|
-
#rescued = false;
|
37
|
-
#begin
|
38
|
-
# out = StringIO.new
|
39
|
-
# args = []
|
40
|
-
# opts = UnusedClassOpts.parse(args,out)
|
41
|
-
#rescue SystemExit => e
|
42
|
-
# assert_equal 0, e.status
|
43
|
-
# assert_match(/Usage/, out.string)
|
44
|
-
# rescued = true
|
45
|
-
#end
|
46
|
-
#flunk() unless rescued
|
47
|
-
end
|
48
|
-
|
49
|
-
should "set manifest and link-report properties" do
|
50
|
-
args = ['-m', 'custom-manifest.xml', '-l', 'custom-link-report.xml']
|
51
|
-
opts = UnusedClassOpts.parse(args)
|
52
|
-
|
53
|
-
assert_equal 'custom-manifest.xml', opts[:manifest]
|
54
|
-
assert_equal 'custom-link-report.xml', opts[:link_report]
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), "/../test_helper")
|
4
|
-
|
5
|
-
class UnusedStyleOptsTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
context "A Unused Style Tool Options Parser" do
|
8
|
-
|
9
|
-
should "return default hash if no arguments are specified" do
|
10
|
-
|
11
|
-
args = []
|
12
|
-
opts = UnusedStyleOpts.parse(args)
|
13
|
-
|
14
|
-
assert_equal 'styles.txt', opts[:output]
|
15
|
-
assert_equal 'style', opts[:css_dir]
|
16
|
-
assert_equal '.', opts[:src]
|
17
|
-
assert_equal false, opts[:verbose]
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
should "display a name" do
|
22
|
-
assert_match(/\w+/, UnusedStyleOpts.name)
|
23
|
-
end
|
24
|
-
|
25
|
-
should "describe itself" do
|
26
|
-
assert_match(/\w+/, UnusedStyleOpts.description)
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|