cookbook-omnifetch 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed71a5a2de183598b020865f4c09f5442e15ee13
4
- data.tar.gz: 05911931abea5ef8742300be91f55bdffff9bd73
3
+ metadata.gz: cbe64ce071a948e6ca39a7108ddcda0f4553468d
4
+ data.tar.gz: 95cd67b5df43e5455b2043fb3580729536f0657b
5
5
  SHA512:
6
- metadata.gz: ae1de192ff0125bfd70e08addaf18e14fe081e92cc85e13a0c07b6e3c9f0cc4aa25b390c3bececf72177a74dc4076a8b0d145c07c15cf8716f7ae156b875e02d
7
- data.tar.gz: 8624065514fa015f4d2e292ebea63215715848a1c188e8dd00e46291cbd4bb68e0e512430575b8844a65cd26fb9d9ecde5a189bee6219eeb439a5808365dd0b2
6
+ metadata.gz: 7566665f88a9b007bdfe46cfddca79c5180020940653ce3876f1a1307c6dcb27a39d4afddd78eee0e71178d7572e6b941466c7b72430226967c9f5be3e3dece8
7
+ data.tar.gz: 2219631bec691166948b54add95c5b52164e1f1c6d8b974ab9dae9586616385f7fa420d49300cdbac8100e96582b49fb20531b533d82a83b01176c7bf1cf1f7c
@@ -124,7 +124,7 @@ module CookbookOmnifetch
124
124
  # @return [Class, nil]
125
125
  def klass_from_options(options)
126
126
  options.each do |key, _|
127
- id = key.to_s.capitalize
127
+ id = key.to_s.split("_").map(&:capitalize).join
128
128
 
129
129
  begin
130
130
  return CookbookOmnifetch.const_get("#{id}Location")
@@ -30,15 +30,16 @@ module CookbookOmnifetch
30
30
  end
31
31
  end
32
32
 
33
- class ChefserverLocation < BaseLocation
33
+ class ChefServerLocation < BaseLocation
34
34
 
35
35
  attr_reader :cookbook_version
36
+ attr_reader :uri
36
37
 
37
38
  def initialize(dependency, options = {})
38
39
  super
39
40
  @cookbook_version = options[:version]
40
41
  @http_client = options[:http_client]
41
- @uri ||= options[:artifactserver]
42
+ @uri ||= options[:chef_server]
42
43
  end
43
44
 
44
45
  def repo_host
@@ -83,6 +84,10 @@ module CookbookOmnifetch
83
84
  @install_path ||= CookbookOmnifetch.storage_path.join(cache_key)
84
85
  end
85
86
 
87
+ def lock_data
88
+ { "chef_server" => uri, "version" => cookbook_version }
89
+ end
90
+
86
91
  def cache_key
87
92
  "#{dependency.name}-#{cookbook_version}"
88
93
  end
@@ -1,3 +1,3 @@
1
1
  module CookbookOmnifetch
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -19,7 +19,7 @@ module CookbookOmnifetch
19
19
  end
20
20
  end
21
21
 
22
- describe ChefserverLocation do
22
+ describe ChefServerLocation do
23
23
 
24
24
  let(:http_client) { double("Http Client") }
25
25
 
@@ -38,10 +38,12 @@ module CookbookOmnifetch
38
38
  let(:cookbook_name) { "example" }
39
39
  let(:cookbook_version) { "0.5.0" }
40
40
 
41
+ let(:url) { "https://chef.example.com/organizations/example" }
42
+
41
43
  let(:cookbook_fixture_path) { fixtures_path.join("cookbooks/example_cookbook") }
42
44
 
43
45
  let(:remote_path) { File.join(test_root, "remote") }
44
- let(:options) { { version: cookbook_version, http_client: http_client } }
46
+ let(:options) { { chef_server: url, version: cookbook_version, http_client: http_client } }
45
47
 
46
48
  let(:cookbook_files) { %w{. .. metadata.rb recipes} }
47
49
  subject(:chef_server_location) { described_class.new(dependency, options) }
@@ -58,6 +60,18 @@ module CookbookOmnifetch
58
60
  FileUtils.rm_r(test_root)
59
61
  end
60
62
 
63
+ it "has a URI" do
64
+ expect(chef_server_location.uri).to eq(url)
65
+ end
66
+
67
+ it "has a cache key containing the site URI and version" do
68
+ expect(chef_server_location.cache_key).to eq("example-0.5.0")
69
+ end
70
+
71
+ it "has an exact version" do
72
+ expect(chef_server_location.cookbook_version).to eq("0.5.0")
73
+ end
74
+
61
75
  it "installs the cookbook to the desired install path" do
62
76
  expect(http_client).to receive(:get).with("/cookbooks/example/0.5.0").and_return(METADATA)
63
77
  expect(http_client).to receive(:streaming_request).twice do |url, &block|
@@ -71,5 +85,14 @@ module CookbookOmnifetch
71
85
  expect(Dir).to exist(chef_server_location.install_path)
72
86
  expect(Dir.entries(chef_server_location.install_path)).to match_array(cookbook_files)
73
87
  end
88
+
89
+ it "provides lock data as a Hash" do
90
+ expected_data = {
91
+ "chef_server" => url,
92
+ "version" => "0.5.0",
93
+ }
94
+ expect(chef_server_location.lock_data).to eq(expected_data)
95
+ end
96
+
74
97
  end
75
98
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cookbook-omnifetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Winsor
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2017-01-17 00:00:00.000000000 Z
16
+ date: 2017-01-18 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: mixlib-archive