chef-api 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 604ea8d7021e718c9a4118755df5097d07c9ae2e
4
- data.tar.gz: 7453647507aa0ae5950878b54ff5eb2712d373f5
3
+ metadata.gz: 1e22717c3690474e0b8d8dc2e49662ae7541c9dd
4
+ data.tar.gz: b77f6c57956db9b6b9e06ee677171fa26bf39ced
5
5
  SHA512:
6
- metadata.gz: c5eab0b7d40e618c0cf0fdc7b647e47d96f07edf6327dda10b37087405d9003f7a810d57a6e345ee14cdecf34c9484c864ea36ab006d27dd75fadcb532fbd6ff
7
- data.tar.gz: 330478952c1e26868ee4ef6780a973f6b05f67104d15f798f3eaf7b84cfdd0fb70a4a962fb8e5dd88336a0ba1769e432fc91e932a7a0fdf45062fe51ea103da1
6
+ metadata.gz: 20c1d17608e4670595086eef399b4ee6108f987546f6124c82ffe7e7a3bbd16fce2015bda69e2f860ea4cc1275e07d7ecfd2d88834fb521ebf391dfe230703d8
7
+ data.tar.gz: dfa5c1c5a75e2f75c1b7dc6c4e0346774aecd664f6ea4103b8d12dd531338f091628b1ac7e7829a3cea59db5b53266f77f55c145c16cee41adee684e6dd5cd3b
@@ -1,8 +1,10 @@
1
1
  sudo: false
2
+ dist: trusty
2
3
 
3
4
  rvm:
4
5
  - 2.2.5
5
6
  - 2.3.1
7
+ - 2.4.1
6
8
 
7
9
  # Don't install local development gems on Travis, use parallel gem downloads
8
10
  bundler_args: --without development --jobs 7
@@ -1,5 +1,13 @@
1
1
  # ChefAPI Changelog
2
2
 
3
+ ## v0.7.1 (2017-08-06)
4
+
5
+ - Don't set nil `JSON.create_id` as it's unnecessary in recent versions
6
+ of the JSON library
7
+ - Avoid ArgumentError when no HOME environment variable is set
8
+ - Add Resource::Organization proxy
9
+ - Update all comments to point to the correct Docs site URLs
10
+
3
11
  ## v0.6.0 (2016-05-05)
4
12
 
5
13
  - Remove support for Ruby 1.9
data/Gemfile CHANGED
@@ -7,6 +7,6 @@ end
7
7
 
8
8
  group :test do
9
9
  gem 'chef-zero', '~> 2.0.0'
10
- gem 'rake', '~> 11.0'
10
+ gem 'rake'
11
11
  gem 'rspec', '~> 3.0'
12
12
  end
@@ -3,9 +3,6 @@ require 'logify'
3
3
  require 'pathname'
4
4
  require 'chef-api/version'
5
5
 
6
- # Do not inflate JSON objects
7
- JSON.create_id = nil
8
-
9
6
  module ChefAPI
10
7
  autoload :Authentication, 'chef-api/authentication'
11
8
  autoload :Boolean, 'chef-api/boolean'
@@ -7,7 +7,7 @@ module ChefAPI
7
7
  #
8
8
  # Connection object for the ChefAPI API.
9
9
  #
10
- # @see http://docs.opscode.com/api_chef_server.html
10
+ # @see https://docs.chef.io/api_chef_server.html
11
11
  #
12
12
  class Connection
13
13
  class << self
@@ -47,6 +47,7 @@ module ChefAPI
47
47
  proxy :roles, 'Resource::Role'
48
48
  proxy :search, 'Resource::Search'
49
49
  proxy :users, 'Resource::User'
50
+ proxy :organizations, 'Resource::Organization'
50
51
 
51
52
  #
52
53
  # Create a new ChefAPI Connection with the given options. Any options
@@ -1,4 +1,5 @@
1
1
  require 'chef-api/version'
2
+ require 'pathname'
2
3
  require 'json'
3
4
 
4
5
  module ChefAPI
@@ -24,8 +25,32 @@ module ChefAPI
24
25
  #
25
26
  # @return [Hash]
26
27
  def config
27
- path = File.expand_path(ENV['CHEF_API_CONFIG'] || '~/.chef-api')
28
- @config ||= File.exist?(path) ? JSON.parse(File.read(path)) : {}
28
+ path = config_path
29
+ @config ||= path.exist? ? JSON.parse(path.read) : {}
30
+ end
31
+
32
+ #
33
+ # Pathname to configuration file, or a blank Pathname.
34
+ #
35
+ # @return [Pathname] an expanded Pathname or a non-existent Pathname
36
+ def config_path
37
+ if result = chef_api_config_path
38
+ Pathname(result).expand_path
39
+ else
40
+ Pathname('')
41
+ end
42
+ end
43
+
44
+ #
45
+ # String representation of path to configuration file
46
+ #
47
+ # @return [String, nil] Path to config file, or nil
48
+ def chef_api_config_path
49
+ ENV['CHEF_API_CONFIG'] || if ENV.key?('HOME')
50
+ '~/.chef-api'
51
+ else
52
+ nil
53
+ end
29
54
  end
30
55
 
31
56
  #
@@ -10,7 +10,7 @@ module ChefAPI
10
10
 
11
11
  class << self
12
12
  #
13
- # About search : http://docs.opscode.com/essentials_search.html
13
+ # About search : https://docs.chef.io/chef_search.html
14
14
  #
15
15
  # @param [String] index
16
16
  # the name of the index to search
@@ -10,7 +10,7 @@ module ChefAPI
10
10
 
11
11
  class << self
12
12
  #
13
- # About search : http://docs.opscode.com/essentials_search.html
13
+ # About search : https://docs.chef.io/chef_search.html
14
14
  #
15
15
  # @param [String] index
16
16
  # the name of the index to search
@@ -1,3 +1,3 @@
1
1
  module ChefAPI
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
@@ -2,6 +2,10 @@ require 'spec_helper'
2
2
 
3
3
  module ChefAPI
4
4
  describe Defaults do
5
+ before(:each) do
6
+ subject.instance_variable_set(:@config, nil)
7
+ end
8
+
5
9
  context 'without a config file' do
6
10
  before(:each) do
7
11
  allow(subject).to receive(:config).and_return(Hash.new)
@@ -16,15 +20,32 @@ module ChefAPI
16
20
  end
17
21
  end
18
22
 
23
+ context 'without a config file and no ENV vars to find it' do
24
+ around do |example|
25
+ old_conf = ENV.delete('CHEF_API_CONFIG')
26
+ old_home = ENV.delete('HOME')
27
+ example.run
28
+ ENV['CHEF_API_CONFIG'] = old_conf
29
+ ENV['HOME'] = old_home
30
+ end
31
+
32
+ it 'returns the default without errors' do
33
+ expect { subject.config }.not_to raise_error
34
+ end
35
+
36
+ it 'returns the default which is the empty hash' do
37
+ expect(subject.config).to eq({})
38
+ end
39
+ end
40
+
19
41
  context 'with a config file' do
20
42
  before(:each) do
21
- subject.instance_variable_set(:@config, nil)
22
- allow(File).to receive(:exist?).with(anything()).and_return(true)
23
- allow(File).to receive(:read).and_return("{\n"\
43
+ config_content = "{\n"\
24
44
  "\"CHEF_API_ENDPOINT\": \"test_endpoint\",\n" \
25
45
  "\"CHEF_API_USER_AGENT\": \"test_user_agent\"\n" \
26
46
  "}"
27
- )
47
+ path = instance_double(Pathname, read: config_content, exist?: true)
48
+ allow(subject).to receive(:config_path).and_return(path)
28
49
  end
29
50
 
30
51
  it 'returns the overridden value for endpoint' do
@@ -20,7 +20,9 @@ module ChefAPI
20
20
 
21
21
  describe '.collection_path' do
22
22
  it 'raises an exception if the collection name is not set' do
23
- expect { described_class.collection_path }.to raise_error
23
+ expect {
24
+ described_class.collection_path
25
+ }.to raise_error(ArgumentError, 'collection_path not set for Class')
24
26
  end
25
27
 
26
28
  it 'sets the collection name' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Vargo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-03 00:00:00.000000000 Z
11
+ date: 2017-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logify
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  requirements: []
146
146
  rubyforge_project:
147
- rubygems_version: 2.6.6
147
+ rubygems_version: 2.6.12
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: A Chef API client in Ruby