natives 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +2 -3
- data/Gemfile.lock +12 -53
- data/README.md +126 -29
- data/Rakefile +4 -5
- data/VERSION +1 -1
- data/bin/natives +1 -0
- data/catalogs/rubygems.yaml +50 -0
- data/lib/natives/apps/detect.rb +21 -0
- data/lib/natives/apps/list.rb +39 -0
- data/lib/natives/apps.rb +2 -0
- data/lib/natives/catalog/loader.rb +30 -0
- data/lib/natives/catalog/merger.rb +26 -0
- data/lib/natives/catalog/selector.rb +79 -0
- data/lib/natives/catalog/validator.rb +18 -0
- data/lib/natives/catalog.rb +56 -0
- data/lib/natives/cli.rb +27 -42
- data/lib/natives/gemfile_viewer.rb +19 -16
- data/lib/natives/host_detection/package_provider.rb +83 -0
- data/lib/natives/host_detection/platform.rb +34 -0
- data/lib/natives/host_detection.rb +25 -0
- data/lib/natives.rb +1 -0
- data/spec/fixtures/dir_with_matching_files/invalid1.yml +9 -0
- data/spec/fixtures/dir_with_matching_files/not_matching.json +0 -0
- data/spec/fixtures/dir_with_matching_files/valid1.yaml +21 -0
- data/spec/fixtures/dir_with_matching_files/valid2.yml +9 -0
- data/spec/fixtures/dir_without_matching_file/not_matching.json +0 -0
- data/spec/natives/apps/detect_spec.rb +26 -0
- data/spec/natives/apps/list_spec.rb +58 -0
- data/spec/natives/catalog/loader_spec.rb +101 -0
- data/spec/natives/catalog/merger_spec.rb +60 -0
- data/spec/natives/catalog/selector_spec.rb +124 -0
- data/spec/natives/catalog/validator_spec.rb +44 -0
- data/spec/natives/catalog_spec.rb +133 -0
- data/spec/natives/gemfile_viewer_spec.rb +3 -3
- data/spec/natives/host_detection/package_provider_spec.rb +33 -0
- data/spec/natives/host_detection/platform_spec.rb +21 -0
- data/spec/natives/host_detection_spec.rb +45 -0
- data/spec/spec_helper.rb +17 -2
- metadata +44 -66
- data/chef/.kitchen.yml +0 -27
- data/chef/Berksfile +0 -4
- data/chef/Berksfile.lock +0 -10
- data/chef/cookbooks/natives/Berksfile +0 -3
- data/chef/cookbooks/natives/Gemfile +0 -5
- data/chef/cookbooks/natives/LICENSE +0 -3
- data/chef/cookbooks/natives/README.md +0 -13
- data/chef/cookbooks/natives/chefignore +0 -96
- data/chef/cookbooks/natives/libraries/natives_recipe_helper.rb +0 -37
- data/chef/cookbooks/natives/metadata.rb +0 -9
- data/chef/cookbooks/natives/recipes/default.rb +0 -31
- data/chef/solo.rb +0 -17
- data/chef/vendored-cookbooks/apt/CHANGELOG.md +0 -144
- data/chef/vendored-cookbooks/apt/README.md +0 -247
- data/chef/vendored-cookbooks/apt/attributes/default.rb +0 -27
- data/chef/vendored-cookbooks/apt/files/default/apt-proxy-v2.conf +0 -50
- data/chef/vendored-cookbooks/apt/libraries/helpers.rb +0 -47
- data/chef/vendored-cookbooks/apt/libraries/network.rb +0 -33
- data/chef/vendored-cookbooks/apt/metadata.json +0 -54
- data/chef/vendored-cookbooks/apt/metadata.rb +0 -34
- data/chef/vendored-cookbooks/apt/providers/preference.rb +0 -61
- data/chef/vendored-cookbooks/apt/providers/repository.rb +0 -141
- data/chef/vendored-cookbooks/apt/recipes/cacher-client.rb +0 -81
- data/chef/vendored-cookbooks/apt/recipes/cacher-ng.rb +0 -43
- data/chef/vendored-cookbooks/apt/recipes/default.rb +0 -83
- data/chef/vendored-cookbooks/apt/resources/preference.rb +0 -30
- data/chef/vendored-cookbooks/apt/resources/repository.rb +0 -41
- data/chef/vendored-cookbooks/apt/templates/debian-6.0/acng.conf.erb +0 -173
- data/chef/vendored-cookbooks/apt/templates/default/01proxy.erb +0 -5
- data/chef/vendored-cookbooks/apt/templates/default/acng.conf.erb +0 -275
- data/chef/vendored-cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb +0 -269
- data/chef/vendored-cookbooks/homebrew/CHANGELOG.md +0 -36
- data/chef/vendored-cookbooks/homebrew/README.md +0 -110
- data/chef/vendored-cookbooks/homebrew/attributes/default.rb +0 -22
- data/chef/vendored-cookbooks/homebrew/libraries/homebrew_mixin.rb +0 -53
- data/chef/vendored-cookbooks/homebrew/libraries/homebrew_package.rb +0 -104
- data/chef/vendored-cookbooks/homebrew/metadata.json +0 -32
- data/chef/vendored-cookbooks/homebrew/metadata.rb +0 -10
- data/chef/vendored-cookbooks/homebrew/providers/tap.rb +0 -48
- data/chef/vendored-cookbooks/homebrew/recipes/default.rb +0 -46
- data/chef/vendored-cookbooks/homebrew/resources/tap.rb +0 -35
- data/lib/natives/app.rb +0 -71
- data/natives.gemspec +0 -125
- data/spec/natives/app_spec.rb +0 -153
@@ -1,48 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Joshua Timberman (<jtimberman@opscode.com>)
|
3
|
-
# Author:: Graeme Mathieson (<mathie@woss.name>)
|
4
|
-
# Cookbook Name:: homebrew
|
5
|
-
# Providers:: tap
|
6
|
-
#
|
7
|
-
# Copyright 2011-2013, Opscode, Inc.
|
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
|
-
def load_current_resource
|
23
|
-
@tap = Chef::Resource::HomebrewTap.new(new_resource.name)
|
24
|
-
tap_dir = @tap.name.gsub('/', '-')
|
25
|
-
|
26
|
-
Chef::Log.debug("Checking whether we've already tapped #{new_resource.name}")
|
27
|
-
if ::File.directory?("/usr/local/Library/Taps/#{tap_dir}")
|
28
|
-
@tap.tapped true
|
29
|
-
else
|
30
|
-
@tap.tapped false
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
action :tap do
|
35
|
-
unless @tap.tapped
|
36
|
-
execute "tapping #{new_resource.name}" do
|
37
|
-
command "/usr/local/bin/brew tap #{new_resource.name}"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
action :untap do
|
43
|
-
if @tap.tapped
|
44
|
-
execute "untapping #{new_resource.name}" do
|
45
|
-
command "/usr/local/bin/brew untap #{new_resource.name}"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Joshua Timberman (<jtimberman@opscode.com>)
|
3
|
-
# Author:: Graeme Mathieson (<mathie@woss.name>)
|
4
|
-
# Cookbook Name:: homebrew
|
5
|
-
# Recipes:: default
|
6
|
-
#
|
7
|
-
# Copyright 2011-2013, Opscode, Inc.
|
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
|
-
self.extend(Homebrew::Mixin)
|
23
|
-
|
24
|
-
homebrew_go = "#{Chef::Config[:file_cache_path]}/homebrew_go"
|
25
|
-
owner = homebrew_owner
|
26
|
-
|
27
|
-
Chef::Log.debug("Homebrew owner is '#{homebrew_owner}'")
|
28
|
-
|
29
|
-
remote_file homebrew_go do
|
30
|
-
source "https://raw.github.com/mxcl/homebrew/go"
|
31
|
-
mode 00755
|
32
|
-
end
|
33
|
-
|
34
|
-
execute homebrew_go do
|
35
|
-
user owner
|
36
|
-
not_if { ::File.exist? '/usr/local/bin/brew' }
|
37
|
-
end
|
38
|
-
|
39
|
-
package 'git' do
|
40
|
-
not_if "which git"
|
41
|
-
end
|
42
|
-
|
43
|
-
execute "update homebrew from github" do
|
44
|
-
user owner
|
45
|
-
command "/usr/local/bin/brew update || true"
|
46
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Joshua Timberman (<jtimberman@opscode.com>)
|
3
|
-
# Author:: Graeme Mathieson (<mathie@woss.name>)
|
4
|
-
# Cookbook Name:: homebrew
|
5
|
-
# Resources:: tap
|
6
|
-
#
|
7
|
-
# Copyright 2011-2013, Opscode, Inc.
|
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
|
-
actions :tap, :untap
|
23
|
-
attribute :name,
|
24
|
-
:name_attribute => true,
|
25
|
-
:kind_of => String,
|
26
|
-
:regex => /\w+(?:\/\w+)+/
|
27
|
-
|
28
|
-
attribute :tapped,
|
29
|
-
:kind_of => [TrueClass, FalseClass]
|
30
|
-
|
31
|
-
### hax for default action
|
32
|
-
def initialize( *args )
|
33
|
-
super
|
34
|
-
@action = :tap
|
35
|
-
end
|
data/lib/natives/app.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'tempfile'
|
2
|
-
require 'json'
|
3
|
-
require 'chef/application/solo'
|
4
|
-
|
5
|
-
module Natives
|
6
|
-
class App
|
7
|
-
def install(catalog_name, packages, configs={})
|
8
|
-
configs = default_configs.merge(configs || {})
|
9
|
-
why_run = configs.delete(:test_run){ false }
|
10
|
-
|
11
|
-
create_solo_json_tempfile(
|
12
|
-
catalog_name.to_s, Array(packages), configs
|
13
|
-
) do |attrs_file|
|
14
|
-
run_chef_solo(attrs_file, why_run)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def run_chef_solo(json_attrs_file, why_run=false)
|
19
|
-
ARGV.clear
|
20
|
-
[
|
21
|
-
'-c', File.join(gem_base_path, 'chef', 'solo.rb'),
|
22
|
-
'-o', 'natives',
|
23
|
-
'-j', json_attrs_file.to_path
|
24
|
-
].each do |token|
|
25
|
-
ARGV << token
|
26
|
-
end
|
27
|
-
|
28
|
-
ARGV << '-W' if why_run
|
29
|
-
|
30
|
-
Chef::Application::Solo.new.run
|
31
|
-
end
|
32
|
-
|
33
|
-
def create_solo_json_tempfile(catalog_name, packages, configs, &block)
|
34
|
-
file = Tempfile.new('natives.temp_attrs_file')
|
35
|
-
file.write(json_attrs(catalog_name, packages, configs))
|
36
|
-
file.flush
|
37
|
-
file.rewind
|
38
|
-
begin
|
39
|
-
block.call(file)
|
40
|
-
ensure
|
41
|
-
file.close!
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def default_configs
|
46
|
-
{
|
47
|
-
working_dir: current_working_dir
|
48
|
-
}
|
49
|
-
end
|
50
|
-
protected
|
51
|
-
|
52
|
-
def current_working_dir
|
53
|
-
Dir.pwd
|
54
|
-
end
|
55
|
-
|
56
|
-
def gem_base_path
|
57
|
-
File.absolute_path(File.join(File.dirname(__FILE__), '..', '..'))
|
58
|
-
end
|
59
|
-
|
60
|
-
def json_attrs(catalog_name, packages, configs)
|
61
|
-
{
|
62
|
-
"natives" => {
|
63
|
-
"install_list" => {
|
64
|
-
catalog_name => packages
|
65
|
-
},
|
66
|
-
"configs" => configs
|
67
|
-
}
|
68
|
-
}.to_json
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
data/natives.gemspec
DELETED
@@ -1,125 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: natives 0.4.1 ruby lib
|
6
|
-
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.name = "natives"
|
9
|
-
s.version = "0.4.1"
|
10
|
-
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
-
s.authors = ["Huiming Teo"]
|
13
|
-
s.date = "2013-11-06"
|
14
|
-
s.description = "Installs native library packages required by Ruby gems on different platforms, based on the catalog maintained by natives-catalog project."
|
15
|
-
s.email = "teohuiming@gmail.com"
|
16
|
-
s.executables = ["natives"]
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"LICENSE.txt",
|
19
|
-
"README.md"
|
20
|
-
]
|
21
|
-
s.files = [
|
22
|
-
".document",
|
23
|
-
".rspec",
|
24
|
-
"Gemfile",
|
25
|
-
"Gemfile.lock",
|
26
|
-
"LICENSE.txt",
|
27
|
-
"README.md",
|
28
|
-
"Rakefile",
|
29
|
-
"VERSION",
|
30
|
-
"bin/natives",
|
31
|
-
"chef/.kitchen.yml",
|
32
|
-
"chef/Berksfile",
|
33
|
-
"chef/Berksfile.lock",
|
34
|
-
"chef/cookbooks/natives/Berksfile",
|
35
|
-
"chef/cookbooks/natives/Gemfile",
|
36
|
-
"chef/cookbooks/natives/LICENSE",
|
37
|
-
"chef/cookbooks/natives/README.md",
|
38
|
-
"chef/cookbooks/natives/chefignore",
|
39
|
-
"chef/cookbooks/natives/libraries/natives_recipe_helper.rb",
|
40
|
-
"chef/cookbooks/natives/metadata.rb",
|
41
|
-
"chef/cookbooks/natives/recipes/default.rb",
|
42
|
-
"chef/solo.rb",
|
43
|
-
"chef/vendored-cookbooks/apt/CHANGELOG.md",
|
44
|
-
"chef/vendored-cookbooks/apt/README.md",
|
45
|
-
"chef/vendored-cookbooks/apt/attributes/default.rb",
|
46
|
-
"chef/vendored-cookbooks/apt/files/default/apt-proxy-v2.conf",
|
47
|
-
"chef/vendored-cookbooks/apt/libraries/helpers.rb",
|
48
|
-
"chef/vendored-cookbooks/apt/libraries/network.rb",
|
49
|
-
"chef/vendored-cookbooks/apt/metadata.json",
|
50
|
-
"chef/vendored-cookbooks/apt/metadata.rb",
|
51
|
-
"chef/vendored-cookbooks/apt/providers/preference.rb",
|
52
|
-
"chef/vendored-cookbooks/apt/providers/repository.rb",
|
53
|
-
"chef/vendored-cookbooks/apt/recipes/cacher-client.rb",
|
54
|
-
"chef/vendored-cookbooks/apt/recipes/cacher-ng.rb",
|
55
|
-
"chef/vendored-cookbooks/apt/recipes/default.rb",
|
56
|
-
"chef/vendored-cookbooks/apt/resources/preference.rb",
|
57
|
-
"chef/vendored-cookbooks/apt/resources/repository.rb",
|
58
|
-
"chef/vendored-cookbooks/apt/templates/debian-6.0/acng.conf.erb",
|
59
|
-
"chef/vendored-cookbooks/apt/templates/default/01proxy.erb",
|
60
|
-
"chef/vendored-cookbooks/apt/templates/default/acng.conf.erb",
|
61
|
-
"chef/vendored-cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb",
|
62
|
-
"chef/vendored-cookbooks/homebrew/CHANGELOG.md",
|
63
|
-
"chef/vendored-cookbooks/homebrew/README.md",
|
64
|
-
"chef/vendored-cookbooks/homebrew/attributes/default.rb",
|
65
|
-
"chef/vendored-cookbooks/homebrew/libraries/homebrew_mixin.rb",
|
66
|
-
"chef/vendored-cookbooks/homebrew/libraries/homebrew_package.rb",
|
67
|
-
"chef/vendored-cookbooks/homebrew/metadata.json",
|
68
|
-
"chef/vendored-cookbooks/homebrew/metadata.rb",
|
69
|
-
"chef/vendored-cookbooks/homebrew/providers/tap.rb",
|
70
|
-
"chef/vendored-cookbooks/homebrew/recipes/default.rb",
|
71
|
-
"chef/vendored-cookbooks/homebrew/resources/tap.rb",
|
72
|
-
"lib/natives.rb",
|
73
|
-
"lib/natives/app.rb",
|
74
|
-
"lib/natives/cli.rb",
|
75
|
-
"lib/natives/gemfile_viewer.rb",
|
76
|
-
"natives.gemspec",
|
77
|
-
"spec/fixtures/Gemfile.empty",
|
78
|
-
"spec/fixtures/Gemfile.empty.lock",
|
79
|
-
"spec/natives/app_spec.rb",
|
80
|
-
"spec/natives/gemfile_viewer_spec.rb",
|
81
|
-
"spec/spec_helper.rb"
|
82
|
-
]
|
83
|
-
s.homepage = "http://github.com/teohm/natives"
|
84
|
-
s.licenses = ["MIT"]
|
85
|
-
s.require_paths = ["lib"]
|
86
|
-
s.rubygems_version = "2.1.10"
|
87
|
-
s.summary = "Installs native library packages required by Ruby gems on your machine."
|
88
|
-
|
89
|
-
if s.respond_to? :specification_version then
|
90
|
-
s.specification_version = 4
|
91
|
-
|
92
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
93
|
-
s.add_runtime_dependency(%q<chef>, [">= 11.6.2"])
|
94
|
-
s.add_runtime_dependency(%q<natives-catalog>, [">= 0.3.4"])
|
95
|
-
s.add_runtime_dependency(%q<thor>, [">= 0"])
|
96
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
97
|
-
s.add_development_dependency(%q<yard>, [">= 0"])
|
98
|
-
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
99
|
-
s.add_development_dependency(%q<bundler>, [">= 0"])
|
100
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
101
|
-
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
102
|
-
else
|
103
|
-
s.add_dependency(%q<chef>, [">= 11.6.2"])
|
104
|
-
s.add_dependency(%q<natives-catalog>, [">= 0.3.4"])
|
105
|
-
s.add_dependency(%q<thor>, [">= 0"])
|
106
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
107
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
108
|
-
s.add_dependency(%q<rdoc>, [">= 0"])
|
109
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
110
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
111
|
-
s.add_dependency(%q<simplecov>, [">= 0"])
|
112
|
-
end
|
113
|
-
else
|
114
|
-
s.add_dependency(%q<chef>, [">= 11.6.2"])
|
115
|
-
s.add_dependency(%q<natives-catalog>, [">= 0.3.4"])
|
116
|
-
s.add_dependency(%q<thor>, [">= 0"])
|
117
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
118
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
119
|
-
s.add_dependency(%q<rdoc>, [">= 0"])
|
120
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
121
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
122
|
-
s.add_dependency(%q<simplecov>, [">= 0"])
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
data/spec/natives/app_spec.rb
DELETED
@@ -1,153 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'natives/app'
|
3
|
-
|
4
|
-
describe Natives::App do
|
5
|
-
describe "#install" do
|
6
|
-
let(:app) { Natives::App.new }
|
7
|
-
|
8
|
-
it "forces packages argument to be an Array" do
|
9
|
-
app.should_receive(:run_chef_solo)
|
10
|
-
app.should_receive(:create_solo_json_tempfile).
|
11
|
-
with("foo", [], app.default_configs).
|
12
|
-
and_call_original
|
13
|
-
|
14
|
-
app.install("foo", nil)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "forces catalog_name to be a String" do
|
18
|
-
app.should_receive(:run_chef_solo)
|
19
|
-
app.should_receive(:create_solo_json_tempfile).
|
20
|
-
with("", ['foo', 'bar'], app.default_configs).
|
21
|
-
and_call_original
|
22
|
-
|
23
|
-
app.install(nil, ['foo', 'bar'])
|
24
|
-
end
|
25
|
-
|
26
|
-
it "merges configs with default configs" do
|
27
|
-
app.should_receive(:run_chef_solo)
|
28
|
-
app.should_receive(:create_solo_json_tempfile).
|
29
|
-
with("foobar", ['foo', 'bar'], app.default_configs.merge({foo: false})).
|
30
|
-
and_call_original
|
31
|
-
|
32
|
-
app.install('foobar', ['foo', 'bar'], {foo: false})
|
33
|
-
end
|
34
|
-
|
35
|
-
it "treats nil configs as empty hash" do
|
36
|
-
app.should_receive(:run_chef_solo)
|
37
|
-
app.should_receive(:create_solo_json_tempfile).
|
38
|
-
with("foobar", ['foo', 'bar'], app.default_configs).
|
39
|
-
and_call_original
|
40
|
-
|
41
|
-
app.install('foobar', ['foo', 'bar'], nil)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "removes test_run flag from configs and use it when run Chef Solo" do
|
45
|
-
app.should_receive(:run_chef_solo).
|
46
|
-
with(anything, true)
|
47
|
-
app.should_receive(:create_solo_json_tempfile).
|
48
|
-
with("foobar", ['foo', 'bar'], app.default_configs).
|
49
|
-
and_call_original
|
50
|
-
|
51
|
-
app.install('foobar', ['foo', 'bar'], {test_run: true})
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "#create_solo_json_tempfile" do
|
56
|
-
let(:app) { Natives::App.new }
|
57
|
-
|
58
|
-
it "generates a valid solo.json file" do
|
59
|
-
json = nil
|
60
|
-
app.create_solo_json_tempfile(
|
61
|
-
'rubygems',
|
62
|
-
['foo', 'bar'],
|
63
|
-
{working_dir: '/path/to/working_dir'}) do |file|
|
64
|
-
json = JSON.parse(file.read)
|
65
|
-
end
|
66
|
-
expect(json).to eq({
|
67
|
-
"natives" => {
|
68
|
-
"install_list" => {
|
69
|
-
"rubygems" => ["foo", "bar"]
|
70
|
-
},
|
71
|
-
"configs" => {
|
72
|
-
"working_dir" => '/path/to/working_dir'
|
73
|
-
}
|
74
|
-
}
|
75
|
-
})
|
76
|
-
end
|
77
|
-
|
78
|
-
it "generates solo.json file based on the given catalog name" do
|
79
|
-
json = nil
|
80
|
-
app.create_solo_json_tempfile(
|
81
|
-
'npm', ['foo', 'bar'],
|
82
|
-
{working_dir: '/path/to/foo'}) do |file|
|
83
|
-
json = JSON.parse(file.read)
|
84
|
-
end
|
85
|
-
expect(json).to eq({
|
86
|
-
"natives" => {
|
87
|
-
"install_list" => {
|
88
|
-
"npm" => ["foo", "bar"]
|
89
|
-
},
|
90
|
-
"configs" => {
|
91
|
-
"working_dir" => '/path/to/foo'
|
92
|
-
}
|
93
|
-
}
|
94
|
-
})
|
95
|
-
end
|
96
|
-
|
97
|
-
it "handles empty package list" do
|
98
|
-
json = nil
|
99
|
-
app.create_solo_json_tempfile('rubygems', [], {}) do |file|
|
100
|
-
json = JSON.parse(file.read)
|
101
|
-
end
|
102
|
-
expect(json).to eq({
|
103
|
-
"natives" => {
|
104
|
-
"install_list" => {
|
105
|
-
"rubygems" => []
|
106
|
-
},
|
107
|
-
"configs" => {
|
108
|
-
}
|
109
|
-
|
110
|
-
}
|
111
|
-
})
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe "#run_chef_solo" do
|
116
|
-
let(:app) { Natives::App.new }
|
117
|
-
|
118
|
-
it "rewrites ARGV with Chef Solo options and run Chef Solo Application" do
|
119
|
-
attrs_file = double()
|
120
|
-
attrs_file.stub(:to_path) { '/path/to/attrs_file' }
|
121
|
-
Chef::Application::Solo.any_instance.should_receive(:run)
|
122
|
-
|
123
|
-
app.run_chef_solo(attrs_file)
|
124
|
-
|
125
|
-
expect(ARGV).to eq([
|
126
|
-
'-c',
|
127
|
-
File.absolute_path(File.join(
|
128
|
-
File.dirname(__FILE__), '..', '..', 'chef', 'solo.rb')),
|
129
|
-
'-o', 'natives',
|
130
|
-
'-j', '/path/to/attrs_file'
|
131
|
-
])
|
132
|
-
end
|
133
|
-
|
134
|
-
it "can turn on Chef's --why-run flag" do
|
135
|
-
attrs_file = double()
|
136
|
-
attrs_file.stub(:to_path) { '/path/to/attrs_file' }
|
137
|
-
Chef::Application::Solo.any_instance.should_receive(:run)
|
138
|
-
|
139
|
-
test_run = true
|
140
|
-
app.run_chef_solo(attrs_file, test_run)
|
141
|
-
|
142
|
-
expect(ARGV).to eq([
|
143
|
-
'-c',
|
144
|
-
File.absolute_path(File.join(
|
145
|
-
File.dirname(__FILE__), '..', '..', 'chef', 'solo.rb')),
|
146
|
-
'-o', 'natives',
|
147
|
-
'-j', '/path/to/attrs_file',
|
148
|
-
'-W'
|
149
|
-
])
|
150
|
-
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|