halite 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -3
- data/lib/halite/gem.rb +21 -2
- data/lib/halite/version.rb +1 -1
- data/spec/fixtures/gems/test4/Rakefile +1 -0
- data/spec/fixtures/gems/test4/lib/test1.rb +2 -0
- data/spec/fixtures/gems/test4/lib/test4/version.rb +3 -0
- data/spec/fixtures/gems/test4/test4.gemspec +24 -0
- data/spec/gem_spec.rb +39 -1
- metadata +9 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5249265d5c7c72220587865b41b064803b947f6a
|
4
|
+
data.tar.gz: 7c9793d015ef7a1bcdac708ffeb8f97abeff9ce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a1e2e4de4f7bd411cf491cb4c8032803d24d74606f42b339c243cf40b721e17743e6e4705f328f67bee7b0ee643c3aeeb77bf61e3bd7465d1c6b44f28d4c452
|
7
|
+
data.tar.gz: ac647c3327ada3bfefa57f1b96bd1181da4c03fb1583f786d437183aca9245f0f0bf8d1ecc4fb98f1cd6a0a6f3f166c3f702d87d3f6b2816b42067dbf9b675e5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Halite
|
2
2
|
|
3
|
-
[![Build Status](https://img.shields.io/travis/
|
3
|
+
[![Build Status](https://img.shields.io/travis/poise/halite.svg)](https://travis-ci.org/poise/halite)
|
4
4
|
[![Gem Version](https://img.shields.io/gem/v/halite.svg)](https://rubygems.org/gems/halite)
|
5
|
-
[![Coverage](https://img.shields.io/codecov/c/github/
|
6
|
-
[![Gemnasium](https://img.shields.io/gemnasium/
|
5
|
+
[![Coverage](https://img.shields.io/codecov/c/github/poise/halite.svg)](https://codecov.io/github/poise/halite)
|
6
|
+
[![Gemnasium](https://img.shields.io/gemnasium/poise/halite.svg)](https://gemnasium.com/poise/halite)
|
7
7
|
[![License](https://img.shields.io/badge/license-Apache_2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
|
8
8
|
|
9
9
|
Write as a gem, release as a cookbook.
|
data/lib/halite/gem.rb
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
require 'chef/cookbook_version'
|
18
18
|
|
19
19
|
require 'halite/dependencies'
|
20
|
+
require 'halite/error'
|
20
21
|
|
21
22
|
|
22
23
|
module Halite
|
@@ -32,7 +33,8 @@ module Halite
|
|
32
33
|
# name can be either a string name, Gem::Dependency, or Gem::Specification
|
33
34
|
# @param name [String, Gem::Dependency, Gem::Specification]
|
34
35
|
def initialize(name, version=nil)
|
35
|
-
|
36
|
+
# Allow passing a Dependency by just grabbing its spec.
|
37
|
+
name = dependency_to_spec(name) if name.is_a?(::Gem::Dependency)
|
36
38
|
if name.is_a?(::Gem::Specification)
|
37
39
|
raise Error.new("Cannot pass version when using an explicit specficiation") if version
|
38
40
|
@spec = name
|
@@ -45,7 +47,7 @@ module Halite
|
|
45
47
|
end
|
46
48
|
|
47
49
|
def spec
|
48
|
-
@spec ||= ::Gem::Dependency.new(@name, ::Gem::Requirement.new(@version))
|
50
|
+
@spec ||= dependency_to_spec(::Gem::Dependency.new(@name, ::Gem::Requirement.new(@version)))
|
49
51
|
end
|
50
52
|
|
51
53
|
def version
|
@@ -163,5 +165,22 @@ module Halite
|
|
163
165
|
# Didn't find anything
|
164
166
|
nil
|
165
167
|
end
|
168
|
+
|
169
|
+
private
|
170
|
+
|
171
|
+
# Find a spec given a dependency.
|
172
|
+
#
|
173
|
+
# @since 1.0.1
|
174
|
+
# @param dep [Gem::Dependency] Dependency to solve.
|
175
|
+
# @return [Gem::Specificiation]
|
176
|
+
def dependency_to_spec(dep)
|
177
|
+
# #to_spec doesn't allow prereleases unless the requirement is
|
178
|
+
# for a prerelease. Just use the last valid spec if possible.
|
179
|
+
spec = dep.to_spec || dep.to_specs.last
|
180
|
+
raise Error.new("Cannot find a gem to satisfy #{dep}") unless spec
|
181
|
+
spec
|
182
|
+
rescue Gem::LoadError => ex
|
183
|
+
raise Error.new("Cannot find a gem to satisfy #{dep}: #{ex}")
|
184
|
+
end
|
166
185
|
end
|
167
186
|
end
|
data/lib/halite/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
require 'halite/rake_tasks'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'test4/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'test4'
|
8
|
+
spec.version = Test4::VERSION
|
9
|
+
spec.authors = ['Noah Kantrowitz']
|
10
|
+
spec.email = %w{noah@coderanger.net}
|
11
|
+
spec.description = %q||
|
12
|
+
spec.summary = %q||
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'Apache 2.0'
|
15
|
+
|
16
|
+
spec.files = `cd #{File.expand_path('..', __FILE__)} && git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = %w{lib}
|
20
|
+
|
21
|
+
spec.add_dependency 'halite'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
end
|
data/spec/gem_spec.rb
CHANGED
@@ -127,6 +127,44 @@ describe Halite::Gem do
|
|
127
127
|
its(:is_halite_cookbook?) { is_expected.to be_truthy }
|
128
128
|
end # /context when loading test3
|
129
129
|
|
130
|
+
context 'when loading a Gem::Dependency' do
|
131
|
+
let(:dependency) do
|
132
|
+
reqs = []
|
133
|
+
reqs << Gem::Requirement.create(gem_version) if gem_version
|
134
|
+
Gem::Dependency.new(gem_name, *reqs)
|
135
|
+
end
|
136
|
+
subject { described_class.new(dependency) }
|
137
|
+
|
138
|
+
context 'test1' do
|
139
|
+
let(:gem_name) { 'test1' }
|
140
|
+
its(:version) { is_expected.to eq '1.2.3' }
|
141
|
+
end # /context test1
|
142
|
+
|
143
|
+
context 'test1 > 1.2.0' do
|
144
|
+
let(:gem_name) { 'test1' }
|
145
|
+
let(:gem_version) { '> 1.2.0' }
|
146
|
+
its(:version) { is_expected.to eq '1.2.3' }
|
147
|
+
end # /context test1 > 1.2.0
|
148
|
+
|
149
|
+
context 'test1 > 1.3.0' do
|
150
|
+
let(:gem_name) { 'test1' }
|
151
|
+
let(:gem_version) { '> 1.3.0' }
|
152
|
+
it { expect { subject }.to raise_error Halite::Error }
|
153
|
+
end # /context test1 > 1.3.0
|
154
|
+
|
155
|
+
context 'test1 ~> 1.2' do
|
156
|
+
let(:gem_name) { 'test1' }
|
157
|
+
let(:gem_version) { '~> 1.2' }
|
158
|
+
its(:version) { is_expected.to eq '1.2.3' }
|
159
|
+
end # /context test1 ~> 1.2
|
160
|
+
|
161
|
+
context 'test4 ~> 2.3' do
|
162
|
+
let(:gem_name) { 'test4' }
|
163
|
+
let(:gem_version) { '~> 2.3' }
|
164
|
+
its(:version) { is_expected.to eq '2.3.1.rc.1' }
|
165
|
+
end # /context test4 ~> 2.3
|
166
|
+
end # /context when loading a Gem::Dependency
|
167
|
+
|
130
168
|
describe '#cookbook_name' do
|
131
169
|
let(:metadata) { {} }
|
132
170
|
subject { described_class.new(Gem::Specification.new {|s| s.name = gem_name; s.metadata.update(metadata) }).cookbook_name }
|
@@ -170,5 +208,5 @@ describe Halite::Gem do
|
|
170
208
|
let(:gem_name) { 'mycompany-mygem' }
|
171
209
|
it { is_expected.to eq 'mycompany-mygem' }
|
172
210
|
end
|
173
|
-
end
|
211
|
+
end # /describe #cookbook_name
|
174
212
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: halite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Kantrowitz
|
@@ -198,6 +198,10 @@ files:
|
|
198
198
|
- spec/fixtures/gems/test3/lib/test3/dsl.rb
|
199
199
|
- spec/fixtures/gems/test3/lib/test3/version.rb
|
200
200
|
- spec/fixtures/gems/test3/test3.gemspec
|
201
|
+
- spec/fixtures/gems/test4/Rakefile
|
202
|
+
- spec/fixtures/gems/test4/lib/test1.rb
|
203
|
+
- spec/fixtures/gems/test4/lib/test4/version.rb
|
204
|
+
- spec/fixtures/gems/test4/test4.gemspec
|
201
205
|
- spec/gem_spec.rb
|
202
206
|
- spec/integration_spec.rb
|
203
207
|
- spec/runner_spec.rb
|
@@ -272,6 +276,10 @@ test_files:
|
|
272
276
|
- spec/fixtures/gems/test3/lib/test3/dsl.rb
|
273
277
|
- spec/fixtures/gems/test3/lib/test3/version.rb
|
274
278
|
- spec/fixtures/gems/test3/test3.gemspec
|
279
|
+
- spec/fixtures/gems/test4/Rakefile
|
280
|
+
- spec/fixtures/gems/test4/lib/test1.rb
|
281
|
+
- spec/fixtures/gems/test4/lib/test4/version.rb
|
282
|
+
- spec/fixtures/gems/test4/test4.gemspec
|
275
283
|
- spec/gem_spec.rb
|
276
284
|
- spec/integration_spec.rb
|
277
285
|
- spec/runner_spec.rb
|