natives 0.2.2 → 0.3.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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGQ5NjE4YjhlOGE3Y2E1YWZiMGVlYzZmMDM2OWQyNGQzNzZmZTQwMw==
4
+ NjQ4ZmU0MzcyMTQyNjVjMzZmOGIxNzk3ZTU5YjcyOGU1ZTdhNGFlMg==
5
5
  data.tar.gz: !binary |-
6
- ZDZmODY4MDI0MThiMmFmMGQyOTcwNmYxMTcwMDk5NjJjMTgzZjAyMg==
6
+ NWQ2NzcyOWM3ZjQ3ODExMzU2MzQzM2M2YzA0YWQ4MTE0Y2Q0NTYyNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmNiYWZjMTZhZjcxY2NkMmY4NmFkMGJjODE0MzMxY2E0MDg3MGVmN2Y3YmFl
10
- OThlZjUzZGJmMmQ2ZTI1MjczMjljNjczNmQwMTY1ZTFjYzA2NWE1NmM2OTAx
11
- NWIwZWQ2ODQyMmM0OTYzZGJmNGNhNzA3Y2E5NDZkM2JmMTIxNjM=
9
+ NTIzNzllZWNlYzI5OGJjZTIxOTRjNjBjNmQ1YTliMjJlNjRhZjlmZDk1ZjE1
10
+ NjU5OTJmMzBlMWQ0YTJmMmM5YmExOGRkOTVjODRhNWVmNzAxYWY0OWU4MWEz
11
+ OTRhM2ExYWI4ZmNhZjJlMGRiOTA1YzgzOTVkYzI5NmI0MjAyZWE=
12
12
  data.tar.gz: !binary |-
13
- MjkzMWFiMzIzMjkzOTk1NjhmODUzMjEzMDYwYjdiZWFiYWRkNTY5ZTAzMGIw
14
- YTVlZDljNDc3OGZlNzFiZDNiMzhlMWEwZTcwZGY5NmM3NmFjM2RhZWY0NDQ1
15
- ZjFkYTMzOGM4MTAxNzZkMTVjNTE1YWY5ZTVhYmVjMzhkMmU1ZDg=
13
+ ZjNkYTFkNDU5OWU1MGQ3ZGEwZWQ0ZmNkZGM5ODJkMzQ4ODdkZjlkZDdiMzZm
14
+ YWRlOWI2MGFlMjA3MzRiNzZhOWIxNzc4MTFhYmVkYjUyOGY1OTAwZWIwZTMy
15
+ YTBkNzRmNGIxYjZiMzUzYmIwNDY5ZDkwNGE3YWE3YzUyYzYwNjk=
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
 
4
4
  gem "chef", ">= 11.6.2"
5
- gem "natives-catalog", ">= 0.3.2"
5
+ gem "natives-catalog", ">= 0.3.4"
6
6
  gem "thor"
7
7
 
8
8
  # Add dependencies to develop your gem here.
data/Gemfile.lock CHANGED
@@ -69,7 +69,7 @@ GEM
69
69
  multi_json (1.8.2)
70
70
  multi_xml (0.5.5)
71
71
  multipart-post (1.2.0)
72
- natives-catalog (0.3.2)
72
+ natives-catalog (0.3.4)
73
73
  net-ssh (2.7.0)
74
74
  net-ssh-gateway (1.2.0)
75
75
  net-ssh (>= 2.6.5)
@@ -129,7 +129,7 @@ DEPENDENCIES
129
129
  bundler
130
130
  chef (>= 11.6.2)
131
131
  jeweler
132
- natives-catalog (>= 0.3.2)
132
+ natives-catalog (>= 0.3.4)
133
133
  rdoc
134
134
  rspec
135
135
  simplecov
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # natives
2
2
 
3
- Installs native library packages required by Ruby gems (normally with native extensions) on your machine.
3
+ Installs native library packages required by gems on your machine.
4
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.
5
+ 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.
6
6
 
7
7
  ## Install
8
8
 
@@ -10,13 +10,22 @@ It uses the [multi-platform catalog](https://github.com/teohm/natives-catalog/bl
10
10
  gem install natives
11
11
  ```
12
12
 
13
- ## Run
14
- ```
13
+ ## Use
14
+ ```
15
15
  natives install curb capybara-webkit nokogiri sqlite3
16
16
  ```
17
- It will try to install native packages required by the following gems: curb, capybara-webkit, nokogiri, sqlite.
17
+ It will lookup and install native packages (e.g. curl, qt, sqlite) required by the following gems: curb, capybara-webkit, nokogiri, sqlite3.
18
+
18
19
 
19
- ### Multi-catalog support
20
+ ### Have a Gemfile?
21
+ If current working directory has a Gemfile, `natives install` will automatically use the gems specified in the Gemfile.
22
+
23
+ ```
24
+ natives install
25
+ natives install --gemfile=path/to/Gemfile.special
26
+ ```
27
+
28
+ ### Switch catalog
20
29
 
21
30
  ```
22
31
  natives install --catalog npm sqlite3
@@ -37,8 +46,7 @@ gem update natives-catalog
37
46
 
38
47
  ### Project-specific
39
48
 
40
- It also looks for a `natives-catalog` directory in current working directory, and loads any YAML catalog files in the directory.
41
-
49
+ It also looks for a `natives-catalog/` directory in current working directory, and loads any YAML catalog files in the directory.
42
50
 
43
51
 
44
52
  ## Contributing to natives
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.3.0
data/bin/natives CHANGED
@@ -1,4 +1,5 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env ruby -W0
2
+ # encoding: UTF-8
2
3
 
3
4
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
5
 
data/lib/natives/cli.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'thor'
2
2
  require 'natives/app'
3
+ require 'natives/gemfile_viewer'
3
4
 
4
5
  module Natives
5
6
  class Cli < Thor
@@ -7,8 +8,24 @@ module Natives
7
8
  method_option :catalog, default: 'rubygems',
8
9
  desc: 'set the catalog to be used',
9
10
  aliases: '-c'
11
+ method_option :gemfile, default: 'Gemfile'
10
12
  def install(*packages)
11
- Natives::App.new.install options[:catalog], packages
13
+ catalog = options[:catalog]
14
+
15
+ if catalog == 'rubygems' && packages.empty?
16
+ packages = packages_in_gemfile(options[:gemfile])
17
+ end
18
+
19
+ puts "Catalog: #{catalog.inspect}\nPackages:\n#{packages.inspect}\n\n"
20
+
21
+ Natives::App.new.install catalog, packages
12
22
  end
23
+
24
+ protected
25
+
26
+ def packages_in_gemfile(gemfile_path)
27
+ Natives::GemfileViewer.new(gemfile_path).packages
28
+ end
29
+
13
30
  end
14
31
  end
@@ -0,0 +1,35 @@
1
+
2
+ module Natives
3
+ class GemfileViewer
4
+ def initialize(gemfile_path)
5
+ @gemfile_path = gemfile_path
6
+ end
7
+
8
+ def packages
9
+ begin
10
+ # After several trial-and-error, this works:
11
+ # 1. cd to the dir containing the gemfile
12
+ # 2. after that run bundle show
13
+ gemfile_dir = File.expand_path(File.dirname(@gemfile_path))
14
+ gemfile_name = File.basename(@gemfile_path)
15
+ output = %x{cd '#{gemfile_dir}' && BUNDLE_GEMFILE=#{gemfile_name} bundle show 2>&1}
16
+ success = ($?.exitstatus == 0)
17
+ unless success
18
+ raise "Failed to list packages in Gemfile: #{@gemfile_path.inspect}\nReason:\n#{output}"
19
+ end
20
+ end
21
+ extract_packages(output)
22
+ end
23
+
24
+ protected
25
+
26
+ def extract_packages(output)
27
+ lines = output.split("\n")
28
+ lines.shift # remove first line
29
+ lines.map do |line|
30
+ _, name, _ = line.split(" ")
31
+ name
32
+ end
33
+ end
34
+ end
35
+ end
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.2.2 ruby lib
5
+ # stub: natives 0.3.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "natives"
9
- s.version = "0.2.2"
9
+ s.version = "0.3.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"]
13
- s.date = "2013-11-04"
13
+ s.date = "2013-11-05"
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"]
@@ -72,8 +72,12 @@ Gem::Specification.new do |s|
72
72
  "lib/natives.rb",
73
73
  "lib/natives/app.rb",
74
74
  "lib/natives/cli.rb",
75
+ "lib/natives/gemfile_viewer.rb",
75
76
  "natives.gemspec",
77
+ "spec/fixtures/Gemfile.empty",
78
+ "spec/fixtures/Gemfile.empty.lock",
76
79
  "spec/natives/app_spec.rb",
80
+ "spec/natives/gemfile_viewer_spec.rb",
77
81
  "spec/spec_helper.rb"
78
82
  ]
79
83
  s.homepage = "http://github.com/teohm/natives"
@@ -87,7 +91,7 @@ Gem::Specification.new do |s|
87
91
 
88
92
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
89
93
  s.add_runtime_dependency(%q<chef>, [">= 11.6.2"])
90
- s.add_runtime_dependency(%q<natives-catalog>, [">= 0.3.2"])
94
+ s.add_runtime_dependency(%q<natives-catalog>, [">= 0.3.4"])
91
95
  s.add_runtime_dependency(%q<thor>, [">= 0"])
92
96
  s.add_development_dependency(%q<rspec>, [">= 0"])
93
97
  s.add_development_dependency(%q<yard>, [">= 0"])
@@ -97,7 +101,7 @@ Gem::Specification.new do |s|
97
101
  s.add_development_dependency(%q<simplecov>, [">= 0"])
98
102
  else
99
103
  s.add_dependency(%q<chef>, [">= 11.6.2"])
100
- s.add_dependency(%q<natives-catalog>, [">= 0.3.2"])
104
+ s.add_dependency(%q<natives-catalog>, [">= 0.3.4"])
101
105
  s.add_dependency(%q<thor>, [">= 0"])
102
106
  s.add_dependency(%q<rspec>, [">= 0"])
103
107
  s.add_dependency(%q<yard>, [">= 0"])
@@ -108,7 +112,7 @@ Gem::Specification.new do |s|
108
112
  end
109
113
  else
110
114
  s.add_dependency(%q<chef>, [">= 11.6.2"])
111
- s.add_dependency(%q<natives-catalog>, [">= 0.3.2"])
115
+ s.add_dependency(%q<natives-catalog>, [">= 0.3.4"])
112
116
  s.add_dependency(%q<thor>, [">= 0"])
113
117
  s.add_dependency(%q<rspec>, [">= 0"])
114
118
  s.add_dependency(%q<yard>, [">= 0"])
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+
@@ -0,0 +1,8 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+
5
+ PLATFORMS
6
+ ruby
7
+
8
+ DEPENDENCIES
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+ require 'natives/gemfile_viewer'
3
+
4
+ describe Natives::GemfileViewer do
5
+ describe "#packages" do
6
+ it "list all gems specified in gemfile" do
7
+ gemfile_path = "spec/fixtures/Gemfile.empty"
8
+ gemfile = Natives::GemfileViewer.new(gemfile_path)
9
+ expect(gemfile.packages).to eq(['bundler'])
10
+ end
11
+
12
+ it "raises error when failed to list gems in gemfile" do
13
+ gemfile = Natives::GemfileViewer.new("gemfile_not_exist")
14
+ expect { gemfile.packages }.to raise_error
15
+ end
16
+ end
17
+ 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.2.2
4
+ version: 0.3.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-04 00:00:00.000000000 Z
11
+ date: 2013-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef
@@ -33,7 +33,7 @@ dependencies:
33
33
  - - ! '>='
34
34
  - !ruby/object:Gem::Version
35
35
  version: !binary |-
36
- MC4zLjI=
36
+ MC4zLjQ=
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -41,7 +41,7 @@ dependencies:
41
41
  - - ! '>='
42
42
  - !ruby/object:Gem::Version
43
43
  version: !binary |-
44
- MC4zLjI=
44
+ MC4zLjQ=
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: thor
47
47
  requirement: !ruby/object:Gem::Requirement
@@ -203,8 +203,12 @@ files:
203
203
  - lib/natives.rb
204
204
  - lib/natives/app.rb
205
205
  - lib/natives/cli.rb
206
+ - lib/natives/gemfile_viewer.rb
206
207
  - natives.gemspec
208
+ - spec/fixtures/Gemfile.empty
209
+ - spec/fixtures/Gemfile.empty.lock
207
210
  - spec/natives/app_spec.rb
211
+ - spec/natives/gemfile_viewer_spec.rb
208
212
  - spec/spec_helper.rb
209
213
  homepage: http://github.com/teohm/natives
210
214
  licenses: