natives 0.4.0 → 0.4.1
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/README.md +15 -1
- data/VERSION +1 -1
- data/lib/natives/app.rb +9 -6
- data/lib/natives/cli.rb +12 -1
- data/natives.gemspec +3 -3
- data/spec/natives/app_spec.rb +29 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWQ1ZWNjOWFlNTg3YThlOGZhZjE3ZmEzMWU2MmJlYWY5MzhhMzdiZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjE2ZWY5Y2IwMzI0NjljNGJkNzE1MmY0YTYzYTgyMWU3Y2FkOWE2OQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTZmYmE1YzRjNDNmMGJhM2Y3NWEzM2RhZGZjY2U0ZDNkZTM1M2U4ZDE2YmYz
|
10
|
+
ZTEzNzJlYTNjM2RhY2JiYjM3MzMwNjRmMGMzMWMyMDcyMWU2Zjg3NGVkY2Ux
|
11
|
+
MjE5YjBhODk4MWJkMmMyNWRiYzQyZmNhNjMyZmY1YjZjN2JjM2M=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmQwNzMxZjUxYmVhNjVkNjhjMjIyMzBiMDkzOWQwMWYwYzQxZTE4ZWUyM2Jh
|
14
|
+
YTY3ZDZmMWFhYWIyMTdkNDM4YmNhMmYwNWIzOGM3MGQxNjIwMjM1NTczZjU2
|
15
|
+
ODg1YWZkYTJlMjEyZTg5NmU5Zjg0MjkxZjI4MmQ0OWRhZWFhMmQ=
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# natives
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/natives)
|
4
|
+
[](https://codeclimate.com/github/teohm/natives)
|
5
|
+
|
3
6
|
Installs native library packages required by gems on your machine.
|
4
7
|
|
5
8
|
It lookups native packages from a [multi-platform catalog](https://github.com/teohm/natives-catalog/blob/master/catalogs/rubygems.yaml) maintained by [natives-catalog](https://github.com/teohm/natives-catalog) project.
|
@@ -18,10 +21,13 @@ It will lookup and install native packages (e.g. curl, qt, sqlite) required by t
|
|
18
21
|
|
19
22
|
|
20
23
|
### Have a Gemfile?
|
21
|
-
If
|
24
|
+
If your working directory has a Gemfile, `natives install` will automatically use gems specified in the Gemfile.
|
22
25
|
|
23
26
|
```
|
24
27
|
natives install
|
28
|
+
natives # run 'install' task by default
|
29
|
+
|
30
|
+
natives install --gemfile=Gemfile.special
|
25
31
|
natives install --gemfile=path/to/Gemfile.special
|
26
32
|
```
|
27
33
|
|
@@ -32,6 +38,14 @@ natives install --catalog npm sqlite3
|
|
32
38
|
```
|
33
39
|
By default, it uses `rubygems` catalog, but it's easy to tell `natives` to use another catalog.
|
34
40
|
|
41
|
+
### Misc
|
42
|
+
|
43
|
+
```
|
44
|
+
natives install --test-run # run without installing native packages
|
45
|
+
natives install --update-provider # update homebrew/apt-get repo first
|
46
|
+
natives help
|
47
|
+
```
|
48
|
+
|
35
49
|
## Catalogs
|
36
50
|
|
37
51
|
### System-wide
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.1
|
data/lib/natives/app.rb
CHANGED
@@ -5,17 +5,17 @@ require 'chef/application/solo'
|
|
5
5
|
module Natives
|
6
6
|
class App
|
7
7
|
def install(catalog_name, packages, configs={})
|
8
|
-
|
9
|
-
|
10
|
-
Array(packages),
|
11
|
-
default_configs.merge(configs || {})
|
8
|
+
configs = default_configs.merge(configs || {})
|
9
|
+
why_run = configs.delete(:test_run){ false }
|
12
10
|
|
11
|
+
create_solo_json_tempfile(
|
12
|
+
catalog_name.to_s, Array(packages), configs
|
13
13
|
) do |attrs_file|
|
14
|
-
run_chef_solo(attrs_file)
|
14
|
+
run_chef_solo(attrs_file, why_run)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def run_chef_solo(json_attrs_file)
|
18
|
+
def run_chef_solo(json_attrs_file, why_run=false)
|
19
19
|
ARGV.clear
|
20
20
|
[
|
21
21
|
'-c', File.join(gem_base_path, 'chef', 'solo.rb'),
|
@@ -24,6 +24,9 @@ module Natives
|
|
24
24
|
].each do |token|
|
25
25
|
ARGV << token
|
26
26
|
end
|
27
|
+
|
28
|
+
ARGV << '-W' if why_run
|
29
|
+
|
27
30
|
Chef::Application::Solo.new.run
|
28
31
|
end
|
29
32
|
|
data/lib/natives/cli.rb
CHANGED
@@ -6,6 +6,11 @@ module Natives
|
|
6
6
|
class Cli < Thor
|
7
7
|
default_task :install
|
8
8
|
|
9
|
+
desc 'version', 'print the version number'
|
10
|
+
def version
|
11
|
+
puts IO.read('VERSION')
|
12
|
+
end
|
13
|
+
|
9
14
|
desc 'install [ENTRY1 ENTRY2 ..]',
|
10
15
|
'install native packages required by the catalog entries'
|
11
16
|
|
@@ -19,10 +24,16 @@ module Natives
|
|
19
24
|
aliases: '-u',
|
20
25
|
desc: "update package provider's repo (eg. apt-get update)"
|
21
26
|
|
27
|
+
method_option :"test-run", type: 'boolean',
|
28
|
+
default: false,
|
29
|
+
aliases: %w(-t --dry-run),
|
30
|
+
desc: "run without actually installing native packages"
|
31
|
+
|
22
32
|
def install(*packages)
|
23
33
|
catalog = options[:catalog]
|
24
34
|
configs = {
|
25
|
-
update_provider: options['update-provider']
|
35
|
+
update_provider: options['update-provider'],
|
36
|
+
test_run: options['test-run']
|
26
37
|
}
|
27
38
|
if catalog == 'rubygems' && packages.empty?
|
28
39
|
packages = packages_in_gemfile(options[:gemfile])
|
data/natives.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: natives 0.4.
|
5
|
+
# stub: natives 0.4.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "natives"
|
9
|
-
s.version = "0.4.
|
9
|
+
s.version = "0.4.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["Huiming Teo"]
|
13
|
-
s.date = "2013-11-
|
13
|
+
s.date = "2013-11-06"
|
14
14
|
s.description = "Installs native library packages required by Ruby gems on different platforms, based on the catalog maintained by natives-catalog project."
|
15
15
|
s.email = "teohuiming@gmail.com"
|
16
16
|
s.executables = ["natives"]
|
data/spec/natives/app_spec.rb
CHANGED
@@ -40,6 +40,16 @@ describe Natives::App do
|
|
40
40
|
|
41
41
|
app.install('foobar', ['foo', 'bar'], nil)
|
42
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
|
43
53
|
end
|
44
54
|
|
45
55
|
describe "#create_solo_json_tempfile" do
|
@@ -108,7 +118,6 @@ describe Natives::App do
|
|
108
118
|
it "rewrites ARGV with Chef Solo options and run Chef Solo Application" do
|
109
119
|
attrs_file = double()
|
110
120
|
attrs_file.stub(:to_path) { '/path/to/attrs_file' }
|
111
|
-
|
112
121
|
Chef::Application::Solo.any_instance.should_receive(:run)
|
113
122
|
|
114
123
|
app.run_chef_solo(attrs_file)
|
@@ -121,5 +130,24 @@ describe Natives::App do
|
|
121
130
|
'-j', '/path/to/attrs_file'
|
122
131
|
])
|
123
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
|
124
152
|
end
|
125
153
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: natives
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
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-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|