penchant 0.2.9 → 0.2.10

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
@@ -2,7 +2,8 @@
2
2
 
3
3
  I like to do these things in all my projects:
4
4
 
5
- * Have all my tests run before committing. I don't like buying ice cream for the team on test failures.
5
+ * Have all my tests run before committing. I don't like buying ice cream for the team on test failures, and setting up internal
6
+ CI for smaller projects is a pain.
6
7
  * If I'm developing gems alongside this project, I use a `Gemfile.penchant` to get around the "one gem, one source" issue in
7
8
  current versions of Bundler.
8
9
  * I can also factor out and simplify a lot of my Gemfile settings.
@@ -45,12 +46,15 @@ no_deployment do
45
46
  # set up defaults for certain gems that are probably being used in envs
46
47
  defaults_for dev_gems, :require => nil
47
48
 
49
+ # set up defaults for all gems in a particular environment
50
+ defaults_for env(:local), :path => '../%s' # the %s is the name of the gem
51
+
48
52
  env :local do
49
53
  # expands to:
50
54
  #
51
55
  # gem 'flowerbox', :path => '../flowerbox', :require => nil
52
56
  # gem 'guard-flowerbox', :path => '../guard-flowerbox', :require => nil
53
- gems dev_gems, :path => '../%s' # the %s is the name of the gem
57
+ gems dev_gems
54
58
  end
55
59
 
56
60
  env :remote do
@@ -77,7 +81,8 @@ end
77
81
  Use `script/gemfile local` to get at the local ones, and `script/gemfile remote` to get at the remote ones.
78
82
  It then runs `bundle install`.
79
83
 
80
- You can also run `penchant gemfile ENV`.
84
+ You can also run `penchant gemfile ENV`. Just straight `penchant gemfile` will rebuild the `Gemfile` from
85
+ `Gemfile.penchant` for whatever environment the `Gemfile` is currently using.
81
86
 
82
87
  ### Deployment mode
83
88
 
@@ -87,6 +92,8 @@ and deploying on another, or if you don't want to deal with the dependencies for
87
92
  frameworks:
88
93
 
89
94
  ``` ruby
95
+ gem 'rails'
96
+
90
97
  no_deployment do
91
98
  os :darwin do
92
99
  gems 'growl_notify', 'growl', 'rb-fsevent'
@@ -128,6 +135,9 @@ env :remote do
128
135
  end
129
136
  ```
130
137
 
138
+ Note that this just does a quick `git clone`, so if your project is already in there in a different state,
139
+ nothing "happens" except that git fails.
140
+
131
141
  ## initialize-environment
132
142
 
133
143
  Get new developers up to speed fast! `script/initialize-environment` does the following when run:
@@ -249,3 +249,17 @@ Feature: Gemfiles
249
249
  # generated by penchant, environment: local
250
250
  gem "one", "1.2.3", {:path=>"../cats"}
251
251
  """
252
+
253
+ Scenario: Define special expansions for properties
254
+ Given I have the file "Gemfile.penchant" with the content:
255
+ """
256
+ defaults_for env(:local), :path => '../%s'
257
+ property(:github) { |name| { :git => "git://github.com/#{name}/%s.git" } }
258
+ gem 'one', :github => 'john'
259
+ """
260
+ When I rebuild the Gemfile for "local" mode
261
+ Then the file "Gemfile" should have the following content:
262
+ """
263
+ # generated by penchant, environment: local
264
+ gem "one", {:git=>"git://github.com/john/one.git"}
265
+ """
@@ -121,6 +121,7 @@ module Penchant
121
121
  @available_environments = []
122
122
  @defined_git_repos = []
123
123
  @defaults = {}
124
+ @properties = {}
124
125
 
125
126
  @_current_env_defaults = {}
126
127
  end
@@ -150,6 +151,10 @@ module Penchant
150
151
  end
151
152
  end
152
153
 
154
+ def property(name, &block)
155
+ @properties[name] = block
156
+ end
157
+
153
158
  def for_environment?(envs)
154
159
  envs.include?(environment) || environment == ANY_ENVIRONMENT
155
160
  end
@@ -192,13 +197,25 @@ module Penchant
192
197
  end
193
198
 
194
199
  def process_options(gem_name, template = {})
195
- Hash[
196
- _defaults_for(gem_name).dup.merge(template).collect { |key, value|
200
+ properties = {}
201
+
202
+ property_stack = _defaults_for(gem_name).dup.merge(template).to_a
203
+
204
+ while !property_stack.empty?
205
+ key, value = property_stack.shift
206
+
207
+ if @properties[key]
208
+ @properties[key].call(*([ value ].flatten)).each do |k, v|
209
+ property_stack.push([ k, v ])
210
+ end
211
+ else
197
212
  value = value % gem_name if value.respond_to?(:%)
198
213
 
199
- [ key, value ]
200
- }.sort
201
- ]
214
+ properties[key] = value
215
+ end
216
+ end
217
+
218
+ Hash[properties.sort]
202
219
  end
203
220
 
204
221
  def _defaults_for(gem_name)
@@ -1,3 +1,3 @@
1
1
  module Penchant
2
- VERSION = "0.2.9"
2
+ VERSION = "0.2.10"
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.9
4
+ version: 0.2.10
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-03 00:00:00.000000000 Z
12
+ date: 2012-07-05 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: -1066545931225637569
196
+ hash: -1638831436357911283
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: -1066545931225637569
205
+ hash: -1638831436357911283
206
206
  requirements: []
207
207
  rubyforge_project: penchant
208
208
  rubygems_version: 1.8.23