cany 0.0.2 → 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 +4 -4
- data/CHANGELOG.md +38 -0
- data/Gemfile +12 -0
- data/Guardfile +20 -0
- data/Rakefile +11 -0
- data/lib/cany.rb +88 -19
- data/lib/cany/dependency.rb +70 -0
- data/lib/cany/dpkg/builder.rb +4 -16
- data/lib/cany/dpkg/creator.rb +39 -29
- data/lib/cany/dpkg/deb_helper_recipe.rb +105 -20
- data/lib/cany/errors.rb +62 -0
- data/lib/cany/mixins/depend_mixin.rb +22 -0
- data/lib/cany/recipe.rb +182 -11
- data/lib/cany/recipes/bundler.rb +28 -5
- data/lib/cany/recipes/bundler/gem.rb +50 -0
- data/lib/cany/recipes/bundler/gem_db.rb +27 -0
- data/lib/cany/recipes/rails.rb +19 -2
- data/lib/cany/recipes/sidekiq.rb +38 -0
- data/lib/cany/recipes/thin.rb +24 -18
- data/lib/cany/recipes/unicorn.rb +16 -0
- data/lib/cany/recipes/web_server.rb +5 -19
- data/lib/cany/specification.rb +49 -1
- data/lib/cany/specification/dsl.rb +23 -3
- data/lib/cany/version.rb +2 -2
- data/spec/cany/dependency_spec.rb +120 -0
- data/spec/cany/dpkg/builder_spec.rb +38 -0
- data/spec/{dpkg → cany/dpkg}/creator_spec.rb +26 -2
- data/spec/cany/dpkg/deb_helper_recipe_spec.rb +91 -0
- data/spec/cany/recipe_spec.rb +213 -0
- data/spec/cany/recipes/bundler/gem_spec.rb +46 -0
- data/spec/cany/recipes/bundler_spec.rb +29 -0
- data/spec/cany/recipes/rails_spec.rb +28 -0
- data/spec/cany/recipes/sidekiq_spec.rb +52 -0
- data/spec/cany/specification_spec.rb +113 -1
- data/spec/spec_helper.rb +31 -4
- metadata +29 -6
- data/spec/dpkg/builder_spec.rb +0 -53
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cany::Recipes::Sidekiq do
|
4
|
+
let(:spec) do
|
5
|
+
Cany::Specification.new do
|
6
|
+
name 'test'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
let(:recipe) { spec.recipes.first }
|
10
|
+
|
11
|
+
context '#binary' do
|
12
|
+
context 'without configuration' do
|
13
|
+
before do
|
14
|
+
spec.setup do
|
15
|
+
use :sidekiq
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should launch sidekiq only with environment specification' do
|
20
|
+
expect(recipe).to receive(:install_service).with(
|
21
|
+
:sidekiq,
|
22
|
+
%w(/usr/bin/test sidekiq --environment production),
|
23
|
+
user: 'www-data', group: 'www-data'
|
24
|
+
)
|
25
|
+
recipe.inner = double('recipe')
|
26
|
+
expect(recipe.inner).to receive(:binary)
|
27
|
+
recipe.binary
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
context 'with queue names' do
|
32
|
+
before do
|
33
|
+
spec.setup do
|
34
|
+
use :sidekiq do
|
35
|
+
queue :name1
|
36
|
+
queue :name2
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should launch sidekiq with the list of queues' do
|
42
|
+
expect(recipe).to receive(:install_service).with(
|
43
|
+
:sidekiq,
|
44
|
+
%w(/usr/bin/test sidekiq --environment production --queue name1,name2),
|
45
|
+
user: 'www-data', group: 'www-data'
|
46
|
+
)
|
47
|
+
recipe.inner = double('recipe')
|
48
|
+
expect(recipe.inner).to receive(:binary)
|
49
|
+
recipe.binary
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cany::Specification do
|
4
|
+
let(:spec) { described_class.new {} }
|
4
5
|
describe '#new' do
|
5
6
|
it 'should have a name' do
|
6
7
|
spec = Cany::Specification.new do
|
@@ -55,7 +56,8 @@ describe Cany::Specification do
|
|
55
56
|
spec = Cany::Specification.new do
|
56
57
|
use :bundler
|
57
58
|
end
|
58
|
-
expect(spec.recipes).to eq
|
59
|
+
expect(spec.recipes.size).to eq 1
|
60
|
+
expect(spec.recipes[0]).to be_instance_of(Cany::Recipes::Bundler)
|
59
61
|
end
|
60
62
|
|
61
63
|
it 'should accept a block for own build steps' do
|
@@ -76,4 +78,114 @@ describe Cany::Specification do
|
|
76
78
|
expect(spec.binary).to be_a_kind_of Proc
|
77
79
|
end
|
78
80
|
end
|
81
|
+
|
82
|
+
context 'with a required cany version' do
|
83
|
+
let(:spec) { Cany::Specification.new { name 'test-spec' } }
|
84
|
+
subject { spec }
|
85
|
+
|
86
|
+
it 'pass if it matches cany\'s version' do
|
87
|
+
expect(Cany::VERSION).to receive(:to_s).at_least(:once).and_return '0.1.1'
|
88
|
+
spec.setup { require_cany '~> 0.1' }
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'fail if cany\'s version is to old' do
|
92
|
+
expect(Cany::VERSION).to receive(:to_s).at_least(:once).and_return '0.0.1'
|
93
|
+
expect { spec.setup { require_cany '~> 0.1' } }.to raise_exception Cany::UnsupportedVersion, /.*require.*"~> 0\.1" but .* "0.0.1"/
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'fail if cany\'s version is to new' do
|
97
|
+
expect(Cany::VERSION).to receive(:to_s).at_least(:once).and_return '1.0'
|
98
|
+
expect { spec.setup { require_cany '~> 0.1' } }.to raise_exception Cany::UnsupportedVersion, /.*require.*"~> 0\.1" but .* "1.0"/
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context '#build_dependencies' do
|
103
|
+
subject { spec.build_dependencies }
|
104
|
+
let(:build_dep1) { Cany::Dependency.new situations: :build }
|
105
|
+
let(:runtime_dep1) { Cany::Dependency.new situations: :runtime }
|
106
|
+
let(:both_dep1) { Cany::Dependency.new situations: [:build, :runtime] }
|
107
|
+
|
108
|
+
it { should eq [] }
|
109
|
+
|
110
|
+
context 'with added build dependencies' do
|
111
|
+
before { spec.dependencies << build_dep1 }
|
112
|
+
|
113
|
+
it 'should include these deps' do
|
114
|
+
should match_array [build_dep1]
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context 'with added runtime dependencies' do
|
119
|
+
before { spec.dependencies << runtime_dep1 }
|
120
|
+
it 'should not include' do
|
121
|
+
should match_array []
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'with added build + runtime dependencies' do
|
126
|
+
before { spec.dependencies << both_dep1 }
|
127
|
+
|
128
|
+
it 'should include this dep' do
|
129
|
+
should match_array [both_dep1]
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context '#runtime_dependencies' do
|
135
|
+
subject { spec.runtime_dependencies }
|
136
|
+
let(:build_dep1) { Cany::Dependency.new situations: :build }
|
137
|
+
let(:runtime_dep1) { Cany::Dependency.new situations: :runtime }
|
138
|
+
let(:both_dep1) { Cany::Dependency.new situations: [:build, :runtime] }
|
139
|
+
|
140
|
+
it { should eq [] }
|
141
|
+
|
142
|
+
context 'with added build dependencies' do
|
143
|
+
before { spec.dependencies << build_dep1 }
|
144
|
+
|
145
|
+
it 'should not include' do
|
146
|
+
should match_array []
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
context 'with added runtime dependencies' do
|
151
|
+
before { spec.dependencies << runtime_dep1 }
|
152
|
+
it 'should include these deps' do
|
153
|
+
should match_array [runtime_dep1]
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
context 'with added build + runtime dependencies' do
|
158
|
+
before { spec.dependencies << both_dep1 }
|
159
|
+
|
160
|
+
it 'should include this dep' do
|
161
|
+
should match_array [both_dep1]
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe '#setup_recipes' do
|
167
|
+
subject { spec.setup_recipes }
|
168
|
+
|
169
|
+
context 'with loaded recipes' do
|
170
|
+
before do
|
171
|
+
spec.setup do
|
172
|
+
use :bundler
|
173
|
+
use :rails
|
174
|
+
end
|
175
|
+
spec.system_recipe = Cany::Dpkg::DebHelperRecipe.new spec
|
176
|
+
end
|
177
|
+
it 'should instance any used recipes' do
|
178
|
+
expect_any_instance_of(Cany::Recipes::Rails).to receive(:inner=).with(kind_of(Cany::Dpkg::DebHelperRecipe)).and_call_original
|
179
|
+
expect_any_instance_of(Cany::Recipes::Bundler).to receive(:inner=).with(kind_of(Cany::Recipes::Rails))
|
180
|
+
subject
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'should call prepare on all recipes' do
|
184
|
+
expect_any_instance_of(Cany::Dpkg::DebHelperRecipe).to receive(:prepare).and_call_original
|
185
|
+
expect_any_instance_of(Cany::Recipes::Bundler).to receive(:prepare).and_call_original
|
186
|
+
expect_any_instance_of(Cany::Recipes::Rails).to receive(:prepare).and_call_original
|
187
|
+
subject
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
79
191
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
if ENV['CI']
|
2
|
+
require 'coveralls'
|
3
|
+
Coveralls.wear! do
|
4
|
+
add_filter 'spec'
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
if ENV["COVERAGE"]
|
9
|
+
require 'simplecov'
|
10
|
+
|
11
|
+
SimpleCov.start do
|
12
|
+
add_filter 'spec'
|
13
|
+
|
14
|
+
add_group 'DPKG', 'lib/cany/dpkg'
|
15
|
+
add_group('Recipes') { |file| file.filename.include? 'recipe' }
|
16
|
+
end
|
4
17
|
end
|
5
18
|
|
6
19
|
require 'cany'
|
@@ -8,6 +21,15 @@ require 'deb_control'
|
|
8
21
|
require 'tmpdir'
|
9
22
|
require 'timecop'
|
10
23
|
|
24
|
+
class TestRecipe < Cany::Recipe
|
25
|
+
register_as :test_recipe
|
26
|
+
hook :test_hook
|
27
|
+
option :test_conf
|
28
|
+
end
|
29
|
+
|
30
|
+
Cany.logger.level = Logger::FATAL
|
31
|
+
|
32
|
+
|
11
33
|
Dir[File.expand_path('spec/support/**/*.rb')].each {|f| require f}
|
12
34
|
|
13
35
|
RSpec.configure do |config|
|
@@ -32,6 +54,11 @@ RSpec.configure do |config|
|
|
32
54
|
|
33
55
|
config.before(:each) do
|
34
56
|
@executed_programs = []
|
35
|
-
allow_any_instance_of(Cany::Recipe).to receive(:exec) { |*args| @executed_programs << args }
|
57
|
+
allow_any_instance_of(Cany::Recipe).to receive(:exec) { |*args| @executed_programs << args.flatten }
|
58
|
+
end
|
59
|
+
|
60
|
+
config.after(:each) do
|
61
|
+
Cany::Recipes::Bundler::Gem.clear
|
62
|
+
load 'cany/recipes/bundler/gem_db.rb'
|
36
63
|
end
|
37
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cany
|
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
|
- Malte Swart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -62,29 +62,45 @@ extra_rdoc_files: []
|
|
62
62
|
files:
|
63
63
|
- .gitignore
|
64
64
|
- .travis.yml
|
65
|
+
- CHANGELOG.md
|
65
66
|
- Gemfile
|
67
|
+
- Guardfile
|
66
68
|
- LICENSE.txt
|
67
69
|
- README.md
|
68
70
|
- Rakefile
|
69
71
|
- bin/cany
|
70
72
|
- cany.gemspec
|
71
73
|
- lib/cany.rb
|
74
|
+
- lib/cany/dependency.rb
|
72
75
|
- lib/cany/dpkg.rb
|
73
76
|
- lib/cany/dpkg/builder.rb
|
74
77
|
- lib/cany/dpkg/creator.rb
|
75
78
|
- lib/cany/dpkg/deb_helper_recipe.rb
|
79
|
+
- lib/cany/errors.rb
|
80
|
+
- lib/cany/mixins/depend_mixin.rb
|
76
81
|
- lib/cany/recipe.rb
|
77
82
|
- lib/cany/recipes/bundler.rb
|
83
|
+
- lib/cany/recipes/bundler/gem.rb
|
84
|
+
- lib/cany/recipes/bundler/gem_db.rb
|
78
85
|
- lib/cany/recipes/rails.rb
|
86
|
+
- lib/cany/recipes/sidekiq.rb
|
79
87
|
- lib/cany/recipes/thin.rb
|
88
|
+
- lib/cany/recipes/unicorn.rb
|
80
89
|
- lib/cany/recipes/web_server.rb
|
81
90
|
- lib/cany/specification.rb
|
82
91
|
- lib/cany/specification/dsl.rb
|
83
92
|
- lib/cany/version.rb
|
93
|
+
- spec/cany/dependency_spec.rb
|
94
|
+
- spec/cany/dpkg/builder_spec.rb
|
95
|
+
- spec/cany/dpkg/creator_spec.rb
|
96
|
+
- spec/cany/dpkg/deb_helper_recipe_spec.rb
|
97
|
+
- spec/cany/recipe_spec.rb
|
98
|
+
- spec/cany/recipes/bundler/gem_spec.rb
|
99
|
+
- spec/cany/recipes/bundler_spec.rb
|
100
|
+
- spec/cany/recipes/rails_spec.rb
|
101
|
+
- spec/cany/recipes/sidekiq_spec.rb
|
84
102
|
- spec/cany/specification_spec.rb
|
85
103
|
- spec/cany_spec.rb
|
86
|
-
- spec/dpkg/builder_spec.rb
|
87
|
-
- spec/dpkg/creator_spec.rb
|
88
104
|
- spec/fixtures/multiple/one.canspec
|
89
105
|
- spec/fixtures/multiple/two.canspec
|
90
106
|
- spec/fixtures/single/single.canspec
|
@@ -116,10 +132,17 @@ signing_key:
|
|
116
132
|
specification_version: 4
|
117
133
|
summary: Canning your ruby applications
|
118
134
|
test_files:
|
135
|
+
- spec/cany/dependency_spec.rb
|
136
|
+
- spec/cany/dpkg/builder_spec.rb
|
137
|
+
- spec/cany/dpkg/creator_spec.rb
|
138
|
+
- spec/cany/dpkg/deb_helper_recipe_spec.rb
|
139
|
+
- spec/cany/recipe_spec.rb
|
140
|
+
- spec/cany/recipes/bundler/gem_spec.rb
|
141
|
+
- spec/cany/recipes/bundler_spec.rb
|
142
|
+
- spec/cany/recipes/rails_spec.rb
|
143
|
+
- spec/cany/recipes/sidekiq_spec.rb
|
119
144
|
- spec/cany/specification_spec.rb
|
120
145
|
- spec/cany_spec.rb
|
121
|
-
- spec/dpkg/builder_spec.rb
|
122
|
-
- spec/dpkg/creator_spec.rb
|
123
146
|
- spec/fixtures/multiple/one.canspec
|
124
147
|
- spec/fixtures/multiple/two.canspec
|
125
148
|
- spec/fixtures/single/single.canspec
|
data/spec/dpkg/builder_spec.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'cany/recipes/bundler'
|
3
|
-
require 'cany/recipes/rails'
|
4
|
-
|
5
|
-
|
6
|
-
describe Cany::Dpkg::Builder do
|
7
|
-
let!(:dir) { Dir.mktmpdir }
|
8
|
-
after { FileUtils.remove_entry dir}
|
9
|
-
let(:spec) do
|
10
|
-
s = Cany::Specification.new do
|
11
|
-
name 'dpkg-creator-test'
|
12
|
-
version '0.1'
|
13
|
-
description 'Test Project'
|
14
|
-
maintainer_name 'Hans Otto'
|
15
|
-
maintainer_email 'hans.otto@example.org'
|
16
|
-
website 'http://example.org'
|
17
|
-
licence 'GPL-2+'
|
18
|
-
end
|
19
|
-
s.base_dir = dir
|
20
|
-
s
|
21
|
-
end
|
22
|
-
let(:builder) { Cany::Dpkg::Builder.new(spec) }
|
23
|
-
|
24
|
-
describe '#setup_recipes' do
|
25
|
-
it 'should always setup debhelper recipe' do
|
26
|
-
expect(Cany::Dpkg::DebHelperRecipe).to receive(:new).with(spec, nil)
|
27
|
-
builder.setup_recipes
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should instance any used recipes' do
|
31
|
-
spec.setup do
|
32
|
-
use :bundler
|
33
|
-
use :rails
|
34
|
-
end
|
35
|
-
expect(Cany::Dpkg::DebHelperRecipe).to receive(:new).ordered.with(spec, nil).and_call_original
|
36
|
-
expect(Cany::Recipes::Rails).to receive(:new).ordered.with(spec, kind_of(Cany::Dpkg::DebHelperRecipe)).and_call_original
|
37
|
-
expect(Cany::Recipes::Bundler).to receive(:new).ordered.with(spec, kind_of(Cany::Recipes::Rails)).and_call_original
|
38
|
-
builder.setup_recipes
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '#run' do
|
43
|
-
it 'should setup recipes' do
|
44
|
-
expect(builder).to receive(:setup_recipes).and_call_original
|
45
|
-
builder.run 'clean'
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should call delegate the clean action to the loaded recipes' do
|
49
|
-
expect_any_instance_of(Cany::Dpkg::DebHelperRecipe).to receive(:clean)
|
50
|
-
builder.run 'clean'
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|