Class: ChefDK::PolicyfileLock::LocalCookbook
- Inherits:
-
Object
- Object
- ChefDK::PolicyfileLock::LocalCookbook
- Defined in:
- lib/chef-dk/policyfile_lock.rb
Overview
LocalCookbook objects represent cookbooks that are sourced from the local filesystem and are assumed to be under active development.
Instance Attribute Summary collapse
- #dotted_decimal_identifier ⇒ Object
- #identifier ⇒ Object
-
#relative_paths_root ⇒ Object
The root path from which source is expanded.
-
#source ⇒ Object
A relative or absolute path to the cookbook.
Instance Method Summary collapse
- #cookbook_path ⇒ Object
- #identifiers ⇒ Object
-
#initialize(name, relative_paths_root) ⇒ LocalCookbook
constructor
A new instance of LocalCookbook.
- #scm_profiler ⇒ Object
- #to_lock ⇒ Object
Constructor Details
#initialize(name, relative_paths_root) ⇒ LocalCookbook
Returns a new instance of LocalCookbook.
119 120 121 122 123 |
# File 'lib/chef-dk/policyfile_lock.rb', line 119 def initialize(name, relative_paths_root) @name = name @identifier = nil @relative_paths_root = relative_paths_root end |
Instance Attribute Details
#dotted_decimal_identifier ⇒ Object
141 142 143 |
# File 'lib/chef-dk/policyfile_lock.rb', line 141 def dotted_decimal_identifier @dotted_decimal_identifier || identifiers.dotted_decimal_identifier end |
#identifier ⇒ Object
137 138 139 |
# File 'lib/chef-dk/policyfile_lock.rb', line 137 def identifier @identifier || identifiers.content_identifier end |
#relative_paths_root ⇒ Object
The root path from which source is expanded.
117 118 119 |
# File 'lib/chef-dk/policyfile_lock.rb', line 117 def relative_paths_root @relative_paths_root end |
#source ⇒ Object
A relative or absolute path to the cookbook. If a relative path is given, it is resolved relative to #relative_paths_root
104 105 106 |
# File 'lib/chef-dk/policyfile_lock.rb', line 104 def source @source end |
Instance Method Details
#cookbook_path ⇒ Object
125 126 127 |
# File 'lib/chef-dk/policyfile_lock.rb', line 125 def cookbook_path File.(source, relative_paths_root) end |
#identifiers ⇒ Object
157 158 159 |
# File 'lib/chef-dk/policyfile_lock.rb', line 157 def identifiers @identifiers ||= CookbookProfiler::Identifiers.new(cookbook_path) end |
#scm_profiler ⇒ Object
129 130 131 132 133 134 135 |
# File 'lib/chef-dk/policyfile_lock.rb', line 129 def scm_profiler if File.exist?(File.join(cookbook_path, ".git")) CookbookProfiler::Git.new(cookbook_path) else CookbookProfiler::NullSCM.new(cookbook_path) end end |
#to_lock ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/chef-dk/policyfile_lock.rb', line 145 def to_lock { "version" => identifiers.semver_version, "identifier" => identifier, "dotted_decimal_identifier" => dotted_decimal_identifier, "source" => source, "cache_key" => nil, "scm_info" => scm_profiler.profile_data } end |