Class: Jeweler::VersionHelper
- Inherits:
-
Object
- Object
- Jeweler::VersionHelper
- Defined in:
- lib/jeweler/version_helper.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) ⇒ VersionHelper
constructor
A new instance of VersionHelper.
- #refresh ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
- #update_to(major, minor, patch) ⇒ Object
- #write ⇒ Object
- #yaml_path ⇒ Object
Constructor Details
#initialize(base_dir) ⇒ VersionHelper
Returns a new instance of VersionHelper.
8 9 10 11 12 13 14 |
# File 'lib/jeweler/version_helper.rb', line 8 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.
5 6 7 |
# File 'lib/jeweler/version_helper.rb', line 5 def base_dir @base_dir end |
#major ⇒ Object (readonly)
Returns the value of attribute major.
6 7 8 |
# File 'lib/jeweler/version_helper.rb', line 6 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
6 7 8 |
# File 'lib/jeweler/version_helper.rb', line 6 def minor @minor end |
#patch ⇒ Object (readonly)
Returns the value of attribute patch.
6 7 8 |
# File 'lib/jeweler/version_helper.rb', line 6 def patch @patch end |
Instance Method Details
#bump_major ⇒ Object
16 17 18 19 20 |
# File 'lib/jeweler/version_helper.rb', line 16 def bump_major @major += 1 @minor = 0 @patch = 0 end |
#bump_minor ⇒ Object
22 23 24 25 |
# File 'lib/jeweler/version_helper.rb', line 22 def bump_minor @minor += 1 @patch = 0 end |
#bump_patch ⇒ Object
27 28 29 |
# File 'lib/jeweler/version_helper.rb', line 27 def bump_patch @patch += 1 end |
#refresh ⇒ Object
55 56 57 |
# File 'lib/jeweler/version_helper.rb', line 55 def refresh parse_yaml end |
#to_hash ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/jeweler/version_helper.rb', line 47 def to_hash { :major => major, :minor => minor, :patch => patch } end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/jeweler/version_helper.rb', line 43 def to_s "#{major}.#{minor}.#{patch}" end |
#update_to(major, minor, patch) ⇒ Object
31 32 33 34 35 |
# File 'lib/jeweler/version_helper.rb', line 31 def update_to(major, minor, patch) @major = major @minor = minor @patch = patch end |
#write ⇒ Object
37 38 39 40 41 |
# File 'lib/jeweler/version_helper.rb', line 37 def write File.open(yaml_path, 'w+') do |f| YAML.dump(self.to_hash, f) end end |
#yaml_path ⇒ Object
59 60 61 62 63 |
# File 'lib/jeweler/version_helper.rb', line 59 def yaml_path denormalized_path = File.join(@base_dir, 'VERSION.yml') absolute_path = File.(denormalized_path) absolute_path.gsub(Dir.getwd + File::SEPARATOR, '') end |