project_releaser 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de9d1d21e70f467e26540f91e0f255b10685c402
4
- data.tar.gz: 3f5a133c270756c2679d01de2fe40a91fdf6b383
3
+ metadata.gz: e42b85241d5de5de7ceb62b2dfcba7f47c5734c6
4
+ data.tar.gz: 621ccb9a1cda741091c825cb8ab17cb2f436384b
5
5
  SHA512:
6
- metadata.gz: a0f58ad856370e553a4c488744843e144eca8f85af1a6482f564242c7ca9b54b5e72accd47e700d5d284289d4c29117e20926de5be60c6b93fe96d1b96caceb1
7
- data.tar.gz: 1f89f0b9273f884e65267fa37cfc3c93d57350211ddc37020aaf50820fa0a9a1b2e46d40ad0a65b37e4473122473290b892c7a4723e3fb2e8ba9def1de0776d0
6
+ metadata.gz: ea7db764109f0ee52c8a228e7e34d3b5ba3d167b36a8aa214cd98a4c5f8e2fd533d0d759a950fdea09b0d1514d25107605d7d267d240c37f50e32a248fbbfda0
7
+ data.tar.gz: f4515caf266dc56251ae036fe798c4efd72497e0b86ce02e57a82915f4f6a6b3d46d21c9c6d652688c07f8edf09036b62d0307e0eb8c82540a4c5ce8a077f5d4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- project_releaser (0.0.1)
4
+ project_releaser (0.0.3)
5
5
  colorize
6
6
  commander
7
7
  git
@@ -48,4 +48,4 @@ DEPENDENCIES
48
48
  rspec
49
49
 
50
50
  BUNDLED WITH
51
- 1.10.3
51
+ 1.12.1
@@ -6,7 +6,7 @@ module ProjectReleaser
6
6
  class MissingBranch < RuntimeError; end;
7
7
 
8
8
  VERSION_PARTS = %I(major minor patch)
9
- DEFAULT_VERSION = [0, 0, 0]
9
+ DEFAULT_VERSION = [1, 0, 0]
10
10
 
11
11
  def initialize(repo_path)
12
12
  @git = open_repository(repo_path)
@@ -80,10 +80,12 @@ module ProjectReleaser
80
80
  def versions
81
81
  tags = @git.tags
82
82
  return [DEFAULT_VERSION] if tags.empty?
83
+ valid_tags = tags
84
+ .map(&:name)
85
+ .select{ |n| n =~ /\Av?\d+(\.\d+){1,2}\z/ }
83
86
 
84
- tags
85
- .map(&:name)
86
- .select{ |n| n.start_with? 'v' }
87
+ return [DEFAULT_VERSION] if valid_tags.empty?
88
+ valid_tags
87
89
  .map{ |n| n.sub('v', '').split('.').map(&:to_i) }
88
90
  .map{ |a| a.fill(0, a.size..2) }
89
91
  .sort
@@ -1,3 +1,3 @@
1
1
  module ProjectReleaser
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -24,11 +24,10 @@ describe ProjectReleaser::Project::Repository do
24
24
  expect(subject.current_version).to eq :major => 1, :minor => 2, :patch => 4
25
25
  end
26
26
 
27
- it 'ignores tags that dont start with v' do
28
- tag_1 = double 'tag', :name => 'v1.2.3'
29
- tag_2 = double 'tag', :name => '1.2.4'
30
- allow(git).to receive(:tags).and_return([tag_1, tag_2])
31
- expect(subject.current_version).to eq :major => 1, :minor => 2, :patch => 3
27
+ it 'supports version without v prefix' do
28
+ tag = double 'tag', :name => '1.2.8'
29
+ allow(git).to receive(:tags).and_return([tag])
30
+ expect(subject.current_version).to eq :major => 1, :minor => 2, :patch => 8
32
31
  end
33
32
 
34
33
  it 'recognizes partial versions' do
@@ -60,7 +59,20 @@ describe ProjectReleaser::Project::Repository do
60
59
 
61
60
  it 'returns default version when there are none' do
62
61
  allow(git).to receive(:tags).and_return([])
63
- expect(subject.current_version).to eq :major => 0, :minor => 0, :patch => 0
62
+ expect(subject.current_version).to eq :major => 1, :minor => 0, :patch => 0
63
+ end
64
+
65
+ it 'returns default version when there are no valid tags' do
66
+ tag = double 'tag', :name => 'random tag'
67
+ allow(git).to receive(:tags).and_return([tag])
68
+ expect(subject.current_version).to eq :major => 1, :minor => 0, :patch => 0
69
+ end
70
+
71
+ it 'ignores tags that do not match semantic versioning and returns default one' do
72
+ tag_1 = double 'tag', :name => 'g1.2.3'
73
+ tag_2 = double 'tag', :name => 'random string'
74
+ allow(git).to receive(:tags).and_return([tag_1, tag_2])
75
+ expect(subject.current_version).to eq :major => 1, :minor => 0, :patch => 0
64
76
  end
65
77
  end
66
78
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: project_releaser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - kagux