app_version_tasks 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/app_version_tasks/semantic_version_file.rb +8 -2
- data/lib/app_version_tasks/version.rb +1 -1
- data/lib/tasks/app_version_tasks.rake +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a4f2b5ab0cb7e2ddd8bbc613aab7d5f92d50048
|
4
|
+
data.tar.gz: ba2d3c79301373fb9d05da1b9a2bbe5fb9fd7fe8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2c04dbb9a5e93ca0628eb51fe3ee630f839f127e01f7a525b481b1c328f1365df6bcd4a1486542d58f686e595c6e2eba3d1ae2b66fd4cab32a37694eeb96a57
|
7
|
+
data.tar.gz: 70b7c0cd557a7fe5b4b9a924073226b1cc07551e79658e4eaab5fb88f80b23bbc9a90196c49aa2913c7cb6b85466d734aa0ccbff40dab2e8f5ddaa02c95a5e86
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
[![Build Status](https://travis-ci.org/sul-dlss/app_version_tasks.svg?branch=master)](https://travis-ci.org/sul-dlss/app_version_tasks) [![Code Climate](https://codeclimate.com/github/sul-dlss/app_version_tasks/badges/gpa.svg)](https://codeclimate.com/github/sul-dlss/app_version_tasks) [![Test Coverage](https://codeclimate.com/github/sul-dlss/app_version_tasks/badges/coverage.svg)](https://codeclimate.com/github/sul-dlss/app_version_tasks/coverage) [![Issue Count](https://codeclimate.com/github/sul-dlss/app_version_tasks/badges/issue_count.svg)](https://codeclimate.com/github/sul-dlss/app_version_tasks) [![Inline docs](http://inch-ci.org/github/sul-dlss/app_version_tasks.svg?branch=master)](http://inch-ci.org/github/sul-dlss/app_version_tasks)
|
2
|
+
[![Build Status](https://travis-ci.org/sul-dlss/app_version_tasks.svg?branch=master)](https://travis-ci.org/sul-dlss/app_version_tasks) [![Code Climate](https://codeclimate.com/github/sul-dlss/app_version_tasks/badges/gpa.svg)](https://codeclimate.com/github/sul-dlss/app_version_tasks) [![Test Coverage](https://codeclimate.com/github/sul-dlss/app_version_tasks/badges/coverage.svg)](https://codeclimate.com/github/sul-dlss/app_version_tasks/coverage) [![Issue Count](https://codeclimate.com/github/sul-dlss/app_version_tasks/badges/issue_count.svg)](https://codeclimate.com/github/sul-dlss/app_version_tasks) [![Inline docs](http://inch-ci.org/github/sul-dlss/app_version_tasks.svg?branch=master)](http://inch-ci.org/github/sul-dlss/app_version_tasks) [![Gem Version](https://badge.fury.io/rb/app_version_tasks.svg)](https://badge.fury.io/rb/app_version_tasks)
|
3
3
|
|
4
4
|
# AppVersionTasks
|
5
5
|
|
@@ -2,6 +2,11 @@
|
|
2
2
|
module AppVersionTasks
|
3
3
|
# Manage application semantic version
|
4
4
|
class SemanticVersionFile
|
5
|
+
##
|
6
|
+
# A semantic version should match this pattern, i.e.
|
7
|
+
# {major_digits}.{minor_digits}.{patch_digits}
|
8
|
+
SEMVER_REGEX = /\d+\.\d+\.\d+/
|
9
|
+
|
5
10
|
def initialize
|
6
11
|
return if File.exist? path
|
7
12
|
File.write(path, version_template)
|
@@ -25,14 +30,15 @@ module AppVersionTasks
|
|
25
30
|
# @param [String] version - 'i.j.k'
|
26
31
|
# @return [Integer] string length written to version file
|
27
32
|
def write(version = '0.0.0')
|
28
|
-
|
33
|
+
raise 'version must match a semantic version pattern' unless version =~ SEMVER_REGEX
|
34
|
+
ver_data = read.gsub(SEMVER_REGEX, version)
|
29
35
|
File.write(path, ver_data)
|
30
36
|
end
|
31
37
|
|
32
38
|
# @return [String] version in version file
|
33
39
|
def version
|
34
40
|
retries ||= 0
|
35
|
-
read.match(
|
41
|
+
read.match(SEMVER_REGEX)[0]
|
36
42
|
rescue
|
37
43
|
retry if (retries += 1) < 3
|
38
44
|
raise 'failed to read and parse version file'
|
@@ -1,32 +1,32 @@
|
|
1
1
|
|
2
2
|
namespace :version do
|
3
3
|
desc 'report the current version'
|
4
|
-
task current
|
4
|
+
task :current do
|
5
5
|
ver = AppVersionTasks::SemanticVersion.new
|
6
6
|
puts ver.version
|
7
7
|
end
|
8
8
|
|
9
9
|
desc 'add and push a release tag for the current version'
|
10
|
-
task release
|
10
|
+
task :release do
|
11
11
|
ver = AppVersionTasks::SemanticVersion.new
|
12
12
|
puts ver.release
|
13
13
|
end
|
14
14
|
|
15
15
|
namespace :bump do
|
16
16
|
desc 'bump and push the major version (x.0.0)'
|
17
|
-
task major
|
17
|
+
task :major do
|
18
18
|
ver = AppVersionTasks::SemanticVersion.new
|
19
19
|
puts ver.bump(:major)
|
20
20
|
end
|
21
21
|
|
22
22
|
desc 'bump and push the minor version (0.x.0)'
|
23
|
-
task minor
|
23
|
+
task :minor do
|
24
24
|
ver = AppVersionTasks::SemanticVersion.new
|
25
25
|
puts ver.bump(:minor)
|
26
26
|
end
|
27
27
|
|
28
28
|
desc 'bump and push the patch version (0.0.x)'
|
29
|
-
task patch
|
29
|
+
task :patch do
|
30
30
|
ver = AppVersionTasks::SemanticVersion.new
|
31
31
|
puts ver.bump(:patch)
|
32
32
|
end
|