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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a88c79b838190b373a56d00ee972a3a5f3c20761
4
- data.tar.gz: be4c14b8249c98d21a99120ae282a624a251b13a
3
+ metadata.gz: 5249265d5c7c72220587865b41b064803b947f6a
4
+ data.tar.gz: 7c9793d015ef7a1bcdac708ffeb8f97abeff9ce1
5
5
  SHA512:
6
- metadata.gz: 601bfbadd49b631708e0825fcaa67b0c0aae0bc5f733cb023ec6466dfcad5d2713a63ed8303ec98b3340f74ffb93126c4f2e962ff53b6c89ce7cdd7d05f373fa
7
- data.tar.gz: 1ebae3856cf9e7f5907f6e20e42b8102f698907c273d40a5d1d552a2f8e2ef491b53d65597ac62f66093e1fc9352e565a5ffd381601fac831171dfdb3269555f
6
+ metadata.gz: 8a1e2e4de4f7bd411cf491cb4c8032803d24d74606f42b339c243cf40b721e17743e6e4705f328f67bee7b0ee643c3aeeb77bf61e3bd7465d1c6b44f28d4c452
7
+ data.tar.gz: ac647c3327ada3bfefa57f1b96bd1181da4c03fb1583f786d437183aca9245f0f0bf8d1ecc4fb98f1cd6a0a6f3f166c3f702d87d3f6b2816b42067dbf9b675e5
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.0.1
4
+
5
+ Fix issues with pre-release version numbers.
6
+
3
7
  ## v1.0.0
4
8
 
5
9
  Initial release!
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Halite
2
2
 
3
- [![Build Status](https://img.shields.io/travis/coderanger/halite.svg)](https://travis-ci.org/coderanger/halite)
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/coderanger/halite.svg)](https://codecov.io/github/coderanger/halite)
6
- [![Gemnasium](https://img.shields.io/gemnasium/coderanger/halite.svg)](https://gemnasium.com/coderanger/halite)
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.
@@ -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
- name = name.to_spec if name.is_a?(::Gem::Dependency) # Allow passing a Dependency by just grabbing its spec.
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)).to_spec
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
@@ -17,5 +17,5 @@
17
17
 
18
18
  module Halite
19
19
  # Halite version.
20
- VERSION = '1.0.0'
20
+ VERSION = '1.0.1'
21
21
  end
@@ -0,0 +1 @@
1
+ require 'halite/rake_tasks'
@@ -0,0 +1,2 @@
1
+ module Test4
2
+ end
@@ -0,0 +1,3 @@
1
+ module Test4
2
+ VERSION = '2.3.1.rc.1'
3
+ end
@@ -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
@@ -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.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