Module: Jeweler::VersionHelper::PlaintextExtension

Defined in:
lib/jeweler/version_helper.rb

Instance Method Summary collapse

Instance Method Details

#parse_plaintextObject



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/jeweler/version_helper.rb', line 61

def parse_plaintext
  plaintext = read_plaintext.chomp
  # http://rubular.com/regexes/10467 -> 3.5.4.a1
  # http://rubular.com/regexes/10468 -> 3.5.4
  if plaintext =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
    @major = $1.to_i
    @minor = $2.to_i
    @patch = $3.to_i
    @build = $4
  end
end

#pathObject



81
82
83
# File 'lib/jeweler/version_helper.rb', line 81

def path
  plaintext_path
end

#read_plaintextObject



73
74
75
# File 'lib/jeweler/version_helper.rb', line 73

def read_plaintext
  File.read(plaintext_path)
end

#refreshObject



77
78
79
# File 'lib/jeweler/version_helper.rb', line 77

def refresh
  parse_plaintext
end

#writeObject



55
56
57
58
59
# File 'lib/jeweler/version_helper.rb', line 55

def write
  File.open(plaintext_path, 'w') do |file|
    file.write to_s
  end
end