Class: Cheflow::Cookbook
- Inherits:
-
Object
- Object
- Cheflow::Cookbook
- Defined in:
- lib/cheflow/cookbook.rb
Instance Attribute Summary collapse
-
#berksfile ⇒ Object
readonly
Returns the value of attribute berksfile.
Instance Method Summary collapse
- #dev_versions ⇒ Object
- #frozen? ⇒ Boolean
-
#initialize(options) ⇒ Cookbook
constructor
A new instance of Cookbook.
- #metadata ⇒ Object
- #name ⇒ Object
- #node_environment_objects ⇒ Object
- #node_environments ⇒ Object
- #path ⇒ Object
- #prod_versions ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
- #version ⇒ Object
- #versions ⇒ Object
Constructor Details
#initialize(options) ⇒ Cookbook
Returns a new instance of Cookbook.
7 8 9 10 |
# File 'lib/cheflow/cookbook.rb', line 7 def initialize() = @berksfile = Berkshelf::Berksfile.(.dup) end |
Instance Attribute Details
#berksfile ⇒ Object (readonly)
Returns the value of attribute berksfile.
4 5 6 |
# File 'lib/cheflow/cookbook.rb', line 4 def berksfile @berksfile end |
Instance Method Details
#dev_versions ⇒ Object
53 54 55 |
# File 'lib/cheflow/cookbook.rb', line 53 def dev_versions versions.select { |v| Semverse::Version.new(v).patch.odd? } end |
#frozen? ⇒ Boolean
65 66 67 |
# File 'lib/cheflow/cookbook.rb', line 65 def frozen? ridley.cookbook.find(name, version).frozen? end |
#metadata ⇒ Object
12 13 14 15 16 17 |
# File 'lib/cheflow/cookbook.rb', line 12 def ||= begin = File.(File.join(path, 'metadata.rb')) Ridley::Chef::Cookbook::Metadata.from_file() end end |
#name ⇒ Object
23 24 25 |
# File 'lib/cheflow/cookbook.rb', line 23 def name @name ||= .name end |
#node_environment_objects ⇒ Object
37 38 39 |
# File 'lib/cheflow/cookbook.rb', line 37 def node_environment_objects @node_environments ||= ridley.search(:environment, "name:node_mongodb*") end |
#node_environments ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/cheflow/cookbook.rb', line 41 def node_environments @node_environment_names ||= node_environment_objects.map do |e| env = e.name.gsub /^#{name}_/, '' env = env == name ? 'production' : env "#{env.ljust(12)} (#{e.cookbook_versions[name]})" end end |
#path ⇒ Object
27 28 29 |
# File 'lib/cheflow/cookbook.rb', line 27 def path @path ||= File.dirname(berksfile.filepath) end |
#prod_versions ⇒ Object
57 58 59 |
# File 'lib/cheflow/cookbook.rb', line 57 def prod_versions versions.select { |v| Semverse::Version.new(v).patch.even? } end |
#to_s ⇒ Object
61 62 63 |
# File 'lib/cheflow/cookbook.rb', line 61 def to_s "#{name} v#{version}#{' (dev)' if version.patch.odd?}#{' (FROZEN)' if frozen?}" end |
#type ⇒ Object
31 32 33 34 35 |
# File 'lib/cheflow/cookbook.rb', line 31 def type if name.start_with? 'node_' 'Node' end end |
#version ⇒ Object
19 20 21 |
# File 'lib/cheflow/cookbook.rb', line 19 def version @version ||= Semverse::Version.new(.version) end |
#versions ⇒ Object
49 50 51 |
# File 'lib/cheflow/cookbook.rb', line 49 def versions @versions ||= ridley.cookbook.versions(name) end |