acquia-cloud 0.5.4 → 0.5.5

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: d344dd0b4aac9724c42177e1db0ebd4ff1e99de5
4
- data.tar.gz: af477384773b947d984e30c6bf7149991ee67d43
3
+ metadata.gz: 85c11648299dbc0bacb54b7fb14027dbe3bea2bd
4
+ data.tar.gz: f8c6f5136af56b64e12ad58f1ad3400a4696f76e
5
5
  SHA512:
6
- metadata.gz: 40b074ee29df0f3cf85787b668e7bd86c7fa238ea787d9c79e712bf9da4250e9e1747822dc48483f7b5d7dfa7961659a8bd38b8bacc2222edee5e2071f641287
7
- data.tar.gz: 96c7aaf78565bb1a3b2cbb606c0fb952647a3436dd7ca284c68973aa4e6554b0a21a0d589c2a7d1b39ada788e75ad80779a3f25535179065c1711fc22a5ffe75
6
+ metadata.gz: 4596ede846c0813bba17132abce2ff2de0464fa7e59a7c901fe1451d053aeca5172b71cdf2e1a1a86f1d8396682bca777ffa57b581e7659be877fdce6afea590
7
+ data.tar.gz: 7409c49b5efce6da5655d27dcbff331f697d8898a06f2c86369fd1a9f4f3c3e71fcc90a2bca7649c34debdbb2a4d66d3102b8ab5f9a35d7876132fd22c09be06
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2017 Matthew Scharley
1
+ Copyright (c) 2017 Equiem Services Pty Ltd
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a
4
4
  copy of this software and associated documentation files (the "Software"),
@@ -30,6 +30,7 @@ end
30
30
  %w{
31
31
  version
32
32
  errors
33
+ credentials
33
34
  api
34
35
  database
35
36
  database_backup
@@ -19,19 +19,10 @@ module Acquia
19
19
  client.use Faraday::Response::RaiseError
20
20
  end
21
21
 
22
- if args[:credentials].nil?
23
- if ENV['ACQUIA_CLOUD_CREDENTIALS'].nil?
24
- raise 'Unable to detect your credentials. Please populate ACQUIA_CLOUD_CREDENTIALS with your username and API key.'
25
- end
26
-
27
- args[:credentials] = ENV['ACQUIA_CLOUD_CREDENTIALS']
28
- end
29
-
30
- @credentials = args[:credentials].split(':', 2)
31
- if @credentials.length < 2
32
- raise 'You must specify both username and API key in credentials.'
33
- end
34
- @acquia.basic_auth *@credentials
22
+ credentials = Credentials.new(args[:credentials])
23
+ raise 'Unable to determine your Acquia Cloud credentials.' \
24
+ unless credentials.defined?
25
+ @acquia.basic_auth credentials.email, credentials.key
35
26
  end
36
27
 
37
28
  def get(url = nil, params = nil, headers = nil, &block)
@@ -0,0 +1,50 @@
1
+ require 'yaml'
2
+
3
+ module Acquia
4
+ class Cloud
5
+ # This class controls access to Acquia Cloud API credentials.
6
+ #
7
+ # This class can load data from a few different places. Firstly, you can
8
+ # pass a string of the form "$email:$key". You can also load a similar
9
+ # string from the environment variable ACQUIA_CLOUD_CREDENTIALS.
10
+ #
11
+ # As a fallback if none of the above is provided then this class will check
12
+ # the ~/.acquia/cloudapi.conf file. This is the recommended approach for
13
+ # using credentials with this API as this file is shared between many
14
+ # different libraries.
15
+ class Credentials
16
+ CREDENTIALS_FILE = "#{ENV['HOME']}/.acquia/cloudapi.conf"
17
+
18
+ attr_reader :email
19
+ attr_reader :key
20
+
21
+ def initialize(value = nil)
22
+ value = ENV['ACQUIA_CLOUD_CREDENTIALS'] if value.nil?
23
+
24
+ if value.nil?
25
+ if File.exist? CREDENTIALS_FILE
26
+ creds = YAML.load_file CREDENTIALS_FILE
27
+
28
+ @email = creds['email']
29
+ @key = creds['key']
30
+ end
31
+ else
32
+ vals = value.split(':', 2)
33
+
34
+ @email = vals[0]
35
+ @key = vals[1]
36
+ end
37
+ end
38
+
39
+ def defined?
40
+ !@email.nil? && !@password.nil?
41
+ end
42
+
43
+ alias_method :old_inspect, :inspect
44
+ private :old_inspect
45
+ def inspect
46
+ old_inspect.gsub(/, @key=".*?"/, '')
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,5 +1,5 @@
1
1
  module Acquia
2
2
  class Cloud
3
- VERSION = '0.5.4'
3
+ VERSION = '0.5.5'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acquia-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Equiem
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-05 00:00:00.000000000 Z
11
+ date: 2017-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -83,6 +83,7 @@ files:
83
83
  - acquia-cloud.gemspec
84
84
  - lib/acquia/cloud.rb
85
85
  - lib/acquia/cloud/api.rb
86
+ - lib/acquia/cloud/credentials.rb
86
87
  - lib/acquia/cloud/database.rb
87
88
  - lib/acquia/cloud/database_backup.rb
88
89
  - lib/acquia/cloud/database_environment.rb
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  version: '0'
118
119
  requirements: []
119
120
  rubyforge_project:
120
- rubygems_version: 2.4.8
121
+ rubygems_version: 2.6.8
121
122
  signing_key:
122
123
  specification_version: 4
123
124
  summary: Bindings to the Acquia Cloud API.