gator 0.0.21.pre → 0.0.22.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/Gemfile +3 -1
  2. data/Rakefile +3 -6
  3. data/VERSION +1 -1
  4. data/bin/gator +2 -3
  5. data/gator.gemspec +52 -30
  6. data/lib/gator.rb +6 -8
  7. data/lib/gator/core.rb +19 -0
  8. data/lib/gator/core/application/application.rb +41 -0
  9. data/lib/gator/core/application/application_configuration.rb +11 -0
  10. data/lib/gator/core/command/act_as_command.rb +40 -0
  11. data/lib/gator/core/command/act_as_command_collection.rb +63 -0
  12. data/lib/gator/core/command/command.rb +20 -0
  13. data/lib/gator/{task.rb → core/command/task.rb} +1 -4
  14. data/lib/gator/core/configuration/act_as_configuration.rb +30 -0
  15. data/lib/gator/core/configuration/configuration.rb +5 -0
  16. data/lib/gator/core/io/paths.rb +21 -0
  17. data/lib/gator/core/io/project_file_locator.rb +28 -0
  18. data/lib/gator/core/io/ruby_file_loader.rb +21 -0
  19. data/lib/gator/core/io/sandbox.rb +9 -0
  20. data/lib/gator/{project.rb → core/project/layout.rb} +3 -44
  21. data/lib/gator/core/project/project.rb +21 -0
  22. data/lib/gator/plugins/generators.rb +5 -0
  23. data/lib/gator/{generators/generator.rb → plugins/generators/act_as_template_generator.rb} +1 -5
  24. data/lib/gator/{commands/generate.rb → plugins/generators/generate_command.rb} +1 -1
  25. data/lib/gator/plugins/generators/generator.rb +6 -0
  26. data/lib/gator/plugins/scaffolding.rb +4 -0
  27. data/lib/gator/plugins/scaffolding/scaffold_command.rb +62 -0
  28. data/lib/gator/plugins/scaffolding/scaffolding_file_utils.rb +58 -0
  29. data/rake/jeweler.rb +17 -0
  30. data/rake/jeweler_prerelease_tasks.rb +50 -0
  31. data/rake/pre_release_gemspec.rb +80 -0
  32. data/rake/pre_release_to_git.rb +59 -0
  33. data/spec/core/application/application_configuration_spec.rb +21 -0
  34. data/spec/core/application/application_spec.rb +15 -0
  35. data/spec/core/command/command_spec.rb +117 -0
  36. data/spec/core/command/task_spec.rb +95 -0
  37. data/spec/core/configuration/configuration_spec.rb +55 -0
  38. data/spec/core/io/paths_spec.rb +44 -0
  39. data/spec/core/io/sandbox_spec.rb +11 -0
  40. data/spec/core/project/layout_spec.rb +64 -0
  41. data/spec/core/project/project_spec.rb +51 -0
  42. data/spec/fixtures/empty_gator_project/gator.rb +4 -0
  43. data/spec/fixtures/no_gator_file/.empty_directory +0 -0
  44. data/spec/plugins/scaffolding/scaffold_command_spec.rb +75 -0
  45. data/spec/spec_helper.rb +14 -9
  46. metadata +65 -36
  47. data/lib/gator/command.rb +0 -109
  48. data/lib/gator/commands.rb +0 -5
  49. data/lib/gator/commands/project.rb +0 -87
  50. data/lib/gator/config.rb +0 -23
  51. data/lib/gator/generators.rb +0 -1
  52. data/lib/gator/runner.rb +0 -21
  53. data/lib/gator/util.rb +0 -91
  54. data/spec/command_spec.rb +0 -84
  55. data/spec/config_spec.rb +0 -14
  56. data/spec/project_spec.rb +0 -15
  57. data/spec/runner_spec.rb +0 -9
  58. data/spec/task_spec.rb +0 -8
  59. data/spec/util_spec.rb +0 -60
@@ -0,0 +1,59 @@
1
+ class Jeweler
2
+ module Commands
3
+ class PreReleaseToGit
4
+ attr_accessor :gemspec, :version, :repo, :output, :gemspec_helper, :base_dir
5
+
6
+ def initialize(attributes = {})
7
+ self.output = $stdout
8
+
9
+ attributes.each_pair do |key, value|
10
+ send("#{key}=", value)
11
+ end
12
+ end
13
+
14
+ def run
15
+ unless clean_staging_area?
16
+ system "git status"
17
+ raise "Unclean staging area! Be sure to commit or .gitignore everything first. See `git status` above."
18
+ end
19
+
20
+ repo.checkout('develop')
21
+ repo.push
22
+
23
+ if release_not_tagged?
24
+ output.puts "Tagging #{release_tag}"
25
+ repo.add_tag(release_tag)
26
+
27
+ output.puts "Pushing #{release_tag} to origin"
28
+ repo.push('origin', release_tag)
29
+ end
30
+ end
31
+
32
+ def clean_staging_area?
33
+ `git ls-files --deleted --modified --others --exclude-standard` == ""
34
+ end
35
+
36
+ def release_tag
37
+ "v#{version}"
38
+ end
39
+
40
+ def release_not_tagged?
41
+ tag = repo.tag(release_tag) rescue nil
42
+ tag.nil?
43
+ end
44
+
45
+ def self.build_for(jeweler)
46
+ command = self.new
47
+
48
+ command.base_dir = jeweler.base_dir
49
+ command.gemspec = jeweler.gemspec
50
+ command.version = jeweler.version
51
+ command.repo = jeweler.repo
52
+ command.output = jeweler.output
53
+ command.gemspec_helper = jeweler.gemspec_helper
54
+
55
+ command
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,21 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Gator::ApplicationConfiguration do
4
+
5
+ before :each do
6
+ @app_config = Gator::ApplicationConfiguration.new
7
+ end
8
+
9
+ it "should have a project configuration" do
10
+ @app_config.project.should be_a_kind_of Gator::Project
11
+ end
12
+
13
+ it "should have an environment configuration" do
14
+ @app_config.environment.should be_a_kind_of Gator::Configuration
15
+ end
16
+
17
+ it "should have an env shortcut to environment" do
18
+ @app_config.env.should equal @app_config.environment
19
+ end
20
+
21
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Gator::Application do
4
+
5
+ before :each do
6
+ @app = Gator::Application.new
7
+ end
8
+
9
+ it "should print the correct version" do
10
+ version = File.read( File.dirname(__FILE__) + '/../../../VERSION' )
11
+ @app.should_receive(:say).with(version)
12
+ @app.version
13
+ end
14
+
15
+ end
@@ -0,0 +1,117 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Gator::Command do
4
+
5
+ before :all do
6
+
7
+ class CommandA < Gator::Command
8
+ define :command => "CommandA", :short => "CA",
9
+ :usage => "CommandA is useless", :description => "CommandA doesn't need a description"
10
+ end
11
+
12
+ class CommandB < Gator::Command
13
+ define :command => "CommandB", :short => "CB",
14
+ :usage => "CommandB is useless", :description => "CommandB doesn't need a description"
15
+ end
16
+
17
+ class CommandC < Gator::Command
18
+ define :command => "CommandC", :short => "CC",
19
+ :usage => "CommandC is useless", :description => "CommandC doesn't need a description"
20
+ end
21
+
22
+ class CommandD < Gator::Command
23
+ define :command => "CommandD", :short => "CD",
24
+ :usage => "CommandD is useless", :description => "CommandD doesn't need a description"
25
+ end
26
+
27
+ CommandA << CommandB
28
+ CommandA << CommandC
29
+ CommandC << CommandD
30
+
31
+ end
32
+
33
+ after :all do
34
+
35
+ remove_const CommandA
36
+ puts "commandA: #{CommandA}"
37
+ remove_const CommandB
38
+ remove_const CommandC
39
+ remove_const CommandD
40
+
41
+ end
42
+
43
+
44
+ describe "ClassMethods" do
45
+
46
+ it "should provide the correct subcommands" do
47
+ CommandA.get_subcommand("CommandB").should equal CommandB
48
+ CommandA.get_subcommand("CommandC").should equal CommandC
49
+ end
50
+
51
+ it "should provide the correct nested subcommands" do
52
+ CommandA.get_subcommand("CommandC", "CommandD").should equal CommandD
53
+ end
54
+
55
+ it "should return nil if a command cannot be found" do
56
+ CommandA.get_subcommand("CommandZ").should_not be
57
+ end
58
+
59
+ it "should resolve the correct subcommand on a parent" do
60
+ CommandB.resolve_subcommand(["CommandA"]).should == CommandA
61
+ end
62
+
63
+ it "should resolve the correct nested subcommand on a parent" do
64
+ CommandD.resolve_subcommand(["CommandA", "CommandB"]).should == CommandB
65
+ end
66
+
67
+ it "should fall back to CommandB" do
68
+ CommandC.resolve_subcommand(["CommandA", "CommandD"], ["CommandA", "CommandB"]).should == CommandB
69
+ end
70
+
71
+ it "should return nil if a command cannot be resolved" do
72
+ CommandC.resolve_subcommand("d").should == nil
73
+ end
74
+
75
+ end
76
+
77
+ describe "InstanceMethods" do
78
+
79
+ before :each do
80
+ @command_a = CommandA.new
81
+ @command_b = CommandB.new
82
+ @command_c = CommandC.new
83
+ @command_d = CommandD.new
84
+ end
85
+
86
+ it "should provide the correct subcommands" do
87
+ @command_a.get_subcommand("CommandB").should equal CommandB
88
+ @command_a.get_subcommand("CommandC").should equal CommandC
89
+ end
90
+
91
+ it "should provide the correct nested subcommands" do
92
+ @command_a.get_subcommand("CommandC", "CommandD").should equal CommandD
93
+ end
94
+
95
+ it "should return nil if a command cannot be found" do
96
+ @command_a.get_subcommand("CommandZ").should_not be
97
+ end
98
+
99
+ it "should resolve the correct subcommand on a parent" do
100
+ @command_a.resolve_subcommand(["CommandA"]).should == CommandA
101
+ end
102
+
103
+ it "should resolve the correct nested subcommand on a parent" do
104
+ @command_d.resolve_subcommand(["CommandA", "CommandB"]).should == CommandB
105
+ end
106
+
107
+ it "should fall back to CommandB" do
108
+ @command_c.resolve_subcommand(["CommandA", "CommandD"], ["CommandA", "CommandB"]).should == CommandB
109
+ end
110
+
111
+ it "should return nil if a command cannot be resolved" do
112
+ @command_c.resolve_subcommand("d").should == nil
113
+ end
114
+
115
+ end
116
+
117
+ end
@@ -0,0 +1,95 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Gator::Task do
4
+
5
+ before :all do
6
+
7
+ class TaskWithoutParent < Gator::Task
8
+ define :command => "TaskWithoutParent", :short => "TWOP",
9
+ :usage => "TaskWithoutParent is useless", :description => "TaskWithoutParent doesn't need a description"
10
+ end
11
+
12
+ class TaskWithParent < Gator::Task
13
+ define :command => "TaskWithParent", :short => "TWP",
14
+ :usage => "TaskWithParent is useless", :description => "TaskWithParent doesn't need a description"
15
+ end
16
+
17
+ class TaskContainer < Gator::Command
18
+ define :command => "TaskContainer", :short => "TC",
19
+ :usage => "TaskContainer is useless", :description => "TaskContainer doesn't need a description"
20
+
21
+ register_subcommand TaskWithParent
22
+ end
23
+
24
+ end
25
+
26
+ after :all do
27
+ remove_const TaskWithoutParent
28
+ remove_const TaskWithParent
29
+ remove_const TaskContainer
30
+ end
31
+
32
+ describe "ClassMethods" do
33
+
34
+ it "should return the correct definition" do
35
+ TaskWithoutParent.definition[:command].should == "TaskWithoutParent"
36
+ TaskWithoutParent.definition[:short].should == "TWOP"
37
+ TaskWithoutParent.definition[:usage].should == "TaskWithoutParent is useless"
38
+ TaskWithoutParent.definition[:description].should == "TaskWithoutParent doesn't need a description"
39
+ end
40
+
41
+ it "should return the correct parent command" do
42
+ TaskWithParent.parent.should equal TaskContainer
43
+ end
44
+
45
+ it "should return nil when it does not have a parent command" do
46
+ TaskWithoutParent.parent.should_not be
47
+ end
48
+
49
+ end
50
+
51
+ describe "InstanceMethods" do
52
+
53
+ before :each do
54
+ @task_with_parent = TaskWithParent.new
55
+ @task_without_parent = TaskWithoutParent.new
56
+ end
57
+
58
+ it "should return the correct definition" do
59
+ @task_without_parent.definition[:command].should == "TaskWithoutParent"
60
+ @task_without_parent.definition[:short].should == "TWOP"
61
+ @task_without_parent.definition[:usage].should == "TaskWithoutParent is useless"
62
+ @task_without_parent.definition[:description].should == "TaskWithoutParent doesn't need a description"
63
+ end
64
+
65
+ it "should return the correct parent command" do
66
+ @task_with_parent.parent.should equal TaskContainer
67
+ end
68
+
69
+ it "should return nil when it does not have a parent command" do
70
+ @task_without_parent.parent.should_not be
71
+ end
72
+
73
+ it "should return nil for requests to subcommands" do
74
+ @task_with_parent.get_subcommand.should_not be
75
+ end
76
+
77
+ it "should return nil for requests to resolve subcommands when it does not have a parent" do
78
+ @task_without_parent.resolve_subcommand("test").should_not be
79
+ end
80
+
81
+ it "should return nil for requests to resolve subcommands with a wrong command name" do
82
+ @task_with_parent.resolve_subcommand("TaskContainer_").should_not be
83
+ end
84
+
85
+ it "should return the parent task for requests with the parents command name" do
86
+ @task_with_parent.resolve_subcommand( [@task_with_parent.parent.definition[:command]] ).should equal @task_with_parent.parent
87
+ end
88
+
89
+ it "should return its class for requests with the its command name" do
90
+ @task_with_parent.resolve_subcommand( [@task_with_parent.definition[:command]] ).should equal @task_with_parent.class
91
+ end
92
+
93
+ end
94
+
95
+ end
@@ -0,0 +1,55 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Gator::Configuration do
4
+
5
+ before :all do
6
+ class ConcreteConfiguration < Gator::Configuration
7
+ end
8
+ end
9
+
10
+ after :all do
11
+ remove_const ConcreteConfiguration
12
+ end
13
+
14
+ before :each do
15
+ @configuration = ConcreteConfiguration.new
16
+ end
17
+
18
+ it "should add a property getter" do
19
+ @configuration.add_configuration :my_prop
20
+ @configuration.should respond_to "my_prop"
21
+ end
22
+
23
+ it "should add a property setter" do
24
+ @configuration.add_configuration :my_prop
25
+ @configuration.should respond_to "my_prop="
26
+ end
27
+
28
+ it "should set and get a property via its setter" do
29
+ a = {}
30
+ @configuration.add_configuration :a
31
+ @configuration.a= a
32
+ @configuration.a.should eql(a)
33
+ end
34
+
35
+ it "should add a value" do
36
+ a = {}
37
+ @configuration.add_configuration :my_prop, a
38
+ @configuration.my_prop.should eql(a)
39
+ end
40
+
41
+ it "should yield around a property" do
42
+ a = {}
43
+ @configuration.add_configuration :my_prop, a
44
+ @configuration.my_prop do |property|
45
+ property.should eql(a)
46
+ end
47
+ end
48
+
49
+ it "should add a getter with a value" do
50
+ a = {}
51
+ @configuration.add_getter :my_getter, a
52
+ @configuration.my_getter.should equal a
53
+ end
54
+
55
+ end
@@ -0,0 +1,44 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+
4
+ describe Gator::Paths do
5
+
6
+ before :all do
7
+ @original_pwd = Dir.pwd
8
+ @empty_project = File.expand_path(File.dirname(__FILE__) + '/../../fixtures/empty_gator_project')
9
+ @not_a_project = File.expand_path(File.dirname(__FILE__) + '/../../fixtures/no_gator_file')
10
+ end
11
+
12
+ after :all do
13
+ Dir.chdir @original_pwd
14
+ end
15
+
16
+ it "should point to the correct gator home in the users directory" do
17
+ Gator::Paths.gator_home.should == File.join(Thor::Util.user_home,".gator")
18
+ end
19
+
20
+ it "should point to the correct project base directory" do
21
+ Dir.chdir @empty_project
22
+ Gator::Paths.project_home.should == @empty_project
23
+ end
24
+
25
+ it "should point to the correct environment file" do
26
+ Gator::Paths.env_file == File.join( Gator::Paths.gator_home, "environment.rb" )
27
+ end
28
+
29
+ it "should return nil for project base directory when not in a project directory" do
30
+ Dir.chdir @not_a_project
31
+ Gator::Paths.project_home.should_not be
32
+ end
33
+
34
+ it "should point to the correct project file" do
35
+ Dir.chdir @empty_project
36
+ Gator::Paths.project_file.should == File.join(@empty_project,"gator.rb")
37
+ end
38
+
39
+ it "should return nil for project file when not in a project directory" do
40
+ Dir.chdir @not_a_project
41
+ Gator::Paths.project_file.should_not be
42
+ end
43
+
44
+ end
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+
4
+ describe Gator::Sandbox do
5
+
6
+ it "should add a getter for a value" do
7
+ Gator::Sandbox.add_getter :my_getter, "MyValue"
8
+ Gator::Sandbox.my_getter.should == "MyValue"
9
+ end
10
+
11
+ end
@@ -0,0 +1,64 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Gator::Layout do
4
+
5
+ before :each do
6
+ @layout = Gator::Layout.new
7
+ end
8
+
9
+ it 'should expand empty to itself' do
10
+ @layout.expand.should eql('')
11
+ @layout.expand('').should eql('')
12
+ end
13
+
14
+ it 'should expand array of symbols' do
15
+ @layout.expand(:foo, :bar).should eql('foo/bar')
16
+ end
17
+
18
+ it 'should expand array of names' do
19
+ @layout.expand('foo', 'bar').should eql('foo/bar')
20
+ end
21
+
22
+ it 'should map symbol to path' do
23
+ @layout[:foo] = 'baz'
24
+ @layout.expand(:foo, :bar).should eql('baz/bar')
25
+ end
26
+
27
+ it 'should map symbols to path' do
28
+ @layout[:foo, :bar] = 'none'
29
+ @layout.expand(:foo, :bar).should eql('none')
30
+ end
31
+
32
+ it 'should map strings to path' do
33
+ @layout[:foo, "bar"] = 'none'
34
+ @layout.expand(:foo, :bar).should eql('none')
35
+ @layout.expand(:foo, 'bar').should eql('none')
36
+ end
37
+
38
+ it 'should ignore nil elements' do
39
+ @layout[:foo, :bar] = 'none'
40
+ @layout.expand(:foo, nil, :bar).should eql('none')
41
+ @layout.expand(nil, :foo).should eql('foo')
42
+ end
43
+
44
+ it 'should return nil if path not mapped' do
45
+ @layout[:foo].should be_nil
46
+ end
47
+
48
+ it 'should return path from symbol' do
49
+ @layout[:foo] = 'path'
50
+ @layout[:foo].should eql('path')
51
+ end
52
+
53
+ it 'should return path from symbol' do
54
+ @layout[:foo, :bar] = 'path'
55
+ @layout[:foo, :bar].should eql('path')
56
+ end
57
+
58
+ it 'should do eager mapping' do
59
+ @layout[:one] = 'none'
60
+ @layout[:one, :two] = '1..2'
61
+ @layout.expand(:one, :two, :three).should eql('1..2/three')
62
+ end
63
+
64
+ end