Module: Jeweler::VersionHelper::YamlExtension
- Defined in:
- lib/jeweler/version_helper.rb
Instance Method Summary collapse
- #parse_yaml ⇒ Object
- #path ⇒ Object
- #read_yaml ⇒ Object
- #refresh ⇒ Object
- #to_hash ⇒ Object
- #write ⇒ Object
Instance Method Details
#parse_yaml ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/jeweler/version_helper.rb', line 33 def parse_yaml yaml = read_yaml @major = (yaml['major'] || yaml[:major]).to_i @minor = (yaml['minor'] || yaml[:minor]).to_i @patch = (yaml['patch'] || yaml[:patch]).to_i @build = (yaml['build'] || yaml[:build]) end |
#path ⇒ Object
49 50 51 |
# File 'lib/jeweler/version_helper.rb', line 49 def path yaml_path end |
#read_yaml ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/jeweler/version_helper.rb', line 41 def read_yaml if File.exists?(yaml_path) YAML.load_file(yaml_path) else raise VersionYmlError, "#{yaml_path} does not exist!" end end |
#refresh ⇒ Object
29 30 31 |
# File 'lib/jeweler/version_helper.rb', line 29 def refresh parse_yaml end |
#to_hash ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/jeweler/version_helper.rb', line 20 def to_hash { :major => major, :minor => minor, :patch => patch, :build => build } end |
#write ⇒ Object
14 15 16 17 18 |
# File 'lib/jeweler/version_helper.rb', line 14 def write File.open(yaml_path, 'w+') do |f| YAML.dump(self.to_hash, f) end end |