Class: CookbookDevelopment::VersionFile
- Inherits:
-
Object
- Object
- CookbookDevelopment::VersionFile
- Defined in:
- lib/cookbook/development/rake/version_tasks.rb
Direct Known Subclasses
Constant Summary collapse
- VERSION_FILE =
File.join(Dir.pwd, 'VERSION')
- ALT_VERSION_FILE =
File.join(Dir.pwd, 'recipes', 'VERSION')
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #bump(level) ⇒ Object
- #bump!(level) ⇒ Object
-
#initialize(path) ⇒ VersionFile
constructor
A new instance of VersionFile.
- #save ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path) ⇒ VersionFile
Returns a new instance of VersionFile.
33 34 35 36 |
# File 'lib/cookbook/development/rake/version_tasks.rb', line 33 def initialize(path) @path = Pathname.new(path) @version = @path.read end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
32 33 34 |
# File 'lib/cookbook/development/rake/version_tasks.rb', line 32 def path @path end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
31 32 33 |
# File 'lib/cookbook/development/rake/version_tasks.rb', line 31 def version @version end |
Class Method Details
.in_dir(dir = Dir.pwd) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cookbook/development/rake/version_tasks.rb', line 11 def in_dir(dir = Dir.pwd) = File.join(Dir.pwd, 'metadata.rb') if File.exist? VERSION_FILE VersionFile.new(VERSION_FILE) elsif File.exist? ALT_VERSION_FILE # The release process relies on having a VERSION file in the root of # your cookbook as well as the version attribute in metadata.rb reading # from said VERSION file. Until https://github.com/opscode/test-kitchen/pull/212 # is resolved we need to put the cookbooks in a place that test-kitchen # will copy to the VM. VersionFile.new(ALT_VERSION_FILE) elsif File.exist? MetadataVersion.new() else raise 'I could not find a VERSION file or a metadata.rb' end end |
Instance Method Details
#bump(level) ⇒ Object
38 39 40 |
# File 'lib/cookbook/development/rake/version_tasks.rb', line 38 def bump(level) @version.to_version.bump!(level).to_s end |
#bump!(level) ⇒ Object
42 43 44 45 46 |
# File 'lib/cookbook/development/rake/version_tasks.rb', line 42 def bump!(level) @version = bump(level) save @version end |
#save ⇒ Object
52 53 54 55 56 |
# File 'lib/cookbook/development/rake/version_tasks.rb', line 52 def save @path.open('w') do |io| io << self end end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/cookbook/development/rake/version_tasks.rb', line 48 def to_s @version end |