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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99c974595b112fea65f60044e91909cac772e974
4
- data.tar.gz: 94a9c735852addc68db0b00c4d5e92c10242bf47
3
+ metadata.gz: 9a4f2b5ab0cb7e2ddd8bbc613aab7d5f92d50048
4
+ data.tar.gz: ba2d3c79301373fb9d05da1b9a2bbe5fb9fd7fe8
5
5
  SHA512:
6
- metadata.gz: e6100f5be5c8e15102f6986f0e37ec542f2e5b23f35575f04e2a7223dcc171121e89c6f02d92334d9f23d51ff8fd0ea1359763e794d16908a5318441394d8006
7
- data.tar.gz: 8eaa8133b4b8f133ee0c10d5945c95006f114bb436cf9c5137a7f44bcb6a650cb2ea7e6b8cffaf5fa40557664dbf9764303a3688be4503289db759e981bcdce5
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
- ver_data = read.gsub(/'.*'/, "'#{version}'")
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(/'(.*)'/)[1]
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,3 +1,3 @@
1
1
  module AppVersionTasks
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -1,32 +1,32 @@
1
1
 
2
2
  namespace :version do
3
3
  desc 'report the current version'
4
- task current: do
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: do
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: do
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: do
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: do
29
+ task :patch do
30
30
  ver = AppVersionTasks::SemanticVersion.new
31
31
  puts ver.bump(:patch)
32
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_version_tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren L. Weber, Ph.D.