borg-rb 0.0.5 → 0.1.0
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.
- checksums.yaml +8 -8
- data/CHANGELOG.md +2 -12
- data/bin/borg +2 -17
- data/borg.gemspec +13 -12
- data/cap/initializers/performance.rb +6 -7
- data/cap/initializers/role_reset.rb +1 -1
- data/cap/initializers/sigint.rb +2 -4
- data/lib/borg-rb.rb +2 -9
- data/lib/borg.rb +15 -0
- data/lib/borg/cli.rb +28 -0
- data/lib/borg/cli/applications.rb +4 -6
- data/lib/borg/cli/assimilator.rb +1 -3
- data/lib/borg/configuration.rb +17 -0
- data/lib/borg/configuration/applications.rb +5 -8
- data/lib/borg/configuration/assimilator.rb +6 -7
- data/lib/borg/configuration/stages.rb +1 -3
- data/lib/borg/version.rb +1 -1
- data/spec/acceptance/borgify_plugin_spec.rb +4 -4
- data/spec/acceptance/borgify_spec.rb +11 -11
- data/spec/lib/borg/cli/applications_spec.rb +83 -50
- data/spec/lib/borg/cli_spec.rb +187 -0
- data/spec/lib/borg/configuration/applications_spec.rb +31 -34
- data/spec/lib/borg/configuration/assimilator_spec.rb +34 -20
- data/spec/lib/borg/configuration/stages_spec.rb +33 -36
- data/spec/lib/borg/configuration_spec.rb +19 -0
- data/spec/support/shared_examples/application_configuration.rb +14 -0
- metadata +12 -5
- data/cap/applications/app1.rb +0 -15
- data/cap/initializers/output.rb +0 -4
@@ -2,34 +2,48 @@ require 'spec_helper'
|
|
2
2
|
require 'borg/configuration/assimilator'
|
3
3
|
|
4
4
|
describe Borg::Configuration::Assimilator do
|
5
|
-
|
6
|
-
Capistrano::Configuration
|
5
|
+
before :all do
|
6
|
+
class MockConfiguration < Capistrano::Configuration
|
7
|
+
include Borg::Configuration::Assimilator
|
8
|
+
end
|
7
9
|
end
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
it "should add to the to_assimilate list" do
|
12
|
-
lambda {subject.assimilate('borg-rb')}.should change {subject.instance_eval("@to_assimilate")}.from(nil).to({'borg-rb' => Gem::Specification.find_by_name('borg-rb').gem_dir})
|
13
|
-
end
|
11
|
+
after :all do
|
12
|
+
Object.send(:remove_const, :MockConfiguration)
|
14
13
|
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
before do
|
16
|
+
@config = MockConfiguration.new
|
17
|
+
end
|
18
|
+
describe '#assimilate' do
|
19
|
+
it 'adds to the to_assimilate array' do
|
20
|
+
expect {
|
21
|
+
@config.assimilate('borg-rb')
|
22
|
+
}.to change {
|
23
|
+
@config.instance_eval('@to_assimilate')
|
24
|
+
}.from(nil).to({'borg-rb' => Gem::Specification.find_by_name('borg-rb').gem_dir})
|
20
25
|
end
|
26
|
+
end
|
21
27
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
28
|
+
describe '#assimilate!' do
|
29
|
+
context 'given we already called assimilate with: `borg-rb`' do
|
30
|
+
before do
|
31
|
+
@config.assimilate('borg-rb')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'loads all the initializers' do
|
35
|
+
Dir['cap/initializers/**/*.rb'].each do |file|
|
36
|
+
@config.should_receive(:load).with(File.expand_path(file))
|
37
|
+
end
|
38
|
+
@config.assimilate!
|
26
39
|
end
|
27
|
-
subject.assimilate!
|
28
|
-
end
|
29
40
|
|
30
|
-
|
31
|
-
|
32
|
-
|
41
|
+
it 'adds the cap directory to the load path' do
|
42
|
+
Dir.stub('[]').and_return([])
|
43
|
+
expect {
|
44
|
+
@config.assimilate!
|
45
|
+
}.to change(@config.load_paths, :count).by 1
|
46
|
+
end
|
33
47
|
end
|
34
48
|
end
|
35
49
|
end
|
@@ -3,68 +3,65 @@ require 'borg/configuration/applications'
|
|
3
3
|
require 'borg/configuration/stages'
|
4
4
|
|
5
5
|
describe Borg::Configuration::Stages do
|
6
|
-
|
7
|
-
|
6
|
+
before :all do
|
7
|
+
class MockConfiguration < Capistrano::Configuration
|
8
|
+
# TODO: Stages has a dependency on Applications module, is that bad?
|
9
|
+
include Borg::Configuration::Applications
|
10
|
+
include Borg::Configuration::Stages
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
after :all do
|
15
|
+
Object.send(:remove_const, :MockConfiguration)
|
8
16
|
end
|
9
17
|
|
10
|
-
|
18
|
+
let(:config) { MockConfiguration.new }
|
19
|
+
|
20
|
+
context 'when an application with a stage is defined' do
|
11
21
|
before do
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
test_notice "You have called app1 stg1"
|
22
|
+
config.load do
|
23
|
+
stage 'app1', 'stg1' do
|
24
|
+
test_notice 'You have called app1 stg1'
|
16
25
|
end
|
17
26
|
end
|
18
27
|
end
|
19
|
-
subject { @config }
|
20
28
|
|
21
|
-
|
22
|
-
expect(subject.applications[:app1]).to be_true
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should symobolize the name" do
|
26
|
-
expect(subject.applications[:app1].stages.keys.first).to eq :stg1
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should create a namespace app1 with task stg1 and a description" do
|
30
|
-
expect(subject.namespaces[:app1]).to be_true
|
31
|
-
expect(subject.namespaces[:app1].tasks[:stg1]).to be_true
|
32
|
-
expect(subject.namespaces[:app1].tasks[:stg1].desc).to be_true
|
33
|
-
end
|
29
|
+
it_behaves_like 'an application configuration'
|
34
30
|
|
35
|
-
it
|
36
|
-
expect(
|
37
|
-
expect(
|
31
|
+
it 'creates and stores a new Stage object with a name and execution block' do
|
32
|
+
expect(config.applications[:app1].stages[:stg1].class).to eq Borg::Configuration::Stages::Stage
|
33
|
+
expect(config.applications[:app1].stages[:stg1].name).to eq 'app1:stg1'
|
34
|
+
expect(config.applications[:app1].stages[:stg1].execution_blocks.count).to eq 1
|
38
35
|
end
|
39
36
|
end
|
40
37
|
end
|
41
38
|
|
42
39
|
describe Borg::Configuration::Stages::Stage do
|
43
|
-
it
|
44
|
-
parent = double
|
45
|
-
parent.stub(:name).and_return
|
40
|
+
it 'initializes: name, parent and execution_blocks' do
|
41
|
+
parent = double('app1')
|
42
|
+
parent.stub(:name).and_return(:app1)
|
46
43
|
stg1 = Borg::Configuration::Stages::Stage.new(:stg1, parent)
|
47
|
-
expect(stg1.name).to eq(
|
44
|
+
expect(stg1.name).to eq('app1:stg1')
|
48
45
|
expect(stg1.parent).to eq(parent)
|
49
46
|
expect(stg1.execution_blocks).to eq([])
|
50
47
|
end
|
51
48
|
|
52
|
-
context
|
49
|
+
context 'a stage with 2 blocks' do
|
53
50
|
before do
|
54
|
-
@stg1 = Borg::Configuration::Stages::Stage.new(:stg1, double(
|
51
|
+
@stg1 = Borg::Configuration::Stages::Stage.new(:stg1, double('app1'))
|
55
52
|
@stg1.execution_blocks << -> {
|
56
|
-
raise
|
53
|
+
raise 'block 1 called'
|
57
54
|
}
|
58
55
|
@stg1.execution_blocks << -> {
|
59
|
-
raise
|
56
|
+
raise 'block 2 called'
|
60
57
|
}
|
61
58
|
end
|
62
|
-
context
|
63
|
-
it
|
64
|
-
config = double(
|
59
|
+
context 'when #load_into is called' do
|
60
|
+
it 'should all blocks into the provided config' do
|
61
|
+
config = double('test config')
|
65
62
|
@stg1.parent.should_receive(:load_into).with(config)
|
66
63
|
config.should_receive(:load).twice
|
67
|
-
@stg1.load_into
|
64
|
+
@stg1.load_into(config)
|
68
65
|
end
|
69
66
|
end
|
70
67
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'borg/configuration'
|
3
|
+
|
4
|
+
describe Borg::Configuration do
|
5
|
+
it 'includes Applications, Assimilator, Stages, and UpstartTasks' do
|
6
|
+
expect(
|
7
|
+
Borg::Configuration.ancestors
|
8
|
+
).to include(Borg::Configuration::Applications,
|
9
|
+
Borg::Configuration::Assimilator,
|
10
|
+
Borg::Configuration::Stages)
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#_cset' do
|
15
|
+
it 'does something' do
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
shared_examples 'an application configuration' do
|
2
|
+
context 'upon loading' do
|
3
|
+
it 'creates and stores a new Application object with a name and execution block' do
|
4
|
+
expect(config.applications[:app1].class).to eq Borg::Configuration::Applications::Application
|
5
|
+
expect(config.applications[:app1].name).to eq :app1
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'creates a new namespace value with a default task/description' do
|
9
|
+
expect(config.namespaces[:app1]).to be_true
|
10
|
+
expect(config.namespaces[:app1].tasks[:default]).to be_true
|
11
|
+
expect(config.namespaces[:app1].tasks[:default].desc).to be_true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: borg-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Identified
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -113,14 +113,15 @@ files:
|
|
113
113
|
- bin/borg
|
114
114
|
- bin/borgify
|
115
115
|
- borg.gemspec
|
116
|
-
- cap/applications/app1.rb
|
117
|
-
- cap/initializers/output.rb
|
118
116
|
- cap/initializers/performance.rb
|
119
117
|
- cap/initializers/role_reset.rb
|
120
118
|
- cap/initializers/sigint.rb
|
121
119
|
- lib/borg-rb.rb
|
120
|
+
- lib/borg.rb
|
121
|
+
- lib/borg/cli.rb
|
122
122
|
- lib/borg/cli/applications.rb
|
123
123
|
- lib/borg/cli/assimilator.rb
|
124
|
+
- lib/borg/configuration.rb
|
124
125
|
- lib/borg/configuration/applications.rb
|
125
126
|
- lib/borg/configuration/assimilator.rb
|
126
127
|
- lib/borg/configuration/stages.rb
|
@@ -140,14 +141,17 @@ files:
|
|
140
141
|
- spec/acceptance/borgify_spec.rb
|
141
142
|
- spec/acceptance/stage_spec.rb
|
142
143
|
- spec/lib/borg/cli/applications_spec.rb
|
144
|
+
- spec/lib/borg/cli_spec.rb
|
143
145
|
- spec/lib/borg/configuration/applications_spec.rb
|
144
146
|
- spec/lib/borg/configuration/assimilator_spec.rb
|
145
147
|
- spec/lib/borg/configuration/stages_spec.rb
|
148
|
+
- spec/lib/borg/configuration_spec.rb
|
146
149
|
- spec/spec_helper.rb
|
147
150
|
- spec/support/isolated_environment.rb
|
148
151
|
- spec/support/matchers/succeed.rb
|
149
152
|
- spec/support/platform.rb
|
150
153
|
- spec/support/shared_contexts/acceptance.rb
|
154
|
+
- spec/support/shared_examples/application_configuration.rb
|
151
155
|
- spec/support/subprocess.rb
|
152
156
|
- spec/support/temp_dir.rb
|
153
157
|
homepage: https://github.com/B0RG/borg
|
@@ -162,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
166
|
requirements:
|
163
167
|
- - ! '>='
|
164
168
|
- !ruby/object:Gem::Version
|
165
|
-
version:
|
169
|
+
version: 1.9.2
|
166
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
171
|
requirements:
|
168
172
|
- - ! '>='
|
@@ -180,14 +184,17 @@ test_files:
|
|
180
184
|
- spec/acceptance/borgify_spec.rb
|
181
185
|
- spec/acceptance/stage_spec.rb
|
182
186
|
- spec/lib/borg/cli/applications_spec.rb
|
187
|
+
- spec/lib/borg/cli_spec.rb
|
183
188
|
- spec/lib/borg/configuration/applications_spec.rb
|
184
189
|
- spec/lib/borg/configuration/assimilator_spec.rb
|
185
190
|
- spec/lib/borg/configuration/stages_spec.rb
|
191
|
+
- spec/lib/borg/configuration_spec.rb
|
186
192
|
- spec/spec_helper.rb
|
187
193
|
- spec/support/isolated_environment.rb
|
188
194
|
- spec/support/matchers/succeed.rb
|
189
195
|
- spec/support/platform.rb
|
190
196
|
- spec/support/shared_contexts/acceptance.rb
|
197
|
+
- spec/support/shared_examples/application_configuration.rb
|
191
198
|
- spec/support/subprocess.rb
|
192
199
|
- spec/support/temp_dir.rb
|
193
200
|
has_rdoc:
|
data/cap/applications/app1.rb
DELETED
data/cap/initializers/output.rb
DELETED