from-scratch 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.chef/knife.rb +6 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Berksfile +17 -0
- data/Berksfile.lock +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +6 -0
- data/Thorfile +5 -0
- data/bin/scratchify +6 -0
- data/chefignore +101 -0
- data/cookbooks/chef_gem/CHANGELOG.md +24 -0
- data/cookbooks/chef_gem/README.md +38 -0
- data/cookbooks/chef_gem/libraries/chef_gem.rb +72 -0
- data/cookbooks/chef_gem/metadata.json +29 -0
- data/cookbooks/chef_gem/recipes/default.rb +0 -0
- data/cookbooks/java/.gitignore +21 -0
- data/cookbooks/java/.kitchen.docker.yml +15 -0
- data/cookbooks/java/.kitchen.yml +126 -0
- data/cookbooks/java/.travis.yml +6 -0
- data/cookbooks/java/Berksfile +10 -0
- data/cookbooks/java/CHANGELOG.md +398 -0
- data/cookbooks/java/CONTRIBUTING.md +12 -0
- data/cookbooks/java/Gemfile +15 -0
- data/cookbooks/java/ISSUES.md +43 -0
- data/cookbooks/java/LICENSE +201 -0
- data/cookbooks/java/README.md +402 -0
- data/cookbooks/java/Rakefile +60 -0
- data/cookbooks/java/TESTING.md +41 -0
- data/cookbooks/java/attributes/default.rb +146 -0
- data/cookbooks/java/libraries/helpers.rb +120 -0
- data/cookbooks/java/libraries/matchers.rb +5 -0
- data/cookbooks/java/metadata.json +69 -0
- data/cookbooks/java/providers/alternatives.rb +94 -0
- data/cookbooks/java/providers/ark.rb +255 -0
- data/cookbooks/java/recipes/default.rb +22 -0
- data/cookbooks/java/recipes/default_java_symlink.rb +19 -0
- data/cookbooks/java/recipes/homebrew.rb +3 -0
- data/cookbooks/java/recipes/ibm.rb +76 -0
- data/cookbooks/java/recipes/ibm_tar.rb +70 -0
- data/cookbooks/java/recipes/openjdk.rb +74 -0
- data/cookbooks/java/recipes/oracle.rb +74 -0
- data/cookbooks/java/recipes/oracle_i386.rb +73 -0
- data/cookbooks/java/recipes/oracle_jce.rb +75 -0
- data/cookbooks/java/recipes/oracle_rpm.rb +60 -0
- data/cookbooks/java/recipes/purge_packages.rb +20 -0
- data/cookbooks/java/recipes/set_attributes_from_version.rb +55 -0
- data/cookbooks/java/recipes/set_java_home.rb +44 -0
- data/cookbooks/java/recipes/windows.rb +82 -0
- data/cookbooks/java/resources/alternatives.rb +30 -0
- data/cookbooks/java/resources/ark.rb +58 -0
- data/cookbooks/java/templates/default/ibm_jdk.installer.properties.erb +3 -0
- data/cookbooks/java/templates/default/oracle.jinfo.erb +6 -0
- data/cookbooks/rvm/.foodcritic +1 -0
- data/cookbooks/rvm/.gitignore +7 -0
- data/cookbooks/rvm/.kitchen.yml +66 -0
- data/cookbooks/rvm/.travis.yml +9 -0
- data/cookbooks/rvm/Berksfile +10 -0
- data/cookbooks/rvm/CHANGELOG.md +253 -0
- data/cookbooks/rvm/CODE_OF_CONDUCT.md +12 -0
- data/cookbooks/rvm/CONTRIBUTING.md +26 -0
- data/cookbooks/rvm/Gemfile +20 -0
- data/cookbooks/rvm/Guardfile +12 -0
- data/cookbooks/rvm/README.md +1459 -0
- data/cookbooks/rvm/Rakefile +18 -0
- data/cookbooks/rvm/attributes/.gitkeep +0 -0
- data/cookbooks/rvm/attributes/default.rb +68 -0
- data/cookbooks/rvm/attributes/gem_package.rb +23 -0
- data/cookbooks/rvm/attributes/vagrant.rb +23 -0
- data/cookbooks/rvm/libraries/chef_rvm_environment_helpers.rb +55 -0
- data/cookbooks/rvm/libraries/chef_rvm_gemset_helpers.rb +67 -0
- data/cookbooks/rvm/libraries/chef_rvm_recipe_helpers.rb +80 -0
- data/cookbooks/rvm/libraries/chef_rvm_ruby_helpers.rb +95 -0
- data/cookbooks/rvm/libraries/chef_rvm_set_helpers.rb +16 -0
- data/cookbooks/rvm/libraries/chef_rvm_shell_helpers.rb +57 -0
- data/cookbooks/rvm/libraries/chef_rvm_string_cache.rb +104 -0
- data/cookbooks/rvm/libraries/chef_rvm_string_helpers.rb +61 -0
- data/cookbooks/rvm/libraries/chef_rvm_version_helpers.rb +45 -0
- data/cookbooks/rvm/libraries/gem_package_monkeypatch.rb +34 -0
- data/cookbooks/rvm/libraries/provider_rvm_installation.rb +185 -0
- data/cookbooks/rvm/libraries/resource_rvm_installation.rb +103 -0
- data/cookbooks/rvm/libraries/rvm_chef_user_environment.rb +55 -0
- data/cookbooks/rvm/libraries/rvm_rubygems_package.rb +189 -0
- data/cookbooks/rvm/libraries/rvm_shell_chef_wrapper.rb +99 -0
- data/cookbooks/rvm/metadata.json +51 -0
- data/cookbooks/rvm/providers/default_ruby.rb +63 -0
- data/cookbooks/rvm/providers/environment.rb +78 -0
- data/cookbooks/rvm/providers/gemset.rb +118 -0
- data/cookbooks/rvm/providers/global_gem.rb +97 -0
- data/cookbooks/rvm/providers/ruby.rb +178 -0
- data/cookbooks/rvm/providers/shell.rb +121 -0
- data/cookbooks/rvm/providers/wrapper.rb +73 -0
- data/cookbooks/rvm/recipes/.gitkeep +0 -0
- data/cookbooks/rvm/recipes/default.rb +40 -0
- data/cookbooks/rvm/recipes/gem_package.rb +33 -0
- data/cookbooks/rvm/recipes/system.rb +37 -0
- data/cookbooks/rvm/recipes/system_install.rb +42 -0
- data/cookbooks/rvm/recipes/user.rb +43 -0
- data/cookbooks/rvm/recipes/user_install.rb +58 -0
- data/cookbooks/rvm/recipes/vagrant.rb +37 -0
- data/cookbooks/rvm/resources/default_ruby.rb +31 -0
- data/cookbooks/rvm/resources/environment.rb +31 -0
- data/cookbooks/rvm/resources/gem.rb +37 -0
- data/cookbooks/rvm/resources/gemset.rb +32 -0
- data/cookbooks/rvm/resources/global_gem.rb +34 -0
- data/cookbooks/rvm/resources/ruby.rb +32 -0
- data/cookbooks/rvm/resources/shell.rb +41 -0
- data/cookbooks/rvm/resources/wrapper.rb +34 -0
- data/cookbooks/rvm/templates/default/rvmrc.erb +14 -0
- data/cookbooks/rvm/templates/default/vagrant-chef-client-wrapper.erb +23 -0
- data/cookbooks/rvm/templates/default/vagrant-chef-solo-wrapper.erb +23 -0
- data/cookbooks/rvm/test/integration/data_bags/users/virgil1.json +4 -0
- data/cookbooks/rvm/test/integration/data_bags/users/virgil2.json +4 -0
- data/cookbooks/rvm/test/integration/data_bags/users/wigglebottom.json +3 -0
- data/cookbooks/rvm/test/integration/installs/bats/version_pinning.bats +13 -0
- data/cookbooks/rvm/test/integration/rubies/bats/_common.bash +16 -0
- data/cookbooks/rvm/test/integration/rubies/bats/verify_1.9.3.bats +9 -0
- data/cookbooks/rvm/test/integration/rubies/bats/verify_jruby.bats +12 -0
- data/cookbooks/rvm/test/integration/rubies/bats/verify_patch_support.bats +19 -0
- data/cookbooks/rvm/test/integration/rubies/bats/verify_ree.bats +9 -0
- data/cookbooks/rvm/test/integration/rubies/bats/verify_rubygems_version_support.bats +15 -0
- data/cookbooks/rvm/test/integration/stock_system_and_user/bats/system.bats +45 -0
- data/cookbooks/rvm/test/unit/libraries/provider_rvm_installation_spec.rb +220 -0
- data/cookbooks/rvm/test/unit/libraries/resource_rvm_installation_spec.rb +139 -0
- data/cookbooks/rvm/test/unit/spec_helper.rb +23 -0
- data/cookbooks/scratchify/.chef/knife.rb +9 -0
- data/cookbooks/scratchify/Berksfile +16 -0
- data/cookbooks/scratchify/Berksfile.lock +19 -0
- data/cookbooks/scratchify/LICENSE.txt +21 -0
- data/cookbooks/scratchify/README.md +41 -0
- data/cookbooks/scratchify/Thorfile +5 -0
- data/cookbooks/scratchify/bin/console +14 -0
- data/cookbooks/scratchify/bin/scratchify +6 -0
- data/cookbooks/scratchify/bin/setup +7 -0
- data/cookbooks/scratchify/chefignore +101 -0
- data/cookbooks/scratchify/data_bags/users/deploy.json +6 -0
- data/cookbooks/scratchify/environments/.gitkeep +0 -0
- data/cookbooks/scratchify/from-scratch.gemspec +36 -0
- data/cookbooks/scratchify/lib/from/scratch.rb +31 -0
- data/cookbooks/scratchify/lib/from/scratch/interviewer.rb +35 -0
- data/cookbooks/scratchify/lib/from/scratch/version.rb +3 -0
- data/cookbooks/scratchify/metadata.json +36 -0
- data/cookbooks/scratchify/nodes/normfood.ru.json +75 -0
- data/cookbooks/scratchify/recipes/default.rb +0 -0
- data/cookbooks/scratchify/roles/.gitkeep +0 -0
- data/cookbooks/scratchify/spec/from/scratch_spec.rb +11 -0
- data/cookbooks/scratchify/spec/spec_helper.rb +2 -0
- data/cookbooks/user/.gitignore +5 -0
- data/cookbooks/user/.kitchen.yml +46 -0
- data/cookbooks/user/.travis.yml +4 -0
- data/cookbooks/user/Berksfile +7 -0
- data/cookbooks/user/CHANGELOG.md +101 -0
- data/cookbooks/user/Gemfile +14 -0
- data/cookbooks/user/README.md +447 -0
- data/cookbooks/user/Rakefile +21 -0
- data/cookbooks/user/attributes/default.rb +50 -0
- data/cookbooks/user/libraries/matchers.rb +26 -0
- data/cookbooks/user/metadata.json +46 -0
- data/cookbooks/user/providers/account.rb +212 -0
- data/cookbooks/user/recipes/data_bag.rb +59 -0
- data/cookbooks/user/recipes/default.rb +18 -0
- data/cookbooks/user/resources/account.rb +41 -0
- data/cookbooks/user/templates/default/authorized_keys.erb +7 -0
- data/from-scratch.gemspec +33 -0
- data/lib/from-scratch.rb +25 -0
- data/lib/from-scratch/version.rb +3 -0
- data/metadata.rb +15 -0
- data/recipes/default.rb +0 -0
- data/templates/node.json.erb +31 -0
- data/templates/user.json.erb +6 -0
- metadata +330 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
require 'foodcritic'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:unit) do |t|
|
7
|
+
t.pattern = "test/unit/**/*_spec.rb"
|
8
|
+
end
|
9
|
+
|
10
|
+
begin
|
11
|
+
require 'kitchen/rake_tasks'
|
12
|
+
Kitchen::RakeTasks.new
|
13
|
+
rescue LoadError
|
14
|
+
puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI']
|
15
|
+
end
|
16
|
+
|
17
|
+
task :default => [:foodcritic, :unit]
|
18
|
+
FoodCritic::Rake::LintTask.new
|
File without changes
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Attributes:: default
|
4
|
+
#
|
5
|
+
# Author:: Fletcher Nichol <fnichol@nichol.ca>
|
6
|
+
#
|
7
|
+
# Copyright 2010, 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
|
+
# ruby that will get installed and set to `rvm use default`.
|
23
|
+
default['rvm']['default_ruby'] = "ruby-1.9.3-p547"
|
24
|
+
default['rvm']['user_default_ruby'] = "ruby-1.9.3-p547"
|
25
|
+
|
26
|
+
# list of additional rubies that will be installed
|
27
|
+
default['rvm']['rubies'] = []
|
28
|
+
default['rvm']['user_rubies'] = []
|
29
|
+
|
30
|
+
# list of gems to be installed in global gemset of all rubies
|
31
|
+
_global_gems_ = [
|
32
|
+
{ 'name' => 'bundler' }
|
33
|
+
]
|
34
|
+
default['rvm']['global_gems'] = _global_gems_.dup
|
35
|
+
default['rvm']['user_global_gems'] = _global_gems_.dup
|
36
|
+
|
37
|
+
# hash of gemsets and their list of additional gems to be installed.
|
38
|
+
default['rvm']['gems'] = Hash.new
|
39
|
+
default['rvm']['user_gems'] = Hash.new
|
40
|
+
|
41
|
+
# hash of rvmrc options
|
42
|
+
default['rvm']['rvmrc_env'] = { "rvm_gem_options" => "--no-ri --no-rdoc" }
|
43
|
+
|
44
|
+
# a hash of user hashes, each an isolated per-user RVM installation
|
45
|
+
default['rvm']['installs'] = Hash.new
|
46
|
+
|
47
|
+
# system-wide installer options
|
48
|
+
default['rvm']['installer_url'] = "https://get.rvm.io"
|
49
|
+
default['rvm']['installer_flags'] = "stable"
|
50
|
+
|
51
|
+
# extra system-wide tunables
|
52
|
+
default['rvm']['root_path'] = "/usr/local/rvm"
|
53
|
+
default['rvm']['group_id'] = 'default'
|
54
|
+
default['rvm']['group_users'] = []
|
55
|
+
|
56
|
+
# GPG key for rvm verification
|
57
|
+
default['rvm']['gpg_key'] = 'D39DC0E3'
|
58
|
+
|
59
|
+
case platform
|
60
|
+
when "redhat","centos","fedora","scientific","amazon"
|
61
|
+
node.set['rvm']['install_pkgs'] = %w{sed grep tar gzip bzip2 bash curl git}
|
62
|
+
when "debian","ubuntu","suse"
|
63
|
+
node.set['rvm']['install_pkgs'] = %w{sed grep tar gzip bzip2 bash curl git-core}
|
64
|
+
when "gentoo"
|
65
|
+
node.set['rvm']['install_pkgs'] = %w{git}
|
66
|
+
when "mac_os_x", "mac_os_x_server"
|
67
|
+
node.set['rvm']['install_pkgs'] = %w{git}
|
68
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Attributes:: gem_package
|
4
|
+
#
|
5
|
+
# Author:: Fletcher Nichol <fnichol@nichol.ca>
|
6
|
+
#
|
7
|
+
# Copyright 2010, 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
|
+
# rvm ruby that will be used for gem_package resources
|
23
|
+
default['rvm']['gem_package']['rvm_string'] = node['rvm']['default_ruby']
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Attributes:: vagrant
|
4
|
+
#
|
5
|
+
# Author:: Fletcher Nichol <fnichol@nichol.ca>
|
6
|
+
#
|
7
|
+
# Copyright 2010, 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
|
+
default['rvm']['vagrant']['system_chef_client'] = "/opt/vagrant_ruby/bin/chef-client"
|
23
|
+
default['rvm']['vagrant']['system_chef_solo'] = "/opt/vagrant_ruby/bin/chef-solo"
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Library:: Chef::RVM::EnvironmentHelpers
|
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
|
+
module RVM
|
24
|
+
module RubyHelpers
|
25
|
+
# stub to satisfy EnvironmentHelpers (library load order not guarenteed)
|
26
|
+
end
|
27
|
+
|
28
|
+
module GemsetHelpers
|
29
|
+
# stub to satisfy EnvironmentHelpers (library load order not guarenteed)
|
30
|
+
end
|
31
|
+
|
32
|
+
module EnvironmentHelpers
|
33
|
+
include RubyHelpers
|
34
|
+
include GemsetHelpers
|
35
|
+
|
36
|
+
##
|
37
|
+
# Determines whether or not and ruby/gemset environment exists
|
38
|
+
#
|
39
|
+
# @param [String, #to_s] the fully qualified RVM ruby string
|
40
|
+
# @return [Boolean] does this environment exist?
|
41
|
+
def env_exists?(ruby_string)
|
42
|
+
return true if system_ruby?(ruby_string)
|
43
|
+
|
44
|
+
rubie = select_ruby(ruby_string)
|
45
|
+
gemset = select_gemset(ruby_string)
|
46
|
+
|
47
|
+
if gemset
|
48
|
+
gemset_exists?(:ruby => rubie, :gemset => gemset)
|
49
|
+
else
|
50
|
+
ruby_installed?(rubie)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Library:: Chef::RVM::GemsetHelpers
|
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
|
+
module RVM
|
24
|
+
module GemsetHelpers
|
25
|
+
##
|
26
|
+
# Lists all gemsets for a given RVM Ruby.
|
27
|
+
#
|
28
|
+
# **Note** that these values are cached for lookup speed. To flush these
|
29
|
+
# values and force an update, call #update_installed_gemsets.
|
30
|
+
#
|
31
|
+
# @param [String, #to_s] the RVM Ruby string
|
32
|
+
# @return [Array] a cached list of gemset names
|
33
|
+
def installed_gemsets(rubie)
|
34
|
+
@installed_gemsets = Hash.new if @installed_gemsets.nil?
|
35
|
+
@installed_gemsets[rubie] ||= update_installed_gemsets(rubie)
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Updates the list of all gemsets for a given RVM Ruby on the system
|
40
|
+
#
|
41
|
+
# @param [String, #to_s] the RVM Ruby string
|
42
|
+
# @return [Array] the current list of gemsets
|
43
|
+
def update_installed_gemsets(rubie)
|
44
|
+
original_rubie = @rvm_env.environment_name
|
45
|
+
@rvm_env.use rubie
|
46
|
+
|
47
|
+
@installed_gemsets ||= {}
|
48
|
+
@installed_gemsets[rubie] = @rvm_env.gemset_list
|
49
|
+
@rvm_env.use original_rubie if original_rubie != rubie
|
50
|
+
@installed_gemsets[rubie]
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Determines whether or not a gemset exists for a given Ruby
|
55
|
+
#
|
56
|
+
# @param [Hash] the options to query a gemset with
|
57
|
+
# @option opts [String] :ruby the Ruby the query within
|
58
|
+
# @option opts [String] :gemset the gemset to look for
|
59
|
+
def gemset_exists?(opts={})
|
60
|
+
return false if opts[:ruby].nil? || opts[:gemset].nil?
|
61
|
+
return false unless ruby_installed?(opts[:ruby])
|
62
|
+
|
63
|
+
installed_gemsets(opts[:ruby]).include?(opts[:gemset])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Library:: Chef::RVM::RecipeHelpers
|
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
|
+
module RVM
|
24
|
+
module RecipeHelpers
|
25
|
+
|
26
|
+
def install_rubies(opts = {})
|
27
|
+
# install additional rubies
|
28
|
+
opts[:rubies].each do |rubie|
|
29
|
+
if rubie.is_a?(Hash)
|
30
|
+
ruby = rubie.fetch("version")
|
31
|
+
ruby_patch = rubie.fetch("patch", nil)
|
32
|
+
ruby_rubygems_version = rubie.fetch("rubygems_version", nil)
|
33
|
+
else
|
34
|
+
ruby = rubie
|
35
|
+
ruby_patch = nil
|
36
|
+
ruby_rubygems_version = nil
|
37
|
+
end
|
38
|
+
|
39
|
+
rvm_ruby ruby do
|
40
|
+
patch ruby_patch
|
41
|
+
user opts[:user]
|
42
|
+
rubygems_version ruby_rubygems_version
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# set a default ruby
|
47
|
+
rvm_default_ruby opts[:default_ruby] do
|
48
|
+
user opts[:user]
|
49
|
+
end
|
50
|
+
|
51
|
+
# install global gems
|
52
|
+
opts[:global_gems].each do |gem|
|
53
|
+
rvm_global_gem gem[:name] do
|
54
|
+
user opts[:user]
|
55
|
+
[:version, :action, :options, :source].each do |attr|
|
56
|
+
send(attr, gem[attr]) if gem[attr]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# install additional gems
|
62
|
+
opts[:gems].each_pair do |rstring, gems|
|
63
|
+
rvm_environment rstring do
|
64
|
+
user opts[:user]
|
65
|
+
end
|
66
|
+
|
67
|
+
gems.each do |gem|
|
68
|
+
rvm_gem gem[:name] do
|
69
|
+
ruby_string rstring
|
70
|
+
user opts[:user]
|
71
|
+
[:version, :action, :options, :source].each do |attr|
|
72
|
+
send(attr, gem[attr]) if gem[attr]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: rvm
|
3
|
+
# Library:: Chef::RVM::RubyHelpers
|
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
|
+
module RVM
|
24
|
+
module RubyHelpers
|
25
|
+
##
|
26
|
+
# Lists all installed RVM Rubies on the system.
|
27
|
+
#
|
28
|
+
# **Note** that these values are cached for lookup speed. To flush these
|
29
|
+
# values and force an update, call #update_installed_rubies.
|
30
|
+
#
|
31
|
+
# @return [Array] the cached list of currently installed RVM Rubies
|
32
|
+
def installed_rubies
|
33
|
+
@installed_rubies ||= update_installed_rubies
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Updates the list of all installed RVM Rubies on the system
|
38
|
+
#
|
39
|
+
# @return [Array] the list of currently installed RVM Rubies
|
40
|
+
def update_installed_rubies
|
41
|
+
@installed_rubies = @rvm_env.list_strings
|
42
|
+
@installed_rubies
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# Determines whether or not the given Ruby is already installed
|
47
|
+
#
|
48
|
+
# @param [String, #to_s] the RVM Ruby string
|
49
|
+
# @return [Boolean] is this Ruby installed?
|
50
|
+
def ruby_installed?(rubie)
|
51
|
+
! installed_rubies.select { |r| r.end_with?(rubie) }.empty?
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# Fetches the current default Ruby string, potentially with gemset
|
56
|
+
#
|
57
|
+
# @return [String] the RVM Ruby string, nil if none is set
|
58
|
+
def current_ruby_default
|
59
|
+
@rvm_env.list_default
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Determines whether or not the given Ruby is the default one
|
64
|
+
#
|
65
|
+
# @param [String, #to_s] the RVM Ruby string
|
66
|
+
# @return [Boolean] is this Ruby the default one?
|
67
|
+
def ruby_default?(rubie)
|
68
|
+
current_default = current_ruby_default
|
69
|
+
|
70
|
+
if current_default.nil?
|
71
|
+
if rubie == "system"
|
72
|
+
return true
|
73
|
+
else
|
74
|
+
return false
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
current_default.start_with?(rubie)
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# Determines whether or not the given Ruby could be considered the
|
83
|
+
# system Ruby.
|
84
|
+
#
|
85
|
+
# @param [String, #to_s] the RVM Ruby string
|
86
|
+
# @return [Boolean] is this Ruby string the a system Ruby?
|
87
|
+
def system_ruby?(rubie)
|
88
|
+
return true if rubie.nil? # nil should be system
|
89
|
+
return true if rubie.empty? # an empty string should be system
|
90
|
+
return true if rubie == "system" # keyword system should be system
|
91
|
+
return false # anything else does not represent system
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Chef
|
2
|
+
module RVM
|
3
|
+
module SetHelpers
|
4
|
+
def rvm_do(user = nil)
|
5
|
+
# Use Gem's version comparing code to compare the two strings
|
6
|
+
rvm_version = VersionCache.fetch_version(user).gsub(/(-|_|#)/, '.')
|
7
|
+
if Gem::Version.new(rvm_version) < Gem::Version.new("1.8.6")
|
8
|
+
"exec"
|
9
|
+
else
|
10
|
+
"do"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|