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.
data/lib/version_info/data.rb
CHANGED
@@ -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?(
|
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(
|
35
|
+
load_from(File.read(file_name))
|
33
36
|
self
|
34
37
|
end
|
35
38
|
|
36
39
|
def save
|
37
|
-
File.open(
|
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
|
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')
|
data/lib/version_info/tasks.rb
CHANGED
@@ -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
|
data/lib/version_info/version.rb
CHANGED
@@ -14,7 +14,7 @@ describe "VersionInfo" do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "has default filename" do
|
17
|
-
TestFile::
|
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
|