Class: CookbookOmnifetch::ChefServerLocation

Inherits:
BaseLocation show all
Defined in:
lib/cookbook-omnifetch/chef_server.rb

Instance Attribute Summary collapse

Attributes inherited from BaseLocation

#dependency, #options

Instance Method Summary collapse

Methods inherited from BaseLocation

#to_lock, #validate_cached!

Constructor Details

#initialize(dependency, options = {}) ⇒ ChefServerLocation

Returns a new instance of ChefServerLocation.



10
11
12
13
14
15
# File 'lib/cookbook-omnifetch/chef_server.rb', line 10

def initialize(dependency, options = {})
  super
  @cookbook_version = options[:version]
  @http_client = options[:http_client] || default_chef_server_http_client
  @uri ||= options[:chef_server]
end

Instance Attribute Details

#cookbook_versionObject (readonly)

Returns the value of attribute cookbook_version.



7
8
9
# File 'lib/cookbook-omnifetch/chef_server.rb', line 7

def cookbook_version
  @cookbook_version
end

#uriObject (readonly)

Returns the value of attribute uri.



8
9
10
# File 'lib/cookbook-omnifetch/chef_server.rb', line 8

def uri
  @uri
end

Instance Method Details

#cache_keyObject



56
57
58
# File 'lib/cookbook-omnifetch/chef_server.rb', line 56

def cache_key
  "#{dependency.name}-#{cookbook_version}"
end

#cached_cookbookObject



61
62
63
# File 'lib/cookbook-omnifetch/chef_server.rb', line 61

def cached_cookbook
  @cached_cookbook ||= CookbookOmnifetch.cached_cookbook_class.from_path(install_path)
end

#cookbook_nameObject



17
18
19
# File 'lib/cookbook-omnifetch/chef_server.rb', line 17

def cookbook_name
  dependency.name
end

#http_clientObject



40
41
42
# File 'lib/cookbook-omnifetch/chef_server.rb', line 40

def http_client
  @http_client
end

#installObject



29
30
31
# File 'lib/cookbook-omnifetch/chef_server.rb', line 29

def install
  installer.install
end

#install_pathPathname?

The path where this cookbook would live in the store, if it were installed.

Returns:

  • (Pathname, nil)


48
49
50
# File 'lib/cookbook-omnifetch/chef_server.rb', line 48

def install_path
  @install_path ||= CookbookOmnifetch.storage_path.join(cache_key)
end

#installed?Boolean

Determine if this revision is installed.

Returns:

  • (Boolean)


36
37
38
# File 'lib/cookbook-omnifetch/chef_server.rb', line 36

def installed?
  install_path.exist?
end

#installerObject



25
26
27
# File 'lib/cookbook-omnifetch/chef_server.rb', line 25

def installer
  MetadataBasedInstaller.new(http_client: http_client, url_path: url_path, install_path: install_path)
end

#lock_dataObject



52
53
54
# File 'lib/cookbook-omnifetch/chef_server.rb', line 52

def lock_data
  { "chef_server" => uri, "version" => cookbook_version }
end

#url_pathObject



21
22
23
# File 'lib/cookbook-omnifetch/chef_server.rb', line 21

def url_path
  "/cookbooks/#{cookbook_name}/#{cookbook_version}"
end