penchant 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -27,6 +27,11 @@ Yeah, it's a `Gemfile` with some extras:
27
27
  source :rubygems
28
28
 
29
29
  gem 'rails', '3.2.3'
30
+ # expands to:
31
+ #
32
+ # gem 'rake'
33
+ # gem 'nokogiri'
34
+ # gem 'rack-rewrite'
30
35
  gems 'rake', 'nokogiri', 'rack-rewrite'
31
36
 
32
37
  no_deployment do
@@ -36,12 +41,30 @@ no_deployment do
36
41
  dev_gems = %w{flowerbox guard-flowerbox}
37
42
 
38
43
  env :local do
44
+ # expands to:
45
+ #
46
+ # gem 'flowerbox', :path => '../flowerbox'
47
+ # gem 'guard-flowerbox', :path => '../guard-flowerbox'
39
48
  gems dev_gems, :path => '../%s'
40
49
  end
41
50
 
42
51
  env :remote do
52
+ # expands to:
53
+ #
54
+ # gem 'flowerbox', :git => 'git://github.com/johnbintz/flowerbox.git'
55
+ # gem 'guard-flowerbox', :git => 'git://github.com/johnbintz/guard-flowerbox.git'
43
56
  gems dev_gems, :git => 'git://github.com/johnbintz/%s.git'
44
57
  end
58
+
59
+ # only expanded on Mac OS X
60
+ os :darwin do
61
+ gem 'rb-fsevent'
62
+ end
63
+
64
+ # only expanded on Linux
65
+ os :linux do
66
+ gems 'rb-inotify', 'ffi'
67
+ end
45
68
  end
46
69
  end
47
70
  ```
@@ -60,13 +83,11 @@ frameworks:
60
83
 
61
84
  ``` ruby
62
85
  no_deployment do
63
- require 'rbconfig'
64
- case RbConfig::CONFIG['host_os']
65
- when /darwin/
66
- gem 'growl_notify'
67
- gem 'growl'
68
- gem 'rb-fsevent'
69
- when /linux/
86
+ os :darwin do
87
+ gems 'growl_notify', 'growl', 'rb-fsevent'
88
+ end
89
+
90
+ os :linux do
70
91
  gem 'libnotify', :require => nil
71
92
  end
72
93
 
@@ -129,3 +129,26 @@ Feature: Gemfiles
129
129
  gem "one", {:path=>"../one"}
130
130
  """
131
131
 
132
+ @wip @mocha
133
+ Scenario: OS-specific blocks
134
+ Given I have the file "Gemfile.penchant" with the content:
135
+ """
136
+ os :darwin do
137
+ gem 'one', :path => '../%s'
138
+ end
139
+ """
140
+ And I am on the "darwin" platform
141
+ When I rebuild the Gemfile for "local" mode
142
+ Then the file "Gemfile" should have the following content:
143
+ """
144
+ # generated by penchant, environment: local
145
+ gem "one", {:path=>"../one"}
146
+ """
147
+ Given I am on the "linux" platform
148
+ When I rebuild the Gemfile for "local" mode
149
+ Then the file "Gemfile" should have the following content:
150
+ """
151
+ # generated by penchant, environment: local
152
+
153
+ """
154
+
@@ -0,0 +1,3 @@
1
+ Given /^I am on the "([^"]*)" platform$/ do |os|
2
+ Penchant::Gemfile::PenchantFile.any_instance.stubs(:current_os).returns(os.to_sym)
3
+ end
@@ -1,14 +1,27 @@
1
1
  require 'fakefs/safe'
2
2
  require 'penchant'
3
+ require 'mocha'
4
+
5
+ World(Mocha::Standalone)
3
6
 
4
7
  Before('@fakefs') do
5
8
  FakeFS.activate!
6
9
  end
7
10
 
11
+ Before('@mocha') do
12
+ mocha_setup
13
+ end
14
+
8
15
  After do
9
16
  FakeFS::FileSystem.clear
10
17
  FakeFS.deactivate!
11
18
 
19
+ begin
20
+ mocha_verify
21
+ ensure
22
+ mocha_teardown
23
+ end
24
+
12
25
  FileUtils.rm_rf 'tmp'
13
26
  end
14
27
 
@@ -112,6 +112,10 @@ module Penchant
112
112
  yield if !is_deployment
113
113
  end
114
114
 
115
+ def os(*args)
116
+ yield if args.include?(current_os)
117
+ end
118
+
115
119
  protected
116
120
  def args_to_string(args)
117
121
  args.inspect[1..-2]
@@ -144,6 +148,18 @@ module Penchant
144
148
  }.sort
145
149
  ]
146
150
  end
151
+
152
+ def current_os
153
+ require 'rbconfig'
154
+ case host_os = RbConfig::CONFIG['host_os']
155
+ when /darwin/
156
+ :darwin
157
+ when /linux/
158
+ :linux
159
+ else
160
+ host_os[%r{^[a-z]+}, 1].to_sym
161
+ end
162
+ end
147
163
  end
148
164
 
149
165
  class ERBFile < FileProcessor
@@ -1,3 +1,3 @@
1
1
  module Penchant
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
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.1
4
+ version: 0.2.2
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-05 00:00:00.000000000 Z
12
+ date: 2012-06-06 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
@@ -30,6 +30,7 @@ files:
30
30
  - features/cli.feature
31
31
  - features/gemfile.feature
32
32
  - features/ruby_gemfile.feature
33
+ - features/step_definitions/given/i_am_on_the_linux_platform.rb
33
34
  - features/step_definitions/given/i_have_the_file_with_content.rb
34
35
  - features/step_definitions/then/the_file_gemfile_should_have_the_following_stripped_content.rb
35
36
  - features/step_definitions/then/the_file_should_have_content.rb
@@ -73,18 +74,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
74
  - - ! '>='
74
75
  - !ruby/object:Gem::Version
75
76
  version: '0'
76
- segments:
77
- - 0
78
- hash: -4406262957412417452
79
77
  required_rubygems_version: !ruby/object:Gem::Requirement
80
78
  none: false
81
79
  requirements:
82
80
  - - ! '>='
83
81
  - !ruby/object:Gem::Version
84
82
  version: '0'
85
- segments:
86
- - 0
87
- hash: -4406262957412417452
88
83
  requirements: []
89
84
  rubyforge_project: penchant
90
85
  rubygems_version: 1.8.23
@@ -96,6 +91,7 @@ test_files:
96
91
  - features/cli.feature
97
92
  - features/gemfile.feature
98
93
  - features/ruby_gemfile.feature
94
+ - features/step_definitions/given/i_am_on_the_linux_platform.rb
99
95
  - features/step_definitions/given/i_have_the_file_with_content.rb
100
96
  - features/step_definitions/then/the_file_gemfile_should_have_the_following_stripped_content.rb
101
97
  - features/step_definitions/then/the_file_should_have_content.rb
@@ -110,3 +106,4 @@ test_files:
110
106
  - spec/lib/penchant/gemfile_spec.rb
111
107
  - spec/lib/penchant_spec.rb
112
108
  - spec/spec_helper.rb
109
+ has_rdoc: