penchant 0.2.20 → 0.2.21
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -0
- data/features/ruby_gemfile.feature +28 -0
- data/lib/penchant/gemfile.rb +33 -4
- data/lib/penchant/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -73,6 +73,15 @@ no_deployment do
|
|
73
73
|
gems dev_gems, :github => 'johnbintz'
|
74
74
|
end
|
75
75
|
|
76
|
+
# an even shorter way to specify environments!
|
77
|
+
# in remote env, expands to:
|
78
|
+
# gem 'bullseye', :git => 'git://github.com/johnbintz/bullseye.git'
|
79
|
+
# in local env, expands to:
|
80
|
+
# gem 'bullseye', :path => '../bullseye'
|
81
|
+
env :remote, :opposite => :local do
|
82
|
+
gem 'bullseye', :github => 'johnbintz'
|
83
|
+
end
|
84
|
+
|
76
85
|
# only expanded on Mac OS X
|
77
86
|
os :darwin do
|
78
87
|
gem 'rb-fsevent'
|
@@ -235,6 +235,34 @@ Feature: Gemfiles
|
|
235
235
|
gem "one", "1.2.3", {:path=>"../one"}
|
236
236
|
"""
|
237
237
|
|
238
|
+
Scenario: Create opposite environment gem assumptions to cut down on repetition
|
239
|
+
Given I have the file "Gemfile.penchant" with the content:
|
240
|
+
"""
|
241
|
+
defaults_for env(:local), :path => '../%s'
|
242
|
+
property(:github) { |name| { :git => "git://github.com/#{name}/%s.git" } }
|
243
|
+
|
244
|
+
env :remote, :opposite => :local do
|
245
|
+
gem 'one', :github => 'johnbintz', :require => nil
|
246
|
+
end
|
247
|
+
env :local, :opposite => :remote do
|
248
|
+
gem 'two', :path => '../%s', :require => nil
|
249
|
+
end
|
250
|
+
"""
|
251
|
+
When I rebuild the Gemfile for "local" mode
|
252
|
+
Then the file "Gemfile" should have the following content:
|
253
|
+
"""
|
254
|
+
# generated by penchant, environment: local
|
255
|
+
gem "one", {:path=>"../one", :require=>nil}
|
256
|
+
gem "two", {:path=>"../two", :require=>nil}
|
257
|
+
"""
|
258
|
+
When I rebuild the Gemfile for "remote" mode
|
259
|
+
Then the file "Gemfile" should have the following content:
|
260
|
+
"""
|
261
|
+
# generated by penchant, environment: remote
|
262
|
+
gem "one", {:git=>"git://github.com/johnbintz/one.git", :require=>nil}
|
263
|
+
gem "two", {:require=>nil}
|
264
|
+
"""
|
265
|
+
|
238
266
|
Scenario: Override defaults for an environment
|
239
267
|
Given I have the file "Gemfile.penchant" with the content:
|
240
268
|
"""
|
data/lib/penchant/gemfile.rb
CHANGED
@@ -138,6 +138,9 @@ module Penchant
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def env(*args)
|
141
|
+
options = {}
|
142
|
+
options = args.pop if args.last.kind_of?(::Hash)
|
143
|
+
|
141
144
|
@available_environments += args
|
142
145
|
|
143
146
|
if block_given?
|
@@ -145,6 +148,16 @@ module Penchant
|
|
145
148
|
@_current_env_defaults = _defaults_for(Env.new(environment))
|
146
149
|
yield
|
147
150
|
@_current_env_defaults = {}
|
151
|
+
else
|
152
|
+
if options[:opposite]
|
153
|
+
if for_environment?([ options[:opposite] ].flatten)
|
154
|
+
@_current_env_defaults = _defaults_for(Env.new(environment))
|
155
|
+
@_strip_pathing_options = true
|
156
|
+
yield
|
157
|
+
@_strip_pathing_options = false
|
158
|
+
@_current_env_defaults = {}
|
159
|
+
end
|
160
|
+
end
|
148
161
|
end
|
149
162
|
else
|
150
163
|
Penchant::Gemfile::Env.new(args.shift)
|
@@ -203,7 +216,22 @@ module Penchant
|
|
203
216
|
def process_options(gem_name, template = {})
|
204
217
|
properties = {}
|
205
218
|
|
206
|
-
property_stack =
|
219
|
+
property_stack = template.to_a
|
220
|
+
|
221
|
+
original_properties = process_option_stack(gem_name, property_stack)
|
222
|
+
|
223
|
+
if @_strip_pathing_options
|
224
|
+
[ :git, :branch, :path ].each { |key| original_properties.delete(key) }
|
225
|
+
end
|
226
|
+
|
227
|
+
properties = process_option_stack(gem_name, _defaults_for(gem_name).to_a).merge(original_properties)
|
228
|
+
|
229
|
+
Hash[properties.sort]
|
230
|
+
end
|
231
|
+
|
232
|
+
def process_option_stack(gem_name, stack)
|
233
|
+
property_stack = stack.dup
|
234
|
+
properties = {}
|
207
235
|
|
208
236
|
while !property_stack.empty?
|
209
237
|
key, value = property_stack.shift
|
@@ -227,8 +255,8 @@ module Penchant
|
|
227
255
|
properties[key] = value
|
228
256
|
end
|
229
257
|
end
|
230
|
-
|
231
|
-
|
258
|
+
|
259
|
+
properties
|
232
260
|
end
|
233
261
|
|
234
262
|
def _defaults_for(gem_name)
|
@@ -322,12 +350,13 @@ module Penchant
|
|
322
350
|
|
323
351
|
args = [ gem_name.first ]
|
324
352
|
args << version if version
|
325
|
-
args << options if !options.empty?
|
326
353
|
|
327
354
|
if options[:git]
|
328
355
|
@defined_git_repos << Penchant::Repo.new(options[:git])
|
329
356
|
end
|
330
357
|
|
358
|
+
args << options if !options.empty?
|
359
|
+
|
331
360
|
@output << %{gem #{args_to_string(args)}}
|
332
361
|
end
|
333
362
|
|
data/lib/penchant/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: penchant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.21
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -199,7 +199,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
199
|
version: '0'
|
200
200
|
segments:
|
201
201
|
- 0
|
202
|
-
hash:
|
202
|
+
hash: 764884557755506875
|
203
203
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
204
|
none: false
|
205
205
|
requirements:
|
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
208
|
version: '0'
|
209
209
|
segments:
|
210
210
|
- 0
|
211
|
-
hash:
|
211
|
+
hash: 764884557755506875
|
212
212
|
requirements: []
|
213
213
|
rubyforge_project: penchant
|
214
214
|
rubygems_version: 1.8.23
|