Class: ChefDK::Policyfile::CookbookSpec
- Inherits:
-
Object
- Object
- ChefDK::Policyfile::CookbookSpec
- Defined in:
- lib/chef-dk/policyfile/cookbook_spec.rb
Constant Summary collapse
- SOURCE_TYPES =
[:git, :github, :path, :artifactserver]
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source_options ⇒ Object
readonly
Returns the value of attribute source_options.
-
#source_type ⇒ Object
readonly
Returns the value of attribute source_type.
-
#version_constraint ⇒ Object
readonly
Returns the value of attribute version_constraint.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #cache_key ⇒ Object
- #cached_cookbook ⇒ Object
- #dependencies ⇒ Object
- #ensure_cached ⇒ Object
-
#initialize(name, version_constraint, source_options, policyfile_filename) ⇒ CookbookSpec
constructor
A new instance of CookbookSpec.
- #installer ⇒ Object
- #mirrors_canonical_upstream? ⇒ Boolean
- #relative_path ⇒ Object
- #relative_paths_root ⇒ Object
- #uri ⇒ Object
- #version ⇒ Object
- #version_fixed? ⇒ Boolean
Constructor Details
#initialize(name, version_constraint, source_options, policyfile_filename) ⇒ CookbookSpec
Returns a new instance of CookbookSpec.
33 34 35 36 37 38 39 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 33 def initialize(name, version_constraint, , policyfile_filename) @name = name @version_constraint = Semverse::Constraint.new(version_constraint) @source_options = @policyfile_filename = policyfile_filename @source_type = SOURCE_TYPES.find { |type| .key?(type) } end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
29 30 31 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 29 def name @name end |
#source_options ⇒ Object (readonly)
Returns the value of attribute source_options.
30 31 32 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 30 def @source_options end |
#source_type ⇒ Object (readonly)
Returns the value of attribute source_type.
31 32 33 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 31 def source_type @source_type end |
#version_constraint ⇒ Object (readonly)
Returns the value of attribute version_constraint.
28 29 30 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 28 def version_constraint @version_constraint end |
Instance Method Details
#==(other) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 41 def ==(other) other.kind_of?(self.class) and other.name == name and other.version_constraint == version_constraint and other. == end |
#cache_key ⇒ Object
62 63 64 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 62 def cache_key installer.cache_key end |
#cached_cookbook ⇒ Object
86 87 88 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 86 def cached_cookbook installer.cached_cookbook end |
#dependencies ⇒ Object
82 83 84 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 82 def dependencies cached_cookbook.dependencies end |
#ensure_cached ⇒ Object
52 53 54 55 56 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 52 def ensure_cached unless installer.installed? installer.install end end |
#installer ⇒ Object
58 59 60 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 58 def installer @installer ||= CookbookOmnifetch.init(self, ) end |
#mirrors_canonical_upstream? ⇒ Boolean
48 49 50 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 48 def mirrors_canonical_upstream? [:git, :github, :artifactserver].include?(source_type) end |
#relative_path ⇒ Object
66 67 68 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 66 def relative_path installer.relative_path.to_s end |
#relative_paths_root ⇒ Object
90 91 92 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 90 def relative_paths_root File.dirname(@policyfile_filename) end |
#uri ⇒ Object
70 71 72 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 70 def uri installer.uri end |
#version ⇒ Object
78 79 80 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 78 def version cached_cookbook.version end |
#version_fixed? ⇒ Boolean
74 75 76 |
# File 'lib/chef-dk/policyfile/cookbook_spec.rb', line 74 def version_fixed? [:git, :github, :path].include?(@source_type) end |