cookbook-omnifetch 0.1.0 → 0.2.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: 7a7a092cd5020fd96e0c0dc5c15816adf03e49fa
4
- data.tar.gz: f3f1e9a7fac7872f6295f97ea486410573036b33
3
+ metadata.gz: 0ae1460747cd8d56df8edb96f910ab7aedc7884d
4
+ data.tar.gz: dfe8988c3227ccb3660a8e591b803596ebf0a4e9
5
5
  SHA512:
6
- metadata.gz: fb5a529f659a4c6212c6fa8e0e72f1b9a6be40084b04fb0857628de11bb59dab8214a7612f4b96632d2da679ca110bfc419793586c4f87482c26c47206ed1dda
7
- data.tar.gz: e1bb5b80e291e8f28db54c1be484e386b5fd409ed81a7e6b3886b322846d2b26314eb7fdcf771d9f2f4d920955432a9dc75cf0dffdd6628d4287e01b104ceaca
6
+ metadata.gz: 0da7ef63902761a5a0d8574d4fcfcd189845a3b9fe3968f4c60e68ce9556f4f9a2f19123001a2e89e5f87a4438bad8f8614c6da9d2bd9c57913add7943ed47ff
7
+ data.tar.gz: 5f9d292cae9cf0ed321c1a288cfa6677b6223e90e6def07a86025cb52999ac72c7934f4421dffc6d375b2fd7ba4e1b0559f15b6415bb88c97ffb89d85cc450c0
@@ -88,6 +88,13 @@ module CookbookOmnifetch
88
88
  "#cached_cookbook must be implemented on #{self.class.name}!"
89
89
  end
90
90
 
91
+ def lock_data
92
+ out = {}
93
+ out["artifactserver"] = uri
94
+ out["version"] = cookbook_version
95
+ out
96
+ end
97
+
91
98
  # The lockfile representation of this location.
92
99
  #
93
100
  # @return [string]
@@ -35,6 +35,14 @@ module CookbookOmnifetch
35
35
  "#cached_cookbook must be implemented on #{self.class.name}!"
36
36
  end
37
37
 
38
+ # A representation of this location suitable for a lockfile, given as a Hash
39
+ #
40
+ # @return [Hash]
41
+ def lock_data
42
+ raise AbstractFunction,
43
+ "#to_lock must be implemented on #{self.class.name}!"
44
+ end
45
+
38
46
  # The lockfile representation of this location.
39
47
  #
40
48
  # @return [string]
@@ -108,6 +108,17 @@ module CookbookOmnifetch
108
108
  end
109
109
  end
110
110
 
111
+ def lock_data
112
+ out = {}
113
+ out["git"] = uri
114
+ out["revision"] = revision
115
+ out["ref"] = shortref if shortref
116
+ out["branch"] = branch if branch
117
+ out["tag"] = tag if tag
118
+ out["rel"] = rel if rel
119
+ out
120
+ end
121
+
111
122
  def to_lock
112
123
  out = " git: #{uri}\n"
113
124
  out << " revision: #{revision}\n"
@@ -69,6 +69,13 @@ module CookbookOmnifetch
69
69
  other.relative_path == relative_path
70
70
  end
71
71
 
72
+ def lock_data
73
+ out = {}
74
+ out["path"] = relative_path.to_s
75
+ out["metadata"] = true if metadata?
76
+ out
77
+ end
78
+
72
79
  def to_lock
73
80
  out = " path: #{relative_path}\n"
74
81
  out << " metadata: true\n" if metadata?
@@ -1,3 +1,3 @@
1
1
  module CookbookOmnifetch
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -12,16 +12,18 @@ module CookbookOmnifetch
12
12
 
13
13
  let(:dependency) { double("Dependency", name: cookbook_name, constraint: constraint) }
14
14
 
15
- let(:options) { {artifactserver: "https://cookbooks.opscode.com/api/v1", version: cookbook_version } }
15
+ let(:url) { "https://supermarket.getchef.com/api/v1/cookbooks/nginx/versions/1.5.23/download" }
16
+
17
+ let(:options) { {artifactserver: url, version: cookbook_version } }
16
18
 
17
19
  subject(:public_repo_location) { ArtifactserverLocation.new(dependency, options) }
18
20
 
19
21
  it "has a URI" do
20
- expect(public_repo_location.uri).to eq("https://cookbooks.opscode.com/api/v1")
22
+ expect(public_repo_location.uri).to eq(url)
21
23
  end
22
24
 
23
25
  it "has a repo host" do
24
- expect(public_repo_location.repo_host).to eq("cookbooks.opscode.com")
26
+ expect(public_repo_location.repo_host).to eq("supermarket.getchef.com")
25
27
  end
26
28
 
27
29
  it "has an exact version" do
@@ -29,11 +31,11 @@ module CookbookOmnifetch
29
31
  end
30
32
 
31
33
  it "has a cache key containing the site URI and version" do
32
- expect(public_repo_location.cache_key).to eq("nginx-1.5.23-cookbooks.opscode.com")
34
+ expect(public_repo_location.cache_key).to eq("nginx-1.5.23-supermarket.getchef.com")
33
35
  end
34
36
 
35
37
  it "sets the install location as the cache path plus cache key" do
36
- expected_install_path = Pathname.new('~/.berkshelf/cookbooks').expand_path.join("nginx-1.5.23-cookbooks.opscode.com")
38
+ expected_install_path = Pathname.new('~/.berkshelf/cookbooks').expand_path.join("nginx-1.5.23-supermarket.getchef.com")
37
39
  expect(public_repo_location.install_path).to eq(expected_install_path)
38
40
  end
39
41
 
@@ -46,6 +48,14 @@ module CookbookOmnifetch
46
48
  expect(public_repo_location.install_path).to receive(:exist?).and_return(false)
47
49
  expect(public_repo_location.installed?).to be false
48
50
  end
51
+
52
+ it "provides lock data as a Hash" do
53
+ expected_data = {
54
+ "artifactserver" => url,
55
+ "version" => "1.5.23"
56
+ }
57
+ expect(public_repo_location.lock_data).to eq(expected_data)
58
+ end
49
59
  end
50
60
  end
51
61
 
@@ -32,6 +32,12 @@ module CookbookOmnifetch
32
32
  end
33
33
  end
34
34
 
35
+ describe '#lock_data' do
36
+ it 'is an abstract function' do
37
+ expect { subject.lock_data }.to raise_error(AbstractFunction)
38
+ end
39
+ end
40
+
35
41
  describe '#validate_cached!' do
36
42
  context 'when the path is not a cookbook' do
37
43
  before { CookbookOmnifetch.stub(:cookbook?).and_return(false) }
@@ -240,6 +240,39 @@ module CookbookOmnifetch
240
240
  end
241
241
  end
242
242
 
243
+ describe '#lock_data' do
244
+ let(:full_lock_data) do
245
+ {
246
+ "git" => "https://repo.com",
247
+ "revision" => "defjkl123456",
248
+ "ref" => "abc123",
249
+ "branch" => "ham",
250
+ "tag" => "v1.2.3",
251
+ "rel" => "hi"
252
+ }
253
+ end
254
+
255
+ it 'includes all the information' do
256
+ expect(subject.lock_data).to eq(full_lock_data)
257
+ end
258
+
259
+ it 'does not include the branch if missing' do
260
+ subject.stub(:branch).and_return(nil)
261
+ expect(subject.lock_data).to_not have_key('branch')
262
+ end
263
+
264
+ it 'does not include the tag if missing' do
265
+ subject.stub(:tag).and_return(nil)
266
+ expect(subject.lock_data).to_not have_key('tag')
267
+ end
268
+
269
+ it 'does not include the rel if missing' do
270
+ subject.stub(:rel).and_return(nil)
271
+ expect(subject.lock_data).to_not have_key('rel')
272
+ end
273
+ end
274
+
275
+
243
276
  describe '#git' do
244
277
  before { described_class.send(:public, :git) }
245
278
 
@@ -92,6 +92,17 @@ module CookbookOmnifetch
92
92
  end
93
93
  end
94
94
 
95
+ describe '#lock_data' do
96
+ it 'includes the path relative to the Berksfile' do
97
+ expect(subject.lock_data).to eq({ "path" => relative_path.to_s })
98
+ end
99
+
100
+ it 'includes the metadata attribute' do
101
+ subject.stub(:metadata?).and_return(true)
102
+ expect(subject.lock_data).to eq({ "path" => relative_path.to_s, "metadata" => true })
103
+ end
104
+ end
105
+
95
106
  describe '#to_s' do
96
107
  it 'uses the relative path' do
97
108
  expect(subject.to_s).to eq("source at #{relative_path}")
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.1.0
4
+ version: 0.2.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: 2014-06-30 00:00:00.000000000 Z
16
+ date: 2014-07-09 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: minitar