Class: Berkshelf::CachedCookbook
- Inherits:
-
Ridley::Chef::Cookbook
- Object
- Ridley::Chef::Cookbook
- Berkshelf::CachedCookbook
- Defined in:
- lib/berkshelf/cached_cookbook.rb
Constant Summary collapse
- DIRNAME_REGEXP =
/^(.+)-(.+)$/
Class Method Summary collapse
-
.from_store_path(path) ⇒ CachedCookbook
An instance of CachedCookbook initialized by the contents found at the given path.
Instance Method Summary collapse
Class Method Details
.from_store_path(path) ⇒ CachedCookbook
Returns an instance of CachedCookbook initialized by the contents found at the given path.
12 13 14 15 16 17 18 |
# File 'lib/berkshelf/cached_cookbook.rb', line 12 def from_store_path(path) path = Pathname.new(path) cached_name = File.basename(path.to_s).slice(DIRNAME_REGEXP, 1) return nil if cached_name.nil? @loaded[path.to_s] ||= from_path(path, name: cached_name) end |
Instance Method Details
#dependencies ⇒ Hash
24 25 26 |
# File 'lib/berkshelf/cached_cookbook.rb', line 24 def dependencies .recommendations.merge(.dependencies) end |
#pretty_hash ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/berkshelf/cached_cookbook.rb', line 45 def pretty_hash {}.tap do |h| h[:name] = cookbook_name unless name.blank? h[:version] = version unless version.blank? h[:description] = .description unless .description.blank? h[:author] = .maintainer unless .maintainer.blank? h[:email] = .maintainer_email unless .maintainer_email.blank? h[:license] = .license unless .license.blank? h[:platforms] = .platforms.to_hash unless .platforms.blank? h[:dependencies] = dependencies.to_hash unless dependencies.blank? end end |
#pretty_json ⇒ Object
41 42 43 |
# File 'lib/berkshelf/cached_cookbook.rb', line 41 def pretty_json pretty_hash.to_json end |
#pretty_print ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/berkshelf/cached_cookbook.rb', line 28 def pretty_print [].tap do |a| a.push " Name: #{cookbook_name}" unless name.blank? a.push " Version: #{version}" unless version.blank? a.push " Description: #{metadata.description}" unless .description.blank? a.push " Author: #{metadata.maintainer}" unless .maintainer.blank? a.push " Email: #{metadata.maintainer_email}" unless .maintainer_email.blank? a.push " License: #{metadata.license}" unless .license.blank? a.push " Platforms: #{pretty_map(metadata.platforms, 14)}" unless .platforms.blank? a.push "Dependencies: #{pretty_map(dependencies, 14)}" unless dependencies.blank? end.join("\n") end |