Class: Blacksmith::Modulefile
- Inherits:
-
Object
- Object
- Blacksmith::Modulefile
- Defined in:
- lib/puppet_blacksmith/modulefile.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #bump! ⇒ Object
- #increase_version(version) ⇒ Object
-
#initialize(path = "Modulefile") ⇒ Modulefile
constructor
A new instance of Modulefile.
- #metadata ⇒ Object
- #name ⇒ Object
- #replace_version(text, version) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(path = "Modulefile") ⇒ Modulefile
Returns a new instance of Modulefile.
20 21 22 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 20 def initialize(path = "Modulefile") @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
18 19 20 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 18 def path @path end |
Instance Method Details
#bump! ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 40 def bump! new_version = increase_version(version) text = File.read(path) text = replace_version(text, new_version) File.open(path, "w") {|file| file.puts text} new_version end |
#increase_version(version) ⇒ Object
52 53 54 55 56 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 52 def increase_version(version) v = Gem::Version.new("#{version}.0") raise Blacksmith::Error, "Unable to increase prerelease version #{version}" if v.prerelease? v.bump.to_s end |
#metadata ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 24 def unless = Puppet::ModuleTool::Metadata.new Puppet::ModuleTool::ModulefileReader.evaluate(, path) = end end |
#name ⇒ Object
33 34 35 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 33 def name .name end |
#replace_version(text, version) ⇒ Object
48 49 50 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 48 def replace_version(text, version) text.gsub(/\nversion[ ]+['"].*['"]/, "\nversion '#{version}'") end |
#version ⇒ Object
36 37 38 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 36 def version .version end |