YAVM 0.5.0 → 0.5.2

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: 00614a6d85ba88c1ee44b69f5411310ce0a35da0
4
- data.tar.gz: c095eb2841da7051fcdefe06fd7a1b95db33aa6d
3
+ metadata.gz: 89f5ae4a9ec1d9aba8068c16cae331911225edbf
4
+ data.tar.gz: 00dd29ac52b21bd6cff55f408263b9398a742eb4
5
5
  SHA512:
6
- metadata.gz: 9b0372097d1be4cc53611184184e973cd94f5dc01fc37d5912bde8c0218565ce579324fa796f1853eebd136ae60423f9ee39fab4d714f677f7ec15744b34fafa
7
- data.tar.gz: 073e1526bbd6658d91cf952b0bb24939eccec6699074fb8f2f1d49983e8d127a888b98047dddf2d40e5cb96757cfd0a442ffba2d5f6ef616a571e95e6090272c
6
+ metadata.gz: 3750f8ab3725a3c65ea16bd2b53d6c8f0db680bff35687e1027b85e83804ab60b3419144a9fb4f4536922c2a29d3fcdc363f54ef75a6a6df99621534086fef32
7
+ data.tar.gz: 5fe02152701c63abf62927279d2200da953cb7f969872b3d57540417cd28b7aefb13271fa06e73e54f05db8c35a82d0b5374b3635e1628b0928b66f19c14d359
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path('../lib/', __FILE__)
4
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
5
+
6
+ lib = File.expand_path('../../lib/', __FILE__)
7
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
8
+
9
+ require 'yavm'
10
+ require 'shell'
11
+
12
+ Shell.def_system_command :git, 'git'
13
+
14
+ sh = Shell.new
15
+
16
+ version = YAVM.version
17
+ files = YAVM.versions.files
18
+
19
+ sh.git('add', *files)
20
+ sh.git('commit', '--allow-empty', '-m', "Version #{version}", '--only', *files)
21
+ sh.git('tag', '-a', version.tag, '-m' "Version #{version}")
22
+
@@ -1,14 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'simplecov_loader' if ENV['COVERAGE']
4
-
5
3
  lib = File.expand_path('../lib/', __FILE__)
6
- $:.unshift lib unless $:.include?(lib)
4
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
7
5
 
8
6
  lib = File.expand_path('../../lib/', __FILE__)
9
- $:.unshift lib unless $:.include?(lib)
10
-
7
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
11
8
 
9
+ require 'simplecov_loader' if ENV['COVERAGE']
12
10
  require 'yavm/command_line'
13
11
 
14
12
  begin
@@ -3,7 +3,7 @@ Feature: Command Line Interface
3
3
  version number, and set the 'special' and 'meta' fields
4
4
 
5
5
  Background:
6
- Given I have a project called "project"
6
+ Given I have a project called "versioning"
7
7
  And I run `version init`
8
8
 
9
9
  Then the output should contain "0.0.0"
@@ -3,7 +3,7 @@ Feature: Command Line Initialization
3
3
  enforce consistency.
4
4
 
5
5
  Background:
6
- Given I have a project called "project"
6
+ Given I have a project called "versioning"
7
7
 
8
8
  Scenario: Project with no version number
9
9
  Given I run `version`
@@ -1,12 +1,12 @@
1
1
  require 'aruba/cucumber'
2
2
 
3
- Before do |scenario|
4
- @dirs = ['tmp/aruba']
3
+ Before do |_scenario|
4
+ @dirs = ['.']
5
5
  @cwd = Dir.pwd
6
6
 
7
7
  set_env('COVERAGE', 'true')
8
8
  end
9
9
 
10
- After do |scenario|
10
+ After do |_scenario|
11
11
  Dir.chdir @cwd
12
12
  end
@@ -1,11 +1,10 @@
1
1
  lib = File.dirname(__FILE__)
2
- $:.unshift lib unless $:.include?(lib)
2
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  require 'yavm/version'
5
5
  require 'yavm/stores'
6
6
 
7
7
  module YAVM
8
-
9
8
  def version(quiet: true, quick: true)
10
9
  versions = YAVM::Stores.locate_versions(quick)
11
10
 
@@ -14,10 +13,13 @@ module YAVM
14
13
  else
15
14
  return nil if quiet
16
15
 
17
- raise RuntimeError, 'No version information available'
16
+ fail 'No version information available'
18
17
  end
19
18
  end
20
19
 
21
- module_function :version
20
+ def versions
21
+ YAVM::Stores.locate_versions
22
+ end
22
23
 
24
+ module_function :version, :versions
23
25
  end
@@ -97,7 +97,14 @@ module YAVM
97
97
  puts "#{version.tag}"
98
98
 
99
99
  when 'files'
100
- puts versions.map { |v| v.store.filename || nil }.compact.join "\n"
100
+ sep = "\n"
101
+ pad = ''
102
+
103
+ sep = ' ' if @args['-1']
104
+ pad = '"' if @args['-1']
105
+ sep = "\0" if @args['-0']
106
+
107
+ puts versions.files.map { |v| "#{pad}#{v}#{pad}" }.join(sep)
101
108
 
102
109
  when 'help'
103
110
  Docopt::Exit.set_usage(nil)
@@ -149,7 +156,7 @@ module YAVM
149
156
  #{@invocation} meta [<string>]
150
157
  #{@invocation} format <string>
151
158
  #{@invocation} tag
152
- #{@invocation} files
159
+ #{@invocation} files [(-1|-0)]
153
160
  #{@invocation} help
154
161
 
155
162
  Options:
@@ -7,13 +7,12 @@ require 'yavm/stores/gem_spec'
7
7
 
8
8
  module YAVM
9
9
  module Stores
10
-
11
10
  def stores
12
11
  [
13
12
  YAVM::Stores::Semver,
14
13
  YAVM::Stores::Package,
15
14
  YAVM::Stores::Bower,
16
- YAVM::Stores::GemSpec,
15
+ YAVM::Stores::GemSpec
17
16
  ]
18
17
  end
19
18
 
@@ -2,7 +2,6 @@ require 'json'
2
2
 
3
3
  module YAVM
4
4
  module Stores
5
-
6
5
  class Base
7
6
  def name
8
7
  self.class.name
@@ -21,11 +20,9 @@ module YAVM
21
20
  def filename
22
21
  Dir[glob].first if exists?
23
22
  end
24
-
25
23
  end
26
24
 
27
25
  class GenericJSON < YAVM::Stores::Base
28
-
29
26
  def data
30
27
  @data ||= JSON.parse(IO.read(filename))
31
28
  end
@@ -38,9 +35,6 @@ module YAVM
38
35
  @data = update_version_key(new_version.to_s)
39
36
  File.open(filename, 'w') { |f| f.write JSON.pretty_generate(data) }
40
37
  end
41
-
42
38
  end
43
-
44
-
45
39
  end
46
40
  end
@@ -3,7 +3,6 @@ require 'yavm/stores/base'
3
3
  module YAVM
4
4
  module Stores
5
5
  class Bower < YAVM::Stores::GenericJSON
6
-
7
6
  def name
8
7
  'bower.json file'
9
8
  end
@@ -18,9 +17,8 @@ module YAVM
18
17
 
19
18
  def update_version_key(what)
20
19
  data['version'] = what
21
- return data
20
+ data
22
21
  end
23
-
24
22
  end
25
23
  end
26
24
  end
@@ -5,7 +5,6 @@ require 'yavm/stores/base'
5
5
  module YAVM
6
6
  module Stores
7
7
  class GemSpec < YAVM::Stores::Base
8
-
9
8
  def name
10
9
  "gemspec: #{filename}"
11
10
  end
@@ -33,7 +32,6 @@ module YAVM
33
32
 
34
33
  File.open(filename, 'w') { |f| f.write new_spec }
35
34
  end
36
-
37
35
  end
38
36
  end
39
37
  end
@@ -3,7 +3,6 @@ require 'yavm/stores/base'
3
3
  module YAVM
4
4
  module Stores
5
5
  class Package < YAVM::Stores::GenericJSON
6
-
7
6
  def name
8
7
  'npm package.json'
9
8
  end
@@ -18,9 +17,8 @@ module YAVM
18
17
 
19
18
  def update_version_key(what)
20
19
  data['version'] = what
21
- return data
20
+ data
22
21
  end
23
-
24
22
  end
25
23
  end
26
24
  end
@@ -5,7 +5,6 @@ require 'yavm/stores/base'
5
5
  module YAVM
6
6
  module Stores
7
7
  class Semver < YAVM::Stores::Base
8
-
9
8
  def name
10
9
  '.semver file'
11
10
  end
@@ -29,7 +28,6 @@ module YAVM
29
28
  def set!(new_version)
30
29
  File.open(filename, 'w') { |f| f.write new_version.to_yaml }
31
30
  end
32
-
33
31
  end
34
32
  end
35
33
  end
@@ -5,6 +5,8 @@ module YAVM
5
5
  class Version
6
6
  extend ::Forwardable
7
7
 
8
+ VERSION_REGEX = /\A(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(?:-(?<special>[a-z0-9]+))?(?:\+(?<meta>[a-z0-9]+))?\z/i
9
+
8
10
  attr_accessor :store
9
11
 
10
12
  def initialize(store, vobject = nil)
@@ -20,24 +22,12 @@ module YAVM
20
22
  end
21
23
  end
22
24
 
23
- def special
24
- empty_is_nil(:special)
25
- end
26
-
27
- def meta
28
- empty_is_nil(:meta)
29
- end
30
-
31
25
  def to_s
32
26
  format('%M.%m.%p%-s')
33
27
  end
34
28
 
35
29
  def to_hash
36
- dump = @_version.marshal_dump
37
- dump[:special] ||= ''
38
- dump[:meta] ||= ''
39
-
40
- dump
30
+ @_version.marshal_dump
41
31
  end
42
32
 
43
33
  def to_yaml
@@ -55,14 +45,17 @@ module YAVM
55
45
  def format(string = '')
56
46
  string = string.dup
57
47
 
48
+ _special = special || ''
49
+ _meta = meta || ''
50
+
58
51
  # ? http://stackoverflow.com/a/8132638
59
52
  string.gsub!('%M', major.to_s)
60
53
  string.gsub!('%m', minor.to_s)
61
54
  string.gsub!('%p', patch.to_s)
62
- string.gsub!('%s', special || '')
63
- string.gsub!('%t', meta || '')
64
- string.gsub!('%-s', special ? "-#{special}" : '')
65
- string.gsub!('%-t', meta ? "+#{meta}" : '')
55
+ string.gsub!('%s', _special)
56
+ string.gsub!('%t', _meta)
57
+ string.gsub!('%-s', _special.empty? ? '' : "-#{special}")
58
+ string.gsub!('%-t', _meta.empty? ? '' : "+#{meta}")
66
59
  string.gsub!('%%', '%')
67
60
 
68
61
  string
@@ -80,28 +73,36 @@ module YAVM
80
73
  case what
81
74
  when :major
82
75
  self.major += 1
83
- self.minor = 0
84
- self.patch = 0
85
76
  when :minor
86
77
  self.minor += 1
87
- self.patch = 0
88
78
  when :patch
89
79
  self.patch += 1
90
80
  else
91
81
  fail "Can't increment #{what}"
92
82
  end
83
+ end
93
84
 
94
- if [:major, :minor, :patch].include? what
95
- self.special = nil
96
- self.meta = nil
97
- end
85
+ def major=(value)
86
+ clears(:minor, :patch, :special, :meta)
87
+ @_version.major = value
88
+ end
89
+
90
+ def minor=(value)
91
+ clears(:patch, :special, :meta)
92
+ @_version.minor = value
93
+ end
94
+
95
+ def patch=(value)
96
+ @_version.patch = value
98
97
  end
99
98
 
100
99
  private
101
100
 
102
- def empty_is_nil(key)
103
- value = @_version.send(key) || ''
104
- value.empty? ? nil : value
101
+ def clears(*properties)
102
+ properties.each do |p|
103
+ value = @_version.send(p).is_a?(Fixnum) ? 0 : ''
104
+ @_version.send("#{p}=", value)
105
+ end
105
106
  end
106
107
 
107
108
  def empty
@@ -111,16 +112,18 @@ module YAVM
111
112
  end
112
113
 
113
114
  def parse(string)
114
- match = string.match(/\A(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(?:-(?<special>[a-z0-9]+))?(?:\+(?<meta>[a-z0-9]+))?\z/i)
115
+ match = string.match(VERSION_REGEX)
115
116
 
116
117
  @_version = Hash[match.names.zip(match.captures)]
117
118
  @_version = OpenStruct.new(@_version)
118
119
  integerize!
120
+ stringify!
119
121
  end
120
122
 
121
123
  def load(hash)
122
124
  @_version = OpenStruct.new(hash)
123
125
  integerize!
126
+ stringify!
124
127
  end
125
128
 
126
129
  def integerize!
@@ -129,11 +132,17 @@ module YAVM
129
132
  @_version.patch = @_version.patch.to_i
130
133
  end
131
134
 
135
+ def stringify!
136
+ @_version.special ||= ''
137
+ @_version.meta ||= ''
138
+ end
139
+
132
140
  #
133
141
  # Allows calling "version.minor" and the like on the Version instance
134
142
  #
135
143
  def_delegators :@_version,
136
- :major, :minor, :patch,
137
- :major=, :minor=, :patch=, :special=, :meta=
144
+ :major, :minor, :patch,
145
+ :special, :meta,
146
+ :special=, :meta=
138
147
  end
139
148
  end
@@ -23,12 +23,15 @@ module YAVM
23
23
  versions.reject { |v| v == versions.first }.length.zero?
24
24
  end
25
25
 
26
+ def files
27
+ versions.map { |v| v.store.filename || nil }.compact
28
+ end
29
+
26
30
  def_delegators :versions, :<<, :length, :size, :[],
27
- :first, :each, :each_with_index, :empty?, :any?, :map
31
+ :first, :each, :each_with_index, :empty?, :any?, :map
28
32
 
29
33
  private
30
34
 
31
35
  attr_accessor :versions
32
-
33
36
  end
34
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: YAVM
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lewis Eason
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-24 00:00:00.000000000 Z
11
+ date: 2015-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +58,14 @@ dependencies:
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '0.28'
61
+ version: '0.32'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '0.28'
68
+ version: '0.32'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: cucumber
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -98,10 +112,12 @@ description: A tiny gem for managing project version numbers
98
112
  email: me@lewiseason.co.uk
99
113
  executables:
100
114
  - version
115
+ - git-versiontag
101
116
  extensions: []
102
117
  extra_rdoc_files: []
103
118
  files:
104
119
  - README.md
120
+ - bin/git-versiontag
105
121
  - bin/version
106
122
  - features/command_line.feature
107
123
  - features/initialization.feature
@@ -137,13 +153,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
153
  version: '0'
138
154
  requirements: []
139
155
  rubyforge_project:
140
- rubygems_version: 2.2.2
156
+ rubygems_version: 2.4.5
141
157
  signing_key:
142
158
  specification_version: 4
143
159
  summary: Yet Another Version Manager
144
160
  test_files:
145
161
  - features/initialization.feature
146
- - features/command_line.feature
147
162
  - features/support/env.rb
163
+ - features/command_line.feature
148
164
  - features/step_definitions/project.rb
149
- has_rdoc: