another_brick 0.2.1 → 0.3.0

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.
@@ -5,8 +5,8 @@ require "another_brick/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "another_brick"
7
7
  s.version = AnotherBrick::VERSION
8
- s.authors = ["Victor Cavalcanti", "Vinicius Higa"]
9
- s.email = ["victorc.rodrigues@gmail.com", "viniciushiga@gmail.com"]
8
+ s.authors = ["Victor Cavalcanti", "Vinicius Higa", "Ricardo Ruiz"]
9
+ s.email = ["victorc.rodrigues@gmail.com", "viniciushiga@gmail.com", "rhruiz@gmail.com"]
10
10
  s.homepage = "https://github.com/viniciushiga/another_brick"
11
11
  s.summary = "Deploy debian packages using bricklayer"
12
12
  s.description = "Creates a testing tag, waits for bricklayer to build the debian package and then updates your server"
@@ -2,27 +2,34 @@ module AnotherBrick
2
2
  module Tag
3
3
  extend self
4
4
 
5
- def create(prefix)
6
- version_tag = get_last_tag('v')
7
-
8
- major, minor = strip_version('v', version_tag)
5
+ PREFIXES = %w(unstable stable testing)
9
6
 
10
- last_tag = get_last_tag("#{prefix}_#{major}.#{minor}")
11
-
12
- build = last_tag ? strip_version("#{prefix}_", last_tag).last + 1 : 0
7
+ def create(prefix)
8
+ major, minor, build = last_tag ? strip_version(last_tag) : [0, 0, 0]
13
9
 
14
- "#{prefix}_#{major}.#{minor}.#{build}".tap do |next_tag|
10
+ "#{prefix}_#{major}.#{minor}.#{build.to_i + 1}".tap do |next_tag|
15
11
  `git tag #{next_tag}`
16
12
  `git push --tags`
17
13
  end
18
14
  end
19
15
 
20
- def get_last_tag(pattern)
21
- `git tag | grep ^#{pattern} | sort -V`.lines.map(&:chomp).last
16
+ def version_sorter
17
+ proc do |v1, v2|
18
+ Gem::Version.new(v1) <=> Gem::Version.new(v2)
19
+ end
20
+ end
21
+
22
+ def last_tag
23
+ prefix_re = /(?:v|#{PREFIXES.map { |e| "#{e}_" }.join("|") })(\d+\.\d+(?:\.\d+)?)/
24
+ `git tag `.lines.map(&:chomp).select { |e| e =~ prefix_re }.map do |line|
25
+ line.gsub(prefix_re, "\\1")
26
+ end.sort(&version_sorter).last
22
27
  end
23
28
 
24
- def strip_version(prefix, version)
25
- version.delete(prefix).split('.').map(&:to_i)
29
+ def strip_version(version)
30
+ version.split('.').map(&:to_i).tap do |v|
31
+ v[2] ||= -1
32
+ end
26
33
  end
27
34
  end
28
35
  end
@@ -1,3 +1,3 @@
1
1
  module AnotherBrick
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: another_brick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Victor Cavalcanti
9
9
  - Vinicius Higa
10
+ - Ricardo Ruiz
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2013-08-20 00:00:00.000000000 Z
14
+ date: 2013-08-21 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: rake
@@ -97,6 +98,7 @@ description: Creates a testing tag, waits for bricklayer to build the debian pac
97
98
  email:
98
99
  - victorc.rodrigues@gmail.com
99
100
  - viniciushiga@gmail.com
101
+ - rhruiz@gmail.com
100
102
  executables:
101
103
  - brick
102
104
  extensions: []
@@ -128,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
130
  version: '0'
129
131
  segments:
130
132
  - 0
131
- hash: -4056119797303108836
133
+ hash: -2471127953251273313
132
134
  required_rubygems_version: !ruby/object:Gem::Requirement
133
135
  none: false
134
136
  requirements:
@@ -137,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
139
  version: '0'
138
140
  segments:
139
141
  - 0
140
- hash: -4056119797303108836
142
+ hash: -2471127953251273313
141
143
  requirements: []
142
144
  rubyforge_project:
143
145
  rubygems_version: 1.8.23