Class: Jeweler::Version
- Inherits:
-
Object
- Object
- Jeweler::Version
- Defined in:
- lib/jeweler/version.rb
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
Returns the value of attribute base_dir.
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#patch ⇒ Object
readonly
Returns the value of attribute patch.
Instance Method Summary collapse
- #bump_major ⇒ Object
- #bump_minor ⇒ Object
- #bump_patch ⇒ Object
-
#initialize(base_dir) ⇒ Version
constructor
A new instance of Version.
- #refresh ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
- #update_to(major, minor, patch) ⇒ Object
- #write ⇒ Object
- #yaml_path ⇒ Object
Constructor Details
#initialize(base_dir) ⇒ Version
Returns a new instance of Version.
6 7 8 9 10 11 12 |
# File 'lib/jeweler/version.rb', line 6 def initialize(base_dir) self.base_dir = base_dir if File.exists?(yaml_path) parse_yaml end end |
Instance Attribute Details
#base_dir ⇒ Object
Returns the value of attribute base_dir.
3 4 5 |
# File 'lib/jeweler/version.rb', line 3 def base_dir @base_dir end |
#major ⇒ Object (readonly)
Returns the value of attribute major.
4 5 6 |
# File 'lib/jeweler/version.rb', line 4 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
4 5 6 |
# File 'lib/jeweler/version.rb', line 4 def minor @minor end |
#patch ⇒ Object (readonly)
Returns the value of attribute patch.
4 5 6 |
# File 'lib/jeweler/version.rb', line 4 def patch @patch end |
Instance Method Details
#bump_major ⇒ Object
14 15 16 17 18 |
# File 'lib/jeweler/version.rb', line 14 def bump_major @major += 1 @minor = 0 @patch = 0 end |
#bump_minor ⇒ Object
20 21 22 23 |
# File 'lib/jeweler/version.rb', line 20 def bump_minor @minor += 1 @patch = 0 end |
#bump_patch ⇒ Object
25 26 27 |
# File 'lib/jeweler/version.rb', line 25 def bump_patch @patch += 1 end |
#refresh ⇒ Object
53 54 55 |
# File 'lib/jeweler/version.rb', line 53 def refresh parse_yaml end |
#to_hash ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/jeweler/version.rb', line 45 def to_hash { :major => major, :minor => minor, :patch => patch } end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/jeweler/version.rb', line 41 def to_s "#{major}.#{minor}.#{patch}" end |
#update_to(major, minor, patch) ⇒ Object
29 30 31 32 33 |
# File 'lib/jeweler/version.rb', line 29 def update_to(major, minor, patch) @major = major @minor = minor @patch = patch end |
#write ⇒ Object
35 36 37 38 39 |
# File 'lib/jeweler/version.rb', line 35 def write File.open(yaml_path, 'w+') do |f| YAML.dump(self.to_hash, f) end end |
#yaml_path ⇒ Object
57 58 59 60 61 |
# File 'lib/jeweler/version.rb', line 57 def yaml_path denormalized_path = File.join(@base_dir, 'VERSION.yml') absolute_path = File.(denormalized_path) absolute_path.gsub(Dir.getwd + File::SEPARATOR, '') end |