spice 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +12 -14
  2. data/lib/spice/version.rb +1 -1
  3. data/lib/spice.rb +44 -7
  4. metadata +30 -30
data/README.md CHANGED
@@ -12,24 +12,20 @@ Of course, You can always grab the source from http://github.com/danryan/spice.
12
12
 
13
13
  ## Configuration
14
14
 
15
- Spice has five configuration variables:
15
+ Spice has four configuration variables:
16
16
 
17
- Spice.host # default: localhost
18
- Spice.port # default: 4000
19
- Spice.scheme # default: http
20
- Spice.chef_version # default: 0.9.14. Should be set to the version you have
17
+ Spice.server_url # default: http://localhost:4000
18
+ Spice.chef_version # default: 0.10.4. Should be set to the version you have
21
19
  Spice.client_name # default: nil. Must be set to a valid admin Chef client
22
20
  Spice.key_file # default: nil. Must be set to a file path
23
21
 
24
22
  To connect to a Chef server at https://chef.example.com:5000 with the "admin" API client, throw this somewhere your app can initialize:
25
23
 
26
- Spice.host = "chef.example.com"
27
- Spice.port = "5000"
28
- Spice.scheme = "https"
24
+ Spice.server_url = "http://chef.example.com:4000"
29
25
  Spice.client_name = "admin"
30
26
  Spice.key_file = "/path/to/keyfile.pem"
31
27
 
32
- Say you had a Chef server v0.9.14 (or Chef solo) running locally on port 4000 over HTTP, you only need to set your `client_name` and `key_file` path:
28
+ Say you had a Chef server v0.10.4 (or Chef solo) running locally on port 4000 over HTTP, you only need to set your `client_name` and `key_file` path:
33
29
 
34
30
  Spice.client_name = "admin"
35
31
  Spice.key_file = "/path/to/keyfile.pem"
@@ -38,20 +34,22 @@ Say you had a Chef server v0.9.14 (or Chef solo) running locally on port 4000 ov
38
34
  You can also use the Spice.setup block if you prefer this style:
39
35
 
40
36
  Spice.setup do |s|
41
- s.host = "chef.example.com"
42
- s.port = "5000"
43
- s.scheme = "https"
37
+ s.server_url = "http://chef.example.com:4000"
44
38
  s.client_name = "admin"
45
39
  s.key_file = "/path/to/keyfile.pem"
46
40
  end
47
41
 
48
- After you have configured Spice, we need to create the connection object you'll use to sign your requests and pass them to the Chef server:
42
+ Next, we need to create the connection object you'll use to sign your requests and pass them to the Chef server. Previous versions of Spice required you to explicitly call `Spice.connect!` to set up the connection object. If you use the `Spice.setup` block, it will call `.connect!` for you:
49
43
 
50
44
  Spice.connect!
51
45
 
52
46
  If you want to reset your config to their default values:
53
47
 
54
48
  Spice.reset!
49
+
50
+ ### Deprecation notice
51
+
52
+ Explicitly setting a `host`, `port`, and `scheme` value has been deprecated in favor of setting a single variable, `server_url`, which matches the format of Chef's client config parameter, chef_server_url. The old way of defining `host`, `port`, and `scheme` are still currently available but will be removed from future versions.
55
53
 
56
54
  ## Usage
57
55
 
@@ -100,6 +98,6 @@ TODO
100
98
 
101
99
  ## Copyright
102
100
 
103
- Copyright (c) 2010 Dan Ryan. See LICENSE.txt for
101
+ Copyright (c) 2011 Dan Ryan. See LICENSE.txt for
104
102
  further details.
105
103
 
data/lib/spice/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Spice
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
data/lib/spice.rb CHANGED
@@ -23,21 +23,49 @@ require 'spice/mock'
23
23
  module Spice
24
24
 
25
25
  class << self
26
- attr_writer :server_url, :client_name, :connection,
27
- :key_file, :raw_key, :chef_version
26
+ attr_writer :server_url, :client_name, :connection, :host, :port, :scheme,
27
+ :key_file, :raw_key, :chef_version, :url_path
28
28
 
29
29
  def default_server_url
30
- @default_server_url || "http://localhost:4000"
30
+ @default_server_url ||= "http://localhost:4000"
31
31
  end
32
32
 
33
33
  def default_url_path
34
- @default_url_path || ""
34
+ @default_url_path ||= ""
35
35
  end
36
36
 
37
+ def default_host
38
+ @default_host ||= "localhost"
39
+ end
40
+
41
+ def default_port
42
+ @default_port ||= "4000"
43
+ end
44
+
45
+ def default_scheme
46
+ @default_scheme ||= "http"
47
+ end
48
+
37
49
  def server_url
38
50
  @server_url || default_server_url
39
51
  end
40
-
52
+
53
+ def url_path
54
+ @url_path || default_url_path
55
+ end
56
+
57
+ def host
58
+ @host || default_host
59
+ end
60
+
61
+ def port
62
+ @port || default_port
63
+ end
64
+
65
+ def scheme
66
+ @scheme || default_scheme
67
+ end
68
+
41
69
  def client_name
42
70
  @client_name
43
71
  end
@@ -58,7 +86,7 @@ module Spice
58
86
  end
59
87
 
60
88
  def default_chef_version
61
- @default_chef_version || "0.10.4"
89
+ @default_chef_version ||= "0.10.4"
62
90
  end
63
91
 
64
92
  def chef_version
@@ -70,8 +98,14 @@ module Spice
70
98
  end
71
99
 
72
100
  def connect!
101
+ # allow old-style connection setup
102
+ if host != default_host || port != default_port || scheme != default_scheme || url_path != default_url_path
103
+ url = "#{scheme}://#{host}:#{port}#{url_path}"
104
+ else
105
+ url = server_url
106
+ end
73
107
  @connection = Connection.new(
74
- :server_url => server_url,
108
+ :server_url => url,
75
109
  :client_name => client_name,
76
110
  :key_file => key_file
77
111
  )
@@ -79,6 +113,9 @@ module Spice
79
113
 
80
114
  def reset!
81
115
  @server_url = default_server_url
116
+ @host = default_host
117
+ @port = default_port
118
+ @scheme = default_scheme
82
119
  @chef_version = default_chef_version
83
120
  @key_file = nil
84
121
  @client_name = nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-04 00:00:00.000000000Z
12
+ date: 2011-09-08 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70138046296360 !ruby/object:Gem::Requirement
16
+ requirement: &70276879512400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.9.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70138046296360
24
+ version_requirements: *70276879512400
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rest-client
27
- requirement: &70138046295740 !ruby/object:Gem::Requirement
27
+ requirement: &70276879511900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.6.6
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70138046295740
35
+ version_requirements: *70276879511900
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mixlib-authentication
38
- requirement: &70138046295180 !ruby/object:Gem::Requirement
38
+ requirement: &70276879511440 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.1.4
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70138046295180
46
+ version_requirements: *70276879511440
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yajl-ruby
49
- requirement: &70138046294600 !ruby/object:Gem::Requirement
49
+ requirement: &70276879510980 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.8.3
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70138046294600
57
+ version_requirements: *70276879510980
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &70138046294020 !ruby/object:Gem::Requirement
60
+ requirement: &70276879510520 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 2.6.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70138046294020
68
+ version_requirements: *70276879510520
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
- requirement: &70138046293460 !ruby/object:Gem::Requirement
71
+ requirement: &70276879510060 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.6.2
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70138046293460
79
+ version_requirements: *70276879510060
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: timecop
82
- requirement: &70138046292880 !ruby/object:Gem::Requirement
82
+ requirement: &70276879509600 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.3.5
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70138046292880
90
+ version_requirements: *70276879509600
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: guard
93
- requirement: &70138046292360 !ruby/object:Gem::Requirement
93
+ requirement: &70276879509140 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 0.6.2
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70138046292360
101
+ version_requirements: *70276879509140
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: guard-rspec
104
- requirement: &70138046291860 !ruby/object:Gem::Requirement
104
+ requirement: &70276879508680 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 0.4.2
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70138046291860
112
+ version_requirements: *70276879508680
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: guard-spork
115
- requirement: &70138046291280 !ruby/object:Gem::Requirement
115
+ requirement: &70276879508200 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 0.2.1
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70138046291280
123
+ version_requirements: *70276879508200
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: spork
126
- requirement: &70138046290720 !ruby/object:Gem::Requirement
126
+ requirement: &70276879507740 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: 0.9.0.rc8
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70138046290720
134
+ version_requirements: *70276879507740
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: rb-fsevent
137
- requirement: &70138046290160 !ruby/object:Gem::Requirement
137
+ requirement: &70276879507280 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: 0.4.3.1
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *70138046290160
145
+ version_requirements: *70276879507280
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: growl
148
- requirement: &70138046289700 !ruby/object:Gem::Requirement
148
+ requirement: &70276879506820 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,7 +153,7 @@ dependencies:
153
153
  version: 1.0.3
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *70138046289700
156
+ version_requirements: *70276879506820
157
157
  description: Spice is a zesty Chef API wrapper. Its primary purpose is to let you
158
158
  easily integrate your apps with a Chef server easily. Spice provides support for
159
159
  the entire released Chef API
@@ -224,7 +224,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
224
224
  version: '0'
225
225
  segments:
226
226
  - 0
227
- hash: 3716504645551320101
227
+ hash: 3721453362787661200
228
228
  required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  none: false
230
230
  requirements:
@@ -233,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  version: '0'
234
234
  segments:
235
235
  - 0
236
- hash: 3716504645551320101
236
+ hash: 3721453362787661200
237
237
  requirements: []
238
238
  rubyforge_project: spice
239
239
  rubygems_version: 1.8.8