Module: Jeweler::VersionHelper::PlaintextExtension

Defined in:
lib/jeweler/version_helper.rb

Instance Method Summary collapse

Instance Method Details

#parse_plaintextObject



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/jeweler/version_helper.rb', line 56

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



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

def path
  plaintext_path
end

#read_plaintextObject



68
69
70
# File 'lib/jeweler/version_helper.rb', line 68

def read_plaintext
  File.read(plaintext_path)
end

#refreshObject



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

def refresh
  parse_plaintext
end

#writeObject



50
51
52
53
54
# File 'lib/jeweler/version_helper.rb', line 50

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