Module: Jeweler::VersionHelper::YamlExtension

Defined in:
lib/jeweler/version_helper.rb

Instance Method Summary collapse

Instance Method Details

#parse_yamlObject



28
29
30
31
32
33
34
# File 'lib/jeweler/version_helper.rb', line 28

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

#pathObject



44
45
46
# File 'lib/jeweler/version_helper.rb', line 44

def path
  yaml_path
end

#read_yamlObject



36
37
38
39
40
41
42
# File 'lib/jeweler/version_helper.rb', line 36

def read_yaml
  if File.exists?(yaml_path)
    YAML.load_file(yaml_path)
  else
    raise VersionYmlError, "#{yaml_path} does not exist!"
  end
end

#refreshObject



24
25
26
# File 'lib/jeweler/version_helper.rb', line 24

def refresh
  parse_yaml
end

#to_hashObject



15
16
17
18
19
20
21
22
# File 'lib/jeweler/version_helper.rb', line 15

def to_hash
  {
    :major => major,
    :minor => minor,
    :patch => patch,
    :build => build
  }
end

#writeObject



9
10
11
12
13
# File 'lib/jeweler/version_helper.rb', line 9

def write
  File.open(yaml_path, 'w+') do |f|
    YAML.dump(self.to_hash, f)
  end
end