Module: Version::File::JewelerFormat
Overview
Jeweler style VERSION file, e.g.
---
:major: 1
:minor: 0
:patch: 0
:build: pre.1
Instance Method Summary collapse
Instance Method Details
#match?(path, data) ⇒ Boolean
19 20 21 22 23 24 |
# File 'lib/versus/file/jeweler_format.rb', line 19 def match?(path, data) return false unless Hash === data data = data.inject({}){|h,(k,v)| h[k.to_sym]=v; h} keys = data.keys - [:major, :minor, :patch, :build] keys.empty? end |
#parse(data) ⇒ Object
39 40 41 42 43 |
# File 'lib/versus/file/jeweler_format.rb', line 39 def parse(data) data = data.inject({}){|h,(k,v)| h[k.to_sym]=v; h} tuple = data.values_at(:major,:minor,:patch,:build).compact Number.new(*tuple) end |
#render(number) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/versus/file/jeweler_format.rb', line 29 def render(number) ":major: #{number[0]}\n" + ":minor: #{number[1]}\n" + ":patch: #{number[2]}\n" + ":build: #{number[3..-1].join('.')}\n" end |