cape 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +6 -0
  3. data/.travis.yml +7 -0
  4. data/.yardopts +1 -0
  5. data/Gemfile +18 -0
  6. data/History.markdown +7 -0
  7. data/MIT-LICENSE.markdown +10 -0
  8. data/README.markdown +157 -0
  9. data/Rakefile +49 -0
  10. data/cape.gemspec +36 -0
  11. data/features/dsl/each_rake_task/with_defined_namespace_argument.feature +43 -0
  12. data/features/dsl/each_rake_task/with_defined_task_argument.feature +37 -0
  13. data/features/dsl/each_rake_task/with_undefined_argument.feature +31 -0
  14. data/features/dsl/each_rake_task/without_arguments.feature +81 -0
  15. data/features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_defined_namespace_argument.feature +93 -0
  16. data/features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_defined_task_argument.feature +66 -0
  17. data/features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_undefined_argument.feature +39 -0
  18. data/features/dsl/mirror_rake_tasks/inside_capistrano_namespace/without_arguments.feature +263 -0
  19. data/features/dsl/mirror_rake_tasks/with_defined_namespace_argument.feature +85 -0
  20. data/features/dsl/mirror_rake_tasks/with_defined_task_argument.feature +60 -0
  21. data/features/dsl/mirror_rake_tasks/with_undefined_argument.feature +35 -0
  22. data/features/dsl/mirror_rake_tasks/without_arguments.feature +243 -0
  23. data/features/step_definitions.rb +33 -0
  24. data/features/support/env.rb +1 -0
  25. data/features/task_invocation/nonparameterized.feature +69 -0
  26. data/features/task_invocation/parameterized.feature +70 -0
  27. data/lib/cape.rb +22 -0
  28. data/lib/cape/capistrano.rb +86 -0
  29. data/lib/cape/core_ext.rb +10 -0
  30. data/lib/cape/core_ext/hash.rb +24 -0
  31. data/lib/cape/core_ext/symbol.rb +25 -0
  32. data/lib/cape/dsl.rb +81 -0
  33. data/lib/cape/rake.rb +60 -0
  34. data/lib/cape/strings.rb +25 -0
  35. data/lib/cape/version.rb +6 -0
  36. data/spec/cape/capistrano_spec.rb +0 -0
  37. data/spec/cape/core_ext/hash_spec.rb +12 -0
  38. data/spec/cape/core_ext/symbol_spec.rb +7 -0
  39. data/spec/cape/dsl_spec.rb +128 -0
  40. data/spec/cape/rake_spec.rb +0 -0
  41. data/spec/cape/strings_spec.rb +44 -0
  42. data/spec/cape/task_spec.rb +0 -0
  43. data/spec/cape/version_spec.rb +6 -0
  44. data/spec/cape_spec.rb +5 -0
  45. metadata +192 -0
@@ -0,0 +1,25 @@
1
+ module Cape
2
+
3
+ # Provides utility methods for String objects.
4
+ module Strings
5
+
6
+ extend self
7
+
8
+ # Returns the English plural form of _noun_, unless _count_ is +1+. The
9
+ # _count_ argument is optional, and defaults to +2+.
10
+ def pluralize(noun, count=2)
11
+ return noun if count == 1
12
+
13
+ "#{noun}s"
14
+ end
15
+
16
+ # Builds an English list phrase from the elements of _array_.
17
+ def to_list_phrase(array)
18
+ return array.join(' and ') if (array.length <= 2)
19
+
20
+ [array[0...-1].join(', '), array[-1]].join ', and '
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,6 @@
1
+ module Cape
2
+
3
+ # The version of Cape.
4
+ VERSION = '1.0.0'
5
+
6
+ end
File without changes
@@ -0,0 +1,12 @@
1
+ require 'cape/core_ext/hash'
2
+
3
+ describe Hash do
4
+ describe '#slice' do
5
+ it 'should return the expected Hash' do
6
+ hash = {:foo => 'bar', :baz => 'qux', :quux => 'corge'}
7
+ hash.slice(:baz, :quux).should == {:baz => 'qux', :quux => 'corge'}
8
+
9
+ {}.slice(:foo).should == {}
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ require 'cape/core_ext/symbol'
2
+
3
+ describe Symbol do
4
+ it 'should compare as expected to another Symbol' do
5
+ (:foo <=> :bar).should == 1
6
+ end
7
+ end
@@ -0,0 +1,128 @@
1
+ require 'cape/dsl'
2
+ require 'cape/capistrano'
3
+ require 'cape/core_ext/hash'
4
+ require 'cape/core_ext/symbol'
5
+ require 'cape/rake'
6
+
7
+ describe Cape::DSL do
8
+ subject do
9
+ Object.new.tap do |o|
10
+ o.extend described_class
11
+ end
12
+ end
13
+
14
+ let(:mock_capistrano) { mock(Cape::Capistrano).as_null_object }
15
+
16
+ let(:mock_rake) { mock(Cape::Rake).as_null_object }
17
+
18
+ let(:task_expression) { 'task:expression' }
19
+
20
+ before :each do
21
+ Cape::Capistrano.stub!(:new).and_return mock_capistrano
22
+ Cape::Rake.stub!(:new).and_return mock_rake
23
+ end
24
+
25
+ describe 'when sent #each_rake_task' do
26
+ def do_each_rake_task(&block)
27
+ subject.each_rake_task(task_expression, &block)
28
+ end
29
+
30
+ it 'should delegate to Rake#each_task' do
31
+ mock_rake.should_receive(:each_task).
32
+ with(task_expression).
33
+ and_yield({:name => task_expression})
34
+ do_each_rake_task do |t|
35
+ t.should == {:name => task_expression}
36
+ end
37
+ end
38
+
39
+ it 'should return itself' do
40
+ do_each_rake_task.should == subject
41
+ end
42
+ end
43
+
44
+ describe 'when sent #mirror_rake_tasks' do
45
+ before :each do
46
+ mock_rake.stub!(:each_task).and_yield({:name => task_expression})
47
+ subject.stub! :raise_unless_capistrano
48
+ end
49
+
50
+ def do_mirror_rake_tasks
51
+ subject.mirror_rake_tasks task_expression
52
+ end
53
+
54
+ it 'should collect Rake#each_task' do
55
+ mock_rake.should_receive(:each_task).with task_expression
56
+ do_mirror_rake_tasks
57
+ end
58
+
59
+ it 'should verify that Capistrano is in use' do
60
+ subject.should_receive :raise_unless_capistrano
61
+ do_mirror_rake_tasks
62
+ end
63
+
64
+ describe 'should Capistrano#define Rake#each_task' do
65
+ it 'with the expected task' do
66
+ mock_capistrano.should_receive(:define).with do |task, options|
67
+ task == {:name => task_expression}
68
+ end
69
+ do_mirror_rake_tasks
70
+ end
71
+
72
+ it 'with the expected named options' do
73
+ mock_capistrano.should_receive(:define).with do |task, opts|
74
+ opts.keys.sort == [:binding, :rake]
75
+ end
76
+ do_mirror_rake_tasks
77
+ end
78
+
79
+ it 'with a :binding option' do
80
+ mock_capistrano.should_receive(:define).with do |task, options|
81
+ options[:binding].is_a? Binding
82
+ end
83
+ do_mirror_rake_tasks
84
+ end
85
+
86
+ it 'with the expected :rake option' do
87
+ mock_capistrano.should_receive(:define).with do |task, options|
88
+ options[:rake] == mock_rake
89
+ end
90
+ do_mirror_rake_tasks
91
+ end
92
+ end
93
+
94
+ it 'should return itself' do
95
+ do_mirror_rake_tasks.should == subject
96
+ end
97
+ end
98
+
99
+ describe 'when sent #local_rake_executable' do
100
+ before :each do
101
+ mock_rake.stub!(:local_executable).and_return 'foo'
102
+ end
103
+
104
+ it 'should delegate to Rake#local_executable' do
105
+ mock_rake.should_receive :local_executable
106
+ subject.local_rake_executable
107
+ end
108
+
109
+ it 'should return the result of Rake#local_executable' do
110
+ subject.local_rake_executable.should == 'foo'
111
+ end
112
+ end
113
+
114
+ describe 'when sent #remote_rake_executable' do
115
+ before :each do
116
+ mock_rake.stub!(:remote_executable).and_return 'foo'
117
+ end
118
+
119
+ it 'should delegate to Rake#remote_executable' do
120
+ mock_rake.should_receive :remote_executable
121
+ subject.remote_rake_executable
122
+ end
123
+
124
+ it 'should return the result of Rake#remote_executable' do
125
+ subject.remote_rake_executable.should == 'foo'
126
+ end
127
+ end
128
+ end
File without changes
@@ -0,0 +1,44 @@
1
+ require 'cape/strings'
2
+
3
+ describe Cape::Strings do
4
+ describe '::pluralize' do
5
+ it "should pluralize 'foo' as expected" do
6
+ Cape::Strings.pluralize('foo').should == 'foos'
7
+ end
8
+
9
+ it "should pluralize 'foo' as expected for a count of 2" do
10
+ Cape::Strings.pluralize('foo', 2).should == 'foos'
11
+ end
12
+
13
+ it "should not pluralize for a count of 1" do
14
+ Cape::Strings.pluralize('foo', 1).should == 'foo'
15
+ end
16
+
17
+ it "should pluralize 'foo' as expected for a count of 0" do
18
+ Cape::Strings.pluralize('foo', 0).should == 'foos'
19
+ end
20
+
21
+ it "should pluralize 'foo' as expected for a count of -1" do
22
+ Cape::Strings.pluralize('foo', -1).should == 'foos'
23
+ end
24
+ end
25
+
26
+ describe '::to_list_phrase' do
27
+ it 'should make the expected list phrase of an empty array' do
28
+ Cape::Strings.to_list_phrase([]).should == ''
29
+ end
30
+
31
+ it 'should make the expected list phrase of a 1-element array' do
32
+ Cape::Strings.to_list_phrase(%w(foo)).should == 'foo'
33
+ end
34
+
35
+ it 'should make the expected list phrase of a 2-element array' do
36
+ Cape::Strings.to_list_phrase(%w(foo bar)).should == 'foo and bar'
37
+ end
38
+
39
+ it 'should make the expected list phrase of a 3-element array' do
40
+ array = %w(foo bar baz)
41
+ Cape::Strings.to_list_phrase(array).should == 'foo, bar, and baz'
42
+ end
43
+ end
44
+ end
File without changes
@@ -0,0 +1,6 @@
1
+ require 'rspec'
2
+ require 'cape/version'
3
+
4
+ describe Cape::VERSION do
5
+ it { should =~ /^\d+\.\d+\.\d+/ }
6
+ end
@@ -0,0 +1,5 @@
1
+ require 'cape/version'
2
+
3
+ describe Cape::VERSION do
4
+ it { should match(/^\d+\.\d+\.\d+$/) }
5
+ end
metadata ADDED
@@ -0,0 +1,192 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cape
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Nils Jonsson
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-28 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: aruba
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: capistrano
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: rake
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ hash: 13
71
+ segments:
72
+ - 2
73
+ - 7
74
+ version: "2.7"
75
+ type: :development
76
+ version_requirements: *id004
77
+ description: Cape provides a simple DSL for selecting Rake tasks to be made available as documented Capistrano recipes. You can pass required arguments to Rake tasks via environment variables.
78
+ email:
79
+ - cape@nilsjonsson.com
80
+ executables: []
81
+
82
+ extensions: []
83
+
84
+ extra_rdoc_files: []
85
+
86
+ files:
87
+ - .gemtest
88
+ - .gitignore
89
+ - .travis.yml
90
+ - .yardopts
91
+ - Gemfile
92
+ - History.markdown
93
+ - MIT-LICENSE.markdown
94
+ - README.markdown
95
+ - Rakefile
96
+ - cape.gemspec
97
+ - features/dsl/each_rake_task/with_defined_namespace_argument.feature
98
+ - features/dsl/each_rake_task/with_defined_task_argument.feature
99
+ - features/dsl/each_rake_task/with_undefined_argument.feature
100
+ - features/dsl/each_rake_task/without_arguments.feature
101
+ - features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_defined_namespace_argument.feature
102
+ - features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_defined_task_argument.feature
103
+ - features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_undefined_argument.feature
104
+ - features/dsl/mirror_rake_tasks/inside_capistrano_namespace/without_arguments.feature
105
+ - features/dsl/mirror_rake_tasks/with_defined_namespace_argument.feature
106
+ - features/dsl/mirror_rake_tasks/with_defined_task_argument.feature
107
+ - features/dsl/mirror_rake_tasks/with_undefined_argument.feature
108
+ - features/dsl/mirror_rake_tasks/without_arguments.feature
109
+ - features/step_definitions.rb
110
+ - features/support/env.rb
111
+ - features/task_invocation/nonparameterized.feature
112
+ - features/task_invocation/parameterized.feature
113
+ - lib/cape.rb
114
+ - lib/cape/capistrano.rb
115
+ - lib/cape/core_ext.rb
116
+ - lib/cape/core_ext/hash.rb
117
+ - lib/cape/core_ext/symbol.rb
118
+ - lib/cape/dsl.rb
119
+ - lib/cape/rake.rb
120
+ - lib/cape/strings.rb
121
+ - lib/cape/version.rb
122
+ - spec/cape/capistrano_spec.rb
123
+ - spec/cape/core_ext/hash_spec.rb
124
+ - spec/cape/core_ext/symbol_spec.rb
125
+ - spec/cape/dsl_spec.rb
126
+ - spec/cape/rake_spec.rb
127
+ - spec/cape/strings_spec.rb
128
+ - spec/cape/task_spec.rb
129
+ - spec/cape/version_spec.rb
130
+ - spec/cape_spec.rb
131
+ homepage: ""
132
+ licenses:
133
+ - MIT
134
+ post_install_message:
135
+ rdoc_options: []
136
+
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ hash: 57
145
+ segments:
146
+ - 1
147
+ - 8
148
+ - 7
149
+ version: 1.8.7
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ hash: 3
156
+ segments:
157
+ - 0
158
+ version: "0"
159
+ requirements: []
160
+
161
+ rubyforge_project:
162
+ rubygems_version: 1.8.10
163
+ signing_key:
164
+ specification_version: 3
165
+ summary: Dynamically generates Capistrano recipes for Rake tasks
166
+ test_files:
167
+ - features/dsl/each_rake_task/with_defined_namespace_argument.feature
168
+ - features/dsl/each_rake_task/with_defined_task_argument.feature
169
+ - features/dsl/each_rake_task/with_undefined_argument.feature
170
+ - features/dsl/each_rake_task/without_arguments.feature
171
+ - features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_defined_namespace_argument.feature
172
+ - features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_defined_task_argument.feature
173
+ - features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_undefined_argument.feature
174
+ - features/dsl/mirror_rake_tasks/inside_capistrano_namespace/without_arguments.feature
175
+ - features/dsl/mirror_rake_tasks/with_defined_namespace_argument.feature
176
+ - features/dsl/mirror_rake_tasks/with_defined_task_argument.feature
177
+ - features/dsl/mirror_rake_tasks/with_undefined_argument.feature
178
+ - features/dsl/mirror_rake_tasks/without_arguments.feature
179
+ - features/step_definitions.rb
180
+ - features/support/env.rb
181
+ - features/task_invocation/nonparameterized.feature
182
+ - features/task_invocation/parameterized.feature
183
+ - spec/cape/capistrano_spec.rb
184
+ - spec/cape/core_ext/hash_spec.rb
185
+ - spec/cape/core_ext/symbol_spec.rb
186
+ - spec/cape/dsl_spec.rb
187
+ - spec/cape/rake_spec.rb
188
+ - spec/cape/strings_spec.rb
189
+ - spec/cape/task_spec.rb
190
+ - spec/cape/version_spec.rb
191
+ - spec/cape_spec.rb
192
+ has_rdoc: true