tool-shed 0.0.7 → 0.0.9

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.
@@ -22,16 +22,13 @@ class StyleVacuum < Tool
22
22
 
23
23
  @css_dir = opt[:css_dir]
24
24
 
25
+ do_exit unless valid_opts
26
+
25
27
  @style_regex = /styleName\s*=\s*["']\s*\{?\s*([\w.]+)\s*\}?\s*["']/
26
28
  @declared_regex = /^\.(\w+)/
27
29
 
28
30
  @declared, @used, @unused, @undeclared = [], [], [], []
29
31
 
30
- unless valid_opts
31
- @out.puts "#{INVALID_OPTS} The specified css directory does not exist, or does not contain css files."
32
- return
33
- end
34
-
35
32
  detect
36
33
 
37
34
  @report = describe
@@ -50,6 +47,9 @@ class StyleVacuum < Tool
50
47
  found.length > 0
51
48
  end
52
49
 
50
+ #
51
+ # Scans the project and detects styles referenced in the source and css files.
52
+ #
53
53
  def detect
54
54
  puts "Scanning project for styles..."
55
55
 
@@ -71,10 +71,8 @@ class StyleVacuum < Tool
71
71
  # Summarise the collected data.
72
72
  #
73
73
  def summarise
74
- puts "Declared styles: #{@declared.length.to_s}"
75
- puts "Undeclared styles: #{@undeclared.length.to_s}"
76
- puts "Used styles: #{@used.length.to_s}"
77
- puts "Unused styles: #{@unused.length.to_s}"
74
+ puts sprintf( "Declared styles: %d\nUndeclared styles: %d\nUsed styles: %d\nUnused styles: %d\n",
75
+ @declared.length, @undeclared.length, @used.length, @unused.length)
78
76
  end
79
77
 
80
78
  #
@@ -89,4 +87,10 @@ class StyleVacuum < Tool
89
87
  desc
90
88
  end
91
89
 
92
- end
90
+ #
91
+ # Log an error message and raise exit.
92
+ #
93
+ def do_exit
94
+ super "The specified css directory does not exist, or does not contain css files."
95
+ end
96
+ end
data/lib/shed/tasks.rb ADDED
@@ -0,0 +1,84 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+
4
+ class HeadersTask < Rake::TaskLib
5
+
6
+ attr_writer :paths
7
+
8
+ def copyright=(value)
9
+ make_header(value)
10
+ end
11
+
12
+ def initialize name = :headers
13
+ @name = name
14
+ @paths = 'src,test'
15
+ @header = make_header
16
+
17
+ yield self if block_given?
18
+
19
+ define
20
+ end
21
+
22
+ def define
23
+ desc "Updates all ActionScript source files to include copyright headers"
24
+ task @name do
25
+ Dir[ "{#{@paths}}/**/*.as" ].each do |uri|
26
+ src = IO.read( uri )
27
+ File.open( uri, 'w+' ) do |f|
28
+ f << src.sub( /.+?(?=package)/m, @header )
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def make_header(rights=default_rights)
37
+ @header = as3_header.sub('[COPYRIGHT]', rights)
38
+ end
39
+
40
+ def default_rights
41
+ "Copyright #{Time.new().year} the original author or authors."
42
+ end
43
+
44
+ def as3_header
45
+ %{//AS3///////////////////////////////////////////////////////////////////////////
46
+ //
47
+ // [COPYRIGHT]
48
+ //
49
+ ////////////////////////////////////////////////////////////////////////////////
50
+
51
+ }
52
+ end
53
+ end
54
+
55
+ class ManifestTask < Rake::TaskLib
56
+ attr_accessor :filter,
57
+ :src,
58
+ :output,
59
+ :silent
60
+
61
+ def initialize name = :manifest
62
+ @name = name
63
+ @output = 'manifest.xml'
64
+ @filter = ''
65
+ @silent = true
66
+
67
+ yield self if block_given?
68
+
69
+ define
70
+ end
71
+
72
+ def define
73
+ desc "Generate a manifest file "
74
+ task @name do
75
+ Manifest.new(to_hash)
76
+ end
77
+ end
78
+
79
+ private
80
+
81
+ def to_hash
82
+ { :filter => filter, :src => src, :output => output, :silent => silent }
83
+ end
84
+ end
data/lib/shed/tool.rb CHANGED
@@ -107,4 +107,12 @@ class Tool
107
107
  declarations.flatten!.sort!.uniq! unless declarations.empty?
108
108
  declarations
109
109
  end
110
+
111
+ #
112
+ # Log an error message and raise exit.
113
+ #
114
+ def do_exit(msg='')
115
+ @out.puts "#{INVALID_OPTS} #{msg}"
116
+ exit
117
+ end
110
118
  end
data/lib/shed/version.rb CHANGED
@@ -5,7 +5,7 @@ module ToolShed #:nodoc:
5
5
  module VERSION #:nodoc:
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- TINY = 7
8
+ TINY = 9
9
9
 
10
10
  STRING = [MAJOR, MINOR, TINY].join('.')
11
11
  end
data/lib/tool_shed.rb CHANGED
@@ -5,14 +5,20 @@ require 'shed/opts/tool_opts'
5
5
 
6
6
  require 'shed/asdoc_package'
7
7
  require 'shed/manifest'
8
+ require 'shed/concrete'
9
+ require 'shed/mixers/actionscript_class'
10
+ require 'shed/mixers/mock4as'
11
+ require 'shed/mixers/just_implement'
8
12
  require 'shed/opts/asdoc_package_opts'
9
- require 'shed/opts/manifest_opts'
10
13
  require 'shed/opts/asset_vacuum_opts'
11
14
  require 'shed/opts/class_vacuum_opts'
15
+ require 'shed/opts/manifest_opts'
16
+ require 'shed/opts/concrete_opts'
12
17
  require 'shed/opts/style_vacuum_opts'
13
18
  require 'shed/project_tools'
14
19
  require 'shed/search'
15
20
  require 'shed/stripper'
21
+ require 'shed/interface'
16
22
  require 'shed/asset_vacuum'
17
23
  require 'shed/class_vacuum'
18
24
  require 'shed/style_vacuum'
data/rakefile.rb CHANGED
@@ -1,10 +1,8 @@
1
-
2
1
  require 'bundler'
3
2
 
4
3
  Bundler.require
5
4
 
6
5
  require 'metric_fu'
7
-
8
6
  require 'rake/clean'
9
7
  require 'rake/testtask'
10
8
  require 'rake/rdoctask'
@@ -43,3 +41,31 @@ task :default => [:test]
43
41
 
44
42
  desc "Run all tests and reports"
45
43
  task :hudson => ['ci:setup:testunit', :test, 'metrics:all']
44
+
45
+ #############################################################################
46
+ #
47
+ # Packaging tasks
48
+ #
49
+ #############################################################################
50
+
51
+ task :release do
52
+ puts ""
53
+ print "Are you sure you want to relase tool-shed #{ToolShed::VERSION::STRING}? [y/N] "
54
+ exit unless STDIN.gets.index(/y/i) == 0
55
+
56
+ unless `git branch` =~ /^\* master$/
57
+ puts "You must be on the master branch to release!"
58
+ exit!
59
+ end
60
+
61
+ # Build gem and upload
62
+ sh "gem build tool-shed.gemspec"
63
+ sh "gem push tool-shed-#{ToolShed::VERSION::STRING}.gem"
64
+ sh "rm tool-shed-#{ToolShed::VERSION::STRING}.gem"
65
+
66
+ # Commit
67
+ sh "git commit --allow-empty -a -m 'v#{ToolShed::VERSION::STRING}'"
68
+ sh "git tag v#{ToolShed::VERSION::STRING}"
69
+ sh "git push origin master"
70
+ sh "git push origin v#{ToolShed::VERSION::STRING}"
71
+ end
@@ -0,0 +1,61 @@
1
+ //AS3///////////////////////////////////////////////////////////////////////////
2
+ //
3
+ // Copyright 2010 the original author or authors.
4
+ //
5
+ ////////////////////////////////////////////////////////////////////////////////
6
+
7
+ //public interface IPacket
8
+ /*
9
+ public interface IPacket
10
+ */
11
+ package org.shed.bench.box
12
+ {
13
+
14
+ /**
15
+ * A trickier fixture to test the <code>as-concrete</code> tool against.
16
+ *
17
+ * @langversion ActionScript 3
18
+ * @playerversion Flash 9.0.0
19
+ *
20
+ * @author Simon Gregory
21
+ */
22
+ public interface ISeedPacket
23
+ {
24
+ /**
25
+ * Sets the seed variety.
26
+ *
27
+ * @return
28
+ */
29
+ function variety(one:Number,
30
+ two:String,
31
+ three:Function):String;
32
+
33
+ /**
34
+ * Sets the seed variety.
35
+ *
36
+ * @return
37
+ */
38
+ function age(planted:Date,
39
+ details:String="a,b,c"):Date;
40
+
41
+ /**
42
+ * @private
43
+ */
44
+ function get material():String;
45
+ function set material(value:String):void;
46
+
47
+ /*
48
+
49
+ function cheese(
50
+ stilton:Boolean
51
+ ):void;
52
+
53
+ */
54
+
55
+ function have(a:String, ...rest):Boolean;
56
+
57
+ function plant(a:String,
58
+ b:Boolean=false,
59
+ c:Seed=pod):Boolean;
60
+ }
61
+ }
@@ -0,0 +1,17 @@
1
+ package
2
+ {
3
+
4
+ public interface IShed
5
+ {
6
+ function get windows():int;
7
+ function set windows(value:int):void;
8
+
9
+ function get doors():uint;
10
+
11
+ function set lamps(value:Number):void;
12
+
13
+ function openDoor():void;
14
+ function startHeater(temperature:Number,fuel:String):void;
15
+ function countTools():Number;
16
+ }
17
+ }
@@ -0,0 +1,14 @@
1
+ package
2
+ {
3
+
4
+ public class Shed extends Object implements IShed
5
+ {
6
+
7
+ public function Shed()
8
+ {
9
+ super();
10
+ }
11
+
12
+ }
13
+
14
+ }
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.join(File.dirname(__FILE__), "/../test_helper")
4
4
 
5
- class ASDocPackageTest < Test::Unit::TestCase
5
+ class TestASDocPackage < Test::Unit::TestCase
6
6
 
7
7
  context "An ASDdoc Package Tool" do
8
8
 
@@ -36,13 +36,16 @@ class ASDocPackageTest < Test::Unit::TestCase
36
36
  end
37
37
 
38
38
  context "A ASDocPackage tool should skip specified directories" do
39
+
39
40
  setup do
40
41
  src = File.expand_path(File.dirname(__FILE__)+ "/../fixtures/src")
41
- opts = { :verbose => true,
42
- :src => src,
43
- :output => '/tmp/asdoc-package-tool-test-output.xml',
44
- :excludes => ['one'],
45
- :silent => true }
42
+ opts = {
43
+ :verbose => true,
44
+ :src => src,
45
+ :output => '/tmp/asdoc-package-tool-test-output.xml',
46
+ :excludes => ['one'],
47
+ :silent => true
48
+ }
46
49
 
47
50
  @pack = ASDocPackage.new(opts)
48
51
  end
@@ -53,9 +56,11 @@ class ASDocPackageTest < Test::Unit::TestCase
53
56
  p = @pack.xml =~ /Package One/ ? true : false
54
57
  assert_equal(false,p)
55
58
  end
59
+
56
60
  end
57
61
 
58
62
  context "A asdoc package builder tool invoked on a empty directory" do
63
+
59
64
  setup do
60
65
  @output = '/tmp/as-manifest-tool-test.xml'
61
66
  src = File.expand_path(File.dirname(__FILE__)+ "/../fixtures/empty")
@@ -67,6 +72,7 @@ class ASDocPackageTest < Test::Unit::TestCase
67
72
  should "not find any files" do
68
73
  assert_match(/No.*files found\./, @out.string)
69
74
  end
75
+
70
76
  end
71
77
 
72
78
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.join(File.dirname(__FILE__), "/../test_helper")
4
4
 
5
- class ASDocPackageOptsTest < Test::Unit::TestCase
5
+ class TestASDocPackageOpts < Test::Unit::TestCase
6
6
 
7
7
  context "A AsDoc Package Tool Options Parser" do
8
8
 
@@ -59,19 +59,25 @@ class TestAssetVacuum < Test::Unit::TestCase
59
59
  should "only search css files referenced in as/mxml for asset references" do
60
60
  #Tecnically yes. Sounds like a pain in the ass to me though.
61
61
  end
62
+
62
63
  end
63
64
 
64
65
  context "with incorrect arguments" do
65
- setup do
66
- opt = {:src => "INVALID", :output => "/tmp/as-asset-vacuum.txt"}
67
- @out = StringIO.new
68
- @tool = AssetVacuum.new(opt,@out)
69
- end
70
66
 
71
67
  should "fail with a warning message" do
72
- assert_match(/#{AssetVacuum::INVALID_OPTS}/, @out.string)
68
+ opt = {:src => "INVALID", :output => "/tmp/as-asset-vacuum.txt"}
69
+ out = StringIO.new
70
+
71
+ begin
72
+ AssetVacuum.new(opt,out)
73
+ flunk
74
+ rescue SystemExit => e
75
+ assert_equal 0, e.status
76
+ assert_match(/#{Tool::INVALID_OPTS} The source/, out.string)
77
+ end
73
78
  end
79
+
74
80
  end
75
- end
76
81
 
82
+ end
77
83
  end
@@ -7,14 +7,12 @@ class TestAssetVacuumOpts < Test::Unit::TestCase
7
7
  context "An Asset Vacuum Tool Options Parser" do
8
8
 
9
9
  should "return default hash if no arguments are specified" do
10
-
11
10
  args = []
12
11
  opts = AssetVacuumOpts.parse(args)
13
12
 
14
13
  assert_equal 'assets.txt', opts[:output]
15
14
  assert_equal '.', opts[:src]
16
15
  assert_equal false, opts[:verbose]
17
-
18
16
  end
19
17
 
20
18
  should "display a name" do
@@ -26,5 +24,4 @@ class TestAssetVacuumOpts < Test::Unit::TestCase
26
24
  end
27
25
 
28
26
  end
29
-
30
27
  end
@@ -34,15 +34,20 @@ class TestClassVacuum < Test::Unit::TestCase
34
34
  end
35
35
 
36
36
  context "with incorrect arguments" do
37
- setup do
38
- opt = {:manifest => "INVALID", :output => '/tmp/as-class-vacuum.txt'}
39
- @out = StringIO.new
40
- @tool = ClassVacuum.new(opt,@out)
41
- end
42
37
 
43
38
  should "fail with a warning message" do
44
- assert_match(/#{ClassVacuum::INVALID_OPTS}/, @out.string)
39
+ opt = {:manifest => "INVALID", :output => '/tmp/as-class-vacuum.txt'}
40
+ out = StringIO.new
41
+
42
+ begin
43
+ ClassVacuum.new(opt,out)
44
+ flunk
45
+ rescue SystemExit => e
46
+ assert_equal 0, e.status
47
+ assert_match(/#{Tool::INVALID_OPTS}/, out.string)
48
+ end
45
49
  end
50
+
46
51
  end
47
52
 
48
53
  end