penchant 0.2.6 → 0.2.8

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
@@ -5,6 +5,7 @@ I like to do these things in all my projects:
5
5
  * Have all my tests run before committing. I don't like buying ice cream for the team on test failures.
6
6
  * If I'm developing gems alongside this project, I use a `Gemfile.penchant` to get around the "one gem, one source" issue in
7
7
  current versions of Bundler.
8
+ * I can also factor out and simplify a lot of my Gemfile settings.
8
9
  * If I'm moving to different machines or (heaven forbid!) having other developers work on the project, I want to make
9
10
  getting all those local gems as easy as possible.
10
11
 
@@ -24,6 +25,7 @@ Installs a bunch of scripts into the `scripts` directory of your project:
24
25
  Yeah, it's a `Gemfile` with some extras:
25
26
 
26
27
  ``` ruby
28
+ # Gemfile.penchant
27
29
  source :rubygems
28
30
 
29
31
  gem 'rails', '3.2.3'
@@ -48,7 +50,7 @@ no_deployment do
48
50
  #
49
51
  # gem 'flowerbox', :path => '../flowerbox', :require => nil
50
52
  # gem 'guard-flowerbox', :path => '../guard-flowerbox', :require => nil
51
- gems dev_gems, :path => '../%s'
53
+ gems dev_gems, :path => '../%s' # the %s is the name of the gem
52
54
  end
53
55
 
54
56
  env :remote do
@@ -103,6 +105,29 @@ end
103
105
  Run `penchant gemfile ENV --deployment` to get this behavior. This is run by default when the
104
106
  pre-commit git hook runs, but only after the default Rake task passes.
105
107
 
108
+ #### Won't this change the project dependencies?!
109
+
110
+ Probably not. You probably have the "main" gems in your project locked to a version of Rails or
111
+ Sinatra or something else, and all of the other gems for authentication, queue processing, etc. are
112
+ dependent on that framework. Ripping out your testing framework and deployment helpers really
113
+ shouldn't be changing the main versions of your application gems. It WORKSFORME and YMMV.
114
+
115
+ ### Getting local gems all set up
116
+
117
+ `penchant bootstrap` will go through and find all git repo references in your `Gemfile.penchant` and
118
+ will download them to the specified directory (by default, '..'). This means blocks like this
119
+ will work as expected when you `penchant bootstrap` and then `penchant gemfile local`:
120
+
121
+ ``` ruby
122
+ env :local do
123
+ gem 'my-gem', :path => '../%s'
124
+ end
125
+
126
+ env :remote do
127
+ gem 'my-gem', :git => 'git://github.com/johnbintz/%s.git'
128
+ end
129
+ ```
130
+
106
131
  ## initialize-environment
107
132
 
108
133
  Get new developers up to speed fast! `script/initialize-environment` does the following when run:
@@ -135,7 +160,7 @@ to your commit if they've changed.
135
160
 
136
161
  ### Skipping all that Rake falderal?
137
162
 
138
- Do it Travis CI style: stick `[ci skip]` in your commit message. That's why the meat of hte git hooks resides in
163
+ Do it Travis CI style: stick `[ci skip]` in your commit message. That's why the meat of the git hooks resides in
139
164
  `commit-msg` and not `pre-commit`: you need the commit message before you can determine if the tests should be run
140
165
  based on the commit message. Weird, I know.
141
166
 
@@ -182,6 +182,18 @@ Feature: Gemfiles
182
182
  Then I should get the following repositories:
183
183
  | git://github.cats/two.git |
184
184
 
185
+ Scenario: Get the list of git repos defined, regardless of environment
186
+ Given I have the file "Gemfile.penchant" with the content:
187
+ """
188
+ gem 'one', :path => '../%s'
189
+ env :remote do
190
+ gem 'two', :git => 'git://github.cats/%s.git'
191
+ end
192
+ """
193
+ When I request the list of git repositories
194
+ Then I should get the following repositories:
195
+ | git://github.cats/two.git |
196
+
185
197
  Scenario: Propose defaults for a gem
186
198
  Given I have the file "Gemfile.penchant" with the content:
187
199
  """
@@ -195,7 +207,6 @@ Feature: Gemfiles
195
207
  gem "one", "1.2.3", {:path=>"../one"}
196
208
  """
197
209
 
198
- @wip
199
210
  Scenario: Propose defaults for an array of gems
200
211
  Given I have the file "Gemfile.penchant" with the content:
201
212
  """
@@ -208,3 +219,18 @@ Feature: Gemfiles
208
219
  # generated by penchant, environment: local
209
220
  gem "one", "1.2.3", {:path=>"../one"}
210
221
  """
222
+
223
+ Scenario: Propose defaults for an environment
224
+ Given I have the file "Gemfile.penchant" with the content:
225
+ """
226
+ defaults_for env(:local), :path => '../%s'
227
+ env :local do
228
+ gem 'one', '1.2.3'
229
+ end
230
+ """
231
+ When I rebuild the Gemfile for "local" mode
232
+ Then the file "Gemfile" should have the following content:
233
+ """
234
+ # generated by penchant, environment: local
235
+ gem "one", "1.2.3", {:path=>"../one"}
236
+ """
@@ -83,9 +83,27 @@ module Penchant
83
83
  gemfile_header['deployment mode'] != nil
84
84
  end
85
85
 
86
+ class Env
87
+ attr_accessor :name
88
+
89
+ def initialize(name)
90
+ @name = name.to_s
91
+ end
92
+
93
+ def ==(other)
94
+ @name == other.name
95
+ end
96
+
97
+ def to_s
98
+ "@#{name}"
99
+ end
100
+ end
101
+
86
102
  class FileProcessor
87
103
  attr_reader :environment, :is_deployment, :available_environments, :defined_git_repos
88
104
 
105
+ ANY_ENVIRONMENT = :any_environment
106
+
89
107
  def self.result(data, *args)
90
108
  new(data).result(*args)
91
109
  end
@@ -103,6 +121,8 @@ module Penchant
103
121
  @available_environments = []
104
122
  @defined_git_repos = []
105
123
  @defaults = {}
124
+
125
+ @_current_env_defaults = {}
106
126
  end
107
127
 
108
128
  def result(_env, _is_deployment)
@@ -119,7 +139,19 @@ module Penchant
119
139
  def env(*args)
120
140
  @available_environments += args
121
141
 
122
- yield if args.include?(environment)
142
+ if block_given?
143
+ if for_environment?(args)
144
+ @_current_env_defaults = _defaults_for(Env.new(environment))
145
+ yield
146
+ @_current_env_defaults = {}
147
+ end
148
+ else
149
+ Penchant::Gemfile::Env.new(args.shift)
150
+ end
151
+ end
152
+
153
+ def for_environment?(envs)
154
+ envs.include?(environment) || environment == ANY_ENVIRONMENT
123
155
  end
124
156
 
125
157
  def no_deployment
@@ -170,7 +202,8 @@ module Penchant
170
202
  end
171
203
 
172
204
  def _defaults_for(gem_name)
173
- @defaults[gem_name.to_s] || {}
205
+ result = @_current_env_defaults
206
+ result.merge(@defaults[gem_name.to_s] || {})
174
207
  end
175
208
 
176
209
  def current_os
@@ -303,7 +336,7 @@ module Penchant
303
336
  end
304
337
 
305
338
  def defined_git_repos
306
- process
339
+ process(FileProcessor::ANY_ENVIRONMENT)
307
340
  builder.defined_git_repos
308
341
  end
309
342
 
@@ -342,8 +375,8 @@ module Penchant
342
375
  File.join(@path, file)
343
376
  end
344
377
 
345
- def process
346
- builder.result(@env, @is_deployment)
378
+ def process(env = @env)
379
+ builder.result(env, @is_deployment)
347
380
  end
348
381
 
349
382
  def builder
@@ -1,3 +1,3 @@
1
1
  module Penchant
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.8"
3
3
  end
data/penchant.gemspec CHANGED
@@ -18,4 +18,6 @@ Gem::Specification.new do |s|
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
+
22
+ s.add_dependency 'bundler'
21
23
  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.6
4
+ version: 0.2.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-20 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-06-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  description: Things I do for my Rails projects to get up to speed in new environments
15
31
  fast
16
32
  email:
@@ -81,7 +97,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
97
  version: '0'
82
98
  segments:
83
99
  - 0
84
- hash: 3133166305662926927
100
+ hash: 4263770194857896104
85
101
  required_rubygems_version: !ruby/object:Gem::Requirement
86
102
  none: false
87
103
  requirements:
@@ -90,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
106
  version: '0'
91
107
  segments:
92
108
  - 0
93
- hash: 3133166305662926927
109
+ hash: 4263770194857896104
94
110
  requirements: []
95
111
  rubyforge_project: penchant
96
112
  rubygems_version: 1.8.23