tool-shed 0.0.4

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.
Files changed (133) hide show
  1. data/Gemfile +9 -0
  2. data/LICENSE +20 -0
  3. data/README.md +52 -0
  4. data/bin/as-asset-detector +16 -0
  5. data/bin/as-class-detector +16 -0
  6. data/bin/as-docp +16 -0
  7. data/bin/as-manifest +16 -0
  8. data/bin/as-style-detector +16 -0
  9. data/coverage/unit/index.html +330 -0
  10. data/coverage/unit/jquery-1.3.2.min.js +19 -0
  11. data/coverage/unit/jquery.tablesorter.min.js +15 -0
  12. data/coverage/unit/lib-hel-asdoc_package_rb.html +447 -0
  13. data/coverage/unit/lib-hel-manifest_rb.html +555 -0
  14. data/coverage/unit/lib-hel-opts-asdoc_package_opts_rb.html +195 -0
  15. data/coverage/unit/lib-hel-opts-manifest_opts_rb.html +195 -0
  16. data/coverage/unit/lib-hel-opts-tool_opts_rb.html +531 -0
  17. data/coverage/unit/lib-hel-opts-unused_class_opts_rb.html +207 -0
  18. data/coverage/unit/lib-hel-opts-unused_style_opts_rb.html +201 -0
  19. data/coverage/unit/lib-hel-project_tools_rb.html +423 -0
  20. data/coverage/unit/lib-hel-search_rb.html +363 -0
  21. data/coverage/unit/lib-hel-stripper_rb.html +357 -0
  22. data/coverage/unit/lib-hel-tool_rb.html +423 -0
  23. data/coverage/unit/lib-hel-unused_class_rb.html +675 -0
  24. data/coverage/unit/lib-hel-unused_style_rb.html +747 -0
  25. data/coverage/unit/lib-hel-version_rb.html +135 -0
  26. data/coverage/unit/lib-hel_tools_rb.html +165 -0
  27. data/coverage/unit/print.css +12 -0
  28. data/coverage/unit/rcov.js +42 -0
  29. data/coverage/unit/screen.css +270 -0
  30. data/coverage.data +0 -0
  31. data/lib/shed/asdoc_package.rb +64 -0
  32. data/lib/shed/manifest.rb +82 -0
  33. data/lib/shed/opts/asdoc_package_opts.rb +22 -0
  34. data/lib/shed/opts/manifest_opts.rb +22 -0
  35. data/lib/shed/opts/tool_opts.rb +114 -0
  36. data/lib/shed/opts/unused_asset_opts.rb +24 -0
  37. data/lib/shed/opts/unused_class_opts.rb +24 -0
  38. data/lib/shed/opts/unused_style_opts.rb +23 -0
  39. data/lib/shed/project_tools.rb +60 -0
  40. data/lib/shed/search.rb +50 -0
  41. data/lib/shed/stripper.rb +49 -0
  42. data/lib/shed/tool.rb +60 -0
  43. data/lib/shed/unused_asset.rb +68 -0
  44. data/lib/shed/unused_class.rb +102 -0
  45. data/lib/shed/unused_style.rb +114 -0
  46. data/lib/shed/version.rb +12 -0
  47. data/lib/tool_shed.rb +19 -0
  48. data/rakefile.rb +109 -0
  49. data/rdoc/classes/ASDocPackage.html +281 -0
  50. data/rdoc/classes/ASDocPackageOpts.html +204 -0
  51. data/rdoc/classes/Manifest.html +323 -0
  52. data/rdoc/classes/ManifestOpts.html +205 -0
  53. data/rdoc/classes/ProjectTools.html +302 -0
  54. data/rdoc/classes/Search.html +203 -0
  55. data/rdoc/classes/Stripper.html +223 -0
  56. data/rdoc/classes/Tool.html +313 -0
  57. data/rdoc/classes/ToolOpts.html +297 -0
  58. data/rdoc/classes/UnusedClass.html +258 -0
  59. data/rdoc/classes/UnusedClassOpts.html +206 -0
  60. data/rdoc/classes/UnusedStyle.html +277 -0
  61. data/rdoc/classes/UnusedStyleOpts.html +205 -0
  62. data/rdoc/created.rid +1 -0
  63. data/rdoc/files/LICENSE.html +129 -0
  64. data/rdoc/files/README_md.html +138 -0
  65. data/rdoc/files/lib/hel/asdoc_package_rb.html +107 -0
  66. data/rdoc/files/lib/hel/manifest_rb.html +107 -0
  67. data/rdoc/files/lib/hel/opts/asdoc_package_opts_rb.html +107 -0
  68. data/rdoc/files/lib/hel/opts/manifest_opts_rb.html +107 -0
  69. data/rdoc/files/lib/hel/opts/tool_opts_rb.html +114 -0
  70. data/rdoc/files/lib/hel/opts/unused_class_opts_rb.html +107 -0
  71. data/rdoc/files/lib/hel/opts/unused_style_opts_rb.html +107 -0
  72. data/rdoc/files/lib/hel/project_tools_rb.html +107 -0
  73. data/rdoc/files/lib/hel/search_rb.html +114 -0
  74. data/rdoc/files/lib/hel/stripper_rb.html +107 -0
  75. data/rdoc/files/lib/hel/tool_rb.html +107 -0
  76. data/rdoc/files/lib/hel/unused_class_rb.html +107 -0
  77. data/rdoc/files/lib/hel/unused_style_rb.html +107 -0
  78. data/rdoc/files/lib/hel/version_rb.html +107 -0
  79. data/rdoc/files/lib/hel_tools_rb.html +127 -0
  80. data/rdoc/fr_class_index.html +39 -0
  81. data/rdoc/fr_file_index.html +43 -0
  82. data/rdoc/fr_method_index.html +75 -0
  83. data/rdoc/index.html +24 -0
  84. data/rdoc/rdoc-style.css +208 -0
  85. data/test/fixtures/search/App.mxml +0 -0
  86. data/test/fixtures/search/hide/Hidden.as +0 -0
  87. data/test/fixtures/search/org/helvector/Main.as +0 -0
  88. data/test/fixtures/src/org/helvector/Helvector.as +16 -0
  89. data/test/fixtures/src/org/helvector/one/HelOne.as +14 -0
  90. data/test/fixtures/src/org/helvector/one/HelOneTwo.mxml +0 -0
  91. data/test/fixtures/src/org/helvector/one/package.asdoc +1 -0
  92. data/test/fixtures/src/org/helvector/package.asdoc +1 -0
  93. data/test/fixtures/src/org/helvector/three/HelThree.as +14 -0
  94. data/test/fixtures/src/org/helvector/three/package.asdoc +1 -0
  95. data/test/fixtures/src/org/helvector/two/HelTwo.as +14 -0
  96. data/test/fixtures/src/org/helvector/two/package.asdoc +1 -0
  97. data/test/fixtures/unused-asset/assets/css/referenced.css +0 -0
  98. data/test/fixtures/unused-asset/assets/css/un-referenced.css +0 -0
  99. data/test/fixtures/unused-asset/assets/fonts/referenced.otf +0 -0
  100. data/test/fixtures/unused-asset/assets/fonts/un-referenced.otf +0 -0
  101. data/test/fixtures/unused-asset/assets/img/referenced.jpg +0 -0
  102. data/test/fixtures/unused-asset/assets/img/referenced.png +0 -0
  103. data/test/fixtures/unused-asset/assets/img/un-referenced.jpg +0 -0
  104. data/test/fixtures/unused-asset/assets/img/un-referenced.png +0 -0
  105. data/test/fixtures/unused-asset/src/org/helvector/ToolShed.as +30 -0
  106. data/test/fixtures/unused-cla/link-report.xml +17 -0
  107. data/test/fixtures/unused-cla/manifest.xml +6 -0
  108. data/test/fixtures/unused-cla/src/Unused.as +0 -0
  109. data/test/fixtures/unused-cla/src/Used.as +0 -0
  110. data/test/fixtures/unused-css/css/styles.css +2 -0
  111. data/test/fixtures/unused-css/css-multiple/more.css +2 -0
  112. data/test/fixtures/unused-css/css-multiple/styles.css +2 -0
  113. data/test/fixtures/unused-css/css-with-comments/commented.css +6 -0
  114. data/test/fixtures/unused-css/src/CSSApp.mxml +5 -0
  115. data/test/test_helper.rb +9 -0
  116. data/test/unit/test_asdoc_package.rb +72 -0
  117. data/test/unit/test_asdoc_package_opts.rb +28 -0
  118. data/test/unit/test_manifest.rb +53 -0
  119. data/test/unit/test_manifest_opts.rb +28 -0
  120. data/test/unit/test_search.rb +67 -0
  121. data/test/unit/test_source_tools.rb +97 -0
  122. data/test/unit/test_stripper.rb +56 -0
  123. data/test/unit/test_tool.rb +73 -0
  124. data/test/unit/test_tool_opts.rb +81 -0
  125. data/test/unit/test_unused_asset.rb +59 -0
  126. data/test/unit/test_unused_asset_opts.rb +32 -0
  127. data/test/unit/test_unused_class.rb +50 -0
  128. data/test/unit/test_unused_class_opts.rb +32 -0
  129. data/test/unit/test_unused_style.rb +103 -0
  130. data/test/unit/test_unused_style_opts.rb +31 -0
  131. data/tool-shed-0.0.3.gem +0 -0
  132. data/tool-shed.gemspec +41 -0
  133. metadata +265 -0
@@ -0,0 +1,97 @@
1
+ # encoding: utf-8
2
+
3
+ require File.join(File.dirname(__FILE__), "/../test_helper")
4
+
5
+ class ProjectToolsTest < Test::Unit::TestCase
6
+
7
+ context "Utility source tools" do
8
+
9
+ should "truncate file paths to their source directory" do
10
+
11
+ p = 'a/b/src/com'
12
+ assert_equal('com', ProjectTools.truncate_to_src(p))
13
+
14
+ p = '/a/b/source/c/src/test/org/helvector/io'
15
+ assert_equal('org/helvector/io', ProjectTools.truncate_to_src(p))
16
+
17
+ p = '/a/b/source/org/helvector/io'
18
+ assert_equal('org/helvector/io', ProjectTools.truncate_to_src(p))
19
+
20
+ p = '/a/b/source/lib/tools/src/org/helvector/io'
21
+ assert_equal('org/helvector/io', ProjectTools.truncate_to_src(p))
22
+
23
+ end
24
+
25
+ should "convert an absolute file path to a package declaration" do
26
+
27
+ p = '/a/b/source/org/helvector/io'
28
+ assert_equal('org.helvector.io', ProjectTools.package(p))
29
+
30
+ p = '/a/b/source/c/src/test/org/helvector/io'
31
+ assert_equal('org.helvector.io', ProjectTools.package(p))
32
+
33
+ p = '/a/b/c/test/org/helvector/io/Vector.as'
34
+ assert_equal('org.helvector.io', ProjectTools.package(p))
35
+
36
+ end
37
+
38
+ should "convert a relative file path to a package declaration" do
39
+
40
+ p = 'a/b/src/com'
41
+ assert_equal('com', ProjectTools.package(p))
42
+
43
+ p = 'a/b/source/lib/tools/src/org/helvector/io'
44
+ assert_equal('org.helvector.io', ProjectTools.package(p))
45
+
46
+ p = 'a/b/source/lib/tools/src/org/helvector/io/Test.as'
47
+ assert_equal('org.helvector.io', ProjectTools.package(p))
48
+
49
+ p = 'a/b/source/lib/tools/src/org/helvector/io/Test.mxml'
50
+ assert_equal('org.helvector.io', ProjectTools.package(p))
51
+
52
+ p = './org/helvector/io/Test.mxml'
53
+ assert_equal('org.helvector.io', ProjectTools.package(p))
54
+
55
+ p = '../../org/helvector/io/Test.mxml'
56
+ assert_equal('org.helvector.io', ProjectTools.package(p))
57
+
58
+ p = 'org/helvector/io/Test.mxml'
59
+ assert_equal('org.helvector.io', ProjectTools.package(p))
60
+
61
+ end
62
+
63
+ should "convert an absolute file path to an import declaration" do
64
+
65
+ p = '/a/b/source/c/src/test/org/helvector/io/Foo.mxml'
66
+ assert_equal('org.helvector.io.Foo', ProjectTools.import(p))
67
+
68
+ p = '/a/b/source/org/helvector/io/Bar.as'
69
+ assert_equal('org.helvector.io.Bar', ProjectTools.import(p))
70
+
71
+ p = '/a/b/source/lib/tools/src/org/helvector/io'
72
+ assert_equal('org.helvector.io', ProjectTools.import(p))
73
+
74
+ end
75
+
76
+ should "convert a relative file path to an import declaration" do
77
+
78
+ p = 'a/b/src/com/Hello.as'
79
+ assert_equal('com.Hello', ProjectTools.import(p))
80
+
81
+ p = 'a/b/source/lib/tools/src/org/helvector/io/Test.as'
82
+ assert_equal('org.helvector.io.Test', ProjectTools.import(p))
83
+
84
+ p = 'a/b/source/lib/tools/src/org/helvector/io/Test.mxml'
85
+ assert_equal('org.helvector.io.Test', ProjectTools.import(p))
86
+
87
+ p = './a/b/source/lib/tools/src/org/helvector/io/Test.mxml'
88
+ assert_equal('org.helvector.io.Test', ProjectTools.import(p))
89
+
90
+ p = './../../a/b/source/lib/tools/src/org/helvector/io/Test.mxml'
91
+ assert_equal('org.helvector.io.Test', ProjectTools.import(p))
92
+
93
+ end
94
+
95
+ end
96
+
97
+ end
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+
3
+ require File.join(File.dirname(__FILE__), "/../test_helper")
4
+
5
+ class StripperTest < Test::Unit::TestCase
6
+
7
+ context "Comment stripper" do
8
+
9
+ should "remove single line xml comments from a string" do
10
+
11
+ s = "<!--single-line-->"
12
+ s = Stripper.xml_comments(s)
13
+
14
+ assert s.empty?
15
+
16
+ end
17
+
18
+ should "remove multi line xml comments from a string" do
19
+
20
+ s = "\n\n<!--\nmulti-line\n-->\n"
21
+ s = Stripper.xml_comments(s)
22
+
23
+ assert_equal(s, "\n\n\n")
24
+
25
+ end
26
+
27
+ should "remove single line ecma script comments" do
28
+
29
+ s = "//single-line"
30
+ s = Stripper.ecma_comments(s)
31
+
32
+ assert s.empty?
33
+
34
+ end
35
+
36
+ should "remove multi line ecma script comments" do
37
+
38
+ s = "\n\n/*\nmulti-line\n*/\n"
39
+ s = Stripper.ecma_comments(s)
40
+
41
+ assert_equal(s, "\n\n\n")
42
+
43
+ end
44
+
45
+ should "remove multi and single line ecma script and xml comments" do
46
+
47
+ s = "\n/*\nmulti-line\n*/\n<!--single-line-->\n//single-line\n<!--\nmulti-line\n-->\n"
48
+ s = Stripper.comments(s)
49
+
50
+ assert_equal(s, "\n\n\n\n\n")
51
+
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,73 @@
1
+ # encoding: utf-8
2
+
3
+ require File.join(File.dirname(__FILE__), "/../test_helper")
4
+
5
+ class ToolTest < Test::Unit::TestCase
6
+
7
+ context "A default tool-shed" do
8
+
9
+ setup do
10
+ @out = StringIO.new
11
+ @tool = Tool.new({:output => '/tmp/tool-shed.txt'},@out)
12
+ end
13
+
14
+ should "puts messages" do
15
+ @tool.puts 'hello'
16
+ assert_equal("hello\n", @out.string)
17
+ end
18
+
19
+ should "not log messages" do
20
+ @tool.log 'hello'
21
+ assert_equal('', @out.string)
22
+ end
23
+
24
+ should "have valid options" do
25
+ assert @tool.valid_opts
26
+ end
27
+
28
+ should "provide a 'generated at' time stamp" do
29
+ assert_match(/Generated at/, @tool.generated_at)
30
+ assert_match(/\d\d:\d\d:\d\d/, @tool.generated_at)
31
+ end
32
+
33
+ end
34
+
35
+ context "A silent tool-shed" do
36
+
37
+ setup do
38
+ @out = StringIO.new
39
+ @tool = Tool.new({:silent => true, :output => '/tmp/tool-shed.txt'}, @out)
40
+ end
41
+
42
+ should "not puts messages" do
43
+ @tool.puts 'hello'
44
+ assert @out.string.empty?
45
+ end
46
+
47
+ should "not log messages" do
48
+ @tool.log 'hello'
49
+ assert @out.string.empty?
50
+ end
51
+
52
+ end
53
+
54
+ context "A verbose tool-shed" do
55
+ setup do
56
+ @out = StringIO.new
57
+ @tool = Tool.new({:verbose => true, :output => '/tmp/tool-shed.txt'}, @out)
58
+ end
59
+
60
+ should "puts messages" do
61
+ @tool.puts 'hello'
62
+ assert_equal("hello\n", @out.string)
63
+ end
64
+
65
+ should "not log messages" do
66
+ @tool.log 'hello'
67
+ assert_equal("hello\n", @out.string)
68
+ end
69
+
70
+ end
71
+
72
+ end
73
+
@@ -0,0 +1,81 @@
1
+ # encoding: utf-8
2
+
3
+ require File.join(File.dirname(__FILE__), "/../test_helper")
4
+
5
+ class ToolOptsTest < Test::Unit::TestCase
6
+
7
+ context "A Tool Options Parser" do
8
+
9
+ should "return default hash if no arguments are specified" do
10
+
11
+ args = []
12
+ opts = ToolOpts.parse(args)
13
+
14
+ assert_equal 'output.xml', opts[:output]
15
+ assert_equal '.', opts[:src]
16
+ assert_equal false, opts[:verbose]
17
+
18
+ end
19
+
20
+ should "define verbose mode when -v is set" do
21
+
22
+ args = ['-v']
23
+ opts = ToolOpts.parse(args)
24
+
25
+ assert opts[:verbose]
26
+
27
+ end
28
+
29
+ should "set source when -s or --source is specified" do
30
+
31
+ path = '/dummy/path'
32
+ args = ['-s', path]
33
+ opts = ToolOpts.parse(args)
34
+
35
+ assert_equal path, opts[:src]
36
+
37
+ args = ['--source', path]
38
+ opts = ToolOpts.parse(args)
39
+
40
+ assert_equal path, opts[:src]
41
+
42
+ end
43
+
44
+ should "display a help message" do
45
+ begin
46
+ out = StringIO.new
47
+ args = ['-h']
48
+ opts = ToolOpts.parse(args,out)
49
+ rescue SystemExit => e
50
+ assert_equal 0, e.status
51
+ assert_match(/Usage/, out.string)
52
+ end
53
+ end
54
+
55
+ should "display version information" do
56
+ begin
57
+ out = StringIO.new
58
+ args = ['--version']
59
+ opts = ToolOpts.parse(args,out)
60
+ rescue SystemExit => e
61
+ assert_equal 0, e.status
62
+ assert_match(/version/, out.string)
63
+ assert_match(/\d/, out.string)
64
+ end
65
+ end
66
+
67
+ should "display a name" do
68
+ assert_match(/\w+/, ToolOpts.name)
69
+ end
70
+
71
+ should "describe itself" do
72
+ assert_match(/\w+/, ToolOpts.description)
73
+ end
74
+
75
+ should "show a version number" do
76
+ assert_match(/\d+/, ToolOpts.version)
77
+ end
78
+
79
+ end
80
+
81
+ end
@@ -0,0 +1,59 @@
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 = { :src => "#{fix}/src",
16
+ :css_dir => "#{fix}/assets" }
17
+
18
+ @out = StringIO.new
19
+ @tool = UnusedAsset.new(opt,@out)
20
+ end
21
+
22
+ should "find all assets in the project" do
23
+ #store list
24
+ end
25
+
26
+ should "load all src files in the project" do
27
+ #css
28
+ #mxml
29
+ #as
30
+ end
31
+
32
+ should "search all loaded src files for asset references and store them in a list" do
33
+ #store list
34
+ end
35
+
36
+ should "produce a list of assets found in the project which are not referenced in the project src" do
37
+ #print list..
38
+ end
39
+
40
+ should "load the project link report and look for assets compiled into the application" do
41
+
42
+ end
43
+
44
+ end
45
+
46
+ context "with incorrect arguments" do
47
+ setup do
48
+ opt = {:manifest => "INVALID", :output => '/tmp/unused-asset-tool.txt'}
49
+ @out = StringIO.new
50
+ @tool = UnusedClass.new(opt,@out)
51
+ end
52
+
53
+ should "fail with a warning message" do
54
+ assert_match(/#{UnusedClass::INVALID_OPTS}/, @out.string)
55
+ end
56
+ end
57
+ end
58
+
59
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+
3
+ require File.join(File.dirname(__FILE__), "/../test_helper")
4
+
5
+ class UnusedAssetOptsTest < Test::Unit::TestCase
6
+
7
+ context "A Unused Asset Tool Options Parser" do
8
+
9
+ should "return default hash if no arguments are specified" do
10
+
11
+ args = []
12
+ opts = UnusedAssetOpts.parse(args)
13
+
14
+ assert_equal 'assets.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+/, UnusedAssetOpts.name)
24
+ end
25
+
26
+ should "describe itself" do
27
+ assert_match(/\w+/, UnusedAssetOpts.description)
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require File.join(File.dirname(__FILE__), "/../test_helper")
4
+
5
+ class TestUnusedClass < Test::Unit::TestCase
6
+
7
+ context "A unused class detector" do
8
+
9
+ context "with correct arguments" do
10
+ setup do
11
+ fix = File.expand_path(File.dirname(__FILE__)+ "/../fixtures/unused-cla")
12
+ opt = { :src => "#{fix}/src",
13
+ :manifest => "#{fix}/manifest.xml",
14
+ :link_report => "#{fix}/link-report.xml",
15
+ :output => '/tmp/hel-unused-class-tool.txt' }
16
+
17
+ @out = StringIO.new
18
+ @tool = UnusedClass.new(opt,@out)
19
+ end
20
+
21
+ should "find unused classes" do
22
+ assert @tool.unused_classes.length == 1
23
+ assert @tool.unused_classes[0] == 'UnusedClass'
24
+ end
25
+
26
+ should "find empty packages" do
27
+ assert @tool.empty_packages.length > 0
28
+ assert_equal('org/helvector', @tool.empty_packages[0])
29
+ end
30
+
31
+ should "have valid options" do
32
+ assert @tool.valid_opts
33
+ end
34
+ end
35
+
36
+ context "with incorrect arguments" do
37
+ setup do
38
+ opt = {:manifest => "INVALID", :output => '/tmp/unused-class-tool.txt'}
39
+ @out = StringIO.new
40
+ @tool = UnusedClass.new(opt,@out)
41
+ end
42
+
43
+ should "fail with a warning message" do
44
+ assert_match(/#{UnusedClass::INVALID_OPTS}/, @out.string)
45
+ end
46
+ end
47
+
48
+ end
49
+
50
+ end
@@ -0,0 +1,32 @@
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 'classes.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
+ end
31
+
32
+ end
@@ -0,0 +1,103 @@
1
+ # encoding: utf-8
2
+
3
+ require File.join(File.dirname(__FILE__), "/../test_helper")
4
+
5
+ class TestUnusedStyle < Test::Unit::TestCase
6
+
7
+ def fix
8
+ File.expand_path(File.dirname(__FILE__)+ "/../fixtures/unused-css")
9
+ end
10
+
11
+ context "A unused style detector" do
12
+
13
+ context "with correct arguments" do
14
+ setup do
15
+ opt = { :src => "#{fix}/src",
16
+ :css_dir => "#{fix}/css" }
17
+
18
+ @out = StringIO.new
19
+ @tool = UnusedStyle.new(opt,@out)
20
+ end
21
+
22
+ should "find declared styles" do
23
+ assert @tool.declared.length == 2
24
+ end
25
+
26
+ should "find unused styles" do
27
+ assert @tool.unused.length == 1
28
+ end
29
+
30
+ should "have valid options" do
31
+ assert_not_equal("The required options were not specified\n", @out.string)
32
+ assert @tool.valid_opts
33
+ end
34
+ end
35
+
36
+ context "with incorrect arguments" do
37
+ setup do
38
+ opt = { :src => "#{fix}/src",
39
+ :css_dir => "#{fix}/src" }
40
+
41
+ @out = StringIO.new
42
+ @tool = UnusedStyle.new(opt,@out)
43
+ end
44
+
45
+ should "fail with a warning message" do
46
+ assert_match(/#{UnusedStyle::INVALID_OPTS}/, @out.string)
47
+ assert_equal(false, @tool.valid_opts)
48
+ end
49
+ end
50
+
51
+ context "when given a css directory containing more than one css" do
52
+ setup do
53
+ opt = { :src => "#{fix}/src",
54
+ :css_dir => "#{fix}/css-multiple" }
55
+
56
+ @tool = UnusedStyle.new(opt)
57
+ end
58
+
59
+ should "find declared styles" do
60
+ assert @tool.declared.length == 4
61
+ end
62
+
63
+ should "find unused styles" do
64
+ assert @tool.unused.length == 3
65
+ end
66
+
67
+ end
68
+
69
+ context "when searching css files for style definitions" do
70
+ setup do
71
+ opt = { :src => "#{fix}/src",
72
+ :css_dir => "#{fix}/css-with-comments" }
73
+
74
+ @tool = UnusedStyle.new(opt)
75
+ end
76
+
77
+ should "find basic declarations" do
78
+ assert @tool.declared.include? 'moreUsedStyle'
79
+ assert @tool.declared.include? 'moreUnUsedStyle'
80
+ end
81
+
82
+ should "ignore declarations that are commented out" do
83
+ assert_equal(false, @tool.declared.include?('aCommentedOutStyle'))
84
+ end
85
+ end
86
+
87
+ context "when searching mxml documents for style useage" do
88
+ setup do
89
+ opt = { :src => "#{fix}/src",
90
+ :css_dir => "#{fix}/css" }
91
+
92
+ @tool = UnusedStyle.new(opt)
93
+ end
94
+
95
+ should "find all values of syleName attributes" do
96
+ assert @tool.used.length == 2
97
+ end
98
+
99
+ end
100
+
101
+ end
102
+
103
+ end
@@ -0,0 +1,31 @@
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
Binary file
data/tool-shed.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ lib = File.expand_path File.join(File.dirname(__FILE__), 'lib')
4
+ $:.unshift lib unless $:.include?(lib)
5
+
6
+ require 'bundler'
7
+ require 'rake'
8
+ require 'tool_shed'
9
+
10
+ #
11
+ # For gem spec reference see:
12
+ # http://docs.rubygems.org/read/chapter/20#rubyforge_project
13
+ #
14
+ Gem::Specification.new do |s|
15
+ s.name = ToolShed::NAME
16
+ s.version = ToolShed::VERSION::STRING
17
+ s.platform = Gem::Platform::RUBY
18
+ s.authors = ["Simon Gregory"]
19
+ s.email = "tool-shed@helvector.org"
20
+ s.homepage = "http://github.com/simongregory/tool-shed"
21
+ s.summary = "ActionScript and Flex Project Tools"
22
+ s.description = <<EOF
23
+ Utility scripts for working with ActionScript and Flex projects.
24
+ EOF
25
+ s.has_rdoc = true
26
+ s.rdoc_options = ["--charset=UTF-8"]
27
+ s.extra_rdoc_files = ['LICENSE', 'README.md']
28
+ s.required_rubygems_version = ">= 1.3.6"
29
+ s.require_path = ['lib']
30
+ s.files = FileList['**/**/*'].exclude /.git|.svn|.DS_Store|.tmproj/
31
+ s.test_files = Dir["test/*_test.rb"]
32
+ s.executables = ['as-docp', 'as-manifest', 'as-class-detector', 'as-style-detector']
33
+ s.post_install_message = <<EOF
34
+ Welcome to the Tool-Shed
35
+ ========================
36
+ Get Tooled Up #{ToolShed::VERSION::STRING}. Kick off.
37
+
38
+ EOF
39
+ s.add_bundler_dependencies
40
+
41
+ end