natives 0.4.1 → 0.5.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 +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
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'natives/catalog/selector'
|
3
|
+
|
4
|
+
describe Natives::Catalog::Selector do
|
5
|
+
describe "#new" do
|
6
|
+
|
7
|
+
describe "assert valid platform hash" do
|
8
|
+
it "raises error if platform hash is not a hash" do
|
9
|
+
expect {
|
10
|
+
Natives::Catalog::Selector.new(nil)
|
11
|
+
}.to raise_error(ArgumentError, "catalog entry should be a hash")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "raises error when found an invalid string as hash key" do
|
15
|
+
expect {
|
16
|
+
Natives::Catalog::Selector.new({
|
17
|
+
"mac_os_x/homebrew" => {"default" => "value"},
|
18
|
+
"ubuntu" => {"default" => "value"},
|
19
|
+
"debian" => {"default" => "value"}
|
20
|
+
})
|
21
|
+
}.to raise_error ArgumentError, /Found an invalid key: "ubuntu"/
|
22
|
+
end
|
23
|
+
|
24
|
+
it "raises error when found an invalid array as hash key" do
|
25
|
+
expect {
|
26
|
+
Natives::Catalog::Selector.new({
|
27
|
+
["fedora/yum", "redhat/yum"] => {"default" => "value"},
|
28
|
+
["centos/yum", "oracle"] => {"default" => "value"},
|
29
|
+
})
|
30
|
+
}.to raise_error ArgumentError, /Found an invalid key: "oracle"/
|
31
|
+
end
|
32
|
+
|
33
|
+
it "raises error if platform hash's value is not a hash" do
|
34
|
+
expect {
|
35
|
+
Natives::Catalog::Selector.new({
|
36
|
+
"ubuntu/apt" => "value",
|
37
|
+
"mac_os_x/homebrew" => {"default" => "value"},
|
38
|
+
})
|
39
|
+
}.to raise_error ArgumentError, /Found an invalid value: "value"/
|
40
|
+
end
|
41
|
+
|
42
|
+
it "accepts default platform value" do
|
43
|
+
expect {
|
44
|
+
Natives::Catalog::Selector.new({
|
45
|
+
"default" => "value"
|
46
|
+
})
|
47
|
+
}.not_to raise_error
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "normalize platform hash" do
|
52
|
+
class ProxySelector < Natives::Catalog::Selector
|
53
|
+
def normalized_values
|
54
|
+
@values
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it "expand platform array" do
|
59
|
+
expect(ProxySelector.new({
|
60
|
+
"mac_os_x/homebrew" => {"default" => "value1"},
|
61
|
+
["ubuntu/apt", "debian/apt"] => {"default" => "value2"}
|
62
|
+
}).normalized_values).to eq({
|
63
|
+
"mac_os_x/homebrew" => {"default" => "value1"},
|
64
|
+
"ubuntu/apt" => {"default" => "value2"},
|
65
|
+
"debian/apt" => {"default" => "value2"}
|
66
|
+
})
|
67
|
+
end
|
68
|
+
|
69
|
+
it "expand version array" do
|
70
|
+
expect(ProxySelector.new({
|
71
|
+
"mac_os_x/homebrew" => {
|
72
|
+
"default" => "value1",
|
73
|
+
["v1", "v2"] => "value2"
|
74
|
+
}
|
75
|
+
}).normalized_values).to eq({
|
76
|
+
"mac_os_x/homebrew" => {
|
77
|
+
"default" => "value1",
|
78
|
+
"v1" => "value2",
|
79
|
+
"v2" => "value2"
|
80
|
+
}
|
81
|
+
})
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#value_for" do
|
87
|
+
it "returns the default value when the platform/package_provider doesn't match" do
|
88
|
+
expect(
|
89
|
+
Natives::Catalog::Selector.new({
|
90
|
+
"ubuntu/apt" => {"default" => "libcurl"},
|
91
|
+
"default" => "curl"
|
92
|
+
}).value_for('mac_os_x', '10.7.5', 'homebrew')
|
93
|
+
).to eq('curl')
|
94
|
+
end
|
95
|
+
|
96
|
+
it "returns a value for a specific platform version" do
|
97
|
+
expect(
|
98
|
+
Natives::Catalog::Selector.new({
|
99
|
+
["mac_os_x/homebrew", "mac_os_x/macports"] => {
|
100
|
+
"10.7.5" => "curl", "default" => "foo"},
|
101
|
+
"default" => "bar"
|
102
|
+
}).value_for('mac_os_x', '10.7.5', 'homebrew')
|
103
|
+
).to eq('curl')
|
104
|
+
end
|
105
|
+
|
106
|
+
it "returns a platform-default value if the platform version doesn't match an explicit one" do
|
107
|
+
expect(
|
108
|
+
Natives::Catalog::Selector.new({
|
109
|
+
"mac_os_x/homebrew" => {
|
110
|
+
"10.7.5" => "curl", "default" => "foo"},
|
111
|
+
"default" => "bar"
|
112
|
+
}).value_for('mac_os_x', '10.8.0', 'homebrew')
|
113
|
+
).to eq('foo')
|
114
|
+
end
|
115
|
+
|
116
|
+
it "returns nil if there is no default and no platforms match" do
|
117
|
+
expect(
|
118
|
+
Natives::Catalog::Selector.new({
|
119
|
+
["mac_os_x/homebrew", "mac_os_x/macports"] => {"10.7.5" => "curl"}
|
120
|
+
}).value_for('mac_os_x', '10.8.0', 'homebrew')
|
121
|
+
).to be_nil
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'natives/catalog/validator'
|
3
|
+
|
4
|
+
describe Natives::Catalog::Validator do
|
5
|
+
|
6
|
+
describe "#ensure_valid_catalog_groups" do
|
7
|
+
let(:validator) { Natives::Catalog::Validator.new }
|
8
|
+
|
9
|
+
it "ensures catalog groups is a hash" do
|
10
|
+
expect {
|
11
|
+
validator.ensure_valid_catalog_groups({"rubygems" => {} })
|
12
|
+
}.not_to raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
it "raises error if catalog groups is not a hash" do
|
16
|
+
expect {
|
17
|
+
validator.ensure_valid_catalog_groups([])
|
18
|
+
}.to raise_error ArgumentError
|
19
|
+
end
|
20
|
+
|
21
|
+
it "allows catalog groups to be empty" do
|
22
|
+
expect {
|
23
|
+
validator.ensure_valid_catalog_groups({})
|
24
|
+
}.not_to raise_error
|
25
|
+
end
|
26
|
+
|
27
|
+
it "ensures each catalog group's value is a hash" do
|
28
|
+
expect {
|
29
|
+
validator.ensure_valid_catalog_groups({"rubygems" => {"a" => "b"} })
|
30
|
+
}.not_to raise_error
|
31
|
+
end
|
32
|
+
|
33
|
+
it "raises error if any catalog group's value is not a hash" do
|
34
|
+
expect {
|
35
|
+
validator.ensure_valid_catalog_groups({
|
36
|
+
"rubygems" => {},
|
37
|
+
"npm" => nil,
|
38
|
+
"foo" => []
|
39
|
+
})
|
40
|
+
}.to raise_error(ArgumentError,
|
41
|
+
"The following catalog group(s) should be a Hash: npm, foo")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'natives/catalog'
|
3
|
+
|
4
|
+
describe Natives::Catalog do
|
5
|
+
|
6
|
+
describe "#new" do
|
7
|
+
it "loads catalogs" do
|
8
|
+
Natives::Catalog.any_instance.should_receive(:reload)
|
9
|
+
Natives::Catalog.new('rubygems', 'mac_os_x', '10.7.5', 'homebrew')
|
10
|
+
end
|
11
|
+
|
12
|
+
it "requires caller to provide platform and package provider details" do
|
13
|
+
catalog = Natives::Catalog.new('rubygems',
|
14
|
+
'mac_os_x', '10.7.5',
|
15
|
+
'homebrew')
|
16
|
+
|
17
|
+
expect(catalog.name).to eq('rubygems')
|
18
|
+
expect(catalog.platform).to eq('mac_os_x')
|
19
|
+
expect(catalog.platform_version).to eq('10.7.5')
|
20
|
+
expect(catalog.package_provider).to eq('homebrew')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#reload" do
|
25
|
+
it "reloads catalogs from default catalog paths" do
|
26
|
+
loader = double()
|
27
|
+
loader.
|
28
|
+
should_receive(:load_from_paths).
|
29
|
+
with([
|
30
|
+
Natives::Catalog::CATALOG_PATH_IN_GEM,
|
31
|
+
File.absolute_path(File.join(Dir.pwd, 'natives-catalogs'))
|
32
|
+
]).
|
33
|
+
and_return({
|
34
|
+
'rubygems' => {'foo' => {'key' => 'value'}},
|
35
|
+
'npm' => {'bar' => {'key' => 'value'}}
|
36
|
+
})
|
37
|
+
|
38
|
+
catalog = Natives::Catalog.new('rubygems',
|
39
|
+
'mac_os_x', '10.7.5', 'homebrew',
|
40
|
+
loader: loader)
|
41
|
+
|
42
|
+
expect(catalog.to_hash).to eq({'foo' => {'key' => 'value'}})
|
43
|
+
end
|
44
|
+
|
45
|
+
it "reloads catalogs from given working directory" do
|
46
|
+
loader = double()
|
47
|
+
loader.
|
48
|
+
should_receive(:load_from_paths).
|
49
|
+
with([
|
50
|
+
Natives::Catalog::CATALOG_PATH_IN_GEM,
|
51
|
+
'/path/to/working_dir/natives-catalogs'
|
52
|
+
]).
|
53
|
+
and_return({
|
54
|
+
'rubygems' => {'foo' => {'key' => 'value'}},
|
55
|
+
'npm' => {'bar' => {'key' => 'value'}}
|
56
|
+
})
|
57
|
+
|
58
|
+
catalog = Natives::Catalog.new('rubygems',
|
59
|
+
'mac_os_x', '10.7.5', 'homebrew',
|
60
|
+
loader: loader,
|
61
|
+
working_dir: '/path/to/working_dir')
|
62
|
+
|
63
|
+
expect(catalog.to_hash).to eq({'foo' => {'key' => 'value'}})
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#to_hash" do
|
69
|
+
before do
|
70
|
+
Natives::Catalog::Loader.any_instance.
|
71
|
+
stub(:load_from_paths).
|
72
|
+
and_return({
|
73
|
+
'rubygems' => {'foo' => {'key' => 'value'}},
|
74
|
+
'npm' => {'bar' => {'key' => 'value'}}
|
75
|
+
})
|
76
|
+
end
|
77
|
+
|
78
|
+
it "returns catalog hash of the specified catalog name" do
|
79
|
+
catalog = Natives::Catalog.new("npm", nil, nil, nil)
|
80
|
+
expect(catalog.to_hash).to eq({'bar' => {'key' => 'value'}})
|
81
|
+
end
|
82
|
+
|
83
|
+
it "returns empty hash if the sepcified catalog not found" do
|
84
|
+
catalog = Natives::Catalog.new("notfound", nil, nil, nil)
|
85
|
+
expect(catalog.to_hash).to eq({})
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#native_packages_for" do
|
90
|
+
before do
|
91
|
+
Natives::Catalog::Loader.any_instance.
|
92
|
+
stub(:load_from_paths).
|
93
|
+
and_return({
|
94
|
+
'rubygems' => {
|
95
|
+
'nokogiri' => {
|
96
|
+
'ubuntu/apt' => {
|
97
|
+
'13.10' => 'value1',
|
98
|
+
'default' => 'value2'
|
99
|
+
}
|
100
|
+
},
|
101
|
+
'curb' => {
|
102
|
+
'ubuntu/apt' => {
|
103
|
+
'default' => 'value3'
|
104
|
+
}
|
105
|
+
}
|
106
|
+
},
|
107
|
+
})
|
108
|
+
end
|
109
|
+
|
110
|
+
it "returns native packages for the given catalog entry name" do
|
111
|
+
catalog = Natives::Catalog.new(:rubygems, 'ubuntu', '13.10', 'apt')
|
112
|
+
expect(catalog.native_packages_for('nokogiri')).to eq(['value1'])
|
113
|
+
end
|
114
|
+
|
115
|
+
it "returns empty list if the given catalog entry name does not exist" do
|
116
|
+
catalog = Natives::Catalog.new(:rubygems, 'ubuntu', '13.10', 'apt')
|
117
|
+
expect(catalog.native_packages_for('notfound')).to eq([])
|
118
|
+
end
|
119
|
+
|
120
|
+
it "return native packages for the given catalog entry name list" do
|
121
|
+
catalog = Natives::Catalog.new(:rubygems, 'ubuntu', '13.10', 'apt')
|
122
|
+
expect(catalog.native_packages_for(
|
123
|
+
'nokogiri', 'notfound', 'curb')).to eq(['value1', 'value3'])
|
124
|
+
end
|
125
|
+
|
126
|
+
it "return native packages for the given catalog entry name array" do
|
127
|
+
catalog = Natives::Catalog.new(:rubygems, 'ubuntu', '13.10', 'apt')
|
128
|
+
expect(catalog.native_packages_for(
|
129
|
+
['nokogiri', 'notfound', 'curb'])).to eq(['value1', 'value3'])
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
@@ -4,14 +4,14 @@ require 'natives/gemfile_viewer'
|
|
4
4
|
describe Natives::GemfileViewer do
|
5
5
|
describe "#packages" do
|
6
6
|
it "list all gems specified in gemfile" do
|
7
|
-
gemfile_path = "
|
7
|
+
gemfile_path = File.join(fixture_path, "Gemfile.empty")
|
8
8
|
gemfile = Natives::GemfileViewer.new(gemfile_path)
|
9
|
-
expect(gemfile.
|
9
|
+
expect(gemfile.gem_names).to eq(['bundler'])
|
10
10
|
end
|
11
11
|
|
12
12
|
it "raises error when failed to list gems in gemfile" do
|
13
13
|
gemfile = Natives::GemfileViewer.new("gemfile_not_exist")
|
14
|
-
expect { gemfile.
|
14
|
+
expect { gemfile.gem_names }.to raise_error
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'natives/host_detection/package_provider'
|
3
|
+
|
4
|
+
describe Natives::HostDetection::PackageProvider do
|
5
|
+
it "detects host's package provider name" do
|
6
|
+
platform = double()
|
7
|
+
platform.should_receive(:name).and_return('ubuntu')
|
8
|
+
|
9
|
+
package_provider = Natives::HostDetection::PackageProvider.new(platform)
|
10
|
+
|
11
|
+
expect(package_provider.name).to eq('apt')
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns first package provider that exists in host" do
|
15
|
+
platform = double()
|
16
|
+
package_provider = Natives::HostDetection::PackageProvider.new(platform)
|
17
|
+
platform.should_receive(:name).and_return('mac_os_x')
|
18
|
+
package_provider.should_receive(:which).with('brew').and_return(nil)
|
19
|
+
package_provider.should_receive(:which).
|
20
|
+
with('port').and_return('/path/to/port')
|
21
|
+
|
22
|
+
expect(package_provider.name).to eq('macports')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns nil when detection fails" do
|
26
|
+
platform = double()
|
27
|
+
platform.should_receive(:name).and_return('unknown')
|
28
|
+
|
29
|
+
package_provider = Natives::HostDetection::PackageProvider.new(platform)
|
30
|
+
|
31
|
+
expect(package_provider.name).to be_nil
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'natives/host_detection/platform'
|
3
|
+
|
4
|
+
describe Natives::HostDetection::Platform do
|
5
|
+
let(:platform) { Natives::HostDetection::Platform.new }
|
6
|
+
|
7
|
+
it "detects platform name" do
|
8
|
+
platform.should_receive(:ohai_hash).and_return({platform: 'ubuntu'})
|
9
|
+
expect(platform.name).to eq('ubuntu')
|
10
|
+
end
|
11
|
+
|
12
|
+
it "detects platform version" do
|
13
|
+
platform.should_receive(:ohai_hash).
|
14
|
+
and_return({platform_version: '12'})
|
15
|
+
expect(platform.version).to eq('12')
|
16
|
+
end
|
17
|
+
|
18
|
+
it "uses Ohai" do
|
19
|
+
expect(platform.ohai_hash).to be_kind_of Ohai::System
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'natives/host_detection'
|
3
|
+
|
4
|
+
describe Natives::HostDetection do
|
5
|
+
it "detects host's platform" do
|
6
|
+
detect_platform = double()
|
7
|
+
detect_platform.stub(:name).and_return('foobar')
|
8
|
+
detect = Natives::HostDetection.new(
|
9
|
+
detect_package_provider: nil,
|
10
|
+
detect_platform: detect_platform)
|
11
|
+
|
12
|
+
expect(detect.platform).to eq('foobar')
|
13
|
+
end
|
14
|
+
|
15
|
+
it "detects host's platform version" do
|
16
|
+
detect_platform = double()
|
17
|
+
detect_platform.stub(:version).and_return('1')
|
18
|
+
detect = Natives::HostDetection.new(
|
19
|
+
detect_package_provider: nil,
|
20
|
+
detect_platform: detect_platform)
|
21
|
+
|
22
|
+
expect(detect.platform_version).to eq('1')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "detects host's package provider" do
|
26
|
+
detect_package_provider = Natives::HostDetection::PackageProvider.new(
|
27
|
+
double())
|
28
|
+
detect_package_provider.stub(:name).and_return('yummy')
|
29
|
+
detect = Natives::HostDetection.new(
|
30
|
+
detect_platform: nil,
|
31
|
+
detect_package_provider: detect_package_provider)
|
32
|
+
|
33
|
+
expect(detect.package_provider).to eq('yummy')
|
34
|
+
end
|
35
|
+
|
36
|
+
it "uses Platform and PackagePacker by default" do
|
37
|
+
Natives::HostDetection::Platform.should_receive(:new).
|
38
|
+
and_return('foo')
|
39
|
+
Natives::HostDetection::PackageProvider.should_receive(:new).
|
40
|
+
with('foo')
|
41
|
+
|
42
|
+
Natives::HostDetection.new
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,27 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
3
|
require 'rspec'
|
4
|
-
|
4
|
+
|
5
|
+
if ENV['COVERAGE']
|
6
|
+
require 'simplecov'
|
7
|
+
SimpleCov.start
|
8
|
+
end
|
5
9
|
|
6
10
|
# Requires supporting files with custom matchers and macros, etc,
|
7
11
|
# in ./support/ and its subdirectories.
|
8
12
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
13
|
|
14
|
+
module Natives
|
15
|
+
module FixtureSupport
|
16
|
+
def fixture_path
|
17
|
+
RSpec.configuration.fixture_path
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
10
22
|
RSpec.configure do |config|
|
11
|
-
|
23
|
+
config.add_setting :fixture_path
|
24
|
+
config.fixture_path = File.join(File.dirname(__FILE__), 'fixtures')
|
25
|
+
|
26
|
+
config.include Natives::FixtureSupport
|
12
27
|
end
|
metadata
CHANGED
@@ -1,55 +1,51 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: natives
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Huiming Teo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: ohai
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
MTEuNi4y
|
19
|
+
version: '0'
|
21
20
|
type: :runtime
|
22
21
|
prerelease: false
|
23
22
|
version_requirements: !ruby/object:Gem::Requirement
|
24
23
|
requirements:
|
25
24
|
- - ! '>='
|
26
25
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
28
|
-
MTEuNi4y
|
26
|
+
version: '0'
|
29
27
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
28
|
+
name: thor
|
31
29
|
requirement: !ruby/object:Gem::Requirement
|
32
30
|
requirements:
|
33
31
|
- - ! '>='
|
34
32
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
36
|
-
MC4zLjQ=
|
33
|
+
version: '0'
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - ! '>='
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
44
|
-
MC4zLjQ=
|
40
|
+
version: '0'
|
45
41
|
- !ruby/object:Gem::Dependency
|
46
|
-
name:
|
42
|
+
name: rspec
|
47
43
|
requirement: !ruby/object:Gem::Requirement
|
48
44
|
requirements:
|
49
45
|
- - ! '>='
|
50
46
|
- !ruby/object:Gem::Version
|
51
47
|
version: '0'
|
52
|
-
type: :
|
48
|
+
type: :development
|
53
49
|
prerelease: false
|
54
50
|
version_requirements: !ruby/object:Gem::Requirement
|
55
51
|
requirements:
|
@@ -57,7 +53,7 @@ dependencies:
|
|
57
53
|
- !ruby/object:Gem::Version
|
58
54
|
version: '0'
|
59
55
|
- !ruby/object:Gem::Dependency
|
60
|
-
name:
|
56
|
+
name: yard
|
61
57
|
requirement: !ruby/object:Gem::Requirement
|
62
58
|
requirements:
|
63
59
|
- - ! '>='
|
@@ -71,7 +67,7 @@ dependencies:
|
|
71
67
|
- !ruby/object:Gem::Version
|
72
68
|
version: '0'
|
73
69
|
- !ruby/object:Gem::Dependency
|
74
|
-
name:
|
70
|
+
name: rdoc
|
75
71
|
requirement: !ruby/object:Gem::Requirement
|
76
72
|
requirements:
|
77
73
|
- - ! '>='
|
@@ -85,7 +81,7 @@ dependencies:
|
|
85
81
|
- !ruby/object:Gem::Version
|
86
82
|
version: '0'
|
87
83
|
- !ruby/object:Gem::Dependency
|
88
|
-
name:
|
84
|
+
name: bundler
|
89
85
|
requirement: !ruby/object:Gem::Requirement
|
90
86
|
requirements:
|
91
87
|
- - ! '>='
|
@@ -99,7 +95,7 @@ dependencies:
|
|
99
95
|
- !ruby/object:Gem::Version
|
100
96
|
version: '0'
|
101
97
|
- !ruby/object:Gem::Dependency
|
102
|
-
name:
|
98
|
+
name: jeweler
|
103
99
|
requirement: !ruby/object:Gem::Requirement
|
104
100
|
requirements:
|
105
101
|
- - ! '>='
|
@@ -113,7 +109,7 @@ dependencies:
|
|
113
109
|
- !ruby/object:Gem::Version
|
114
110
|
version: '0'
|
115
111
|
- !ruby/object:Gem::Dependency
|
116
|
-
name:
|
112
|
+
name: debugger
|
117
113
|
requirement: !ruby/object:Gem::Requirement
|
118
114
|
requirements:
|
119
115
|
- - ! '>='
|
@@ -140,8 +136,7 @@ dependencies:
|
|
140
136
|
- - ! '>='
|
141
137
|
- !ruby/object:Gem::Version
|
142
138
|
version: '0'
|
143
|
-
description:
|
144
|
-
based on the catalog maintained by natives-catalog project.
|
139
|
+
description: Lookup native package dependencies required by gems.
|
145
140
|
email: teohuiming@gmail.com
|
146
141
|
executables:
|
147
142
|
- natives
|
@@ -159,56 +154,39 @@ files:
|
|
159
154
|
- Rakefile
|
160
155
|
- VERSION
|
161
156
|
- bin/natives
|
162
|
-
-
|
163
|
-
- chef/Berksfile
|
164
|
-
- chef/Berksfile.lock
|
165
|
-
- chef/cookbooks/natives/Berksfile
|
166
|
-
- chef/cookbooks/natives/Gemfile
|
167
|
-
- chef/cookbooks/natives/LICENSE
|
168
|
-
- chef/cookbooks/natives/README.md
|
169
|
-
- chef/cookbooks/natives/chefignore
|
170
|
-
- chef/cookbooks/natives/libraries/natives_recipe_helper.rb
|
171
|
-
- chef/cookbooks/natives/metadata.rb
|
172
|
-
- chef/cookbooks/natives/recipes/default.rb
|
173
|
-
- chef/solo.rb
|
174
|
-
- chef/vendored-cookbooks/apt/CHANGELOG.md
|
175
|
-
- chef/vendored-cookbooks/apt/README.md
|
176
|
-
- chef/vendored-cookbooks/apt/attributes/default.rb
|
177
|
-
- chef/vendored-cookbooks/apt/files/default/apt-proxy-v2.conf
|
178
|
-
- chef/vendored-cookbooks/apt/libraries/helpers.rb
|
179
|
-
- chef/vendored-cookbooks/apt/libraries/network.rb
|
180
|
-
- chef/vendored-cookbooks/apt/metadata.json
|
181
|
-
- chef/vendored-cookbooks/apt/metadata.rb
|
182
|
-
- chef/vendored-cookbooks/apt/providers/preference.rb
|
183
|
-
- chef/vendored-cookbooks/apt/providers/repository.rb
|
184
|
-
- chef/vendored-cookbooks/apt/recipes/cacher-client.rb
|
185
|
-
- chef/vendored-cookbooks/apt/recipes/cacher-ng.rb
|
186
|
-
- chef/vendored-cookbooks/apt/recipes/default.rb
|
187
|
-
- chef/vendored-cookbooks/apt/resources/preference.rb
|
188
|
-
- chef/vendored-cookbooks/apt/resources/repository.rb
|
189
|
-
- chef/vendored-cookbooks/apt/templates/debian-6.0/acng.conf.erb
|
190
|
-
- chef/vendored-cookbooks/apt/templates/default/01proxy.erb
|
191
|
-
- chef/vendored-cookbooks/apt/templates/default/acng.conf.erb
|
192
|
-
- chef/vendored-cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb
|
193
|
-
- chef/vendored-cookbooks/homebrew/CHANGELOG.md
|
194
|
-
- chef/vendored-cookbooks/homebrew/README.md
|
195
|
-
- chef/vendored-cookbooks/homebrew/attributes/default.rb
|
196
|
-
- chef/vendored-cookbooks/homebrew/libraries/homebrew_mixin.rb
|
197
|
-
- chef/vendored-cookbooks/homebrew/libraries/homebrew_package.rb
|
198
|
-
- chef/vendored-cookbooks/homebrew/metadata.json
|
199
|
-
- chef/vendored-cookbooks/homebrew/metadata.rb
|
200
|
-
- chef/vendored-cookbooks/homebrew/providers/tap.rb
|
201
|
-
- chef/vendored-cookbooks/homebrew/recipes/default.rb
|
202
|
-
- chef/vendored-cookbooks/homebrew/resources/tap.rb
|
157
|
+
- catalogs/rubygems.yaml
|
203
158
|
- lib/natives.rb
|
204
|
-
- lib/natives/
|
159
|
+
- lib/natives/apps.rb
|
160
|
+
- lib/natives/apps/detect.rb
|
161
|
+
- lib/natives/apps/list.rb
|
162
|
+
- lib/natives/catalog.rb
|
163
|
+
- lib/natives/catalog/loader.rb
|
164
|
+
- lib/natives/catalog/merger.rb
|
165
|
+
- lib/natives/catalog/selector.rb
|
166
|
+
- lib/natives/catalog/validator.rb
|
205
167
|
- lib/natives/cli.rb
|
206
168
|
- lib/natives/gemfile_viewer.rb
|
207
|
-
- natives.
|
169
|
+
- lib/natives/host_detection.rb
|
170
|
+
- lib/natives/host_detection/package_provider.rb
|
171
|
+
- lib/natives/host_detection/platform.rb
|
208
172
|
- spec/fixtures/Gemfile.empty
|
209
173
|
- spec/fixtures/Gemfile.empty.lock
|
210
|
-
- spec/
|
174
|
+
- spec/fixtures/dir_with_matching_files/invalid1.yml
|
175
|
+
- spec/fixtures/dir_with_matching_files/not_matching.json
|
176
|
+
- spec/fixtures/dir_with_matching_files/valid1.yaml
|
177
|
+
- spec/fixtures/dir_with_matching_files/valid2.yml
|
178
|
+
- spec/fixtures/dir_without_matching_file/not_matching.json
|
179
|
+
- spec/natives/apps/detect_spec.rb
|
180
|
+
- spec/natives/apps/list_spec.rb
|
181
|
+
- spec/natives/catalog/loader_spec.rb
|
182
|
+
- spec/natives/catalog/merger_spec.rb
|
183
|
+
- spec/natives/catalog/selector_spec.rb
|
184
|
+
- spec/natives/catalog/validator_spec.rb
|
185
|
+
- spec/natives/catalog_spec.rb
|
211
186
|
- spec/natives/gemfile_viewer_spec.rb
|
187
|
+
- spec/natives/host_detection/package_provider_spec.rb
|
188
|
+
- spec/natives/host_detection/platform_spec.rb
|
189
|
+
- spec/natives/host_detection_spec.rb
|
212
190
|
- spec/spec_helper.rb
|
213
191
|
homepage: http://github.com/teohm/natives
|
214
192
|
licenses:
|
@@ -233,5 +211,5 @@ rubyforge_project:
|
|
233
211
|
rubygems_version: 2.1.10
|
234
212
|
signing_key:
|
235
213
|
specification_version: 4
|
236
|
-
summary:
|
214
|
+
summary: Lookup native packages required by gems.
|
237
215
|
test_files: []
|