semantic_versioning 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module SemanticVersioning
2
- GEM_VERSION = '0.1.0'
2
+ GEM_VERSION = '0.2.0'
3
3
  end
@@ -84,7 +84,8 @@ module SemanticVersioning
84
84
  end
85
85
 
86
86
  def clear_optional_identifiers
87
- @pre, @build = nil, nil
87
+ @pre = nil
88
+ @build = nil
88
89
  end
89
90
 
90
91
  end
@@ -4,10 +4,15 @@ module SemanticVersioning
4
4
 
5
5
  class VersionSet < SortedSet
6
6
 
7
+ def initialize(versions)
8
+ versions.map! { |v| Version.new(v) } if versions.all? { |v| v.is_a?(String) }
9
+ super(versions)
10
+ end
11
+
7
12
  def where(operator, version)
8
13
  version = Version.new(version) if version.is_a? String
9
14
  subset = select { |v| v.send(operator, version) }
10
- self.class.new subset
15
+ self.class.new(subset)
11
16
  end
12
17
 
13
18
  end
@@ -2,8 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe SemanticVersioning::VersionSet do
4
4
 
5
- let(:versions) { [v('1.0.0'), v('1.0.10'), v('0.10.0')] }
6
- let(:set) { SemanticVersioning::VersionSet.new(versions) }
5
+ let(:versions) { [v('1.0.0'), v('1.0.10'), v('0.10.0')] }
6
+ let(:set_klass) { SemanticVersioning::VersionSet }
7
+ let(:set) { set_klass.new(versions) }
8
+
9
+ specify 'constructor accepts array of strings' do
10
+ set_klass.new(['1.0.0', '0.9.0']).should == set_klass.new([v('1.0.0'), v('0.9.0')])
11
+ end
7
12
 
8
13
  it 'yields version in correct order' do
9
14
  results = set.map{ |v| v }
@@ -20,7 +25,7 @@ describe SemanticVersioning::VersionSet do
20
25
  set.where(:<, v('1.0.0')).should be_a SemanticVersioning::VersionSet
21
26
  end
22
27
  it 'allows version to be given as a string' do
23
- set.where(:<, '1.0.0').first.should be_a SemanticVersioning::Version
28
+ set.where(:<, '1.0.0').should be_a SemanticVersioning::VersionSet
24
29
  end
25
30
  specify { set.where(:<, v('1.0.10')).length.should == 2 }
26
31
  specify { set.where(:<=, v('1.0.10')).length.should == 3 }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semantic_versioning
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-06 00:00:00.000000000 Z
12
+ date: 2013-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec