cany 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/cany/recipe.rb +5 -5
- data/lib/cany/recipes/bundler.rb +21 -7
- data/lib/cany/version.rb +1 -1
- data/spec/cany/recipe_spec.rb +24 -3
- data/spec/cany/recipes/bundler_spec.rb +80 -2
- data/spec/spec_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb28ebd8992f0b5c01534840500584da6ad36a65
|
4
|
+
data.tar.gz: c1afaa9591e78de6d04e9e6b9fd409bc764ee9fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d86b1242fb186b139f1e0d38128d2d4b3a74b32e3ec6ef30329bc72c579cadb41aa073cb1542794a7841a823f88f4fcf10e770ed1eb7e6d50b51490ae4d3f9e
|
7
|
+
data.tar.gz: 143e0ece665c4e6adfc86a8f80487f53634f8f545f763329a3620a6f472ccf4073740f1d038beb245afdb78e4eeb7b5c2c54d7b18f2b74eea133790e289da141
|
data/CHANGELOG.md
CHANGED
data/lib/cany/recipe.rb
CHANGED
@@ -36,8 +36,8 @@ module Cany
|
|
36
36
|
@hooks = Hash[(self.class.defined_hooks || []).map do |name|
|
37
37
|
[name, Cany.hash_with_array_as_default]
|
38
38
|
end]
|
39
|
-
@options = Hash[(self.class.defined_options ||
|
40
|
-
[name,
|
39
|
+
@options = Hash[(self.class.defined_options || {}).map do |name, default|
|
40
|
+
[name, default.dup]
|
41
41
|
end]
|
42
42
|
self.class.const_get(:DSL).new(self).exec(&configure_block) if configure_block
|
43
43
|
end
|
@@ -160,9 +160,9 @@ module Cany
|
|
160
160
|
# recipes not for the user. See Recipe::DSL for this.
|
161
161
|
# @param name[Symbol] The name of the option. The option name is scoped
|
162
162
|
# inside a recipe.
|
163
|
-
def option(name)
|
164
|
-
@defined_options ||=
|
165
|
-
@defined_options
|
163
|
+
def option(name, default={})
|
164
|
+
@defined_options ||= {}
|
165
|
+
@defined_options[name] = default
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
data/lib/cany/recipes/bundler.rb
CHANGED
@@ -2,18 +2,20 @@ module Cany
|
|
2
2
|
module Recipes
|
3
3
|
class Bundler < Cany::Recipe
|
4
4
|
register_as :bundler
|
5
|
-
option :env_vars
|
5
|
+
option :env_vars, GEM_PATH: 'bundler'
|
6
|
+
option :skip_groups, development: true, test: true
|
7
|
+
|
8
|
+
class DSL < Recipe::DSL
|
9
|
+
def skip_group(name, skip=true)
|
10
|
+
@recipe.configure :skip_groups, name => skip
|
11
|
+
end
|
12
|
+
end
|
6
13
|
|
7
14
|
def clean
|
8
15
|
rmtree 'bundler'
|
9
|
-
# rmtree 'vendor/bundle' -- do not remove gems, increase testing time
|
10
16
|
inner.clean
|
11
17
|
end
|
12
18
|
|
13
|
-
def prepare
|
14
|
-
configure :env_vars, GEM_PATH: 'bundler'
|
15
|
-
end
|
16
|
-
|
17
19
|
def create(creator)
|
18
20
|
require 'bundler'
|
19
21
|
lock_path = File.join(spec.base_dir, 'Gemfile.lock')
|
@@ -30,8 +32,12 @@ module Cany
|
|
30
32
|
def build
|
31
33
|
ENV['GEM_PATH'] = 'bundler'
|
32
34
|
ENV['PATH'] = 'bundler/bin:' + ENV['PATH']
|
35
|
+
ENV['GEM_HOME'] = File.absolute_path('debian/gems')
|
36
|
+
old_home = ENV['HOME']
|
37
|
+
ENV['HOME'] = File.absolute_path('debian')
|
33
38
|
ruby_bin 'gem', %w(install bundler --no-ri --no-rdoc --install-dir bundler --bindir bundler/bin)
|
34
|
-
|
39
|
+
ENV['HOME'] = old_home
|
40
|
+
ruby_bin 'bundle', %w(install --deployment --without), skipped_groups
|
35
41
|
inner.build
|
36
42
|
end
|
37
43
|
|
@@ -51,6 +57,14 @@ module Cany
|
|
51
57
|
content += [ "exec /usr/share/#{spec.name}/bundler/bin/bundle exec \"$@\"", '' ]
|
52
58
|
content.join "\n"
|
53
59
|
end
|
60
|
+
|
61
|
+
def skipped_groups
|
62
|
+
option(:skip_groups).select do |option, skipped|
|
63
|
+
skipped
|
64
|
+
end.map do |name, _|
|
65
|
+
name.to_s
|
66
|
+
end
|
67
|
+
end
|
54
68
|
end
|
55
69
|
end
|
56
70
|
end
|
data/lib/cany/version.rb
CHANGED
data/spec/cany/recipe_spec.rb
CHANGED
@@ -87,19 +87,40 @@ describe Cany::Recipe do
|
|
87
87
|
|
88
88
|
context 'should be configurable' do
|
89
89
|
before do
|
90
|
-
test_recipe.configure
|
90
|
+
test_recipe.configure option_name, env: 'production'
|
91
91
|
end
|
92
92
|
it { expect(subject).to eq(env: 'production') }
|
93
93
|
end
|
94
94
|
|
95
95
|
context 'options should be merged between multiple calls' do
|
96
96
|
before do
|
97
|
-
test_recipe.configure
|
98
|
-
test_recipe.configure
|
97
|
+
test_recipe.configure option_name, env: 'production'
|
98
|
+
test_recipe.configure option_name, env2: 'hans'
|
99
99
|
end
|
100
100
|
it { expect(subject).to eq(env: 'production', env2: 'hans') }
|
101
101
|
end
|
102
102
|
end
|
103
|
+
|
104
|
+
context 'with a defined config with a default' do
|
105
|
+
let(:option_name) { :text_conf_with_default }
|
106
|
+
it 'should be initialized with this default' do
|
107
|
+
expect(subject).to eq(hans: :otto)
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'should be configurable' do
|
111
|
+
before do
|
112
|
+
test_recipe.configure option_name, env: 'production'
|
113
|
+
end
|
114
|
+
it { expect(subject).to eq(hans: :otto, env: 'production') }
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'options should be merged between multiple calls' do
|
118
|
+
before do
|
119
|
+
test_recipe.configure option_name, hans: :meyer
|
120
|
+
end
|
121
|
+
it { expect(subject).to eq(hans: :meyer) }
|
122
|
+
end
|
123
|
+
end
|
103
124
|
end
|
104
125
|
|
105
126
|
describe '#recipe' do
|
@@ -4,13 +4,16 @@ describe Cany::Recipes::Bundler do
|
|
4
4
|
let(:spec) do
|
5
5
|
Cany::Specification.new do
|
6
6
|
name 'test'
|
7
|
-
use :bundler
|
8
7
|
end
|
9
8
|
end
|
10
9
|
let(:recipe) { spec.recipes[0] }
|
11
|
-
before { recipe.prepare }
|
12
10
|
|
13
11
|
context 'wrapper-script' do
|
12
|
+
before do
|
13
|
+
spec.setup do
|
14
|
+
use :bundler
|
15
|
+
end
|
16
|
+
end
|
14
17
|
subject { recipe.wrapper_script }
|
15
18
|
context 'without additional env variables' do
|
16
19
|
it 'should contain GEM_PATH to find bundler' do
|
@@ -26,4 +29,79 @@ describe Cany::Recipes::Bundler do
|
|
26
29
|
end
|
27
30
|
end
|
28
31
|
end
|
32
|
+
|
33
|
+
context 'bundle install' do
|
34
|
+
|
35
|
+
context 'by default' do
|
36
|
+
before do
|
37
|
+
spec.setup do
|
38
|
+
use :bundler
|
39
|
+
end
|
40
|
+
recipe.inner = double('recipe')
|
41
|
+
expect(recipe.inner).to receive(:build)
|
42
|
+
end
|
43
|
+
let(:bundler_args) { %(bundle install --deployment --without development test) }
|
44
|
+
it 'should ignore development and test' do
|
45
|
+
@second = false
|
46
|
+
expect(recipe).to receive(:ruby_bin) do |*args|
|
47
|
+
if @second then
|
48
|
+
expect(args.flatten).to eq bundler_args
|
49
|
+
end
|
50
|
+
unless @second then @second = true end
|
51
|
+
end
|
52
|
+
expect(recipe).to receive(:ruby_bin).with(any_args())
|
53
|
+
recipe.build
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'with additional ignored group' do
|
58
|
+
before do
|
59
|
+
spec.setup do
|
60
|
+
use :bundler do
|
61
|
+
skip_group :integration
|
62
|
+
end
|
63
|
+
end
|
64
|
+
recipe.inner = double('recipe')
|
65
|
+
expect(recipe.inner).to receive(:build)
|
66
|
+
end
|
67
|
+
let(:bundler_args) { %w(bundle install --deployment --without development test integration) }
|
68
|
+
it 'should ignore development, test and integration' do
|
69
|
+
@second = false
|
70
|
+
expect(recipe).to receive(:ruby_bin).twice do |*args|
|
71
|
+
if @second then
|
72
|
+
expect(args.flatten).to eq bundler_args
|
73
|
+
@second = 6
|
74
|
+
end
|
75
|
+
unless @second then @second = true end
|
76
|
+
end
|
77
|
+
recipe.build
|
78
|
+
expect(@second).to eq 6
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'with reenabled group' do
|
83
|
+
before do
|
84
|
+
spec.setup do
|
85
|
+
use :bundler do
|
86
|
+
skip_group :development, false
|
87
|
+
end
|
88
|
+
end
|
89
|
+
recipe.inner = double('recipe')
|
90
|
+
expect(recipe.inner).to receive(:build)
|
91
|
+
end
|
92
|
+
let(:bundler_args) { %w(bundle install --deployment --without test) }
|
93
|
+
it 'should ignore only left over one' do
|
94
|
+
@second = false
|
95
|
+
expect(recipe).to receive(:ruby_bin).twice do |*args|
|
96
|
+
if @second then
|
97
|
+
expect(args.flatten).to eq bundler_args
|
98
|
+
@second = 6
|
99
|
+
end
|
100
|
+
unless @second then @second = true end
|
101
|
+
end
|
102
|
+
recipe.build
|
103
|
+
expect(@second).to eq 6
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
29
107
|
end
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 0.4.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-10-
|
11
|
+
date: 2013-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|