penchant 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -40,19 +40,22 @@ no_deployment do
40
40
 
41
41
  dev_gems = %w{flowerbox guard-flowerbox}
42
42
 
43
+ # set up defaults for certain gems that are probably being used in envs
44
+ defaults_for dev_gems, :require => nil
45
+
43
46
  env :local do
44
47
  # expands to:
45
48
  #
46
- # gem 'flowerbox', :path => '../flowerbox'
47
- # gem 'guard-flowerbox', :path => '../guard-flowerbox'
49
+ # gem 'flowerbox', :path => '../flowerbox', :require => nil
50
+ # gem 'guard-flowerbox', :path => '../guard-flowerbox', :require => nil
48
51
  gems dev_gems, :path => '../%s'
49
52
  end
50
53
 
51
54
  env :remote do
52
55
  # expands to:
53
56
  #
54
- # gem 'flowerbox', :git => 'git://github.com/johnbintz/flowerbox.git'
55
- # gem 'guard-flowerbox', :git => 'git://github.com/johnbintz/guard-flowerbox.git'
57
+ # gem 'flowerbox', :git => 'git://github.com/johnbintz/flowerbox.git', :require => nil
58
+ # gem 'guard-flowerbox', :git => 'git://github.com/johnbintz/guard-flowerbox.git', :require => nil
56
59
  gems dev_gems, :git => 'git://github.com/johnbintz/%s.git'
57
60
  end
58
61
 
@@ -182,3 +182,29 @@ Feature: Gemfiles
182
182
  Then I should get the following repositories:
183
183
  | git://github.cats/two.git |
184
184
 
185
+ Scenario: Propose defaults for a gem
186
+ Given I have the file "Gemfile.penchant" with the content:
187
+ """
188
+ defaults_for 'one', :path => '../%s'
189
+ gem 'one', '1.2.3'
190
+ """
191
+ When I rebuild the Gemfile for "local" mode
192
+ Then the file "Gemfile" should have the following content:
193
+ """
194
+ # generated by penchant, environment: local
195
+ gem "one", "1.2.3", {:path=>"../one"}
196
+ """
197
+
198
+ @wip
199
+ Scenario: Propose defaults for an array of gems
200
+ Given I have the file "Gemfile.penchant" with the content:
201
+ """
202
+ defaults_for ['one'], :path => '../%s'
203
+ gem 'one', '1.2.3'
204
+ """
205
+ When I rebuild the Gemfile for "local" mode
206
+ Then the file "Gemfile" should have the following content:
207
+ """
208
+ # generated by penchant, environment: local
209
+ gem "one", "1.2.3", {:path=>"../one"}
210
+ """
@@ -102,6 +102,7 @@ module Penchant
102
102
  @data = data
103
103
  @available_environments = []
104
104
  @defined_git_repos = []
105
+ @defaults = {}
105
106
  end
106
107
 
107
108
  def result(_env, _is_deployment)
@@ -129,6 +130,12 @@ module Penchant
129
130
  yield if args.include?(current_os)
130
131
  end
131
132
 
133
+ def defaults_for(*args)
134
+ defaults = args.pop
135
+
136
+ args.flatten.each { |gem| @defaults[gem.to_s] = defaults.dup }
137
+ end
138
+
132
139
  protected
133
140
  def args_to_string(args)
134
141
  args.inspect[1..-2]
@@ -154,7 +161,7 @@ module Penchant
154
161
 
155
162
  def process_options(gem_name, template = {})
156
163
  Hash[
157
- template.collect { |key, value|
164
+ template.merge(_defaults_for(gem_name)).collect { |key, value|
158
165
  value = value % gem_name if value.respond_to?(:%)
159
166
 
160
167
  [ key, value ]
@@ -162,6 +169,10 @@ module Penchant
162
169
  ]
163
170
  end
164
171
 
172
+ def _defaults_for(gem_name)
173
+ @defaults[gem_name.to_s] || {}
174
+ end
175
+
165
176
  def current_os
166
177
  require 'rbconfig'
167
178
  case host_os = RbConfig::CONFIG['host_os']
@@ -242,7 +253,7 @@ module Penchant
242
253
 
243
254
  version = args.first
244
255
 
245
- options = process_options(gem_name, template)
256
+ options = process_options(gem_name.first, template)
246
257
 
247
258
  args = [ gem_name.first ]
248
259
  args << version if version
@@ -1,3 +1,3 @@
1
1
  module Penchant
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
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.5
4
+ version: 0.2.6
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-06-11 00:00:00.000000000 Z
12
+ date: 2012-06-20 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Things I do for my Rails projects to get up to speed in new environments
15
15
  fast
@@ -81,7 +81,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
81
  version: '0'
82
82
  segments:
83
83
  - 0
84
- hash: -1641612638013508489
84
+ hash: 3133166305662926927
85
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  segments:
92
92
  - 0
93
- hash: -1641612638013508489
93
+ hash: 3133166305662926927
94
94
  requirements: []
95
95
  rubyforge_project: penchant
96
96
  rubygems_version: 1.8.23