penchant 0.2.10 → 0.2.11

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.
@@ -263,3 +263,18 @@ Feature: Gemfiles
263
263
  # generated by penchant, environment: local
264
264
  gem "one", {:git=>"git://github.com/john/one.git"}
265
265
  """
266
+
267
+ Scenario: Define special expansions for properties as a hash
268
+ Given I have the file "Gemfile.penchant" with the content:
269
+ """
270
+ defaults_for env(:local), :path => '../%s'
271
+ property :github, :git => "git://github.com/$1/%s.git"
272
+ gem 'one', :github => 'john'
273
+ """
274
+ When I rebuild the Gemfile for "local" mode
275
+ Then the file "Gemfile" should have the following content:
276
+ """
277
+ # generated by penchant, environment: local
278
+ gem "one", {:git=>"git://github.com/john/one.git"}
279
+ """
280
+
@@ -151,8 +151,8 @@ module Penchant
151
151
  end
152
152
  end
153
153
 
154
- def property(name, &block)
155
- @properties[name] = block
154
+ def property(name, hash = nil, &block)
155
+ @properties[name] = hash || block
156
156
  end
157
157
 
158
158
  def for_environment?(envs)
@@ -204,9 +204,18 @@ module Penchant
204
204
  while !property_stack.empty?
205
205
  key, value = property_stack.shift
206
206
 
207
- if @properties[key]
208
- @properties[key].call(*([ value ].flatten)).each do |k, v|
209
- property_stack.push([ k, v ])
207
+ if property = @properties[key]
208
+ values = [ value ].flatten
209
+
210
+ if property.respond_to?(:call)
211
+ property.call(*values).each do |k, v|
212
+ property_stack.push([ k, v ])
213
+ end
214
+ else
215
+ property.each do |k, v|
216
+ v = v.dup.gsub(%r{\$(\d+)}) { |m| values[m.to_i - 1 ] }
217
+ property_stack.push([ k, v ])
218
+ end
210
219
  end
211
220
  else
212
221
  value = value % gem_name if value.respond_to?(:%)
@@ -238,6 +247,8 @@ module Penchant
238
247
 
239
248
  class ERBFile < FileProcessor
240
249
  def handle_result(data)
250
+ $stderr.puts "ERB files are deprecated. Please convert them to the Ruby format."
251
+
241
252
  @output << ERB.new(data, nil, nil, '@_erbout').result(binding)
242
253
  end
243
254
 
@@ -1,3 +1,3 @@
1
1
  module Penchant
2
- VERSION = "0.2.10"
2
+ VERSION = "0.2.11"
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.10
4
+ version: 0.2.11
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-07-05 00:00:00.000000000 Z
12
+ date: 2012-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -193,7 +193,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  segments:
195
195
  - 0
196
- hash: -1638831436357911283
196
+ hash: -3735889517013965270
197
197
  required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  none: false
199
199
  requirements:
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  version: '0'
203
203
  segments:
204
204
  - 0
205
- hash: -1638831436357911283
205
+ hash: -3735889517013965270
206
206
  requirements: []
207
207
  rubyforge_project: penchant
208
208
  rubygems_version: 1.8.23