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.
18 19 20 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 18 def initialize(path = "Modulefile") @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
16 17 18 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 16 def path @path end |
Instance Method Details
#bump! ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 38 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
50 51 52 53 54 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 50 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
22 23 24 25 26 27 28 29 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 22 def unless = Puppet::ModuleTool::Metadata.new Puppet::ModuleTool::ModulefileReader.evaluate(, path) = end end |
#name ⇒ Object
31 32 33 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 31 def name .name end |
#replace_version(text, version) ⇒ Object
46 47 48 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 46 def replace_version(text, version) text.gsub(/\nversion[ ]+['"].*['"]/, "\nversion '#{version}'") end |
#version ⇒ Object
34 35 36 |
# File 'lib/puppet_blacksmith/modulefile.rb', line 34 def version .version end |