gator 0.0.20.pre → 0.0.21.pre

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.20.pre
1
+ 0.0.21.pre
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gator}
8
- s.version = "0.0.20.pre"
8
+ s.version = "0.0.21.pre"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dominic Graefen"]
12
- s.date = %q{2011-08-15}
12
+ s.date = %q{2011-08-19}
13
13
  s.default_executable = %q{gator}
14
14
  s.description = %q{gator - the friendly code-generator}
15
15
  s.email = %q{dominic.graefen@gmail.com}
@@ -34,6 +34,8 @@ Gem::Specification.new do |s|
34
34
  "lib/gator/commands/generate.rb",
35
35
  "lib/gator/commands/project.rb",
36
36
  "lib/gator/config.rb",
37
+ "lib/gator/generators.rb",
38
+ "lib/gator/generators/generator.rb",
37
39
  "lib/gator/project.rb",
38
40
  "lib/gator/runner.rb",
39
41
  "lib/gator/task.rb",
@@ -1,7 +1,8 @@
1
- require 'gator/config'
2
- require 'gator/project'
3
- require 'gator/util'
4
- require 'gator/command'
5
- require 'gator/task'
6
- require 'gator/runner'
7
- require 'gator/commands'
1
+ require File.dirname(__FILE__) + '/gator/config'
2
+ require File.dirname(__FILE__) + '/gator/project'
3
+ require File.dirname(__FILE__) + '/gator/util'
4
+ require File.dirname(__FILE__) + '/gator/command'
5
+ require File.dirname(__FILE__) + '/gator/task'
6
+ require File.dirname(__FILE__) + '/gator/generators'
7
+ require File.dirname(__FILE__) + '/gator/runner'
8
+ require File.dirname(__FILE__) + '/gator/commands'
@@ -24,6 +24,10 @@ module Gator
24
24
  self.class.parent
25
25
  end
26
26
 
27
+ def definition
28
+ self.class.definition
29
+ end
30
+
27
31
  def get_subcommand(*args)
28
32
  nil
29
33
  end
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + '/generators/generator'
@@ -0,0 +1,31 @@
1
+ module Gator
2
+ class Generator < Task
3
+ def init
4
+ end
5
+ end
6
+ module ActAsTemplateGenerator
7
+
8
+ def self.included(base)
9
+ base.extend(ClassMethods)
10
+ end
11
+
12
+ module ClassMethods
13
+
14
+ def template_root
15
+ nil
16
+ end
17
+
18
+ def source_paths
19
+ unless @template_roots
20
+ @template_roots = []
21
+ @template_roots += Gator::Project.project.template_roots if Gator::Project.project
22
+ @template_roots << Gator::Util.generator_template_root
23
+ @template_roots << template_root if template_root
24
+ end
25
+ @template_roots
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
@@ -32,6 +32,10 @@ module Gator
32
32
  @options ||= {}
33
33
  end
34
34
 
35
+ def template_roots
36
+ @template_roots ||= []
37
+ end
38
+
35
39
  end
36
40
 
37
41
  # THIS CLASS IS STOLEN FROM BUILDR
@@ -29,6 +29,10 @@ module Gator
29
29
  File.join(gator_root, "templates", "projects")
30
30
  end
31
31
 
32
+ def self.generator_template_root
33
+ File.join(gator_root, "templates", "generators" )
34
+ end
35
+
32
36
  def self.load_rubyfile(path, content=nil, debug=false)
33
37
  content ||= File.binread(path)
34
38
 
@@ -1,20 +1,84 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
+ class CommandA < Gator::Command
4
+ define :command => "a", :short => "a",
5
+ :usage => "a", :description => "a"
6
+ end
7
+
8
+ class CommandB < Gator::Command
9
+ define :command => "b", :short => "b",
10
+ :usage => "b", :description => "b"
11
+ end
12
+
13
+ class CommandC < Gator::Command
14
+ define :command => "c", :short => "c",
15
+ :usage => "c", :description => "c"
16
+ end
17
+
18
+ class SpecCollection < Gator::Command
19
+ define :command => "collection", :short => "c",
20
+ :usage => "collection", :description => "collection"
21
+
22
+ register_subcommand CommandA
23
+ CommandA.register_subcommand CommandB
24
+ register_subcommand CommandC
25
+ end
3
26
 
4
27
  describe Gator::ActAsCommand do
5
28
 
6
- it "should have some tests"
29
+ it "should contain the correct definition" do
30
+ CommandA.definition[:command].should == "a"
31
+ CommandA.definition[:short].should == "a"
32
+ CommandA.definition[:usage].should == "a"
33
+ CommandA.definition[:description].should == "a"
34
+ end
35
+
36
+ it "should have the correct parent" do
37
+ CommandB.parent.should == CommandA
38
+ CommandA.parent.should == SpecCollection
39
+ CommandC.parent.should == SpecCollection
40
+ SpecCollection.parent.should == nil
41
+ end
7
42
 
8
43
  end
9
44
 
10
45
  describe Gator::ActAsCommandCollection do
11
46
 
12
- it "should have some tests"
47
+ it "should provide the correct subcommands" do
48
+ SpecCollection.get_subcommand("a").should == CommandA
49
+ SpecCollection.get_subcommand("c").should == CommandC
50
+ end
51
+
52
+ it "should provide the correct nested subcommands" do
53
+ SpecCollection.get_subcommand("a","b").should == CommandB
54
+ end
55
+
56
+ it "should return nil if a command cannot be found" do
57
+ SpecCollection.get_subcommand("d").should == nil
58
+ end
59
+
60
+ it "should resolve the correct subcommand on a parent" do
61
+ CommandB.resolve_subcommand(["a"]).should == CommandA
62
+ CommandB.resolve_subcommand(["c"]).should == CommandC
63
+ end
64
+
65
+ it "should resolve the correct nested subcommand on a parent" do
66
+ CommandC.resolve_subcommand(["a","b"]).should == CommandB
67
+ end
68
+
69
+ it "should fall back to CommandB" do
70
+ CommandC.resolve_subcommand(["a","d"],["a","b"]).should == CommandB
71
+ end
72
+
73
+ it "should return nil if a command cannot be resolved" do
74
+ CommandC.resolve_subcommand("d").should == nil
75
+ end
13
76
 
14
77
  end
15
78
 
16
79
  describe Gator::Command do
17
80
 
18
- it "should have some tests"
81
+ it "should be covered by Gator::ActAsCommandCollection & Gator::ActAsCommand" do
82
+ end
19
83
 
20
84
  end
@@ -3,6 +3,6 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
 
4
4
  describe Gator::Task do
5
5
 
6
- it "should have some tests"
6
+ it "should really have some tests"
7
7
 
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20.pre
4
+ version: 0.0.21.pre
5
5
  prerelease: 7
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-15 00:00:00.000000000 +02:00
12
+ date: 2011-08-19 00:00:00.000000000 +02:00
13
13
  default_executable: gator
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
17
- requirement: &2158120480 !ruby/object:Gem::Requirement
17
+ requirement: &2158656960 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.14.6
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2158120480
25
+ version_requirements: *2158656960
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec
28
- requirement: &2158119980 !ruby/object:Gem::Requirement
28
+ requirement: &2158656340 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 2.3.0
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2158119980
36
+ version_requirements: *2158656340
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: ci_reporter
39
- requirement: &2158119440 !ruby/object:Gem::Requirement
39
+ requirement: &2158655620 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.6.5
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2158119440
47
+ version_requirements: *2158655620
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: bundler
50
- requirement: &2158115740 !ruby/object:Gem::Requirement
50
+ requirement: &2158654900 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 1.0.0
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2158115740
58
+ version_requirements: *2158654900
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: jeweler
61
- requirement: &2158115200 !ruby/object:Gem::Requirement
61
+ requirement: &2158653320 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 1.6.2
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *2158115200
69
+ version_requirements: *2158653320
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rcov
72
- requirement: &2158114640 !ruby/object:Gem::Requirement
72
+ requirement: &2158652720 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,7 +77,7 @@ dependencies:
77
77
  version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *2158114640
80
+ version_requirements: *2158652720
81
81
  description: gator - the friendly code-generator
82
82
  email: dominic.graefen@gmail.com
83
83
  executables:
@@ -102,6 +102,8 @@ files:
102
102
  - lib/gator/commands/generate.rb
103
103
  - lib/gator/commands/project.rb
104
104
  - lib/gator/config.rb
105
+ - lib/gator/generators.rb
106
+ - lib/gator/generators/generator.rb
105
107
  - lib/gator/project.rb
106
108
  - lib/gator/runner.rb
107
109
  - lib/gator/task.rb
@@ -130,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
132
  version: '0'
131
133
  segments:
132
134
  - 0
133
- hash: 382817011434397857
135
+ hash: -2425800773055495603
134
136
  required_rubygems_version: !ruby/object:Gem::Requirement
135
137
  none: false
136
138
  requirements: