Module: Spice

Extended by:
Config
Defined in:
lib/spice/request.rb,
lib/spice.rb,
lib/spice/base.rb,
lib/spice/node.rb,
lib/spice/role.rb,
lib/spice/error.rb,
lib/spice/client.rb,
lib/spice/config.rb,
lib/spice/version.rb,
lib/spice/cookbook.rb,
lib/spice/data_bag.rb,
lib/spice/connection.rb,
lib/spice/environment.rb,
lib/spice/identity_map.rb,
lib/spice/request/auth.rb,
lib/spice/data_bag_item.rb,
lib/spice/authentication.rb,
lib/spice/connection/nodes.rb,
lib/spice/connection/roles.rb,
lib/spice/cookbook_version.rb,
lib/spice/connection/search.rb,
lib/spice/connection/clients.rb,
lib/spice/response/parse_json.rb,
lib/spice/connection/cookbooks.rb,
lib/spice/connection/data_bags.rb,
lib/spice/response/client_error.rb,
lib/spice/connection/environments.rb

Overview

require 'spice/request/auth' require 'spice/response/parse_json' require 'spice/response/client_error'

Defined Under Namespace

Modules: Authentication, Config, Request, Response Classes: Base, Client, Connection, Cookbook, CookbookVersion, DataBag, DataBagItem, Environment, Error, IdentityMap, Node, Role

Constant Summary collapse

VERSION =
"1.0.6"

Constants included from Config

Config::DEFAULT_CHEF_VERSION, Config::DEFAULT_CLIENT_KEY, Config::DEFAULT_CLIENT_NAME, Config::DEFAULT_CONNECTION_OPTIONS, Config::DEFAULT_MIDDLEWARE, Config::DEFAULT_SERVER_URL, Config::DEFAULT_USER_AGENT, Config::VALID_OPTIONS_KEYS

Class Method Summary collapse

Methods included from Config

extended, options, reset, setup

Class Method Details

.method_missing(method, *args, &block) ⇒ Object

Delegate methods to Spice::Connection


18
19
20
21
# File 'lib/spice.rb', line 18

def method_missing(method, *args, &block)
  return super unless new.respond_to?(method)
  new.send(method, *args, &block)
end

.mockObject

def respond_to?


27
28
29
30
31
32
33
# File 'lib/spice.rb', line 27

def mock
  Spice.server_url = 'http://localhost:4000/organizations/spice'
  Spice.client_name = "testclient"
  Spice.client_key = Spice.read_key_file(File.expand_path("../../spec/fixtures/client.pem", __FILE__))
  Spice.chef_version = "0.10.10"
  self
end

.new(options = Mash.new) ⇒ Object

Convience alias for Spice::Connection.new

return [Spice::Connection]


13
14
15
# File 'lib/spice.rb', line 13

def new(options=Mash.new)
  Spice::Connection.new(options)
end

.read_key_file(path) ⇒ Object

def mock


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/spice.rb', line 35

def read_key_file(path)
  key_file_path = File.expand_path(path)
  
  begin
    raw_key = File.read(key_file_path).strip
  rescue SystemCallError, IOError => e
    raise IOError, "Unable to read #{key_file_path}"
  end
  
  begin_rsa = "-----BEGIN RSA PRIVATE KEY-----"
  end_rsa   = "-----END RSA PRIVATE KEY-----"
  
  unless (raw_key =~ /\A#{begin_rsa}$/) && (raw_key =~ /^#{end_rsa}\Z/)
    msg = "The file #{key_file_path} is not a properly formatted private key.\n"
    msg << "It must contain '#{begin_rsa}' and '#{end_rsa}'"
    raise ArgumentError, msg
  end
  return OpenSSL::PKey::RSA.new(raw_key)
end

.respond_to?(method, include_private = false) ⇒ Boolean

def method_missing

Returns:

  • (Boolean)

23
24
25
# File 'lib/spice.rb', line 23

def respond_to?(method, include_private=false)
  new.respond_to?(method, include_private) || super(method, include_private)
end