app_version 0.1.11 → 0.1.13

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: b8a3627e88d2e9c6afa001fa2948a7cb2201efaa
4
- data.tar.gz: 36fd04c5ec9f91adf8765d81f173c7562b28a9cf
3
+ metadata.gz: 7148181a3d6ae3e29934a56410a929dba01da205
4
+ data.tar.gz: e26f0e0cbaffa146e34ae7cf0c249f52103b6039
5
5
  SHA512:
6
- metadata.gz: 1aaefcd51024da2c581a2447697b1032ec407b5569785f4643ea5b35ab9c8a9bf7da16a3eefd86dfd3bd9c6b13ee71c96e0cc6e5ca35091a0fea0f71382c3bd6
7
- data.tar.gz: 3cf78c28951ce2d6bcf781a9f1bf7c6d7c2bf4e6a9e765c817c8afce11bc751288602a27864ff778f041335926dfcf503e43090df4cb218918169b1629dcd735
6
+ metadata.gz: bfbdaf8c11a5a31710c78ba142a76f2b89a68f2d44c1db2d2af5e4bc3eaf9ae4803f6f4344d2e6bd71a0899a4db102601848f425b1e6a5f69bbaee959366eb15
7
+ data.tar.gz: b184e039160439924996c83b504aea7920fa861cf7abe2d11ede5186ba8ed1ce4d8e7d810a4dfaf9f326ca5430d9bcb606b70409a6f4aeafe131c88eb36134a6
data/README.md CHANGED
@@ -35,7 +35,7 @@ To include the version information into your running application create an initi
35
35
  This will load a constant called APP_VERSION That includes the version information. This can then be rendered within the application using
36
36
 
37
37
  APP_VERSION.to_s
38
-
38
+
39
39
  Use this within your application view or helper methods, more detail on other version meta data in the usage section.
40
40
 
41
41
  ### Usage
@@ -59,7 +59,7 @@ If you use the special string it will query the source control system and output
59
59
 
60
60
  Using 'svn' for the build number will cause the plugin to query Subversion for the current revision number. Since Git doesn't have a numbered revision we have to fake it. 'git-revcount' will count the number of commits to the repository and use that as the build number whereas 'git-hash' will use the first 6 digits of the current HEAD's hash.
61
61
 
62
- The plugin creates a constant `APP_VERSION` that contains the version number of the application. Calling the `to_s` method on APP_VERSION will result in a properly formatted version number.
62
+ The plugin creates a constant `APP_VERSION` that contains the version number of the application. Calling the `to_s` method on APP_VERSION will result in a properly formatted version number.
63
63
 
64
64
  APP_VERSION also has `major`, `minor`, `patch`, `meta`, `milestone`, `build`,`branch`, `committer`, and `build_date` methods to retrieve the individual components of the version number.
65
65
 
data/Rakefile CHANGED
@@ -7,6 +7,7 @@ task :default => :test
7
7
 
8
8
  desc 'Test the app_version plugin.'
9
9
  Rake::TestTask.new(:test) do |t|
10
+ t.libs << "test"
10
11
  t.libs << 'lib'
11
12
  t.pattern = 'test/**/*_test.rb'
12
13
  t.verbose = true
@@ -1,3 +1,4 @@
1
+
1
2
  module App
2
3
  require 'app_version/railtie' if defined?(Rails)
3
4
  end
@@ -1,12 +1,30 @@
1
- require 'active_support/core_ext/object'
1
+ require 'active_support/core_ext/object'
2
2
 
3
3
  require 'yaml'
4
4
 
5
+ #
6
+ # App::Version Namespace
7
+ #
5
8
  module App
9
+ #
10
+ # Application Version main class
11
+ #
12
+ # @attr [String] major Major Version number
13
+ # @attr [String] minor Minor Version number
14
+ # @attr [String] patch Patch number
15
+ # @attr [String] milestone Milestone information
16
+ # @attr [String] build Build number
17
+ # @attr [String] branch Git Branch information
18
+ # @attr [String] meta Semantic version meta info
19
+ # @attr [String] commiter Git Commiter information
20
+ # @attr [String] build_date Build Date
21
+ # @attr [String] format Format information
22
+ #
6
23
  class Version
7
24
  include Comparable
8
25
 
9
- attr_accessor :major, :minor, :patch, :milestone, :build, :branch, :meta, :committer, :build_date, :format
26
+ attr_accessor :major, :minor, :patch, :milestone, :build
27
+ attr_accessor :branch, :meta, :committer, :build_date, :format
10
28
 
11
29
  [:major, :minor, :patch, :milestone, :build, :branch, :committer, :meta, :format].each do |attr|
12
30
  define_method "#{attr}=".to_sym do |value|
@@ -20,10 +38,10 @@ module App
20
38
  # Version.new(:major => 1, :minor => 0) #=> "1.0"
21
39
  def initialize(args = nil)
22
40
  if args && args.is_a?(Hash)
23
- args.keys.reject {|key| key.is_a?(Symbol) }.each {|key| args[key.to_sym] = args.delete(key) }
41
+ args.keys.reject { |key| key.is_a?(Symbol) }.each { |key| args[key.to_sym] = args.delete(key) }
24
42
 
25
43
  [:major, :minor].each do |param|
26
- raise ArgumentError.new("The #{param.to_s} parameter is required") if args[param].blank?
44
+ fail ArgumentError.new("The #{param} parameter is required") if args[param].blank?
27
45
  end
28
46
 
29
47
  @major = args[:major].to_s
@@ -38,11 +56,11 @@ module App
38
56
 
39
57
  unless args[:build_date].blank?
40
58
  b_date = case args[:build_date]
41
- when 'git-revdate'
42
- get_revdate_from_git
43
- else
44
- args[:build_date].to_s
45
- end
59
+ when 'git-revdate'
60
+ get_revdate_from_git
61
+ else
62
+ args[:build_date].to_s
63
+ end
46
64
  @build_date = Date.parse(b_date)
47
65
  end
48
66
 
@@ -62,49 +80,66 @@ module App
62
80
  end
63
81
 
64
82
  # Parses a version string to create an instance of the Version class.
83
+ #
84
+ # @param version [String] Version Number String to parse and initialize object with
85
+ # @raise [ArguementError] In the event string not parsable
86
+ # @return [App:Version] Returns populated Version object
65
87
  def self.parse(version)
66
88
  m = version.match(/(\d+)\.(\d+)(?:\.(\d+))?(?:-([\w.\d]+))?(?:\sM(\d+))?(?:\s\((\d+)\))?(?:\sof\s(\w+))?(?:\sby\s(\w+))?(?:\son\s(\S+))?/)
67
89
 
68
- raise ArgumentError.new("The version '#{version}' is unparsable") if m.nil?
90
+ fail ArgumentError.new("The version '#{version}' is unparsable") if m.nil?
69
91
 
70
- version = App::Version.new :major => m[1],
71
- :minor => m[2],
72
- :patch => m[3],
73
- :meta => m[4],
74
- :milestone => m[5],
75
- :build => m[6],
76
- :branch => m[7],
77
- :committer => m[8]
92
+ version = App::Version.new major: m[1],
93
+ minor: m[2],
94
+ patch: m[3],
95
+ meta: m[4],
96
+ milestone: m[5],
97
+ build: m[6],
98
+ branch: m[7],
99
+ committer: m[8]
78
100
 
79
- if (m[9] && m[9] != '')
101
+ if m[9] && m[9] != ''
80
102
  date = Date.parse(m[9])
81
103
  version.build_date = date
82
104
  end
83
105
 
84
- return version
106
+ version
85
107
  end
86
108
 
87
109
  # Loads the version information from a YAML file.
110
+ #
111
+ # @param path [String] Yaml file name to load
88
112
  def self.load(path)
89
- App::Version.new YAML::load(File.open(path))
113
+ App::Version.new YAML.load(File.open(path))
90
114
  end
91
115
 
116
+ #
117
+ # Combined Compare operator for version
118
+ #
119
+ # @param other [App::Version] Version object to compare against
120
+ # @return [Integer] returns -1 if (a <=> b)
121
+ #
92
122
  def <=>(other)
93
123
  # if !self.build.nil? && !other.build.nil?
94
124
  # return self.build <=> other.build
95
125
  # end
96
126
 
97
127
  %w(build major minor patch milestone branch meta committer build_date).each do |meth|
98
- rhs = self.send(meth) || -1
128
+ rhs = send(meth) || -1
99
129
  lhs = other.send(meth) || -1
100
130
 
101
131
  ret = lhs <=> rhs
102
132
  return ret unless ret == 0
103
133
  end
104
134
 
105
- return 0
135
+ 0
106
136
  end
107
137
 
138
+ #
139
+ # Generate version string
140
+ #
141
+ # @return [String] Returns App Version string
142
+ #
108
143
  def to_s
109
144
  if @format
110
145
  str = eval(@format.to_s.inspect)
@@ -121,30 +156,28 @@ module App
121
156
  str
122
157
  end
123
158
 
124
- private
159
+ private
125
160
 
126
161
  def get_build_from_subversion
127
- if File.exists?(".svn")
128
- #YAML.parse(`svn info`)['Revision'].value
162
+ if File.exist?('.svn')
163
+ # YAML.parse(`svn info`)['Revision'].value
129
164
  match = /(?:\d+:)?(\d+)M?S?/.match(`svnversion . -c`)
130
165
  match && match[1]
131
166
  end
132
167
  end
133
168
 
134
169
  def get_revcount_from_git
135
- if File.exists?(".git")
136
- `git rev-list --count HEAD`.strip
137
- end
170
+ `git rev-list --count HEAD`.strip if File.exist?('.git')
138
171
  end
139
-
172
+
140
173
  def get_revdate_from_git
141
- if File.exists?(".git")
174
+ if File.exist?('.git')
142
175
  `git show --date=short --pretty=format:%cd|head -n1`.strip
143
176
  end
144
177
  end
145
-
178
+
146
179
  def get_hash_from_git
147
- if File.exists?(".git")
180
+ if File.exist?('.git')
148
181
  `git show --pretty=format:%H|head -n1|cut -c 1-6`.strip
149
182
  end
150
183
  end
@@ -1,7 +1,13 @@
1
1
  require 'app_version/app_version'
2
- require 'rails'
2
+ require 'rails'
3
3
 
4
+ #
5
+ # Add App::Version Rake tasks
6
+ #
4
7
  module AppVersion
8
+ #
9
+ # Add App::Version Rake tasks
10
+ #
5
11
  class Railtie < Rails::Railtie
6
12
  railtie_name :app_version
7
13
 
@@ -9,4 +15,4 @@ module AppVersion
9
15
  load "tasks/app_version_tasks.rake"
10
16
  end
11
17
  end
12
- end
18
+ end
@@ -1,8 +1,6 @@
1
- require 'minitest/autorun'
2
- require 'active_support'
3
- require 'app_version'
1
+ require 'test_helper'
4
2
 
5
- class AppVersionTest < MiniTest::Unit::TestCase
3
+ class AppVersionTest < MiniTest::Test
6
4
 
7
5
  def setup
8
6
  @version = App::Version.new
@@ -0,0 +1,7 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
4
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
5
+ require 'minitest/autorun'
6
+ require 'active_support'
7
+ require 'app_version'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_version
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Kapp
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-26 00:00:00.000000000 Z
12
+ date: 2016-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -17,16 +17,16 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 4.2.5
20
+ version: 4.2.5.2
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 4.2.5
27
+ version: 4.2.5.2
28
28
  description: App Version Gem originally App Version Rails Plugin from https://github.com/toland/app_version,
29
- updated to work within Rails 3.2+ and Rails 4.x as a gem.
29
+ updated to run with later rails versions as a gem, currently supports Rails 4.2.x.
30
30
  email:
31
31
  - mort666@virus.org
32
32
  - phil.toland@gmail.com
@@ -45,6 +45,7 @@ files:
45
45
  - lib/tasks/app_version_tasks.rake
46
46
  - lib/uninstall.rb
47
47
  - test/app_version_test.rb
48
+ - test/test_helper.rb
48
49
  - test/version.yml
49
50
  homepage: https://github.com/mort666/app_version
50
51
  licenses: []
@@ -65,11 +66,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
66
  version: '0'
66
67
  requirements: []
67
68
  rubyforge_project:
68
- rubygems_version: 2.4.3
69
+ rubygems_version: 2.4.8
69
70
  signing_key:
70
71
  specification_version: 4
71
72
  summary: Rails App Version Gem
72
73
  test_files:
73
74
  - test/app_version_test.rb
75
+ - test/test_helper.rb
74
76
  - test/version.yml
75
- has_rdoc: