chef-api 0.10.0 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  module ChefAPI
2
2
  class Resource::Organization < Resource::Base
3
- collection_path '/organizations'
3
+ collection_path "/organizations"
4
4
 
5
5
  schema do
6
6
  attribute :name, type: String, primary: true, required: true
@@ -16,7 +16,7 @@ module ChefAPI
16
16
  ignore :billing_plan
17
17
  ignore :requester_id
18
18
  ignore :assigned_at
19
- ignore 'couchrest-type'
19
+ ignore "couchrest-type"
20
20
  end
21
21
  end
22
22
  end
@@ -1,6 +1,6 @@
1
1
  module ChefAPI
2
2
  class Resource::PartialSearch < Resource::Base
3
- collection_path '/search/:index'
3
+ collection_path "/search/:index"
4
4
 
5
5
  schema do
6
6
  attribute :total, type: Integer
@@ -24,19 +24,19 @@ module ChefAPI
24
24
  # @return [self]
25
25
  # the current resource
26
26
  #
27
- def query(index, keys, query = '*:*', options = {})
27
+ def query(index, keys, query = "*:*", options = {})
28
28
  return nil if index.nil?
29
29
 
30
30
  params = {}.tap do |o|
31
31
  o[:q] = query
32
32
  o[:rows] = options[:rows] || 1000
33
- o[:sort] = options[:sort] || 'X_CHEF_id_CHEF_X'
33
+ o[:sort] = options[:sort] || "X_CHEF_id_CHEF_X"
34
34
  o[:start] = options[:start] || 0
35
35
  end
36
36
 
37
37
  path = expanded_collection_path(index: index.to_s)
38
38
  response = connection.post(path, keys.to_json, params)
39
- response['rows'].map! { |row| row['data'] }
39
+ response["rows"].map! { |row| row["data"] }
40
40
  from_json(response, index: index.to_s)
41
41
  end
42
42
  end
@@ -1,6 +1,6 @@
1
1
  module ChefAPI
2
2
  class Resource::Principal < Resource::Base
3
- collection_path '/principals'
3
+ collection_path "/principals"
4
4
 
5
5
  schema do
6
6
  attribute :name, type: String, primary: true, required: true
@@ -1,7 +1,7 @@
1
1
  module ChefAPI
2
2
  class Resource::Role < Resource::Base
3
3
  include ChefAPI::AclAble
4
- collection_path '/roles'
4
+ collection_path "/roles"
5
5
 
6
6
  schema do
7
7
  attribute :name, type: String, primary: true, required: true
@@ -1,6 +1,6 @@
1
1
  module ChefAPI
2
2
  class Resource::Search < Resource::Base
3
- collection_path '/search/:index'
3
+ collection_path "/search/:index"
4
4
 
5
5
  schema do
6
6
  attribute :total, type: Integer
@@ -22,22 +22,22 @@ module ChefAPI
22
22
  # @return [self]
23
23
  # the current resource
24
24
  #
25
- def query(index, query = '*:*', options = {})
25
+ def query(index, query = "*:*", options = {})
26
26
  return nil if index.nil?
27
27
 
28
28
  params = {}.tap do |o|
29
29
  o[:q] = query
30
30
  o[:rows] = options[:rows] || 1000
31
- o[:sort] = options[:sort] || 'X_CHEF_id_CHEF_X'
31
+ o[:sort] = options[:sort] || "X_CHEF_id_CHEF_X"
32
32
  o[:start] = options[:start] || 0
33
33
  end
34
34
 
35
35
  path = expanded_collection_path(index: index.to_s)
36
36
 
37
37
  response = if filter_result = options[:filter_result]
38
- connection.post(path, filter_result.to_json, params)
39
- else
40
- connection.get(path, params)
38
+ connection.post(path, filter_result.to_json, params)
39
+ else
40
+ connection.get(path, params)
41
41
  end
42
42
 
43
43
  from_json(response, index: index.to_s)
@@ -1,6 +1,6 @@
1
1
  module ChefAPI
2
2
  class Resource::User < Resource::Base
3
- collection_path '/users'
3
+ collection_path "/users"
4
4
 
5
5
  schema do
6
6
  flavor :enterprise do
@@ -38,7 +38,7 @@ module ChefAPI
38
38
  # HEC/EC returns a slightly different response than OSC/CZ
39
39
  if users.is_a?(Array)
40
40
  users.each do |info|
41
- name = URI.escape(info['user']['username'])
41
+ name = URI.escape(info["user"]["username"])
42
42
  response = connection.get("/users/#{name}")
43
43
  result = from_json(response, prefix)
44
44
 
@@ -75,7 +75,7 @@ module ChefAPI
75
75
  # the parsed JSON response from the server
76
76
  #
77
77
  def authenticate(options = {})
78
- connection.post('/authenticate_user', options.to_json)
78
+ connection.post("/authenticate_user", options.to_json)
79
79
  end
80
80
  end
81
81
  end
@@ -14,10 +14,10 @@ module ChefAPI
14
14
  def underscore(string)
15
15
  string
16
16
  .to_s
17
- .gsub(/::/, '/')
18
- .gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
19
- .gsub(/([a-z\d])([A-Z])/,'\1_\2')
20
- .tr('-', '_')
17
+ .gsub(/::/, "/")
18
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
19
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
20
+ .tr("-", "_")
21
21
  .downcase
22
22
  end
23
23
 
@@ -32,8 +32,8 @@ module ChefAPI
32
32
  def camelize(string)
33
33
  string
34
34
  .to_s
35
- .split('_')
36
- .map { |e| e.capitalize }
35
+ .split("_")
36
+ .map(&:capitalize)
37
37
  .join
38
38
  end
39
39
 
@@ -49,7 +49,7 @@ module ChefAPI
49
49
  length = options[:length] || 30
50
50
 
51
51
  if string.length > length
52
- string[0..length-3] + '...'
52
+ string[0..length - 3] + "..."
53
53
  else
54
54
  string
55
55
  end
@@ -77,7 +77,7 @@ module ChefAPI
77
77
  #
78
78
  def safe_read(path)
79
79
  path = File.expand_path(path)
80
- name = File.basename(path, '.*')
80
+ name = File.basename(path, ".*")
81
81
  contents = File.read(path)
82
82
 
83
83
  [name, contents]
@@ -1,8 +1,8 @@
1
1
  module ChefAPI
2
2
  module Validator
3
- autoload :Base, 'chef-api/validators/base'
4
- autoload :Required, 'chef-api/validators/required'
5
- autoload :Type, 'chef-api/validators/type'
3
+ autoload :Base, "chef-api/validators/base"
4
+ autoload :Required, "chef-api/validators/required"
5
+ autoload :Type, "chef-api/validators/type"
6
6
 
7
7
  #
8
8
  # Find a validator by the given key.
@@ -35,7 +35,7 @@ module ChefAPI
35
35
  # @return [Symbol]
36
36
  #
37
37
  def key
38
- name = self.class.name.split('::').last
38
+ name = self.class.name.split("::").last
39
39
  Util.underscore(name).to_sym
40
40
  end
41
41
 
@@ -47,7 +47,7 @@ module ChefAPI
47
47
  # the parent resource to validate against
48
48
  #
49
49
  def validate(resource)
50
- raise Error::AbstractMethod.new(method: 'Validators::Base#validate')
50
+ raise Error::AbstractMethod.new(method: "Validators::Base#validate")
51
51
  end
52
52
 
53
53
  #
@@ -76,7 +76,7 @@ module ChefAPI
76
76
  # @return [String]
77
77
  #
78
78
  def classname
79
- @classname ||= self.class.name.split('::')[1..-1].join('::')
79
+ @classname ||= self.class.name.split("::")[1..-1].join("::")
80
80
  end
81
81
  end
82
82
  end
@@ -4,7 +4,7 @@ module ChefAPI
4
4
  value = resource._attributes[attribute]
5
5
 
6
6
  if value.to_s.strip.empty?
7
- resource.errors.add(attribute, 'must be present')
7
+ resource.errors.add(attribute, "must be present")
8
8
  end
9
9
  end
10
10
  end
@@ -15,7 +15,7 @@ module ChefAPI
15
15
  value = resource._attributes[attribute]
16
16
 
17
17
  if value && !types.any? { |type| value.is_a?(type) }
18
- short_name = type.to_s.split('::').last
18
+ short_name = type.to_s.split("::").last
19
19
  resource.errors.add(attribute, "must be a kind of #{short_name}")
20
20
  end
21
21
  end
@@ -1,3 +1,3 @@
1
1
  module ChefAPI
2
- VERSION = "0.10.0".freeze
2
+ VERSION = "0.10.2".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Vargo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-10-18 00:00:00.000000000 Z
12
+ date: 2019-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: logify