natives 0.5.2 → 0.5.3

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
- MjdhYzVkMjU3YmYzMDRmNzIwMWMyOGVmNTZhYjM3ZGQ4ODdhNmQ5MA==
4
+ NGJiYWNiZGIzY2JkMjQzNzQyNmY0NDdmYjQ5M2Y0YWNhMjVlNTJjNg==
5
5
  data.tar.gz: !binary |-
6
- MmVhMGEzZjVkOGU2ODJmZTExOTU3ODlmZWI3MDhjZGFmZTUwZDAzMg==
6
+ MmExZGFlMGEzNjcxNTlkNDAxNjc1Y2ZkMzk0ZTk0NzFiY2FmOTZjNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZmY3ZmJjMmYzYjU2OWMzNjhhMjE3NWU3MTU2Y2NmOTlmNDUzNmJhNWFlMGNj
10
- Y2ZkNzU2NmIxOGE3MjgzMjhlYTg1OTkxMzhkY2I0ZDc4MzI1ZGJiYTgzNzkx
11
- ZmU0YTZlMDE1NGJiNjljOWVmMzkwNDNhNWY4MDdlOWNhOGMxNTU=
9
+ NDJiMTNiZjg0MWRmNWJmMjc0YTkyMWE2ZDdmOTM1YmExYzU0ZGJhMTAzOWM3
10
+ NjQyYTE1OWRkN2NjZGMxNTU0NWY4MzA1NDQ4MGQ1OTNlYzliNTFmMzAwNjk4
11
+ MTBjNjcyZjVhZmVjNzI3ZTdkOTE1Yzk3MWM4NWJlNDczNzg5Mzg=
12
12
  data.tar.gz: !binary |-
13
- NGM0Zjc0OTQzNTFhMzlhZDQ3YzVjZjEyNDMxNjY4ODAzMWQ4ZWE4YmRjMDIz
14
- YWE5ZjNmMmQ0MzE5ZTJjNjIyMjkyYzE2NjkyMTIzOGZiYjc2MzEzZGFmNWQ2
15
- OGZkNmNmYTg0OGJhZWNkYTUwNGRmOTYzNmU5Njc4ZTNjMzEzN2Y=
13
+ Nzg0ZjBmYjZmYjJiMzAwODUzNTZmODk1ZWIyN2M4MWI3NmVhODMyM2Y5YjZh
14
+ NjJhNTBkYjBhNzExMDlkOGMwMzEyNTljZGIzNDIyMTQ0MTQ3ZWI4ZjU0MzVm
15
+ MWQyZjc5MzY3OWVkMTExMTA2ZTY2Mjc5YjJiYjc1NjU1YzAwMmY=
data/Gemfile CHANGED
@@ -2,6 +2,7 @@ source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  gem "ohai"
4
4
  gem "thor"
5
+ gem "bundler"
5
6
 
6
7
  # Add dependencies to develop your gem here.
7
8
  # Include everything needed to run rake, tests, features, etc.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.2
1
+ 0.5.3
@@ -1,38 +1,16 @@
1
+ require 'bundler'
2
+
1
3
  module Natives
2
4
  class GemfileViewer
3
5
  def initialize(gemfile_path)
4
6
  @gemfile_path = gemfile_path
7
+ @lockfile_path = "#{gemfile_path}.lock"
5
8
  end
6
9
 
7
10
  def gem_names
8
- extract_gem_names(bundle_list(@gemfile_path))
11
+ lockfile = Bundler::LockfileParser.new(Bundler.read_file(@lockfile_path))
12
+ lockfile.specs.map(&:name)
9
13
  end
10
14
 
11
- protected
12
-
13
- def bundle_list(gemfile_path)
14
- # after trial-and-error, these steps work best:
15
- # 1. cd to dir containing the gemfile
16
- # 2. bundle list
17
- dir = File.expand_path(File.dirname(@gemfile_path))
18
- filename = File.basename(@gemfile_path)
19
- output = %x{cd '#{dir}' && BUNDLE_GEMFILE=#{filename} bundle list 2>&1}
20
- successful_run = ($?.exitstatus == 0)
21
-
22
- unless successful_run
23
- raise "Cannot list gems in gemfile #{@gemfile_path.inspect}: #{output}"
24
- end
25
-
26
- output
27
- end
28
-
29
- def extract_gem_names(output)
30
- lines = output.split("\n")
31
- lines.shift # remove first line
32
- lines.map do |line|
33
- _, name, _ = line.split(" ")
34
- name
35
- end
36
- end
37
15
  end
38
16
  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.5.2 ruby lib
5
+ # stub: natives 0.5.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "natives"
9
- s.version = "0.5.2"
9
+ s.version = "0.5.3"
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-09"
13
+ s.date = "2013-11-11"
14
14
  s.description = "Lookup native package dependencies required by gems on your machine."
15
15
  s.email = "teohuiming@gmail.com"
16
16
  s.executables = ["natives"]
@@ -53,6 +53,9 @@ Gem::Specification.new do |s|
53
53
  "natives.gemspec",
54
54
  "spec/fixtures/Gemfile.empty",
55
55
  "spec/fixtures/Gemfile.empty.lock",
56
+ "spec/fixtures/Gemfile.no_lockfile",
57
+ "spec/fixtures/Gemfile.with_lockfile",
58
+ "spec/fixtures/Gemfile.with_lockfile.lock",
56
59
  "spec/fixtures/dir_with_matching_files/invalid1.yml",
57
60
  "spec/fixtures/dir_with_matching_files/not_matching.json",
58
61
  "spec/fixtures/dir_with_matching_files/valid1.yaml",
@@ -83,6 +86,7 @@ Gem::Specification.new do |s|
83
86
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
84
87
  s.add_runtime_dependency(%q<ohai>, [">= 0"])
85
88
  s.add_runtime_dependency(%q<thor>, [">= 0"])
89
+ s.add_runtime_dependency(%q<bundler>, [">= 0"])
86
90
  s.add_development_dependency(%q<rspec>, [">= 0"])
87
91
  s.add_development_dependency(%q<yard>, [">= 0"])
88
92
  s.add_development_dependency(%q<rdoc>, [">= 0"])
@@ -93,6 +97,7 @@ Gem::Specification.new do |s|
93
97
  else
94
98
  s.add_dependency(%q<ohai>, [">= 0"])
95
99
  s.add_dependency(%q<thor>, [">= 0"])
100
+ s.add_dependency(%q<bundler>, [">= 0"])
96
101
  s.add_dependency(%q<rspec>, [">= 0"])
97
102
  s.add_dependency(%q<yard>, [">= 0"])
98
103
  s.add_dependency(%q<rdoc>, [">= 0"])
@@ -104,6 +109,7 @@ Gem::Specification.new do |s|
104
109
  else
105
110
  s.add_dependency(%q<ohai>, [">= 0"])
106
111
  s.add_dependency(%q<thor>, [">= 0"])
112
+ s.add_dependency(%q<bundler>, [">= 0"])
107
113
  s.add_dependency(%q<rspec>, [">= 0"])
108
114
  s.add_dependency(%q<yard>, [">= 0"])
109
115
  s.add_dependency(%q<rdoc>, [">= 0"])
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "bundler"
4
+ gem "curb"
5
+
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "bundler"
4
+ gem "curb"
@@ -0,0 +1,11 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ curb (0.8.5)
5
+
6
+ PLATFORMS
7
+ ruby
8
+
9
+ DEPENDENCIES
10
+ bundler
11
+ curb
@@ -4,9 +4,16 @@ 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 = File.join(fixture_path, "Gemfile.empty")
7
+ gemfile_path = File.join(fixture_path, "Gemfile.with_lockfile")
8
8
  gemfile = Natives::GemfileViewer.new(gemfile_path)
9
- expect(gemfile.gem_names).to eq(['bundler'])
9
+ expect(gemfile.gem_names).to eq(['curb'])
10
+ # not sure why 'bundler' gem is always excluded from the list
11
+ end
12
+
13
+ it "raises error when gemfile does not have lockfile" do
14
+ gemfile_path = File.join(fixture_path, "Gemfile.no_lockfile")
15
+ gemfile = Natives::GemfileViewer.new(gemfile_path)
16
+ expect { gemfile.gem_names }.to raise_error
10
17
  end
11
18
 
12
19
  it "raises error when failed to list gems in gemfile" do
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.5.2
4
+ version: 0.5.3
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-09 00:00:00.000000000 Z
11
+ date: 2013-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ohai
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -179,6 +193,9 @@ files:
179
193
  - natives.gemspec
180
194
  - spec/fixtures/Gemfile.empty
181
195
  - spec/fixtures/Gemfile.empty.lock
196
+ - spec/fixtures/Gemfile.no_lockfile
197
+ - spec/fixtures/Gemfile.with_lockfile
198
+ - spec/fixtures/Gemfile.with_lockfile.lock
182
199
  - spec/fixtures/dir_with_matching_files/invalid1.yml
183
200
  - spec/fixtures/dir_with_matching_files/not_matching.json
184
201
  - spec/fixtures/dir_with_matching_files/valid1.yaml