natives 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDI3ZTlkZGExYjdmZDNkZTMyZWFjMzA2NGE4Y2UyZmQyNmIyODEwZQ==
4
+ MTUzYTlmMWQzYTI2YjI4ZjcyZjdjOTc2MzI4MTczMjM4OTk0OWVjMQ==
5
5
  data.tar.gz: !binary |-
6
- MDNkZDgzYjFmYjhiMjY5NGJmNmI1NmEzZWVhNzgwZmM2ZmYxYjhhYg==
6
+ MzA4ZGI3ZGJiOTdjZWEzNDg3MDJmOTNhNjU1ZTQ3NzAwMDRiYTQ1ZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjJkNDRmOWM0N2RjNDViMTllOGFkODM0MTQ2OGY4ZWVkODk1MTNiZTI0MzY3
10
- NzZmNzdiOWVhZTIxMzM3ZjEwY2I0ODllZDU2MDk5MWUyMmJmMTdlYzNkMzJj
11
- NjU0MGMyNDI0ZDQxYWEwZDA4NGU4ZjkxYTFmMmVmZDdlMThjMzA=
9
+ N2ZmY2E3OGFiZTRkMmRlMjA1YTI5OGQ2YWQwZTc4YmIyOTgyYjk1NzNiMGNk
10
+ YmU5ZjUzYzMwNmJjZWM3YTI0MzFmMDRlOWY4Y2I3Mjk4OGY3NzI3ZWE5NDE4
11
+ NTRlYThiZmIxYjdjN2EzNzliNzk4ZDY0ZGQ2NzM5ZmM1Mzc5MzU=
12
12
  data.tar.gz: !binary |-
13
- ZGJkYzViMjljNjMzODIwZmI0YjhmYzM2M2U1NWZmN2Q5NjZkM2M4MmJiOWNl
14
- NmNmMjI5MTY1N2JkYzkyMWE0MTY1ZjgzNGNhNzEyZTE5ZWQwODdmNGQ4MzUz
15
- MjM4OWRhNWYzODVkZTNlNTg5YzMzZmU2Njg2YjVkNjk0ZGRjYzI=
13
+ MzE1NTIzZDYzNTIyYjExN2NlM2RlOThkMzk4YTFkY2VmNWUwZDc1NDA1ZWQy
14
+ MDBkZTNhYTY4MWFlMmVhYzllYTBmNWM3MTY4Yzk3MDE2MjU1MGUxNjIwZGFl
15
+ OGEwODdjMjUxNDBlMTM1ZTA0ZTA5YjIzYjFmZTQzNWNiY2FiYTI=
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # natives
2
+
3
+ Installs native library packages required by Ruby gems (normally with native extensions) on your machine.
4
+
5
+ It uses the [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.
6
+
7
+ ## Install
8
+
9
+ ```
10
+ gem install natives
11
+ ```
12
+
13
+ ## Run
14
+ ```
15
+ natives install curb capybara-webkit nokogiri sqlite3
16
+ ```
17
+ It will try to install native packages required by the following gems: curb, capybara-webkit, nokogiri, sqlite.
18
+
19
+ ### Multi-catalog support
20
+
21
+ ```
22
+ natives install --catalog npm sqlite3
23
+ ```
24
+ By default, it uses `rubygems` catalog, but it's easy to tell `natives` to use another catalog.
25
+
26
+ ## Catalogs
27
+
28
+ ### System-wide
29
+
30
+ By default, it uses [the catalog](https://github.com/teohm/natives-catalog/blob/master/catalogs/rubygems.yaml) shipped with [natives-catalog](https://github.com/teohm/natives-catalog) gem.
31
+
32
+ To update the catalogs:
33
+
34
+ ```
35
+ gem update natives-catalog
36
+ ```
37
+
38
+ ### Project-specific
39
+
40
+ It also looks for a `natives-catalog` directory in current working directory, and loads any YAML catalog files in the directory.
41
+
42
+
43
+
44
+ ## Contributing to natives
45
+
46
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
47
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
48
+ * Fork the project.
49
+ * Start a feature/bugfix branch.
50
+ * Commit and push until you are happy with your contribution.
51
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
52
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
53
+
54
+ ## Copyright
55
+
56
+ Copyright (c) 2013 Huiming Teo. See LICENSE.txt for
57
+ further details.
58
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.2.0
data/lib/natives/app.rb CHANGED
@@ -4,8 +4,8 @@ require 'chef/application/solo'
4
4
 
5
5
  module Natives
6
6
  class App
7
- def install(packages)
8
- create_tmp_attrs_file(Array(packages)) do |attrs_file|
7
+ def install(catalog_name, packages)
8
+ create_tmp_attrs_file(catalog_name.to_s, Array(packages)) do |attrs_file|
9
9
  run_chef_solo(attrs_file)
10
10
  end
11
11
  end
@@ -22,9 +22,9 @@ module Natives
22
22
  Chef::Application::Solo.new.run
23
23
  end
24
24
 
25
- def create_tmp_attrs_file(packages, &block)
25
+ def create_tmp_attrs_file(catalog_name, packages, &block)
26
26
  file = Tempfile.new('natives.temp_attrs_file')
27
- file.write(json_attrs(packages))
27
+ file.write(json_attrs(catalog_name, packages))
28
28
  file.flush
29
29
  file.rewind
30
30
  begin
@@ -44,11 +44,11 @@ module Natives
44
44
  File.absolute_path(File.join(File.dirname(__FILE__), '..', '..'))
45
45
  end
46
46
 
47
- def json_attrs(packages)
47
+ def json_attrs(catalog_name, packages)
48
48
  {
49
49
  "natives" => {
50
50
  "install_list" => {
51
- "rubygems" => packages
51
+ catalog_name => packages
52
52
  },
53
53
  "config" => {
54
54
  "working_dir" => current_working_dir
data/lib/natives/cli.rb CHANGED
@@ -4,8 +4,11 @@ require 'natives/app'
4
4
  module Natives
5
5
  class Cli < Thor
6
6
  desc 'install PACKAGE1 PACKAGE2 ..', 'install a list of ruby packages'
7
+ method_option :catalog, default: 'rubygems',
8
+ desc: 'set the catalog to be used',
9
+ aliases: '-c'
7
10
  def install(*packages)
8
- Natives::App.new.install(packages)
11
+ Natives::App.new.install options[:catalog], packages
9
12
  end
10
13
  end
11
14
  end
data/natives.gemspec CHANGED
@@ -2,11 +2,11 @@
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.1.3 ruby lib
5
+ # stub: natives 0.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "natives"
9
- s.version = "0.1.3"
9
+ s.version = "0.2.0"
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"]
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.executables = ["natives"]
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE.txt",
19
- "README.rdoc"
19
+ "README.md"
20
20
  ]
21
21
  s.files = [
22
22
  ".document",
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  "Gemfile",
25
25
  "Gemfile.lock",
26
26
  "LICENSE.txt",
27
- "README.rdoc",
27
+ "README.md",
28
28
  "Rakefile",
29
29
  "VERSION",
30
30
  "bin/natives",
@@ -7,18 +7,26 @@ describe Natives::App do
7
7
 
8
8
  it "forces packages argument to be an Array" do
9
9
  app.should_receive(:run_chef_solo)
10
- app.should_receive(:create_tmp_attrs_file).with([]).and_call_original
10
+ app.should_receive(:create_tmp_attrs_file).with("foo", []).and_call_original
11
+
12
+ app.install("foo", nil)
13
+ end
14
+
15
+ it "forces catalog_name to be a String" do
16
+ app.should_receive(:run_chef_solo)
17
+ app.should_receive(:create_tmp_attrs_file).with("", []).and_call_original
18
+
19
+ app.install(nil, nil)
11
20
 
12
- app.install(nil)
13
21
  end
14
22
  end
15
23
 
16
24
  describe "#create_tmp_attrs_file" do
17
25
  let(:app) { Natives::App.new }
18
26
 
19
- it "generates a valid Chef JSON attrs file" do
27
+ it "generates a valid solo.json file" do
20
28
  json = nil
21
- app.create_tmp_attrs_file(['foo', 'bar']) do |file|
29
+ app.create_tmp_attrs_file('rubygems', ['foo', 'bar']) do |file|
22
30
  json = JSON.parse(file.read)
23
31
  end
24
32
  expect(json).to eq({
@@ -33,9 +41,26 @@ describe Natives::App do
33
41
  })
34
42
  end
35
43
 
44
+ it "generates solo.json file based on the given catalog name" do
45
+ json = nil
46
+ app.create_tmp_attrs_file('npm', ['foo', 'bar']) do |file|
47
+ json = JSON.parse(file.read)
48
+ end
49
+ expect(json).to eq({
50
+ "natives" => {
51
+ "install_list" => {
52
+ "npm" => ["foo", "bar"]
53
+ },
54
+ "config" => {
55
+ "working_dir" => Dir.pwd
56
+ }
57
+ }
58
+ })
59
+ end
60
+
36
61
  it "handles empty package list" do
37
62
  json = nil
38
- app.create_tmp_attrs_file([]) do |file|
63
+ app.create_tmp_attrs_file('rubygems', []) do |file|
39
64
  json = JSON.parse(file.read)
40
65
  end
41
66
  expect(json).to eq({
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: natives
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: !binary |-
5
+ MC4yLjA=
5
6
  platform: ruby
6
7
  authors:
7
8
  - Huiming Teo
@@ -147,14 +148,14 @@ executables:
147
148
  extensions: []
148
149
  extra_rdoc_files:
149
150
  - LICENSE.txt
150
- - README.rdoc
151
+ - README.md
151
152
  files:
152
153
  - .document
153
154
  - .rspec
154
155
  - Gemfile
155
156
  - Gemfile.lock
156
157
  - LICENSE.txt
157
- - README.rdoc
158
+ - README.md
158
159
  - Rakefile
159
160
  - VERSION
160
161
  - bin/natives
data/README.rdoc DELETED
@@ -1,19 +0,0 @@
1
- = natives
2
-
3
- Description goes here.
4
-
5
- == Contributing to natives
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
- * Fork the project.
10
- * Start a feature/bugfix branch.
11
- * Commit and push until you are happy with your contribution.
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2013 Huiming Teo. See LICENSE.txt for
18
- further details.
19
-