penchant 0.2.22 → 0.2.23

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.
data/README.md CHANGED
@@ -107,6 +107,22 @@ ensuring that hooks are always installed when `penchant gemfile` is executed, an
107
107
  that lets you pass in the username of the repo to reference that repo:
108
108
  `gem 'penchant', :github => 'johnbintz'`.
109
109
 
110
+ ### Stupid-simple local/remote setup
111
+
112
+ Use `opposites :local, :remote` and environment settings for local/remote gems will be set accordingly depending
113
+ on environment:
114
+
115
+ ``` ruby
116
+ defaults_for env(:local), :path => '../%s'
117
+ opposites :local, :remote
118
+
119
+ env :remote do
120
+ gem 'my-gem', :git => 'git://github.com/johnbintz/my-gem.git'
121
+ end
122
+ ```
123
+
124
+ In `remote`, the Git repo version is used. In `local`, the path is used. Only one gem definition needed!
125
+
110
126
  ### Deployment mode
111
127
 
112
128
  Use `no_deployment` blocks to indicate gems that shouldn't even appear in `Gemfiles` destined for
data/features/cli.feature CHANGED
@@ -62,7 +62,6 @@ Feature: CLI
62
62
  When I run "bin/penchant gemfile remote" in the "tmp" directory
63
63
  Then the output should not include "git hooks not installed"
64
64
 
65
- @wip
66
65
  Scenario: Install Penchant into a directory with no Gemfile
67
66
  Given I have the directory "tmp"
68
67
  When I run "bin/penchant install" in the "tmp" directory
@@ -263,6 +263,65 @@ Feature: Gemfiles
263
263
  gem "two", {:require=>nil}
264
264
  """
265
265
 
266
+ Scenario: Set the opposite environment in the environment defaults
267
+ Given I have the file "Gemfile.penchant" with the content:
268
+ """
269
+ defaults_for env(:local), :path => '../%s', :opposite => :remote
270
+ defaults_for env(:remote), :opposite => :local
271
+ property(:github) { |name| { :git => "git://github.com/#{name}/%s.git" } }
272
+
273
+ env :remote do
274
+ gem 'one', :github => 'johnbintz', :require => nil
275
+ end
276
+ env :local do
277
+ gem 'two', :path => '../%s', :require => nil
278
+ end
279
+ """
280
+ When I rebuild the Gemfile for "local" mode
281
+ Then the file "Gemfile" should have the following content:
282
+ """
283
+ # generated by penchant, environment: local
284
+ gem "one", {:path=>"../one", :require=>nil}
285
+ gem "two", {:path=>"../two", :require=>nil}
286
+ """
287
+ When I rebuild the Gemfile for "remote" mode
288
+ Then the file "Gemfile" should have the following content:
289
+ """
290
+ # generated by penchant, environment: remote
291
+ gem "one", {:git=>"git://github.com/johnbintz/one.git", :require=>nil}
292
+ gem "two", {:require=>nil}
293
+ """
294
+
295
+ Scenario: Define a pair of opposites
296
+ Given I have the file "Gemfile.penchant" with the content:
297
+ """
298
+ defaults_for env(:local), :path => '../%s'
299
+ opposites :local, :remote
300
+
301
+ property(:github) { |name| { :git => "git://github.com/#{name}/%s.git" } }
302
+
303
+ env :remote do
304
+ gem 'one', :github => 'johnbintz', :require => nil
305
+ end
306
+ env :local do
307
+ gem 'two', :path => '../%s', :require => nil
308
+ end
309
+ """
310
+ When I rebuild the Gemfile for "local" mode
311
+ Then the file "Gemfile" should have the following content:
312
+ """
313
+ # generated by penchant, environment: local
314
+ gem "one", {:path=>"../one", :require=>nil}
315
+ gem "two", {:path=>"../two", :require=>nil}
316
+ """
317
+ When I rebuild the Gemfile for "remote" mode
318
+ Then the file "Gemfile" should have the following content:
319
+ """
320
+ # generated by penchant, environment: remote
321
+ gem "one", {:git=>"git://github.com/johnbintz/one.git", :require=>nil}
322
+ gem "two", {:require=>nil}
323
+ """
324
+
266
325
  Scenario: Override defaults for an environment
267
326
  Given I have the file "Gemfile.penchant" with the content:
268
327
  """
@@ -143,15 +143,17 @@ module Penchant
143
143
 
144
144
  @available_environments += args
145
145
 
146
+ requested_env_defaults = _defaults_for(Env.new(environment))
147
+
146
148
  if block_given?
147
149
  if for_environment?(args)
148
- @_current_env_defaults = _defaults_for(Env.new(environment))
150
+ @_current_env_defaults = requested_env_defaults
149
151
  yield
150
152
  @_current_env_defaults = {}
151
153
  else
152
- if options[:opposite]
153
- if for_environment?([ options[:opposite] ].flatten)
154
- @_current_env_defaults = _defaults_for(Env.new(environment))
154
+ if opposite_environment = (options[:opposite] or requested_env_defaults[:opposite])
155
+ if for_environment?([ environment, args, opposite_environment ].flatten.uniq)
156
+ @_current_env_defaults = requested_env_defaults
155
157
  @_strip_pathing_options = true
156
158
  yield
157
159
  @_strip_pathing_options = false
@@ -160,7 +162,7 @@ module Penchant
160
162
  end
161
163
  end
162
164
  else
163
- Penchant::Gemfile::Env.new(args.shift)
165
+ Env.new(args.shift)
164
166
  end
165
167
  end
166
168
 
@@ -168,6 +170,14 @@ module Penchant
168
170
  @properties[name] = hash || block
169
171
  end
170
172
 
173
+ def opposites(left, right)
174
+ @defaults[Env.new(left).to_s] ||= {}
175
+ @defaults[Env.new(left).to_s][:opposite] = right
176
+
177
+ @defaults[Env.new(right).to_s] ||= {}
178
+ @defaults[Env.new(right).to_s][:opposite] = left
179
+ end
180
+
171
181
  def for_environment?(envs)
172
182
  envs.include?(environment) || environment == ANY_ENVIRONMENT
173
183
  end
@@ -226,6 +236,8 @@ module Penchant
226
236
 
227
237
  properties = process_option_stack(gem_name, _defaults_for(gem_name).to_a).merge(original_properties)
228
238
 
239
+ properties.delete(:opposite)
240
+
229
241
  Hash[properties.sort]
230
242
  end
231
243
 
@@ -1,3 +1,3 @@
1
1
  module Penchant
2
- VERSION = "0.2.22"
2
+ VERSION = "0.2.23"
3
3
  end
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.22
4
+ version: 0.2.23
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-09-04 00:00:00.000000000 Z
12
+ date: 2012-09-14 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: 2606576906095808762
202
+ hash: 2360032587759944188
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: 2606576906095808762
211
+ hash: 2360032587759944188
212
212
  requirements: []
213
213
  rubyforge_project: penchant
214
214
  rubygems_version: 1.8.23