Class: Stove::Cookbook
- Inherits:
-
Object
- Object
- Stove::Cookbook
- Includes:
- Logify
- Defined in:
- lib/stove/cookbook.rb,
lib/stove/cookbook/metadata.rb
Defined Under Namespace
Classes: Metadata
Instance Attribute Summary collapse
-
#category ⇒ String
The category for this cookbook on the community site.
-
#changeset ⇒ String?
The changeset for this cookbook.
-
#metadata ⇒ Stove::Cookbook::Metadata
readonly
The metadata for this cookbook.
-
#name ⇒ String
readonly
The name of the cookbook (must correspond to the name of the cookbook on the community site).
-
#path ⇒ Pathname
readonly
The path to this cookbook on disk.
-
#version ⇒ String
readonly
The version of this cookbook (originally).
Instance Method Summary collapse
-
#bump(new_version) ⇒ String
Bump the version in the metdata.rb to the specified parameter.
-
#initialize(path) ⇒ Cookbook
constructor
Create a new wrapper around the cookbook object.
- #release! ⇒ Object
-
#released? ⇒ Boolean
Deterine if this cookbook version is released on the community site.
-
#tag_version ⇒ String
The tag version.
-
#tarball ⇒ File
So there’s this really really crazy bug that the tmp directory could be deleted mid-request…
-
#url ⇒ String
The URL for the cookbook on the Community Site.
Constructor Details
#initialize(path) ⇒ Cookbook
Create a new wrapper around the cookbook object.
63 64 65 66 |
# File 'lib/stove/cookbook.rb', line 63 def initialize(path) @path = Pathname.new(path). end |
Instance Attribute Details
#category ⇒ String
The category for this cookbook on the community site.
73 74 75 76 77 78 |
# File 'lib/stove/cookbook.rb', line 73 def category @category ||= Community.cookbook(name)['category'] rescue Faraday::Error::ResourceNotFound log.warn("Cookbook `#{name}' not found on the Chef community site") nil end |
#changeset ⇒ String?
The changeset for this cookbook. This is written by the changelog generator and read by various plugins.
55 56 57 |
# File 'lib/stove/cookbook.rb', line 55 def changeset @changeset end |
#metadata ⇒ Stove::Cookbook::Metadata (readonly)
The metadata for this cookbook.
38 39 40 |
# File 'lib/stove/cookbook.rb', line 38 def @metadata end |
#name ⇒ String (readonly)
The name of the cookbook (must correspond to the name of the cookbook on the community site).
24 25 26 |
# File 'lib/stove/cookbook.rb', line 24 def name @name end |
#path ⇒ Pathname (readonly)
The path to this cookbook on disk.
16 17 18 |
# File 'lib/stove/cookbook.rb', line 16 def path @path end |
#version ⇒ String (readonly)
The version of this cookbook (originally).
31 32 33 |
# File 'lib/stove/cookbook.rb', line 31 def version @version end |
Instance Method Details
#bump(new_version) ⇒ String
Bump the version in the metdata.rb to the specified parameter.
153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/stove/cookbook.rb', line 153 def bump(new_version) return true if new_version.to_s == version.to_s = path.join('metadata.rb') contents = File.read() contents.sub!(/^version(\s+)('|")#{version}('|")/, "version\\1\\2#{new_version}\\3") File.open(, 'w') { |f| f.write(contents) } end |
#release! ⇒ Object
121 122 123 124 125 126 |
# File 'lib/stove/cookbook.rb', line 121 def release! if [:changelog] log.info('Updating changelog') update_changelog end end |
#released? ⇒ Boolean
Deterine if this cookbook version is released on the community site
113 114 115 116 117 118 |
# File 'lib/stove/cookbook.rb', line 113 def released? Community.cookbook(name, version) true rescue Faraday::Error::ResourceNotFound false end |
#tag_version ⇒ String
The tag version. This is just the current version prefixed with the letter “v”.
98 99 100 |
# File 'lib/stove/cookbook.rb', line 98 def tag_version "v#{version}" end |
#tarball ⇒ File
So there’s this really really crazy bug that the tmp directory could be deleted mid-request…
134 135 136 137 138 139 140 141 |
# File 'lib/stove/cookbook.rb', line 134 def tarball return @tarball if @tarball && File.exists?(@tarball) begin @tarball = Stove::Packager.new(self).package_path end until File.exists?(@tarball) @tarball end |
#url ⇒ String
The URL for the cookbook on the Community Site.
85 86 87 |
# File 'lib/stove/cookbook.rb', line 85 def url URI.join(Community.base_url, 'cookbooks', name) end |