Class: Jeweler::VersionHelper
- Inherits:
-
Object
- Object
- Jeweler::VersionHelper
- Defined in:
- lib/jeweler/version_helper.rb
Defined Under Namespace
Modules: PlaintextExtension, YamlExtension
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
Returns the value of attribute base_dir.
-
#build ⇒ Object
readonly
Returns the value of attribute build.
-
#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.
- #plaintext_path ⇒ Object
- #to_s ⇒ Object
- #update_to(major, minor, patch, build = nil) ⇒ Object
- #yaml_path ⇒ Object
Constructor Details
#initialize(base_dir) ⇒ VersionHelper
Returns a new instance of VersionHelper.
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/jeweler/version_helper.rb', line 81 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 |
#build ⇒ Object (readonly)
Returns the value of attribute build.
6 7 8 |
# File 'lib/jeweler/version_helper.rb', line 6 def build @build 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
95 96 97 98 99 100 |
# File 'lib/jeweler/version_helper.rb', line 95 def bump_major @major += 1 @minor = 0 @patch = 0 @build = nil end |
#bump_minor ⇒ Object
102 103 104 105 106 |
# File 'lib/jeweler/version_helper.rb', line 102 def bump_minor @minor += 1 @patch = 0 @build = nil end |
#bump_patch ⇒ Object
108 109 110 111 |
# File 'lib/jeweler/version_helper.rb', line 108 def bump_patch @patch += 1 @build = nil end |
#plaintext_path ⇒ Object
130 131 132 133 134 |
# File 'lib/jeweler/version_helper.rb', line 130 def plaintext_path denormalized_path = File.join(@base_dir, 'VERSION') absolute_path = File.(denormalized_path) absolute_path.gsub(Dir.getwd + File::SEPARATOR, '') end |
#to_s ⇒ Object
120 121 122 |
# File 'lib/jeweler/version_helper.rb', line 120 def to_s [major, minor, patch, build].compact.join('.') end |
#update_to(major, minor, patch, build = nil) ⇒ Object
113 114 115 116 117 118 |
# File 'lib/jeweler/version_helper.rb', line 113 def update_to(major, minor, patch, build=nil) @major = major @minor = minor @patch = patch @build = build end |
#yaml_path ⇒ Object
124 125 126 127 128 |
# File 'lib/jeweler/version_helper.rb', line 124 def yaml_path denormalized_path = File.join(@base_dir, 'VERSION.yml') absolute_path = File.(denormalized_path) absolute_path.gsub(Dir.getwd + File::SEPARATOR, '') end |