Class: Jeweler::VersionHelper
- Inherits:
-
Object
- Object
- Jeweler::VersionHelper
show all
- Defined in:
- lib/jeweler/version_helper.rb
Defined Under Namespace
Modules: PlaintextExtension, YamlExtension
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of VersionHelper.
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/jeweler/version_helper.rb', line 80
def initialize(base_dir)
self.base_dir = base_dir
if File.exists?(yaml_path)
extend YamlExtension
parse_yaml
else
extend PlaintextExtension
if File.exists?(plaintext_path)
parse_plaintext
end
end
end
|
Instance Attribute Details
#base_dir ⇒ Object
Returns the value of attribute base_dir.
5
6
7
|
# File 'lib/jeweler/version_helper.rb', line 5
def base_dir
@base_dir
end
|
#major ⇒ Object
Returns the value of attribute major.
6
7
8
|
# File 'lib/jeweler/version_helper.rb', line 6
def major
@major
end
|
#minor ⇒ Object
Returns the value of attribute minor.
6
7
8
|
# File 'lib/jeweler/version_helper.rb', line 6
def minor
@minor
end
|
#patch ⇒ Object
Returns the value of attribute patch.
6
7
8
|
# File 'lib/jeweler/version_helper.rb', line 6
def patch
@patch
end
|
#timestamp ⇒ Object
Returns the value of attribute timestamp.
6
7
8
|
# File 'lib/jeweler/version_helper.rb', line 6
def timestamp
@timestamp
end
|
Instance Method Details
#bump_major ⇒ Object
94
95
96
97
98
|
# File 'lib/jeweler/version_helper.rb', line 94
def bump_major
@major += 1
@minor = 0
@patch = 0
end
|
#bump_minor ⇒ Object
100
101
102
103
|
# File 'lib/jeweler/version_helper.rb', line 100
def bump_minor
@minor += 1
@patch = 0
end
|
#bump_patch ⇒ Object
105
106
107
|
# File 'lib/jeweler/version_helper.rb', line 105
def bump_patch
@patch += 1
end
|
#bump_timestamp ⇒ Object
109
110
111
|
# File 'lib/jeweler/version_helper.rb', line 109
def bump_timestamp
@timestamp = Time.now.strftime("%Y%m%d%H%M%S")
end
|
#plaintext_path ⇒ Object
133
134
135
136
137
|
# File 'lib/jeweler/version_helper.rb', line 133
def plaintext_path
denormalized_path = File.join(@base_dir, 'VERSION')
absolute_path = File.expand_path(denormalized_path)
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
end
|
#to_s ⇒ Object
123
124
125
|
# File 'lib/jeweler/version_helper.rb', line 123
def to_s
"#{major}.#{minor}.#{patch}" + (timestamp ? ".#{timestamp}" : "")
end
|
#update_to(major, minor, patch, timestamp = nil) ⇒ Object
113
114
115
116
117
118
119
120
121
|
# File 'lib/jeweler/version_helper.rb', line 113
def update_to(major, minor, patch, timestamp=nil)
if timestamp.kind_of? Time
timestamp = strftime("%Y%m%d%H%M%S")
end
@major = major
@minor = minor
@patch = patch
@timestamp = timestamp
end
|
#yaml_path ⇒ Object
127
128
129
130
131
|
# File 'lib/jeweler/version_helper.rb', line 127
def yaml_path
denormalized_path = File.join(@base_dir, 'VERSION.yml')
absolute_path = File.expand_path(denormalized_path)
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
end
|