natives-catalog 0.3.0 → 0.3.1

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
- YzM0MTQxY2QwN2VhZTZkODA3NmE3ZTU4ZTg0NjY2NjY3MWY4OGI0Mg==
4
+ N2ZkYTA1YWNkOTNkMjdhMWFmM2VmNmFmODc2ODk3MzJiN2Y5MGJkYg==
5
5
  data.tar.gz: !binary |-
6
- M2JiZjQ0MDJkOGQyMDgzNzQ3OTAzMDdmYjIwZmRiOGNmYTFlNmM1YQ==
6
+ NTljZDE2ZTkzYjg2YWUyNzYyZGFiOGNjYzZkZDQ0ZDlhMDg4YzU4Nw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWIwYjA0MDQ5N2ZiMmQxMTU4ZmE2OTFiNzkyYzI0NWFmZmZjYTQ5MTM2YzEy
10
- OThlNzVjMTg5NmU3MDQxYTQ0ZjRiMzJkYWMzMTBlMjk3ZjhkZWM4MDZkNTdh
11
- NjUxZTIyYmE5MWI3OWFhYjRlNDQ2NTc0MGY2NjM1OGMwYzlkMTQ=
9
+ ZmRiYjVhNDYxNTZiNTZkNWI2Y2Y0NmVhMzFhMDdiMjcxZjc2NmFmZmNjMTZh
10
+ OTk2YzY0MjY4MDlkMTg5MzQ0NTU1OTE1MzBiMDI1ZDgyOGFlN2VlNDdkOGUy
11
+ NzVhZGFlOTM4YzY2N2FkYzU3Y2Q1YzViMjdhMzViODE4ODY3ODQ=
12
12
  data.tar.gz: !binary |-
13
- ZTRjZDU5Yjk4MDJkMTkzODUzZDE2ZThmM2ZmMmE4MDU5ZDJlYzFhZTQ1OWMw
14
- NDVkZGRjNzkwYjE4ZTVjNWUxNTYxY2M2Y2RiMDliZjA4ZGY5MDg2ZTk1ZWQ5
15
- MTc4ZDQxODFhYTMzYjdjZDNmYWJkNjUwZTY0OTA1N2QxNWE0NWE=
13
+ ZThlYjM1ODEzMTZlMmNkYmQyNTAwMTJlNTc3NTQyYjM2OGM1M2JiMmQ3NGIz
14
+ YWY1ZjI5MWZmY2JiNjNkYmE4NTQ5ZTFiNDUyYmM5NGU2NGYyOTFjMGJmNmI1
15
+ YzlkNzU3YWRkYzJkOGUzZmQxZDYwZTZkNmE3M2NlMzA4MDk4MGM=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -6,26 +6,29 @@ module Natives
6
6
 
7
7
  CATALOG_PATH_IN_GEM = File.absolute_path(File.join(
8
8
  File.dirname(__FILE__), '..', '..', 'catalogs'))
9
- CATALOG_PATH_IN_WORKING_DIR = File.absolute_path(File.join('.', 'natives-catalogs'))
10
9
 
11
- CATALOG_PATHS = [
12
- CATALOG_PATH_IN_GEM,
13
- CATALOG_PATH_IN_WORKING_DIR
14
- ].freeze
10
+ WORKING_DIR_CATALOG_DIRNAME = 'natives-catalogs'
15
11
 
16
12
  attr_reader :platform, :platform_version, :package_provider, :name
17
13
 
18
- def initialize(catalog_name, platform, platform_version, package_provider)
19
- reload
14
+ def initialize(catalog_name,
15
+ platform, platform_version,
16
+ package_provider,
17
+ opts={})
20
18
 
21
19
  @name = catalog_name.to_s
22
20
  @platform = platform.to_s
23
21
  @platform_version = platform_version.to_s
24
22
  @package_provider = package_provider.to_s
23
+
24
+ @loader = opts.fetch(:loader, Loader.new)
25
+ @working_dir = opts.fetch(:working_dir, Dir.pwd)
26
+
27
+ reload
25
28
  end
26
29
 
27
30
  def reload
28
- @catalogs = Loader.new.load_from_paths(CATALOG_PATHS)
31
+ @catalogs = @loader.load_from_paths(catalog_paths)
29
32
  end
30
33
 
31
34
  def to_hash
@@ -40,5 +43,14 @@ module Natives
40
43
  packages.flatten.compact
41
44
  end
42
45
 
46
+ protected
47
+
48
+ def catalog_paths
49
+ [
50
+ CATALOG_PATH_IN_GEM,
51
+ File.absolute_path(File.join(@working_dir, WORKING_DIR_CATALOG_DIRNAME))
52
+ ]
53
+ end
54
+
43
55
  end
44
56
  end
@@ -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-catalog 0.3.0 ruby lib
5
+ # stub: natives-catalog 0.3.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "natives-catalog"
9
- s.version = "0.3.0"
9
+ s.version = "0.3.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-10-27"
13
+ s.date = "2013-11-04"
14
14
  s.description = "A catalog of native packages in different platforms required by ruby gems."
15
15
  s.email = "teohuiming@gmail.com"
16
16
  s.extra_rdoc_files = [
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
49
49
  s.homepage = "http://github.com/teohm/natives-catalog"
50
50
  s.licenses = ["MIT"]
51
51
  s.require_paths = ["lib"]
52
- s.rubygems_version = "2.1.9"
52
+ s.rubygems_version = "2.1.10"
53
53
  s.summary = "A catalog of native packages for ruby gems."
54
54
 
55
55
  if s.respond_to? :specification_version then
@@ -10,7 +10,10 @@ describe Natives::Catalog do
10
10
  end
11
11
 
12
12
  it "requires caller to provide platform and package provider details" do
13
- catalog = Natives::Catalog.new('rubygems', 'mac_os_x', '10.7.5', 'homebrew')
13
+ catalog = Natives::Catalog.new('rubygems',
14
+ 'mac_os_x', '10.7.5',
15
+ 'homebrew')
16
+
14
17
  expect(catalog.name).to eq('rubygems')
15
18
  expect(catalog.platform).to eq('mac_os_x')
16
19
  expect(catalog.platform_version).to eq('10.7.5')
@@ -20,18 +23,45 @@ describe Natives::Catalog do
20
23
 
21
24
  describe "#reload" do
22
25
  it "reloads catalogs from default catalog paths" do
23
- Natives::Catalog::Loader.any_instance.
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.
24
48
  should_receive(:load_from_paths).
25
- with(Natives::Catalog::CATALOG_PATHS).
49
+ with([
50
+ Natives::Catalog::CATALOG_PATH_IN_GEM,
51
+ '/path/to/working_dir/natives-catalogs'
52
+ ]).
26
53
  and_return({
27
54
  'rubygems' => {'foo' => {'key' => 'value'}},
28
55
  'npm' => {'bar' => {'key' => 'value'}}
29
56
  })
30
57
 
31
58
  catalog = Natives::Catalog.new('rubygems',
32
- 'mac_os_x', '10.7.5', 'homebrew')
59
+ 'mac_os_x', '10.7.5', 'homebrew',
60
+ loader: loader,
61
+ working_dir: '/path/to/working_dir')
33
62
 
34
63
  expect(catalog.to_hash).to eq({'foo' => {'key' => 'value'}})
64
+
35
65
  end
36
66
  end
37
67
 
@@ -39,7 +69,6 @@ describe Natives::Catalog do
39
69
  before do
40
70
  Natives::Catalog::Loader.any_instance.
41
71
  stub(:load_from_paths).
42
- with(Natives::Catalog::CATALOG_PATHS).
43
72
  and_return({
44
73
  'rubygems' => {'foo' => {'key' => 'value'}},
45
74
  'npm' => {'bar' => {'key' => 'value'}}
@@ -61,7 +90,6 @@ describe Natives::Catalog do
61
90
  before do
62
91
  Natives::Catalog::Loader.any_instance.
63
92
  stub(:load_from_paths).
64
- with(Natives::Catalog::CATALOG_PATHS).
65
93
  and_return({
66
94
  'rubygems' => {
67
95
  'nokogiri' => {
@@ -102,13 +130,4 @@ describe Natives::Catalog do
102
130
  end
103
131
  end
104
132
 
105
- describe "::CATALOG_PATHS" do
106
- it "contains the default catalog paths" do
107
- expect(Natives::Catalog::CATALOG_PATHS).to eq([
108
- Natives::Catalog::CATALOG_PATH_IN_GEM,
109
- Natives::Catalog::CATALOG_PATH_IN_WORKING_DIR
110
- ])
111
- end
112
- end
113
-
114
133
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: natives-catalog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: !binary |-
5
+ MC4zLjE=
5
6
  platform: ruby
6
7
  authors:
7
8
  - Huiming Teo
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-10-27 00:00:00.000000000 Z
12
+ date: 2013-11-04 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rspec
@@ -164,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
165
  version: '0'
165
166
  requirements: []
166
167
  rubyforge_project:
167
- rubygems_version: 2.1.9
168
+ rubygems_version: 2.1.10
168
169
  signing_key:
169
170
  specification_version: 4
170
171
  summary: A catalog of native packages for ruby gems.