poise-ruby 2.0.0 → 2.1.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/chef/recipes/default.rb +1 -1
- data/lib/poise_ruby.rb +1 -0
- data/lib/poise_ruby/bundler_mixin.rb +84 -0
- data/lib/poise_ruby/resources/ruby_execute.rb +8 -9
- data/lib/poise_ruby/resources/ruby_gem.rb +6 -0
- data/lib/poise_ruby/resources/ruby_runtime_test.rb +213 -0
- data/lib/poise_ruby/ruby_command_mixin.rb +1 -1
- data/lib/poise_ruby/ruby_providers.rb +3 -0
- data/lib/poise_ruby/ruby_providers/base.rb +1 -0
- data/lib/poise_ruby/ruby_providers/chef.rb +1 -1
- data/lib/poise_ruby/ruby_providers/dummy.rb +77 -0
- data/lib/poise_ruby/ruby_providers/scl.rb +3 -3
- data/lib/poise_ruby/version.rb +1 -1
- data/poise-ruby.gemspec +1 -1
- data/test/cookbooks/poise-ruby_test/metadata.rb +1 -0
- data/test/cookbooks/poise-ruby_test/recipes/default.rb +13 -58
- data/test/integration/default/serverspec/Gemfile +19 -0
- data/test/integration/default/serverspec/default_spec.rb +9 -26
- data/test/spec/resources/bundle_install_spec.rb +1 -1
- data/test/spec/resources/ruby_execute_spec.rb +6 -6
- data/test/spec/ruby_providers/dummy_spec.rb +62 -0
- metadata +12 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b31dcb91d57100ee4c5c5b64a67f1900cd81e9f4
|
4
|
+
data.tar.gz: f4ad01094229e47d3872578819f5399a046c6ebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e363c5bd743beef1a55230feeffc9779c25e4a59dc647fdbc78fc620d38b6cd751f54d0e8f171a13d23e38589a726c23918b222fe84626921362da19235c37e7
|
7
|
+
data.tar.gz: bcea796ae857b24dac0683b7381be1e44bb458f27618a7f4370336a58a896bf88a82ca1080a1ad0cd526d1472fb102a1b0860c07769482b5c7ce5d255d5ce277
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## v2.1.0
|
4
|
+
|
5
|
+
* Fix version field for default Ruby runtime.
|
6
|
+
* Add a `:dummy` provider for `ruby_runtime` for unit testing or complex overrides.
|
7
|
+
* Improved handling for `bundle exec` in `ruby_execute`.
|
8
|
+
* New integration test harness.
|
9
|
+
|
10
|
+
## v2.0.0
|
11
|
+
|
12
|
+
* Initial release (again)!
|
13
|
+
|
14
|
+
## v1.0.0
|
15
|
+
|
16
|
+
* Pre-history, we do not speak of these times.
|
data/chef/recipes/default.rb
CHANGED
@@ -16,4 +16,4 @@
|
|
16
16
|
|
17
17
|
# Default runtimes, last one will be the default.
|
18
18
|
ruby_runtime('chef') { provider :chef } if node['poise-ruby']['install_chef_ruby']
|
19
|
-
ruby_runtime
|
19
|
+
ruby_runtime('ruby') { version '' } if node['poise-ruby']['install_ruby']
|
data/lib/poise_ruby.rb
CHANGED
@@ -0,0 +1,84 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2015, Noah Kantrowitz
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'poise_ruby/error'
|
18
|
+
|
19
|
+
|
20
|
+
module PoiseRuby
|
21
|
+
# Mixin for creating bundle exec commands.
|
22
|
+
#
|
23
|
+
# @since 2.1.0
|
24
|
+
module BundlerMixin
|
25
|
+
# Transform a command to run under `bundle exec` with the same semantics as
|
26
|
+
# Ruby execution elsewhere in this system. That means you should end up with
|
27
|
+
# something like `/bin/ruby /bin/bundle exec /bin/ruby /bin/cmd args`.
|
28
|
+
#
|
29
|
+
# @param cmd [String, Array<String>] Command to transform.
|
30
|
+
# @param path [String] Optional input path for command resolution.
|
31
|
+
# @return [String, Array<String>]
|
32
|
+
def bundle_exec_command(cmd, path: nil)
|
33
|
+
bundle = new_resource.parent_bundle
|
34
|
+
return cmd unless bundle
|
35
|
+
is_array = cmd.is_a?(Array)
|
36
|
+
cmd = Shellwords.split(cmd) unless is_array
|
37
|
+
root_path = ::File.expand_path('..', bundle.gemfile_path)
|
38
|
+
# Grab this once in case I need it for the extra path.
|
39
|
+
bundler_binary = bundle.bundler_binary
|
40
|
+
# This doesn't account for the potential of a .bundle/config created with
|
41
|
+
# settings that Chef doesn't know about. (╯°□°)╯︵ ┻━┻
|
42
|
+
extra_path = if bundle.binstubs
|
43
|
+
bundle.binstubs == true ? 'bin' : bundle.binstubs
|
44
|
+
elsif bundle.vendor || bundle.deployment
|
45
|
+
# Find the relative path to start searching from.
|
46
|
+
vendor_base_path = if bundle.vendor && bundle.vendor != true
|
47
|
+
bundle.vendor
|
48
|
+
else
|
49
|
+
'vendor/bundle'
|
50
|
+
end
|
51
|
+
# Add the ruby/.
|
52
|
+
vendor_base_path = ::File.join(File.expand_path(vendor_base_path, root_path), 'ruby')
|
53
|
+
# Find the version number folder inside that.
|
54
|
+
candidates = Dir.entries(vendor_base_path)
|
55
|
+
ruby_abi_folder = candidates.find {|name| name =~ /^\d\./ }
|
56
|
+
vendor_sub_path = if ruby_abi_folder
|
57
|
+
::File.join(ruby_abi_folder, 'bin')
|
58
|
+
elsif candidates.include?('bin')
|
59
|
+
'bin'
|
60
|
+
else
|
61
|
+
raise PoiseRuby::Error.new("Unable to find the vendor bin folder for #{vendor_base_path}: #{candidates.join(', ')}")
|
62
|
+
end
|
63
|
+
# Make the final path.
|
64
|
+
::File.join(vendor_base_path, vendor_sub_path)
|
65
|
+
else
|
66
|
+
# The folder the bundler binary is in was the global gem executable dir.
|
67
|
+
::File.dirname(bundler_binary)
|
68
|
+
end
|
69
|
+
# Resolve relative paths against Bundler.root.
|
70
|
+
extra_path = ::File.expand_path(extra_path, root_path)
|
71
|
+
# Create the full $PATH.
|
72
|
+
path ||= ENV['PATH']
|
73
|
+
bundle_exec_path = extra_path + ::File::PATH_SEPARATOR + path
|
74
|
+
# Resolve the command
|
75
|
+
abs_cmd = PoiseLanguages::Utils.absolute_command(cmd, path: bundle_exec_path)
|
76
|
+
bundle_exec = [new_resource.ruby, bundler_binary, 'exec', new_resource.ruby] + abs_cmd
|
77
|
+
if is_array
|
78
|
+
bundle_exec
|
79
|
+
else
|
80
|
+
PoiseLanguages::Utils.shelljoin(bundle_exec)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -14,13 +14,12 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require 'shellwords'
|
18
|
-
|
19
17
|
require 'chef/mash'
|
20
18
|
require 'chef/provider/execute'
|
21
19
|
require 'chef/resource/execute'
|
22
20
|
require 'poise'
|
23
21
|
|
22
|
+
require 'poise_ruby/bundler_mixin'
|
24
23
|
require 'poise_ruby/ruby_command_mixin'
|
25
24
|
|
26
25
|
|
@@ -54,6 +53,7 @@ module PoiseRuby
|
|
54
53
|
# @see Resource
|
55
54
|
# @provides ruby_execute
|
56
55
|
class Provider < Chef::Provider::Execute
|
56
|
+
include PoiseRuby::BundlerMixin
|
57
57
|
provides(:ruby_execute)
|
58
58
|
|
59
59
|
private
|
@@ -62,15 +62,14 @@ module PoiseRuby
|
|
62
62
|
#
|
63
63
|
# @return [String, Array<String>]
|
64
64
|
def command
|
65
|
-
prefix = [new_resource.ruby]
|
66
65
|
if new_resource.parent_bundle
|
67
|
-
|
68
|
-
prefix << 'exec'
|
69
|
-
end
|
70
|
-
if new_resource.command.is_a?(Array)
|
71
|
-
prefix + new_resource.command
|
66
|
+
bundle_exec_command(new_resource.command, path: environment['PATH'])
|
72
67
|
else
|
73
|
-
|
68
|
+
if new_resource.command.is_a?(Array)
|
69
|
+
[new_resource.ruby] + new_resource.command
|
70
|
+
else
|
71
|
+
"#{new_resource.ruby} #{new_resource.command}"
|
72
|
+
end
|
74
73
|
end
|
75
74
|
end
|
76
75
|
|
@@ -96,6 +96,12 @@ module PoiseRuby
|
|
96
96
|
end
|
97
97
|
|
98
98
|
begin
|
99
|
+
if ENV['GEM_HOME'] && !ENV['GEM_HOME'].empty?
|
100
|
+
Chef::Log.warn("[#{new_resource}] $GEM_HOME is set in Chef's environment, this will likely interfere with gem installation")
|
101
|
+
end
|
102
|
+
if ENV['GEM_PATH'] && !ENV['GEM_PATH'].empty?
|
103
|
+
Chef::Log.warn("[#{new_resource}] $GEM_PATH is set in Chef's environment, this will likely interfere with gem installation")
|
104
|
+
end
|
99
105
|
old_vars = environment_to_add.inject({}) do |memo, (key, value)|
|
100
106
|
memo[key] = ENV[key]
|
101
107
|
ENV[key] = value
|
@@ -0,0 +1,213 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2015, Noah Kantrowitz
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'chef/mixin/convert_to_class_name'
|
18
|
+
require 'chef/provider'
|
19
|
+
require 'chef/resource'
|
20
|
+
require 'poise'
|
21
|
+
|
22
|
+
|
23
|
+
module PoiseRuby
|
24
|
+
module Resources
|
25
|
+
# (see RubyRuntimeTest::Resource)
|
26
|
+
# @since 2.1.0
|
27
|
+
# @api private
|
28
|
+
module RubyRuntimeTest
|
29
|
+
# A `ruby_runtime_test` resource for integration testing of this
|
30
|
+
# cookbook. This is an internal API and can change at any time.
|
31
|
+
#
|
32
|
+
# @provides ruby_runtime_test
|
33
|
+
# @action run
|
34
|
+
class Resource < Chef::Resource
|
35
|
+
include Poise
|
36
|
+
provides(:ruby_runtime_test)
|
37
|
+
actions(:run)
|
38
|
+
|
39
|
+
attribute(:version, kind_of: String, name_attribute: true)
|
40
|
+
attribute(:runtime_provider, kind_of: Symbol)
|
41
|
+
attribute(:path, kind_of: String, default: lazy { default_path })
|
42
|
+
|
43
|
+
def default_path
|
44
|
+
::File.join('', 'root', "ruby_test_#{name}")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# The default provider for `ruby_runtime_test`.
|
49
|
+
#
|
50
|
+
# @see Resource
|
51
|
+
# @provides ruby_runtime_test
|
52
|
+
class Provider < Chef::Provider
|
53
|
+
include Poise
|
54
|
+
provides(:ruby_runtime_test)
|
55
|
+
|
56
|
+
# The `run` action for the `ruby_runtime_test` resource.
|
57
|
+
#
|
58
|
+
# @return [void]
|
59
|
+
def action_run
|
60
|
+
notifying_block do
|
61
|
+
# Top level directory for this test.
|
62
|
+
directory new_resource.path
|
63
|
+
|
64
|
+
# Install and log the version.
|
65
|
+
ruby_runtime new_resource.name do
|
66
|
+
provider new_resource.runtime_provider if new_resource.runtime_provider
|
67
|
+
version new_resource.version
|
68
|
+
end
|
69
|
+
test_version
|
70
|
+
|
71
|
+
# Test ruby_gem.
|
72
|
+
ruby_gem 'thor remove before' do
|
73
|
+
action :remove
|
74
|
+
package_name 'thor'
|
75
|
+
ruby new_resource.name
|
76
|
+
end
|
77
|
+
test_require('thor', 'thor_before')
|
78
|
+
ruby_gem 'thor' do
|
79
|
+
ruby new_resource.name
|
80
|
+
notifies :create, sentinel_file('thor'), :immediately
|
81
|
+
end
|
82
|
+
test_require('thor', 'thor_mid')
|
83
|
+
ruby_gem 'thor again' do
|
84
|
+
package_name 'thor'
|
85
|
+
ruby new_resource.name
|
86
|
+
notifies :create, sentinel_file('thor2'), :immediately
|
87
|
+
end
|
88
|
+
ruby_gem 'thor remove after' do
|
89
|
+
action :remove
|
90
|
+
package_name 'thor'
|
91
|
+
ruby new_resource.name
|
92
|
+
end
|
93
|
+
test_require('thor', 'thor_after')
|
94
|
+
|
95
|
+
# Use bundler to test something that should always be installed.
|
96
|
+
ruby_gem 'bundler' do
|
97
|
+
ruby new_resource.name
|
98
|
+
notifies :create, sentinel_file('bundler'), :immediately
|
99
|
+
end
|
100
|
+
|
101
|
+
# Create and install a Gemfile.
|
102
|
+
bundle1_path = ::File.join(new_resource.path, 'bundle1')
|
103
|
+
directory bundle1_path
|
104
|
+
file ::File.join(bundle1_path, 'Gemfile') do
|
105
|
+
content <<-EOH
|
106
|
+
source 'https://rubygems.org/'
|
107
|
+
gem 'hashie'
|
108
|
+
gem 'tomlrb', '1.1.0'
|
109
|
+
EOH
|
110
|
+
end
|
111
|
+
bundle1 = bundle_install bundle1_path do
|
112
|
+
ruby new_resource.name
|
113
|
+
end
|
114
|
+
test_require('hashie', bundle: bundle1)
|
115
|
+
test_require('tomlrb', bundle: bundle1)
|
116
|
+
test_require('thor', 'thor_bundle', bundle: bundle1)
|
117
|
+
|
118
|
+
# Test for bundle exec shebang issues.
|
119
|
+
bundle2_path = ::File.join(new_resource.path, 'bundle2')
|
120
|
+
directory bundle2_path
|
121
|
+
file ::File.join(bundle2_path, 'Gemfile') do
|
122
|
+
content <<-EOH
|
123
|
+
source 'https://rubygems.org/'
|
124
|
+
gem 'unicorn'
|
125
|
+
EOH
|
126
|
+
end
|
127
|
+
file ::File.join(bundle2_path, 'Gemfile.lock') do
|
128
|
+
content <<-EOH
|
129
|
+
GEM
|
130
|
+
remote: https://rubygems.org/
|
131
|
+
specs:
|
132
|
+
kgio (2.10.0)
|
133
|
+
rack (1.6.4)
|
134
|
+
raindrops (0.15.0)
|
135
|
+
unicorn (4.9.0)
|
136
|
+
kgio (~> 2.6)
|
137
|
+
rack
|
138
|
+
raindrops (~> 0.7)
|
139
|
+
|
140
|
+
PLATFORMS
|
141
|
+
ruby
|
142
|
+
|
143
|
+
DEPENDENCIES
|
144
|
+
unicorn
|
145
|
+
|
146
|
+
BUNDLED WITH
|
147
|
+
1.10.6
|
148
|
+
EOH
|
149
|
+
end
|
150
|
+
bundle2 = bundle_install bundle2_path do
|
151
|
+
ruby new_resource.name
|
152
|
+
deployment true
|
153
|
+
end
|
154
|
+
# test_require('unicorn', bundle: bundle2)
|
155
|
+
ruby_execute "unicorn --version > #{::File.join(new_resource.path, "unicorn_version")}" do
|
156
|
+
ruby new_resource.name
|
157
|
+
parent_bundle bundle2
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def sentinel_file(name)
|
163
|
+
file ::File.join(new_resource.path, "sentinel_#{name}") do
|
164
|
+
action :nothing
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
private
|
169
|
+
|
170
|
+
def test_version(ruby: new_resource.name)
|
171
|
+
# Only queue up this resource once, the ivar is just for tracking.
|
172
|
+
@ruby_version_test ||= file ::File.join(new_resource.path, 'ruby_version.rb') do
|
173
|
+
user 'root'
|
174
|
+
group 'root'
|
175
|
+
mode '644'
|
176
|
+
content <<-EOH
|
177
|
+
File.new(ARGV[0], 'w').write(RUBY_VERSION)
|
178
|
+
EOH
|
179
|
+
end
|
180
|
+
|
181
|
+
ruby_execute "#{@ruby_version_test.path} #{::File.join(new_resource.path, 'version')}" do
|
182
|
+
ruby ruby if ruby
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_require(name, path=name, ruby: new_resource.name, bundle: nil, class_name: nil)
|
187
|
+
# Only queue up this resource once, the ivar is just for tracking.
|
188
|
+
@ruby_require_test ||= file ::File.join(new_resource.path, 'require_version.rb') do
|
189
|
+
user 'root'
|
190
|
+
group 'root'
|
191
|
+
mode '644'
|
192
|
+
content <<-EOH
|
193
|
+
require 'rubygems'
|
194
|
+
begin
|
195
|
+
require "\#{ARGV[0]}/version"
|
196
|
+
klass = ARGV[1].split('::').inject(Object) {|memo, name| memo.const_get(name) }
|
197
|
+
File.new(ARGV[2], 'w').write(klass::VERSION)
|
198
|
+
rescue LoadError
|
199
|
+
end
|
200
|
+
EOH
|
201
|
+
end
|
202
|
+
|
203
|
+
class_name ||= Chef::Mixin::ConvertToClassName.convert_to_class_name(name)
|
204
|
+
ruby_execute "#{@ruby_require_test.path} #{name} #{class_name} #{::File.join(new_resource.path, "require_#{path}")}" do
|
205
|
+
ruby ruby if ruby
|
206
|
+
parent_bundle bundle if bundle
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
@@ -14,7 +14,10 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
+
require 'chef/platform/provider_priority_map'
|
18
|
+
|
17
19
|
require 'poise_ruby/ruby_providers/chef'
|
20
|
+
require 'poise_ruby/ruby_providers/dummy'
|
18
21
|
require 'poise_ruby/ruby_providers/scl'
|
19
22
|
require 'poise_ruby/ruby_providers/system'
|
20
23
|
|
@@ -20,7 +20,7 @@ require 'poise_ruby/ruby_providers/base'
|
|
20
20
|
|
21
21
|
module PoiseRuby
|
22
22
|
module RubyProviders
|
23
|
-
# Inversion provider for the `
|
23
|
+
# Inversion provider for the `ruby_runtime` resource to use whatever Ruby is
|
24
24
|
# currently running, generally Chef's omnibus-d Ruby.
|
25
25
|
#
|
26
26
|
# @since 2.0.0
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2015, Noah Kantrowitz
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'poise_ruby/ruby_providers/base'
|
18
|
+
|
19
|
+
|
20
|
+
module PoiseRuby
|
21
|
+
module RubyProviders
|
22
|
+
# Inversion provider for the `ruby_runtime` resource to use a fake Ruby,
|
23
|
+
# for use in unit tests.
|
24
|
+
#
|
25
|
+
# @since 2.1.0
|
26
|
+
# @provides dummy
|
27
|
+
class Dummy < Base
|
28
|
+
provides(:dummy)
|
29
|
+
|
30
|
+
def self.default_inversion_options(node, resource)
|
31
|
+
super.merge({
|
32
|
+
# Manual overrides for dummy data.
|
33
|
+
ruby_binary: ::File.join('', 'ruby'),
|
34
|
+
ruby_environment: nil,
|
35
|
+
gem_binary: nil,
|
36
|
+
})
|
37
|
+
end
|
38
|
+
|
39
|
+
# The `install` action for the `ruby_runtime` resource.
|
40
|
+
#
|
41
|
+
# @return [void]
|
42
|
+
def action_install
|
43
|
+
# This space left intentionally blank.
|
44
|
+
end
|
45
|
+
|
46
|
+
# The `uninstall` action for the `ruby_runtime` resource.
|
47
|
+
#
|
48
|
+
# @return [void]
|
49
|
+
def action_uninstall
|
50
|
+
# This space left intentionally blank.
|
51
|
+
end
|
52
|
+
|
53
|
+
# Path to the non-existent ruby.
|
54
|
+
#
|
55
|
+
# @return [String]
|
56
|
+
def ruby_binary
|
57
|
+
options['ruby_binary']
|
58
|
+
end
|
59
|
+
|
60
|
+
# Environment for the non-existent Ruby.
|
61
|
+
#
|
62
|
+
# @return [String]
|
63
|
+
def ruby_environment
|
64
|
+
options['ruby_environment'] || super
|
65
|
+
end
|
66
|
+
|
67
|
+
# Path to the non-existent gem.
|
68
|
+
#
|
69
|
+
# @return [String]
|
70
|
+
def gem_binary
|
71
|
+
options['gem_binary'] || super
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
@@ -25,13 +25,13 @@ module PoiseRuby
|
|
25
25
|
class Scl < Base
|
26
26
|
include PoiseLanguages::Scl::Mixin
|
27
27
|
provides(:scl)
|
28
|
-
scl_package('2.2.2', 'rh-ruby22', {
|
28
|
+
scl_package('2.2.2', 'rh-ruby22', 'rh-ruby22-ruby-devel', {
|
29
29
|
['redhat', 'centos'] => {
|
30
30
|
'~> 7.0' => 'https://www.softwarecollections.org/en/scls/rhscl/rh-ruby22/epel-7-x86_64/download/rhscl-rh-ruby22-epel-7-x86_64.noarch.rpm',
|
31
31
|
'~> 6.0' => 'https://www.softwarecollections.org/en/scls/rhscl/rh-ruby22/epel-6-x86_64/download/rhscl-rh-ruby22-epel-6-x86_64.noarch.rpm',
|
32
32
|
},
|
33
33
|
})
|
34
|
-
scl_package('2.0.0', 'ruby200', {
|
34
|
+
scl_package('2.0.0', 'ruby200', 'ruby200-ruby-devel', {
|
35
35
|
['redhat', 'centos'] => {
|
36
36
|
# On CentOS 7, the system package is Ruby 2.0.0 and is newer than the SCL build.
|
37
37
|
#'~> 7.0' => 'https://www.softwarecollections.org/en/scls/rhscl/ruby200/epel-7-x86_64/download/rhscl-ruby200-epel-7-x86_64.noarch.rpm',
|
@@ -42,7 +42,7 @@ module PoiseRuby
|
|
42
42
|
'~> 20.0' => 'https://www.softwarecollections.org/en/scls/rhscl/ruby200/fedora-20-x86_64/download/rhscl-ruby200-fedora-20-x86_64.noarch.rpm',
|
43
43
|
},
|
44
44
|
})
|
45
|
-
scl_package('1.9.3', 'ruby193', {
|
45
|
+
scl_package('1.9.3', 'ruby193', 'ruby193-ruby-devel', {
|
46
46
|
['redhat', 'centos'] => {
|
47
47
|
'~> 7.0' => 'https://www.softwarecollections.org/en/scls/rhscl/ruby193/epel-7-x86_64/download/rhscl-ruby193-epel-7-x86_64.noarch.rpm',
|
48
48
|
'~> 6.0' => 'https://www.softwarecollections.org/en/scls/rhscl/ruby193/epel-6-x86_64/download/rhscl-ruby193-epel-6-x86_64.noarch.rpm',
|
data/lib/poise_ruby/version.rb
CHANGED
data/poise-ruby.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
|
36
36
|
spec.add_dependency 'halite', '~> 1.0'
|
37
37
|
spec.add_dependency 'poise', '~> 2.0'
|
38
|
-
spec.add_dependency 'poise-languages', '~> 1.
|
38
|
+
spec.add_dependency 'poise-languages', '~> 1.2'
|
39
39
|
|
40
40
|
spec.add_development_dependency 'poise-boiler', '~> 1.0'
|
41
41
|
end
|
@@ -14,72 +14,27 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
+
require 'poise_ruby/resources/ruby_runtime_test'
|
18
|
+
|
19
|
+
include_recipe 'build-essential'
|
20
|
+
|
17
21
|
# Install lsb-release because Debian 6 doesn't by default and serverspec requires it
|
18
22
|
package 'lsb-release' if platform?('debian') && node['platform_version'].start_with?('6')
|
19
23
|
|
20
|
-
|
21
|
-
|
24
|
+
ruby_runtime_test 'chef' do
|
25
|
+
runtime_provider :chef
|
22
26
|
end
|
23
27
|
|
24
|
-
|
28
|
+
ruby_runtime_test 'system' do
|
25
29
|
version ''
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
file '/root/poise_ruby_test.rb' do
|
30
|
-
user 'root'
|
31
|
-
group 'root'
|
32
|
-
mode '644'
|
33
|
-
content <<-EOH
|
34
|
-
File.open(ARGV[0], 'w') do |f|
|
35
|
-
f.write(RUBY_VERSION)
|
36
|
-
end
|
37
|
-
EOH
|
30
|
+
runtime_provider :system
|
38
31
|
end
|
39
32
|
|
40
|
-
ruby_execute '/root/poise_ruby_test.rb /root/one'
|
41
|
-
|
42
|
-
ruby_execute '/root/poise_ruby_test.rb /root/two' do
|
43
|
-
ruby 'chef'
|
44
|
-
end
|
45
|
-
|
46
|
-
ruby_gem 'rack' do
|
47
|
-
version '1.6.0'
|
48
|
-
end
|
49
|
-
|
50
|
-
file '/root/poise_ruby_test2.rb' do
|
51
|
-
user 'root'
|
52
|
-
group 'root'
|
53
|
-
mode '644'
|
54
|
-
content <<-EOH
|
55
|
-
require 'rubygems'
|
56
|
-
require 'rack'
|
57
|
-
File.open(ARGV[0], 'w') do |f|
|
58
|
-
f.write(Rack.release)
|
59
|
-
end
|
60
|
-
EOH
|
61
|
-
end
|
62
|
-
|
63
|
-
ruby_execute '/root/poise_ruby_test2.rb /root/three'
|
64
|
-
|
65
33
|
if platform_family?('rhel')
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
version '2'
|
70
|
-
provider :scl
|
71
|
-
end
|
72
|
-
|
73
|
-
ruby_execute '/root/poise_ruby_test.rb /root/four' do
|
74
|
-
ruby 'scl'
|
75
|
-
end
|
76
|
-
|
77
|
-
ruby_gem 'rack' do
|
78
|
-
version '1.6.0'
|
79
|
-
ruby 'scl'
|
80
|
-
end
|
81
|
-
|
82
|
-
ruby_execute '/root/poise_ruby_test2.rb /root/five' do
|
83
|
-
ruby 'scl'
|
34
|
+
ruby_runtime_test 'scl' do
|
35
|
+
version ''
|
36
|
+
runtime_provider :scl
|
84
37
|
end
|
38
|
+
else
|
39
|
+
file '/no_scl'
|
85
40
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2015, Noah Kantrowitz
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
source 'https://rubygems.org/'
|
18
|
+
|
19
|
+
gem 'poise-ruby-spechelper'
|
@@ -14,33 +14,16 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require '
|
18
|
-
set :backend, :exec
|
17
|
+
require 'poise_ruby/spec_helper'
|
19
18
|
|
20
|
-
describe '
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
describe file('/root/two') do
|
26
|
-
it { is_expected.to be_a_file }
|
27
|
-
its(:content) { are_expected.to start_with '2.1' }
|
28
|
-
end
|
29
|
-
|
30
|
-
describe file('/root/three') do
|
31
|
-
it { is_expected.to be_a_file }
|
32
|
-
its(:content) { are_expected.to eq '1.5' }
|
33
|
-
end
|
19
|
+
describe 'chef provider' do
|
20
|
+
it_should_behave_like 'a ruby_runtime_test', 'chef'
|
21
|
+
end
|
34
22
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
its(:content) { are_expected.to eq '2.2.2' }
|
39
|
-
end
|
23
|
+
describe 'system provider', unless: File.exist?('/no_system') do
|
24
|
+
it_should_behave_like 'a ruby_runtime_test', 'system'
|
25
|
+
end
|
40
26
|
|
41
|
-
|
42
|
-
|
43
|
-
its(:content) { are_expected.to eq '1.5' }
|
44
|
-
end
|
45
|
-
end
|
27
|
+
describe 'scl provider', unless: File.exist?('/no_scl') do
|
28
|
+
it_should_behave_like 'a ruby_runtime_test', 'scl'
|
46
29
|
end
|
@@ -22,7 +22,7 @@ describe PoiseRuby::Resources::BundleInstall do
|
|
22
22
|
bundle_install '/test/Gemfile'
|
23
23
|
end
|
24
24
|
before do
|
25
|
-
|
25
|
+
allow(PoiseLanguages::Utils).to receive(:which).with('ruby').and_return('/test/bin/ruby')
|
26
26
|
end
|
27
27
|
|
28
28
|
it { is_expected.to install_bundle_install('/test/Gemfile').with(gem_binary: '/test/bin/gem') }
|
@@ -23,7 +23,7 @@ describe PoiseRuby::Resources::RubyExecute do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it { is_expected.to run_ruby_execute('myapp.rb') }
|
26
|
-
end
|
26
|
+
end # /describe PoiseRuby::Resources::RubyExecute::Resource
|
27
27
|
|
28
28
|
describe PoiseRuby::Resources::RubyExecute::Provider do
|
29
29
|
let(:command) { nil }
|
@@ -56,15 +56,15 @@ describe PoiseRuby::Resources::RubyExecute do
|
|
56
56
|
|
57
57
|
context 'with a bundle parent' do
|
58
58
|
let(:command) { 'myapp.rb' }
|
59
|
-
let(:parent_bundle) { double('parent_bundle', bundler_binary: '/bundle', gemfile_path: '/srv/Gemfile') }
|
60
|
-
its(:command) { is_expected.to eq '/ruby /bundle exec myapp.rb' }
|
59
|
+
let(:parent_bundle) { double('parent_bundle', bundler_binary: '/bundle', gemfile_path: '/srv/Gemfile', binstubs: false, vendor: false, deployment: false) }
|
60
|
+
its(:command) { is_expected.to eq '/ruby /bundle exec /ruby myapp.rb' }
|
61
61
|
its(:environment) { is_expected.to eq({'BUNDLE_GEMFILE' => '/srv/Gemfile'}) }
|
62
62
|
end # /context with a bundle parent
|
63
63
|
|
64
64
|
context 'with a bundle parent and an array command' do
|
65
65
|
let(:command) { %w{myapp.rb} }
|
66
|
-
let(:parent_bundle) { double('parent_bundle', bundler_binary: '/bundle', gemfile_path: '/srv/Gemfile') }
|
67
|
-
its(:command) { is_expected.to eq %w{/ruby /bundle exec myapp.rb} }
|
66
|
+
let(:parent_bundle) { double('parent_bundle', bundler_binary: '/bundle', gemfile_path: '/srv/Gemfile', binstubs: false, vendor: false, deployment: false) }
|
67
|
+
its(:command) { is_expected.to eq %w{/ruby /bundle exec /ruby myapp.rb} }
|
68
68
|
its(:environment) { is_expected.to eq({'BUNDLE_GEMFILE' => '/srv/Gemfile'}) }
|
69
69
|
end # /context with a bundle parent and an array command
|
70
70
|
|
@@ -74,5 +74,5 @@ describe PoiseRuby::Resources::RubyExecute do
|
|
74
74
|
its(:command) { is_expected.to eq '/ruby myapp.rb' }
|
75
75
|
its(:environment) { is_expected.to eq({'PATH' => '/bin'}) }
|
76
76
|
end # /context with a ruby parent
|
77
|
-
end
|
77
|
+
end # /describe PoiseRuby::Resources::RubyExecute::Provider
|
78
78
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2015, Noah Kantrowitz
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
describe PoiseRuby::RubyProviders::Dummy do
|
20
|
+
let(:ruby_runtime) { chef_run.ruby_runtime('test') }
|
21
|
+
step_into(:ruby_runtime)
|
22
|
+
recipe do
|
23
|
+
ruby_runtime 'test' do
|
24
|
+
provider :dummy
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#ruby_binary' do
|
29
|
+
subject { ruby_runtime.ruby_binary }
|
30
|
+
|
31
|
+
it { is_expected.to eq '/ruby' }
|
32
|
+
end # /describe #ruby_binary
|
33
|
+
|
34
|
+
describe '#ruby_environment' do
|
35
|
+
subject { ruby_runtime.ruby_environment }
|
36
|
+
|
37
|
+
it { is_expected.to eq({}) }
|
38
|
+
end # /describe #ruby_environment
|
39
|
+
|
40
|
+
describe '#gem_binary' do
|
41
|
+
subject { ruby_runtime.gem_binary }
|
42
|
+
|
43
|
+
it { is_expected.to eq '/gem' }
|
44
|
+
end # /describe #gem_binary
|
45
|
+
|
46
|
+
describe 'action :install' do
|
47
|
+
# Just make sure it doesn't error.
|
48
|
+
it { run_chef }
|
49
|
+
end # /describe action :install
|
50
|
+
|
51
|
+
describe 'action :uninstall' do
|
52
|
+
recipe do
|
53
|
+
ruby_runtime 'test' do
|
54
|
+
action :uninstall
|
55
|
+
provider :dummy
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Just make sure it doesn't error.
|
60
|
+
it { run_chef }
|
61
|
+
end # /describe action :uninstall
|
62
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poise-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Kantrowitz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: halite
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: '1.2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: '1.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: poise-boiler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- ".travis.yml"
|
80
80
|
- ".yardopts"
|
81
81
|
- Berksfile
|
82
|
+
- CHANGELOG.md
|
82
83
|
- Gemfile
|
83
84
|
- LICENSE
|
84
85
|
- README.md
|
@@ -86,6 +87,7 @@ files:
|
|
86
87
|
- chef/attributes/default.rb
|
87
88
|
- chef/recipes/default.rb
|
88
89
|
- lib/poise_ruby.rb
|
90
|
+
- lib/poise_ruby/bundler_mixin.rb
|
89
91
|
- lib/poise_ruby/cheftie.rb
|
90
92
|
- lib/poise_ruby/error.rb
|
91
93
|
- lib/poise_ruby/resources.rb
|
@@ -93,10 +95,12 @@ files:
|
|
93
95
|
- lib/poise_ruby/resources/ruby_execute.rb
|
94
96
|
- lib/poise_ruby/resources/ruby_gem.rb
|
95
97
|
- lib/poise_ruby/resources/ruby_runtime.rb
|
98
|
+
- lib/poise_ruby/resources/ruby_runtime_test.rb
|
96
99
|
- lib/poise_ruby/ruby_command_mixin.rb
|
97
100
|
- lib/poise_ruby/ruby_providers.rb
|
98
101
|
- lib/poise_ruby/ruby_providers/base.rb
|
99
102
|
- lib/poise_ruby/ruby_providers/chef.rb
|
103
|
+
- lib/poise_ruby/ruby_providers/dummy.rb
|
100
104
|
- lib/poise_ruby/ruby_providers/scl.rb
|
101
105
|
- lib/poise_ruby/ruby_providers/system.rb
|
102
106
|
- lib/poise_ruby/version.rb
|
@@ -108,11 +112,13 @@ files:
|
|
108
112
|
- test/docker/docker.pem
|
109
113
|
- test/gemfiles/chef-12.gemfile
|
110
114
|
- test/gemfiles/master.gemfile
|
115
|
+
- test/integration/default/serverspec/Gemfile
|
111
116
|
- test/integration/default/serverspec/bundle_install_spec.rb
|
112
117
|
- test/integration/default/serverspec/default_spec.rb
|
113
118
|
- test/spec/resources/bundle_install_spec.rb
|
114
119
|
- test/spec/resources/ruby_execute_spec.rb
|
115
120
|
- test/spec/ruby_command_mixin_spec.rb
|
121
|
+
- test/spec/ruby_providers/dummy_spec.rb
|
116
122
|
- test/spec/spec_helper.rb
|
117
123
|
homepage: https://github.com/poise/poise-ruby
|
118
124
|
licenses:
|
@@ -146,10 +152,12 @@ test_files:
|
|
146
152
|
- test/docker/docker.pem
|
147
153
|
- test/gemfiles/chef-12.gemfile
|
148
154
|
- test/gemfiles/master.gemfile
|
155
|
+
- test/integration/default/serverspec/Gemfile
|
149
156
|
- test/integration/default/serverspec/bundle_install_spec.rb
|
150
157
|
- test/integration/default/serverspec/default_spec.rb
|
151
158
|
- test/spec/resources/bundle_install_spec.rb
|
152
159
|
- test/spec/resources/ruby_execute_spec.rb
|
153
160
|
- test/spec/ruby_command_mixin_spec.rb
|
161
|
+
- test/spec/ruby_providers/dummy_spec.rb
|
154
162
|
- test/spec/spec_helper.rb
|
155
163
|
has_rdoc:
|