flombe 0.1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.gitmodules +3 -0
- data/.rspec +2 -0
- data/Flombefile +9 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +57 -0
- data/LICENSE +20 -0
- data/Rakefile +33 -0
- data/bin/flombe +17 -0
- data/config/rake.rb +38 -0
- data/cookbooks/homebrew/README.rdoc +8 -0
- data/cookbooks/homebrew/metadata.rb +8 -0
- data/cookbooks/homebrew/providers/homebrew.rb +39 -0
- data/cookbooks/homebrew/recipes/default.rb +42 -0
- data/cookbooks/homebrew/resources/homebrew.rb +14 -0
- data/cookbooks/mysql/README.rdoc +8 -0
- data/cookbooks/mysql/metadata.rb +6 -0
- data/cookbooks/mysql/recipes/default.rb +43 -0
- data/cookbooks/mysql/recipes/timezone.rb +10 -0
- data/cookbooks/redis/README.rdoc +8 -0
- data/cookbooks/redis/metadata.rb +6 -0
- data/cookbooks/redis/recipes/2.0.4.rb +24 -0
- data/cookbooks/redis/recipes/default.rb +7 -0
- data/cookbooks/rvm/CHANGELOG.md +19 -0
- data/cookbooks/rvm/README.md +564 -0
- data/cookbooks/rvm/Rakefile +35 -0
- data/cookbooks/rvm/attributes/default.rb +54 -0
- data/cookbooks/rvm/attributes/gem_package.rb +23 -0
- data/cookbooks/rvm/attributes/vagrant.rb +22 -0
- data/cookbooks/rvm/libraries/gem_package_monkeypatch.rb +34 -0
- data/cookbooks/rvm/libraries/helpers.rb +334 -0
- data/cookbooks/rvm/libraries/rvm_rubygems_package.rb +108 -0
- data/cookbooks/rvm/metadata.json +271 -0
- data/cookbooks/rvm/metadata.rb +95 -0
- data/cookbooks/rvm/providers/default_ruby.rb +46 -0
- data/cookbooks/rvm/providers/environment.rb +50 -0
- data/cookbooks/rvm/providers/gemset.rb +135 -0
- data/cookbooks/rvm/providers/global_gem.rb +99 -0
- data/cookbooks/rvm/providers/ruby.rb +100 -0
- data/cookbooks/rvm/providers/shell.rb +68 -0
- data/cookbooks/rvm/providers/wrapper.rb +58 -0
- data/cookbooks/rvm/recipes/default.rb +73 -0
- data/cookbooks/rvm/recipes/gem_package.rb +23 -0
- data/cookbooks/rvm/recipes/system.rb +69 -0
- data/cookbooks/rvm/recipes/user.rb +47 -0
- data/cookbooks/rvm/recipes/vagrant.rb +30 -0
- data/cookbooks/rvm/resources/default_ruby.rb +29 -0
- data/cookbooks/rvm/resources/environment.rb +29 -0
- data/cookbooks/rvm/resources/gem.rb +36 -0
- data/cookbooks/rvm/resources/gemset.rb +30 -0
- data/cookbooks/rvm/resources/global_gem.rb +33 -0
- data/cookbooks/rvm/resources/ruby.rb +29 -0
- data/cookbooks/rvm/resources/shell.rb +40 -0
- data/cookbooks/rvm/resources/wrapper.rb +32 -0
- data/cookbooks/rvm/templates/default/rvmrc.erb +14 -0
- data/cookbooks/rvm/templates/default/vagrant-chef-solo-wrapper.erb +23 -0
- data/cookbooks/utils/README.rdoc +8 -0
- data/cookbooks/utils/metadata.rb +6 -0
- data/cookbooks/utils/recipes/default.rb +10 -0
- data/cookbooks/utils/recipes/dotfiles.rb +21 -0
- data/cookbooks/utils/templates/default/dot.profile.erb +36 -0
- data/flombe.gemspec +28 -0
- data/lib/flombe/dsl.rb +66 -0
- data/lib/flombe.rb +107 -0
- data/spec/dsl_spec.rb +111 -0
- data/spec/flombe_spec.rb +30 -0
- data/spec/quality_spec.rb +11 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/helpers.rb +18 -0
- data/spec/support/matchers.rb +9 -0
- data/spec/support/path.rb +21 -0
- data/templates/chef_solo.erb +11 -0
- metadata +154 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Library: gem_package resource monkey patch
|
4
|
+
#
|
5
|
+
# Author:: Fletcher Nichol <fnichol@nichol.ca>
|
6
|
+
#
|
7
|
+
# Copyright 2011, Fletcher Nichol
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
|
22
|
+
##
|
23
|
+
# Patch Chef::Reousrce::GemPackage resource to use the RVMRubygems provider.
|
24
|
+
# This has potentially dangerous side effects and should be considered
|
25
|
+
# experimental. You have been warned.
|
26
|
+
def patch_gem_package
|
27
|
+
::Chef::Resource::GemPackage.class_eval do
|
28
|
+
def initialize(name, run_context=nil)
|
29
|
+
super
|
30
|
+
@resource_name = :gem_package
|
31
|
+
@provider = Chef::Provider::Package::RVMRubygems
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,334 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Library:: helpers
|
4
|
+
#
|
5
|
+
# Author:: Fletcher Nichol <fnichol@nichol.ca>
|
6
|
+
#
|
7
|
+
# Copyright 2011, Fletcher Nichol
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
|
22
|
+
begin
|
23
|
+
require 'rvm'
|
24
|
+
rescue LoadError
|
25
|
+
Chef::Log.warn("Missing gem 'rvm'")
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Determines if given ruby string is moderatley sane and potentially legal
|
30
|
+
#
|
31
|
+
# @param [String, #to_s] the fully qualified RVM ruby string
|
32
|
+
# @return [Boolean] is this ruby string sane?
|
33
|
+
def ruby_string_sane?(rubie)
|
34
|
+
return true if "goruby" == rubie # gorubie has no versions yet
|
35
|
+
return true if rubie =~ /^[^-]+-[^-]+/ # must be xxx-vvv at least
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Lists all installed RVM rubies on the system.
|
40
|
+
#
|
41
|
+
# **Note** that these values are cached for lookup speed. To flush these
|
42
|
+
# values and force an update, call #update_installed_rubies.
|
43
|
+
#
|
44
|
+
# @return [Array] the cached list of currently installed rvm rubies
|
45
|
+
def installed_rubies
|
46
|
+
@installed_rubies ||= update_installed_rubies
|
47
|
+
end
|
48
|
+
|
49
|
+
##
|
50
|
+
# Updates the list of all installed RVM rubies on the system
|
51
|
+
#
|
52
|
+
# @return [Array] the list of currently installed rvm rubies
|
53
|
+
def update_installed_rubies
|
54
|
+
@installed_rubies = RVM.list_strings
|
55
|
+
@installed_rubies
|
56
|
+
end
|
57
|
+
|
58
|
+
##
|
59
|
+
# Determines whether or not the given ruby is already installed
|
60
|
+
#
|
61
|
+
# @param [String, #to_s] the fully qualified RVM ruby string
|
62
|
+
# @return [Boolean] is this ruby installed?
|
63
|
+
def ruby_installed?(rubie)
|
64
|
+
return false unless ruby_string_sane?(rubie)
|
65
|
+
|
66
|
+
! installed_rubies.select { |r| r.start_with?(rubie) }.empty?
|
67
|
+
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# Inverse of #ruby_installed?
|
71
|
+
#
|
72
|
+
# @param [String, #to_s] the fully qualified RVM ruby string
|
73
|
+
# @return [Boolean] is this ruby not installed?
|
74
|
+
def ruby_not_installed?(rubie)
|
75
|
+
!ruby_installed?(rubie)
|
76
|
+
end
|
77
|
+
|
78
|
+
##
|
79
|
+
# Determines whether or not the given ruby is a known ruby string
|
80
|
+
#
|
81
|
+
# @param [String, #to_s] the fully qualified RVM ruby string
|
82
|
+
# @return [Boolean] is this ruby in the known ruby string list?
|
83
|
+
def ruby_known?(rubie)
|
84
|
+
return false unless ruby_string_sane?(rubie)
|
85
|
+
|
86
|
+
matches = known_rubies.select { |r| r.start_with?(rubie) }
|
87
|
+
if matches.empty?
|
88
|
+
# last-ditch attempt at matching. we'll drop the last -.*$ bit off the
|
89
|
+
# string assuming that the rubie contains a non-default patchlevel that
|
90
|
+
# will actually exist
|
91
|
+
fuzzier_rubie = rubie.sub(/-[^-]+$/, '')
|
92
|
+
return ! known_rubies.select { |r| r.start_with?(fuzzier_rubie) }.empty?
|
93
|
+
else
|
94
|
+
return true
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
##
|
99
|
+
# List all known RVM ruby strings.
|
100
|
+
#
|
101
|
+
# **Note** that these values are cached for lookup speed. To flush these
|
102
|
+
# values and force an update, call #update_known_rubies.
|
103
|
+
#
|
104
|
+
# @return [Array] the cached list of known ruby strings
|
105
|
+
def known_rubies
|
106
|
+
@known_rubies ||= update_known_rubies
|
107
|
+
end
|
108
|
+
|
109
|
+
##
|
110
|
+
# Updates the list of all known RVM strings.
|
111
|
+
#
|
112
|
+
# @return [Array] the list of known ruby strings
|
113
|
+
def update_known_rubies
|
114
|
+
@known_rubies = RVM.list_known_strings
|
115
|
+
@known_rubies
|
116
|
+
end
|
117
|
+
|
118
|
+
##
|
119
|
+
# Inverse of #ruby_known?
|
120
|
+
#
|
121
|
+
# @param [String, #to_s] the fully qualified RVM ruby string
|
122
|
+
# @return [Boolean] is this ruby an unknown ruby string?
|
123
|
+
def ruby_unknown?(rubie)
|
124
|
+
!ruby_known?(rubie)
|
125
|
+
end
|
126
|
+
|
127
|
+
##
|
128
|
+
# Fetches the current default ruby string, potentially with gemset
|
129
|
+
#
|
130
|
+
# @return [String] the fully qualified RVM ruby string, nil if none is set
|
131
|
+
def current_ruby_default
|
132
|
+
RVM.list_default
|
133
|
+
end
|
134
|
+
|
135
|
+
##
|
136
|
+
# Determines whether or not the given ruby is the default one
|
137
|
+
#
|
138
|
+
# @param [String, #to_s] the fully qualified RVM ruby string
|
139
|
+
# @return [Boolean] is this ruby the default one?
|
140
|
+
def ruby_default?(rubie)
|
141
|
+
current_default = current_ruby_default
|
142
|
+
|
143
|
+
if current_default.nil?
|
144
|
+
if rubie == "system"
|
145
|
+
return true
|
146
|
+
else
|
147
|
+
return false
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
return false unless ruby_string_sane?(rubie)
|
152
|
+
current_default.start_with?(rubie)
|
153
|
+
end
|
154
|
+
|
155
|
+
##
|
156
|
+
# Determines whether or not the given ruby could be considered the system
|
157
|
+
# ruby.
|
158
|
+
#
|
159
|
+
# @param [String, #to_s] an RVM ruby string
|
160
|
+
# @return [Boolean] is this ruby string the a system ruby?
|
161
|
+
def system_ruby?(rubie)
|
162
|
+
return true if rubie.nil? # nil should be system
|
163
|
+
return true if rubie.empty? # an empty string should be system
|
164
|
+
return true if rubie == "system" # keyword system should be system
|
165
|
+
return false # anything else does not represent system
|
166
|
+
end
|
167
|
+
|
168
|
+
##
|
169
|
+
# Determines whether or not and ruby/gemset environment exists
|
170
|
+
#
|
171
|
+
# @param [String, #to_s] the fully qualified RVM ruby string
|
172
|
+
# @return [Boolean] does this environment exist?
|
173
|
+
def env_exists?(ruby_string)
|
174
|
+
return true if system_ruby?(ruby_string)
|
175
|
+
|
176
|
+
rubie = select_ruby(ruby_string)
|
177
|
+
gemset = select_gemset(ruby_string)
|
178
|
+
|
179
|
+
if gemset
|
180
|
+
gemset_exists?(:ruby => rubie, :gemset => gemset)
|
181
|
+
else
|
182
|
+
ruby_installed?(rubie)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
##
|
187
|
+
# Lists all gemsets for a given RVM ruby.
|
188
|
+
#
|
189
|
+
# **Note** that these values are cached for lookup speed. To flush these
|
190
|
+
# values and force an update, call #update_installed_gemsets.
|
191
|
+
#
|
192
|
+
# @param [String, #to_s] the fully qualified RVM ruby string
|
193
|
+
# @return [Array] a cached list of gemset names
|
194
|
+
def installed_gemsets(rubie)
|
195
|
+
@installed_gemsets = Hash.new if @installed_gemsets.nil?
|
196
|
+
@installed_gemsets[rubie] ||= update_installed_gemsets(rubie)
|
197
|
+
end
|
198
|
+
|
199
|
+
##
|
200
|
+
# Updates the list of all gemsets for a given RVM ruby on the system
|
201
|
+
#
|
202
|
+
# @param [String, #to_s] the fully qualified RVM ruby string
|
203
|
+
# @return [Array] the current list of gemsets
|
204
|
+
def update_installed_gemsets(rubie)
|
205
|
+
env = RVM::Environment.new
|
206
|
+
env.use rubie
|
207
|
+
|
208
|
+
@installed_gemsets ||= {}
|
209
|
+
@installed_gemsets[rubie] = env.gemset_list
|
210
|
+
@installed_gemsets[rubie]
|
211
|
+
end
|
212
|
+
|
213
|
+
##
|
214
|
+
# Determines whether or not a gemset exists for a given ruby
|
215
|
+
#
|
216
|
+
# @param [Hash] the options to query a gemset with
|
217
|
+
# @option opts [String] :ruby the ruby the query within
|
218
|
+
# @option opts [String] :gemset the gemset to look for
|
219
|
+
def gemset_exists?(opts={})
|
220
|
+
return false if opts[:ruby].nil? || opts[:gemset].nil?
|
221
|
+
return false unless ruby_string_sane?(opts[:ruby])
|
222
|
+
return false unless ruby_installed?(opts[:ruby])
|
223
|
+
|
224
|
+
installed_gemsets(opts[:ruby]).include?(opts[:gemset])
|
225
|
+
end
|
226
|
+
|
227
|
+
##
|
228
|
+
# Determines whether or not there is a gemset defined in a given ruby string
|
229
|
+
#
|
230
|
+
# @param [String, #to_s] the fully qualified RVM ruby string
|
231
|
+
# @return [Boolean] does the ruby string appear to have a gemset included?
|
232
|
+
def string_include_gemset?(ruby_string)
|
233
|
+
ruby_string.include?('@')
|
234
|
+
end
|
235
|
+
|
236
|
+
##
|
237
|
+
# Filters out any gemset declarations in an RVM ruby string
|
238
|
+
#
|
239
|
+
# @param [String, #to_s] the fully qualified RVM ruby string
|
240
|
+
# @return [String] the ruby string, minus gemset
|
241
|
+
def select_ruby(ruby_string)
|
242
|
+
ruby_string.split('@').first
|
243
|
+
end
|
244
|
+
|
245
|
+
##
|
246
|
+
# Filters out any ruby declaration in an RVM ruby string
|
247
|
+
#
|
248
|
+
# @param [String, #to_s] the fully qualified RVM ruby string
|
249
|
+
# @return [String] the gemset string, minus ruby or nil if no gemset given
|
250
|
+
def select_gemset(ruby_string)
|
251
|
+
if string_include_gemset?(ruby_string)
|
252
|
+
ruby_string.split('@').last
|
253
|
+
else
|
254
|
+
nil
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
##
|
259
|
+
# Sanitizes a ruby string so that it's more normalized.
|
260
|
+
#
|
261
|
+
# @param [String, #to_s] an RVM ruby string
|
262
|
+
# @return [String] a fully qualified RVM ruby string
|
263
|
+
def normalize_ruby_string(ruby_string)
|
264
|
+
# get the actual ruby string that corresponds to "default"
|
265
|
+
if ruby_string.start_with?("default")
|
266
|
+
ruby_string.sub(/default/, current_ruby_default)
|
267
|
+
else
|
268
|
+
ruby_string
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
##
|
273
|
+
# Finds the correct shell profile to source to init an RVM-aware
|
274
|
+
# shell environment
|
275
|
+
#
|
276
|
+
# @return [String] full path the shell profile
|
277
|
+
def find_profile_to_source
|
278
|
+
if ::File.directory?("/etc/profile.d")
|
279
|
+
"/etc/profile.d/rvm.sh"
|
280
|
+
else
|
281
|
+
"/etc/profile"
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
##
|
286
|
+
# Returns a shell command that is RVM-aware
|
287
|
+
#
|
288
|
+
# @param [String, #to_s] the shell command to be wrapped
|
289
|
+
# @return [String] the command wrapped in RVM-initialized bash command
|
290
|
+
def rvm_wrap_cmd(cmd)
|
291
|
+
%{bash -c "source #{find_profile_to_source} && source ~/.bash_profile && #{cmd.gsub(/"/, '\"')}"}
|
292
|
+
end
|
293
|
+
|
294
|
+
##
|
295
|
+
# Installs any package dependencies needed by a given ruby
|
296
|
+
#
|
297
|
+
# @param [String, #to_s] the fully qualified RVM ruby string
|
298
|
+
def install_ruby_dependencies(rubie)
|
299
|
+
pkgs = []
|
300
|
+
if rubie =~ /^1\.[89]\../ || rubie =~ /^ree/ || rubie =~ /^ruby-/
|
301
|
+
case node[:platform]
|
302
|
+
when "debian","ubuntu"
|
303
|
+
pkgs = %w{ build-essential bison openssl libreadline6 libreadline6-dev
|
304
|
+
zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0
|
305
|
+
libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev ssl-cert }
|
306
|
+
pkgs += %w{ git-core subversion autoconf } if rubie =~ /^ruby-head$/
|
307
|
+
when "suse"
|
308
|
+
pkgs = %w{ gcc-c++ patch zlib zlib-devel libffi-devel
|
309
|
+
sqlite3-devel libxml2-devel libxslt-devel }
|
310
|
+
if node.platform_version.to_f >= 11.0
|
311
|
+
pkgs += %w{ libreadline5 readline-devel libopenssl-devel }
|
312
|
+
else
|
313
|
+
pkgs += %w{ readline readline-devel openssl-devel }
|
314
|
+
end
|
315
|
+
pkgs += %w{ git subversion autoconf } if rubie =~ /^ruby-head$/
|
316
|
+
when "centos","redhat","fedora"
|
317
|
+
pkgs = %w{ gcc-c++ patch readline readline-devel zlib zlib-devel
|
318
|
+
libyaml-devel libffi-devel openssl-devel }
|
319
|
+
pkgs += %w{ git subversion autoconf } if rubie =~ /^ruby-head$/
|
320
|
+
end
|
321
|
+
elsif rubie =~ /^jruby/
|
322
|
+
# TODO: need to figure out how to pull in java recipe only when needed. For
|
323
|
+
# now, users of jruby will have to add the "java" recipe to their run_list.
|
324
|
+
#include_recipe "java"
|
325
|
+
pkgs << "g++"
|
326
|
+
end
|
327
|
+
|
328
|
+
pkgs.each do |pkg|
|
329
|
+
p = package pkg do
|
330
|
+
action :nothing
|
331
|
+
end
|
332
|
+
p.run_action(:install)
|
333
|
+
end
|
334
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Provider:: Chef::Provider::Package::RVMRubygems
|
4
|
+
#
|
5
|
+
# Author:: Fletcher Nichol <fnichol@nichol.ca>
|
6
|
+
#
|
7
|
+
# Copyright 2011, Fletcher Nichol
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
class Provider
|
24
|
+
class Package
|
25
|
+
class RVMRubygems < Chef::Provider::Package::Rubygems
|
26
|
+
|
27
|
+
class RVMGemEnvironment < AlternateGemEnvironment
|
28
|
+
attr_reader :ruby_string
|
29
|
+
|
30
|
+
def initialize(gem_binary_location, ruby_string)
|
31
|
+
super(gem_binary_location)
|
32
|
+
@ruby_string = ruby_string
|
33
|
+
end
|
34
|
+
|
35
|
+
def gem_paths
|
36
|
+
# shellout! is a fork/exec which won't work on windows
|
37
|
+
shell_style_paths = shell_out!(rvm_wrap_cmd(
|
38
|
+
"rvm #{ruby_string} exec #{@gem_binary_location} env gempath")).stdout
|
39
|
+
# on windows, the path separator is semicolon
|
40
|
+
paths = shell_style_paths.split(
|
41
|
+
::File::PATH_SEPARATOR).map { |path| path.strip }
|
42
|
+
end
|
43
|
+
|
44
|
+
def gem_platforms
|
45
|
+
gem_environment = shell_out!(rvm_wrap_cmd(
|
46
|
+
"rvm #{ruby_string} exec #{@gem_binary_location} env")).stdout
|
47
|
+
if jruby = gem_environment[JRUBY_PLATFORM]
|
48
|
+
['ruby', Gem::Platform.new(jruby)]
|
49
|
+
else
|
50
|
+
Gem.platforms
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def initialize(new_resource, run_context=nil)
|
56
|
+
super
|
57
|
+
@gem_env = RVMGemEnvironment.new(gem_binary_path, ruby_string)
|
58
|
+
end
|
59
|
+
|
60
|
+
def ruby_string
|
61
|
+
@ruby_string ||= if new_resource.respond_to?("ruby_string")
|
62
|
+
new_resource.ruby_string
|
63
|
+
else
|
64
|
+
node['rvm']['gem_package']['rvm_string']
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def install_package(name, version)
|
69
|
+
ruby_string_normalized = normalize_ruby_string(ruby_string)
|
70
|
+
|
71
|
+
# ensure ruby is installed and gemset exists
|
72
|
+
e = rvm_environment ruby_string_normalized do
|
73
|
+
action :nothing
|
74
|
+
end
|
75
|
+
e.run_action(:create)
|
76
|
+
|
77
|
+
install_via_gem_command(name, version)
|
78
|
+
true
|
79
|
+
end
|
80
|
+
|
81
|
+
def install_via_gem_command(name, version)
|
82
|
+
src = @new_resource.source &&
|
83
|
+
" --source=#{@new_resource.source} --source=http://rubygems.org"
|
84
|
+
|
85
|
+
cmd = %{rvm #{ruby_string} #{gem_binary_path}}
|
86
|
+
cmd << %{ install #{name} -q --no-rdoc --no-ri -v "#{version}"}
|
87
|
+
cmd << %{#{src}#{opts}}
|
88
|
+
shell_out!(rvm_wrap_cmd(cmd), :env => nil)
|
89
|
+
end
|
90
|
+
|
91
|
+
def remove_package(name, version)
|
92
|
+
uninstall_via_gem_command(name, version)
|
93
|
+
end
|
94
|
+
|
95
|
+
def uninstall_via_gem_command(name, version)
|
96
|
+
cmd = %{rvm #{ruby_string} #{gem_binary_path}}
|
97
|
+
cmd << %{ uninstall #{name} -q -x -I}
|
98
|
+
if version
|
99
|
+
cmd << %{ -v "#{version}"#{opts}}
|
100
|
+
else
|
101
|
+
cmd << %{ -a#{opts}}
|
102
|
+
end
|
103
|
+
shell_out!(cmd, :env=>nil)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|