version_info 0.5.3 → 0.6.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.
@@ -3,22 +3,25 @@ require 'yaml'
3
3
 
4
4
  module VersionInfo
5
5
  class Data < OpenStruct
6
- class << self
7
- attr_accessor :file_name
8
- def file_name
9
- @file_name ||= Dir.pwd + '/' + underscore(self.name) + '_info.yml'
10
- end
11
- end
12
6
 
13
7
  def initialize
14
8
  super
15
- if File.exist?(self.class.file_name)
9
+ if File.exist?(file_name)
16
10
  load
17
11
  else
18
12
  marshal_load(get_defaults)
19
13
  end
20
14
  end
21
15
 
16
+ def file_name
17
+ @file_name ||= Dir.pwd + '/' + underscore(self.class.name) + '_info.yml'
18
+ end
19
+
20
+ def file_name=(value)
21
+ @file_name = value
22
+ load if File.exist?(@file_name)
23
+ end
24
+
22
25
  def bump(key)
23
26
  idx = VersionInfo.segments.index(key.to_sym) + 1
24
27
  return unless idx
@@ -29,12 +32,12 @@ module VersionInfo
29
32
  end
30
33
 
31
34
  def load
32
- load_from(File.read(self.class.file_name))
35
+ load_from(File.read(file_name))
33
36
  self
34
37
  end
35
38
 
36
39
  def save
37
- File.open(self.class.file_name, 'w' ) {|out| save_to(out)}
40
+ File.open(file_name, 'w' ) {|out| save_to(out)}
38
41
  self
39
42
  end
40
43
 
@@ -64,7 +67,7 @@ module VersionInfo
64
67
  self
65
68
  end
66
69
 
67
- def self.underscore(camel_cased_word)
70
+ def underscore(camel_cased_word)
68
71
  word = camel_cased_word.to_s.dup
69
72
  word.gsub!(/::/, '/')
70
73
  word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
@@ -16,6 +16,12 @@ module VersionInfo
16
16
 
17
17
  def install
18
18
  namespace :vinfo do
19
+
20
+ desc "Inspect all current version keys"
21
+ task :inspect do
22
+ puts target::VERSION.inspect
23
+ end
24
+
19
25
  desc "Show current version tag and create version_info.yml if missing"
20
26
  task :show do
21
27
  puts target::VERSION.tag
@@ -1,7 +1,7 @@
1
1
  module VersionInfo
2
2
  Version = Class.new(Data)
3
- Version.file_name = 'lib/version_info/version_info.yml'
4
3
 
5
4
  VERSION = Version.new
5
+ VERSION.file_name = 'lib/version_info/version_info.yml'
6
6
  end
7
7
 
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  major: 0
3
- minor: 5
4
- patch: 3
3
+ minor: 6
4
+ patch: 0
@@ -14,7 +14,7 @@ describe "VersionInfo" do
14
14
  end
15
15
 
16
16
  it "has default filename" do
17
- TestFile::Version.file_name.should == Dir.pwd + '/test_file/version_info.yml'
17
+ TestFile::VERSION.file_name.should == Dir.pwd + '/test_file/version_info.yml'
18
18
  end
19
19
 
20
20
  it "can assign filename" do
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 5
8
- - 3
9
- version: 0.5.3
7
+ - 6
8
+ - 0
9
+ version: 0.6.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jorge L. Cangas