penchant 0.1.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/Guardfile +7 -4
- data/README.md +28 -19
- data/bin/penchant +2 -2
- data/config/cucumber.yml +8 -0
- data/features/gemfile.feature +73 -0
- data/features/ruby_gemfile.feature +131 -0
- data/features/step_definitions/then/the_file_gemfile_should_have_the_following_stripped_content.rb +7 -0
- data/features/step_definitions/when/i_rebuild_the_gemfile_for_local_mode.rb +4 -0
- data/features/support/cuke-pack.rb +20 -0
- data/features/support/env.rb +1 -0
- data/lib/penchant/gemfile.rb +188 -9
- data/lib/penchant/version.rb +1 -1
- data/script/hooks/commit-msg +0 -8
- data/template/script/hooks/commit-msg +2 -8
- data/template/script/hooks/pre-commit +4 -1
- metadata +14 -5
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -9,10 +9,13 @@ group :rspec do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
# added by cuke-pack
|
13
|
+
|
14
|
+
group :wip do
|
15
|
+
guard 'cucumber', :env => :cucumber, :cli => '-p wip' do
|
16
|
+
watch(%r{^features/.+.feature$})
|
17
|
+
watch(%r{^(app|lib).*}) { 'features' }
|
15
18
|
watch(%r{^features/support/.+$}) { 'features' }
|
16
|
-
watch(%r{^features/step_definitions/(.+)
|
19
|
+
watch(%r{^features/step_definitions/(.+).rb$}) { 'features' }
|
17
20
|
end
|
18
21
|
end
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
I like to do these things in all my projects:
|
4
4
|
|
5
5
|
* Have all my tests run before committing. I don't like buying ice cream for the team on test failures.
|
6
|
-
* If I'm developing gems alongside this project, I use a `Gemfile.
|
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
8
|
* If I'm moving to different machines or (heaven forbid!) having other developers work on the project, I want to make
|
9
9
|
getting all those local gems as easy as possible.
|
@@ -14,27 +14,36 @@ This gem makes that easier!
|
|
14
14
|
|
15
15
|
Installs a bunch of scripts into the `scripts` directory of your project:
|
16
16
|
|
17
|
-
* `gemfile` which switches between `Gemfile.
|
17
|
+
* `gemfile` which switches between `Gemfile.penchant` environments
|
18
18
|
* `install-git-hooks` which will do just what it says
|
19
19
|
* `hooks`, several git hooks that the prior script symlinks into .git/hooks for you
|
20
20
|
* `initialize-environment`, which bootstraps your local environment so you can get up and running
|
21
21
|
|
22
|
-
## Gemfile.
|
22
|
+
## Gemfile.penchant?!
|
23
23
|
|
24
|
-
Yeah, it's a `Gemfile` with
|
24
|
+
Yeah, it's a `Gemfile` with some extras:
|
25
25
|
|
26
|
-
```
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
``` ruby
|
27
|
+
source :rubygems
|
28
|
+
|
29
|
+
gem 'rails', '3.2.3'
|
30
|
+
gems 'rake', 'nokogiri', 'rack-rewrite'
|
31
|
+
|
32
|
+
no_deployment do
|
33
|
+
group :development, :test do
|
34
|
+
gem 'rspec', '~> 2.6.0'
|
30
35
|
|
31
|
-
|
32
|
-
gem 'guard', :git => 'git://github.com/johnbintz/guard.git'
|
33
|
-
<% end %>
|
36
|
+
dev_gems = %w{flowerbox guard-flowerbox}
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
env :local do
|
39
|
+
gems dev_gems, :path => '../%s'
|
40
|
+
end
|
41
|
+
|
42
|
+
env :remote do
|
43
|
+
gems dev_gems, :git => 'git://github.com/johnbintz/%s.git'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
38
47
|
```
|
39
48
|
|
40
49
|
Use `script/gemfile local` to get at the local ones, and `script/gemfile remote` to get at the remote ones.
|
@@ -49,8 +58,8 @@ remote servers. *Very* helpful when you have OS-specific gems and are developing
|
|
49
58
|
and deploying on another, or if you don't want to deal with the dependencies for your testing
|
50
59
|
frameworks:
|
51
60
|
|
52
|
-
```
|
53
|
-
|
61
|
+
``` ruby
|
62
|
+
no_deployment do
|
54
63
|
require 'rbconfig'
|
55
64
|
case RbConfig::CONFIG['host_os']
|
56
65
|
when /darwin/
|
@@ -64,7 +73,7 @@ frameworks:
|
|
64
73
|
group :test do
|
65
74
|
# ... all your testing libraries you won't need on the deployed end ...
|
66
75
|
end
|
67
|
-
|
76
|
+
end
|
68
77
|
```
|
69
78
|
|
70
79
|
Run `penchant gemfile ENV --deployment` to get this behavior. This is run by default when the
|
@@ -74,8 +83,8 @@ pre-commit git hook runs, but only after the default Rake task passes.
|
|
74
83
|
|
75
84
|
Get new developers up to speed fast! `script/initialize-environment` does the following when run:
|
76
85
|
|
77
|
-
* Check out any remote repos found in `Gemfile.
|
78
|
-
That way, you can have your `Gemfile.
|
86
|
+
* Check out any remote repos found in `Gemfile.penchant` to the same directory where your current project lives.
|
87
|
+
That way, you can have your `Gemfile.penchant` set up as above and everything works cleanly.
|
79
88
|
* Runs `script/gemfile remote` to set your project to using remote repositories.
|
80
89
|
* Runs `rake bootstrap` for the project if it exists.
|
81
90
|
|
data/bin/penchant
CHANGED
@@ -30,7 +30,7 @@ class PenchantCLI < Thor
|
|
30
30
|
method_options :dir => 'script'
|
31
31
|
def convert
|
32
32
|
install
|
33
|
-
FileUtils.mv 'Gemfile', 'Gemfile.
|
33
|
+
FileUtils.mv 'Gemfile', 'Gemfile.penchant'
|
34
34
|
gemfile(:remote)
|
35
35
|
end
|
36
36
|
|
@@ -52,7 +52,7 @@ class PenchantCLI < Thor
|
|
52
52
|
|
53
53
|
gemfile = Penchant::Gemfile.new
|
54
54
|
if !gemfile.has_gemfile?
|
55
|
-
puts "No Gemfile or Gemfile.
|
55
|
+
puts "No Gemfile or Gemfile.penchant, exiting."
|
56
56
|
exit 1
|
57
57
|
end
|
58
58
|
system %{bundle}
|
data/config/cucumber.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<%
|
2
|
+
std_opts = "-r features --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} -f Cucumber::StepWriter --out features/step_definitions --strict"
|
3
|
+
%>
|
4
|
+
default: <%= std_opts %> features
|
5
|
+
wip: <%= std_opts %> --tags @wip features
|
6
|
+
precommit: FAILFAST=true <%= std_opts %> --tags ~@wip:0 features
|
7
|
+
cleanup: <%= std_opts %> -f Cucumber::CleanupFormatter --out unused.txt features
|
8
|
+
|
data/features/gemfile.feature
CHANGED
@@ -31,3 +31,76 @@ Feature: Gemfiles
|
|
31
31
|
# generated by penchant, environment: local
|
32
32
|
this is content
|
33
33
|
"""
|
34
|
+
|
35
|
+
Scenario: Use placeholder expansion
|
36
|
+
Given I have the file "Gemfile.erb" with the content:
|
37
|
+
"""
|
38
|
+
<% env :local, :path => '../%s' do %>
|
39
|
+
gem 'test'
|
40
|
+
<% end %>
|
41
|
+
"""
|
42
|
+
When I rebuild the Gemfile for "local" mode
|
43
|
+
Then the file "Gemfile" should have the following stripped content:
|
44
|
+
"""
|
45
|
+
# generated by penchant, environment: local
|
46
|
+
gem 'test', :path => %{../test}
|
47
|
+
"""
|
48
|
+
|
49
|
+
Scenario: Use a gem list for an operation
|
50
|
+
Given I have the file "Gemfile.erb" with the content:
|
51
|
+
"""
|
52
|
+
<% gems 'test' do %>
|
53
|
+
<% env :local, :path => '../%s' do %>
|
54
|
+
<%= gem %>
|
55
|
+
<% end %>
|
56
|
+
<% end %>
|
57
|
+
"""
|
58
|
+
When I rebuild the Gemfile for "local" mode
|
59
|
+
Then the file "Gemfile" should have the following stripped content:
|
60
|
+
"""
|
61
|
+
# generated by penchant, environment: local
|
62
|
+
gem 'test', :path => %{../test}
|
63
|
+
"""
|
64
|
+
|
65
|
+
Scenario: Let gem get additional info
|
66
|
+
Given I have the file "Gemfile.erb" with the content:
|
67
|
+
"""
|
68
|
+
<% gems 'test' do %>
|
69
|
+
<%= gem :path => '../%s' %>
|
70
|
+
<% end %>
|
71
|
+
"""
|
72
|
+
When I rebuild the Gemfile for "local" mode
|
73
|
+
Then the file "Gemfile" should have the following content:
|
74
|
+
"""
|
75
|
+
# generated by penchant, environment: local
|
76
|
+
|
77
|
+
gem 'test', {:path=>"../test"}
|
78
|
+
|
79
|
+
"""
|
80
|
+
|
81
|
+
Scenario: Use a gem list without a block
|
82
|
+
Given I have the file "Gemfile.erb" with the content:
|
83
|
+
"""
|
84
|
+
<% gems 'test', :path => '../%s' %>
|
85
|
+
"""
|
86
|
+
When I rebuild the Gemfile for "local" mode
|
87
|
+
Then the file "Gemfile" should have the following content:
|
88
|
+
"""
|
89
|
+
# generated by penchant, environment: local
|
90
|
+
gem 'test', {:path=>"../test"}
|
91
|
+
|
92
|
+
"""
|
93
|
+
|
94
|
+
Scenario: Use a gem list with an array
|
95
|
+
Given I have the file "Gemfile.erb" with the content:
|
96
|
+
"""
|
97
|
+
<% gems [ 'test' ], :path => '../%s' %>
|
98
|
+
"""
|
99
|
+
When I rebuild the Gemfile for "local" mode
|
100
|
+
Then the file "Gemfile" should have the following content:
|
101
|
+
"""
|
102
|
+
# generated by penchant, environment: local
|
103
|
+
gem 'test', {:path=>"../test"}
|
104
|
+
|
105
|
+
"""
|
106
|
+
|
@@ -0,0 +1,131 @@
|
|
1
|
+
@fakefs
|
2
|
+
Feature: Gemfiles
|
3
|
+
Scenario: Process a pure Ruby gemfile
|
4
|
+
Given I have the file "Gemfile.penchant" with the content:
|
5
|
+
"""
|
6
|
+
source :rubygems
|
7
|
+
|
8
|
+
group :cats, :dogs do
|
9
|
+
case environment
|
10
|
+
when :local
|
11
|
+
gem 'test', :path => '../test'
|
12
|
+
when :remote
|
13
|
+
gem 'test', :git => 'git://github.com/johnbintz/test.git'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
"""
|
17
|
+
When I rebuild the Gemfile for "local" mode
|
18
|
+
Then the file "Gemfile" should have the following content:
|
19
|
+
"""
|
20
|
+
# generated by penchant, environment: local
|
21
|
+
source :rubygems
|
22
|
+
|
23
|
+
group :cats, :dogs do
|
24
|
+
gem "test", {:path=>"../test"}
|
25
|
+
end
|
26
|
+
"""
|
27
|
+
When I rebuild the Gemfile for "remote" mode
|
28
|
+
Then the file "Gemfile" should have the following content:
|
29
|
+
"""
|
30
|
+
# generated by penchant, environment: remote
|
31
|
+
source :rubygems
|
32
|
+
|
33
|
+
group :cats, :dogs do
|
34
|
+
gem "test", {:git=>"git://github.com/johnbintz/test.git"}
|
35
|
+
end
|
36
|
+
"""
|
37
|
+
|
38
|
+
Scenario: Use a gemlist
|
39
|
+
Given I have the file "Gemfile.penchant" with the content:
|
40
|
+
"""
|
41
|
+
gems 'one', 'two', 'three', :path => '../%s'
|
42
|
+
"""
|
43
|
+
When I rebuild the Gemfile for "local" mode
|
44
|
+
Then the file "Gemfile" should have the following content:
|
45
|
+
"""
|
46
|
+
# generated by penchant, environment: local
|
47
|
+
gem "one", {:path=>"../one"}
|
48
|
+
gem "two", {:path=>"../two"}
|
49
|
+
gem "three", {:path=>"../three"}
|
50
|
+
"""
|
51
|
+
|
52
|
+
Scenario: Use an env block
|
53
|
+
Given I have the file "Gemfile.penchant" with the content:
|
54
|
+
"""
|
55
|
+
env :local do
|
56
|
+
gems 'one', 'two', 'three', :path => '../%s'
|
57
|
+
end
|
58
|
+
"""
|
59
|
+
When I rebuild the Gemfile for "local" mode
|
60
|
+
Then the file "Gemfile" should have the following content:
|
61
|
+
"""
|
62
|
+
# generated by penchant, environment: local
|
63
|
+
gem "one", {:path=>"../one"}
|
64
|
+
gem "two", {:path=>"../two"}
|
65
|
+
gem "three", {:path=>"../three"}
|
66
|
+
"""
|
67
|
+
|
68
|
+
When I rebuild the Gemfile for "remote" mode
|
69
|
+
Then the file "Gemfile" should have the following content:
|
70
|
+
"""
|
71
|
+
# generated by penchant, environment: remote
|
72
|
+
|
73
|
+
"""
|
74
|
+
|
75
|
+
Scenario: Skip deployment blocks
|
76
|
+
Given I have the file "Gemfile.penchant" with the content:
|
77
|
+
"""
|
78
|
+
no_deployment do
|
79
|
+
gem 'one'
|
80
|
+
end
|
81
|
+
"""
|
82
|
+
When I rebuild the Gemfile for "local" mode
|
83
|
+
Then the file "Gemfile" should have the following content:
|
84
|
+
"""
|
85
|
+
# generated by penchant, environment: local
|
86
|
+
gem "one"
|
87
|
+
"""
|
88
|
+
|
89
|
+
When I rebuild the Gemfile for "local" mode with deployment
|
90
|
+
Then the file "Gemfile" should have the following content:
|
91
|
+
"""
|
92
|
+
# generated by penchant, environment: local, deployment mode (was local)
|
93
|
+
|
94
|
+
"""
|
95
|
+
|
96
|
+
Scenario: Peel multiple hashes off a gemlist
|
97
|
+
Given I have the file "Gemfile.penchant" with the content:
|
98
|
+
"""
|
99
|
+
gems 'one', { :path => '../%s' }, { :require => nil }
|
100
|
+
"""
|
101
|
+
When I rebuild the Gemfile for "local" mode
|
102
|
+
Then the file "Gemfile" should have the following content:
|
103
|
+
"""
|
104
|
+
# generated by penchant, environment: local
|
105
|
+
gem "one", {:path=>"../one", :require=>nil}
|
106
|
+
"""
|
107
|
+
|
108
|
+
Scenario: Don't add an empty hash
|
109
|
+
Given I have the file "Gemfile.penchant" with the content:
|
110
|
+
"""
|
111
|
+
gems 'one'
|
112
|
+
"""
|
113
|
+
When I rebuild the Gemfile for "local" mode
|
114
|
+
Then the file "Gemfile" should have the following content:
|
115
|
+
"""
|
116
|
+
# generated by penchant, environment: local
|
117
|
+
gem "one"
|
118
|
+
"""
|
119
|
+
|
120
|
+
Scenario: Single gem gets processed like a gems list
|
121
|
+
Given I have the file "Gemfile.penchant" with the content:
|
122
|
+
"""
|
123
|
+
gem 'one', :path => '../%s'
|
124
|
+
"""
|
125
|
+
When I rebuild the Gemfile for "local" mode
|
126
|
+
Then the file "Gemfile" should have the following content:
|
127
|
+
"""
|
128
|
+
# generated by penchant, environment: local
|
129
|
+
gem "one", {:path=>"../one"}
|
130
|
+
"""
|
131
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'cuke-pack/support/pause'
|
2
|
+
require 'cuke-pack/support/pending'
|
3
|
+
|
4
|
+
Before do
|
5
|
+
# if you want pending steps to pause before marking the step as pending,
|
6
|
+
# set @pause_ok to true
|
7
|
+
|
8
|
+
@pause_ok = false
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'cuke-pack/support/step_writer'
|
12
|
+
require 'cuke-pack/support/wait_for'
|
13
|
+
require 'cuke-pack/support/failfast'
|
14
|
+
|
15
|
+
# set the level of flaying on the step definitions
|
16
|
+
# set it to false to skip flaying
|
17
|
+
flay_level = 32
|
18
|
+
|
19
|
+
require 'cuke-pack/support/flay'
|
20
|
+
|
data/features/support/env.rb
CHANGED
data/lib/penchant/gemfile.rb
CHANGED
@@ -18,7 +18,7 @@ module Penchant
|
|
18
18
|
|
19
19
|
def self.pre_switch(env, deployment = false)
|
20
20
|
gemfile = Penchant::Gemfile.new
|
21
|
-
return false if !gemfile.
|
21
|
+
return false if !gemfile.has_processable_gemfile?
|
22
22
|
gemfile.run_dot_penchant!(env, deployment)
|
23
23
|
|
24
24
|
gemfile
|
@@ -46,10 +46,26 @@ module Penchant
|
|
46
46
|
file_in_path('Gemfile.erb')
|
47
47
|
end
|
48
48
|
|
49
|
+
def gemfile_penchant_path
|
50
|
+
file_in_path('Gemfile.penchant')
|
51
|
+
end
|
52
|
+
|
49
53
|
def has_gemfile_erb?
|
50
54
|
File.file?(gemfile_erb_path)
|
51
55
|
end
|
52
56
|
|
57
|
+
def has_gemfile_penchant?
|
58
|
+
File.file?(gemfile_penchant_path)
|
59
|
+
end
|
60
|
+
|
61
|
+
def has_processable_gemfile?
|
62
|
+
has_gemfile_erb? || has_gemfile_penchant?
|
63
|
+
end
|
64
|
+
|
65
|
+
def processable_gemfile_path
|
66
|
+
has_gemfile_erb? ? gemfile_erb_path : gemfile_penchant_path
|
67
|
+
end
|
68
|
+
|
53
69
|
def environment
|
54
70
|
gemfile_header.strip[%r{environment: ([^, ]*)}, 1]
|
55
71
|
end
|
@@ -58,10 +74,170 @@ module Penchant
|
|
58
74
|
gemfile_header['deployment mode'] != nil
|
59
75
|
end
|
60
76
|
|
77
|
+
class FileProcessor
|
78
|
+
attr_reader :environment, :is_deployment
|
79
|
+
|
80
|
+
def self.result(data, *args)
|
81
|
+
new(data).result(*args)
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.handle_result(&block)
|
85
|
+
if block
|
86
|
+
@handle_result = block
|
87
|
+
else
|
88
|
+
@handle_result
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def initialize(data)
|
93
|
+
@data = data
|
94
|
+
end
|
95
|
+
|
96
|
+
def result(_env, _is_deployment)
|
97
|
+
@environment = _env.to_s.to_sym
|
98
|
+
@is_deployment = _is_deployment
|
99
|
+
|
100
|
+
@output = []
|
101
|
+
|
102
|
+
handle_result(@data)
|
103
|
+
|
104
|
+
@output.join("\n")
|
105
|
+
end
|
106
|
+
|
107
|
+
def env(*args)
|
108
|
+
yield if args.include?(environment)
|
109
|
+
end
|
110
|
+
|
111
|
+
def no_deployment
|
112
|
+
yield if !is_deployment
|
113
|
+
end
|
114
|
+
|
115
|
+
protected
|
116
|
+
def args_to_string(args)
|
117
|
+
args.inspect[1..-2]
|
118
|
+
end
|
119
|
+
|
120
|
+
def split_args(args)
|
121
|
+
template = {}
|
122
|
+
|
123
|
+
while args.last.instance_of?(Hash)
|
124
|
+
template.merge!(args.pop)
|
125
|
+
end
|
126
|
+
|
127
|
+
[ args, template ]
|
128
|
+
end
|
129
|
+
|
130
|
+
def call_and_indent_output(block)
|
131
|
+
index = @output.length
|
132
|
+
block.call
|
133
|
+
index.upto(@output.length - 1) do |i|
|
134
|
+
@output[i] = " " + @output[i]
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def process_options(gem_name, template = {})
|
139
|
+
Hash[
|
140
|
+
template.collect { |key, value|
|
141
|
+
value = value % gem_name if value.respond_to?(:%)
|
142
|
+
|
143
|
+
[ key, value ]
|
144
|
+
}.sort
|
145
|
+
]
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
class ERBFile < FileProcessor
|
150
|
+
def handle_result(data)
|
151
|
+
@output << ERB.new(data, nil, nil, '@_erbout').result(binding)
|
152
|
+
end
|
153
|
+
|
154
|
+
def env(check, template = {}, &block)
|
155
|
+
if check.to_s == @env.to_s
|
156
|
+
original_erbout = @_erbout.dup
|
157
|
+
|
158
|
+
output = instance_eval(&block).lines.to_a
|
159
|
+
|
160
|
+
output.each do |line|
|
161
|
+
if gem_name = line[%r{gem ['"]([^'"]+)['"]}, 1]
|
162
|
+
line.replace(line.rstrip + process_options(gem_name, template) + "\n")
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
@_erbout = original_erbout + output.join
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def gems(*gems)
|
171
|
+
template = {}
|
172
|
+
template = gems.pop if gems.last.instance_of?(Hash)
|
173
|
+
|
174
|
+
gems.flatten.each do |gem|
|
175
|
+
@_current_gem = gem
|
176
|
+
if block_given?
|
177
|
+
yield
|
178
|
+
else
|
179
|
+
@_erbout += gem(template) + "\n"
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def gem(template = {})
|
185
|
+
output = "gem '#{@_current_gem}'"
|
186
|
+
options = process_options(@_current_gem, template)
|
187
|
+
if !options.empty?
|
188
|
+
output += ", #{options.inspect}"
|
189
|
+
end
|
190
|
+
output
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
class PenchantFile < FileProcessor
|
195
|
+
def handle_result(data)
|
196
|
+
instance_eval(data)
|
197
|
+
end
|
198
|
+
|
199
|
+
def gem(*args)
|
200
|
+
gem_name, template = split_args(args)
|
201
|
+
|
202
|
+
options = process_options(gem_name, template)
|
203
|
+
|
204
|
+
args = [ gem_name.first ]
|
205
|
+
args << options if !options.empty?
|
206
|
+
|
207
|
+
@output << %{gem #{args_to_string(args)}}
|
208
|
+
end
|
209
|
+
|
210
|
+
def gems(*args)
|
211
|
+
gems, template = split_args(args)
|
212
|
+
|
213
|
+
gems.flatten.each do |gem_name|
|
214
|
+
options = process_options(gem_name, template)
|
215
|
+
|
216
|
+
args = [ gem_name ]
|
217
|
+
args << options if !options.empty?
|
218
|
+
|
219
|
+
gem *args
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def group(*args, &block)
|
224
|
+
@output << ""
|
225
|
+
@output << %{group #{args_to_string(args)} do}
|
226
|
+
|
227
|
+
call_and_indent_output(block)
|
228
|
+
|
229
|
+
@output << %{end}
|
230
|
+
end
|
231
|
+
|
232
|
+
def source(*args)
|
233
|
+
@output << %{source #{args_to_string(args)}}
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
61
237
|
def switch_to!(gemfile_env = nil, deployment = false)
|
62
238
|
@env, @is_deployment = gemfile_env, deployment
|
63
239
|
|
64
|
-
output = [ header,
|
240
|
+
output = [ header, process(template) ]
|
65
241
|
|
66
242
|
File.open(gemfile_path, 'wb') { |fh| fh.print output.join("\n") }
|
67
243
|
end
|
@@ -93,16 +269,19 @@ module Penchant
|
|
93
269
|
File.join(@path, file)
|
94
270
|
end
|
95
271
|
|
96
|
-
def template
|
97
|
-
File.
|
98
|
-
|
272
|
+
def process(template)
|
273
|
+
builder = case File.extname(processable_gemfile_path)
|
274
|
+
when '.penchant'
|
275
|
+
PenchantFile
|
276
|
+
when '.erb'
|
277
|
+
ERBFile
|
278
|
+
end
|
99
279
|
|
100
|
-
|
101
|
-
instance_eval(&block) if check.to_s == @env.to_s
|
280
|
+
builder.result(template, @env, @is_deployment)
|
102
281
|
end
|
103
282
|
|
104
|
-
def
|
105
|
-
|
283
|
+
def template
|
284
|
+
File.read(processable_gemfile_path)
|
106
285
|
end
|
107
286
|
|
108
287
|
def gemfile_header
|
data/lib/penchant/version.rb
CHANGED
data/script/hooks/commit-msg
CHANGED
@@ -14,11 +14,3 @@ if [[ "${msg}" != *"[ci skip]"* ]]; then
|
|
14
14
|
if [ $R -ne 0 ]; then exit $R; fi
|
15
15
|
fi
|
16
16
|
|
17
|
-
if [ "$(penchant gemfile-env)" != "remote deployment" ]; then
|
18
|
-
unset GIT_DIR
|
19
|
-
penchant gemfile remote --deployment
|
20
|
-
GIT_DIR=$OLD_GIT_DIR
|
21
|
-
git add Gemfile*
|
22
|
-
fi
|
23
|
-
|
24
|
-
exit 0
|
@@ -6,7 +6,9 @@ OLD_GIT_DIR=$GIT_DIR
|
|
6
6
|
|
7
7
|
if [[ "${msg}" != *"[ci skip]"* ]]; then
|
8
8
|
if [ "$(penchant gemfile-env)" != "remote" ]; then
|
9
|
+
unset GIT_DIR
|
9
10
|
penchant gemfile remote
|
11
|
+
GIT_DIR=$OLD_GIT_DIR
|
10
12
|
fi
|
11
13
|
|
12
14
|
bundle exec rake
|
@@ -14,11 +16,3 @@ if [[ "${msg}" != *"[ci skip]"* ]]; then
|
|
14
16
|
if [ $R -ne 0 ]; then exit $R; fi
|
15
17
|
fi
|
16
18
|
|
17
|
-
if [ "$(penchant gemfile-env)" != "remote deployment" ]; then
|
18
|
-
unset GIT_DIR
|
19
|
-
penchant gemfile remote --deployment
|
20
|
-
GIT_DIR=$OLD_GIT_DIR
|
21
|
-
git add Gemfile*
|
22
|
-
fi
|
23
|
-
|
24
|
-
exit 0
|
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.1
|
4
|
+
version: 0.2.1
|
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-
|
12
|
+
date: 2012-06-05 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
|
@@ -26,14 +26,19 @@ files:
|
|
26
26
|
- README.md
|
27
27
|
- Rakefile
|
28
28
|
- bin/penchant
|
29
|
+
- config/cucumber.yml
|
29
30
|
- features/cli.feature
|
30
31
|
- features/gemfile.feature
|
32
|
+
- features/ruby_gemfile.feature
|
31
33
|
- features/step_definitions/given/i_have_the_file_with_content.rb
|
34
|
+
- features/step_definitions/then/the_file_gemfile_should_have_the_following_stripped_content.rb
|
32
35
|
- features/step_definitions/then/the_file_should_have_content.rb
|
33
36
|
- features/step_definitions/then/the_output_should_include.rb
|
37
|
+
- features/step_definitions/when/i_rebuild_the_gemfile_for_local_mode.rb
|
34
38
|
- features/step_definitions/when/i_rebuild_the_gemfile_switching_back.rb
|
35
39
|
- features/step_definitions/when/i_rebuild_the_gemfile_with_deployment.rb
|
36
40
|
- features/step_definitions/when/i_run_in.rb
|
41
|
+
- features/support/cuke-pack.rb
|
37
42
|
- features/support/env.rb
|
38
43
|
- lib/penchant.rb
|
39
44
|
- lib/penchant/dot_penchant.rb
|
@@ -70,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
75
|
version: '0'
|
71
76
|
segments:
|
72
77
|
- 0
|
73
|
-
hash:
|
78
|
+
hash: -4406262957412417452
|
74
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
80
|
none: false
|
76
81
|
requirements:
|
@@ -79,10 +84,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
84
|
version: '0'
|
80
85
|
segments:
|
81
86
|
- 0
|
82
|
-
hash:
|
87
|
+
hash: -4406262957412417452
|
83
88
|
requirements: []
|
84
89
|
rubyforge_project: penchant
|
85
|
-
rubygems_version: 1.8.
|
90
|
+
rubygems_version: 1.8.23
|
86
91
|
signing_key:
|
87
92
|
specification_version: 3
|
88
93
|
summary: Things I do for my Rails projects to get up to speed in new environments
|
@@ -90,12 +95,16 @@ summary: Things I do for my Rails projects to get up to speed in new environment
|
|
90
95
|
test_files:
|
91
96
|
- features/cli.feature
|
92
97
|
- features/gemfile.feature
|
98
|
+
- features/ruby_gemfile.feature
|
93
99
|
- features/step_definitions/given/i_have_the_file_with_content.rb
|
100
|
+
- features/step_definitions/then/the_file_gemfile_should_have_the_following_stripped_content.rb
|
94
101
|
- features/step_definitions/then/the_file_should_have_content.rb
|
95
102
|
- features/step_definitions/then/the_output_should_include.rb
|
103
|
+
- features/step_definitions/when/i_rebuild_the_gemfile_for_local_mode.rb
|
96
104
|
- features/step_definitions/when/i_rebuild_the_gemfile_switching_back.rb
|
97
105
|
- features/step_definitions/when/i_rebuild_the_gemfile_with_deployment.rb
|
98
106
|
- features/step_definitions/when/i_run_in.rb
|
107
|
+
- features/support/cuke-pack.rb
|
99
108
|
- features/support/env.rb
|
100
109
|
- spec/lib/penchant/dot_penchant_spec.rb
|
101
110
|
- spec/lib/penchant/gemfile_spec.rb
|