fog-core 2.1.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +5 -5
  2. data/.github/FUNDING.yml +2 -0
  3. data/.github/dependabot.yml +10 -0
  4. data/.github/workflows/ci.yml +32 -0
  5. data/.rubocop.yml +16 -12
  6. data/.rubocop_todo.yml +724 -0
  7. data/CONTRIBUTING.md +5 -1
  8. data/Gemfile +1 -1
  9. data/README.md +2 -1
  10. data/Rakefile +2 -14
  11. data/SECURITY.md +6 -0
  12. data/changelog.md +241 -141
  13. data/fog-core.gemspec +13 -9
  14. data/lib/fog/account.rb +0 -16
  15. data/lib/fog/billing.rb +0 -11
  16. data/lib/fog/compute/models/server.rb +7 -3
  17. data/lib/fog/compute.rb +3 -25
  18. data/lib/fog/core/association.rb +1 -0
  19. data/lib/fog/core/attributes/default.rb +7 -0
  20. data/lib/fog/core/attributes.rb +42 -5
  21. data/lib/fog/core/cache.rb +58 -55
  22. data/lib/fog/core/collection.rb +9 -3
  23. data/lib/fog/core/connection.rb +4 -6
  24. data/lib/fog/core/current_machine.rb +1 -1
  25. data/lib/fog/core/errors.rb +1 -1
  26. data/lib/fog/core/logger.rb +5 -2
  27. data/lib/fog/core/mock.rb +7 -2
  28. data/lib/fog/core/model.rb +34 -5
  29. data/lib/fog/core/provider.rb +37 -4
  30. data/lib/fog/core/scp.rb +16 -11
  31. data/lib/fog/core/service.rb +5 -5
  32. data/lib/fog/core/services_mixin.rb +62 -10
  33. data/lib/fog/core/ssh.rb +49 -25
  34. data/lib/fog/core/stringify_keys.rb +0 -2
  35. data/lib/fog/core/time.rb +2 -2
  36. data/lib/fog/core/uuid.rb +2 -8
  37. data/lib/fog/core/version.rb +3 -1
  38. data/lib/fog/core/wait_for.rb +2 -1
  39. data/lib/fog/core/wait_for_defaults.rb +2 -0
  40. data/lib/fog/core.rb +57 -59
  41. data/lib/fog/dns.rb +0 -11
  42. data/lib/fog/formatador.rb +9 -8
  43. data/lib/fog/monitoring.rb +0 -11
  44. data/lib/fog/network.rb +0 -12
  45. data/lib/fog/schema/data_validator.rb +1 -0
  46. data/lib/fog/storage.rb +15 -30
  47. data/lib/fog/support.rb +0 -12
  48. data/lib/fog/test_helpers/collection_helper.rb +2 -0
  49. data/lib/fog/test_helpers/formats_helper.rb +2 -2
  50. data/lib/fog/test_helpers/helper.rb +3 -3
  51. data/lib/fog/test_helpers/minitest/assertions.rb +1 -1
  52. data/lib/fog/test_helpers/minitest/expectations.rb +1 -1
  53. data/lib/fog/test_helpers/mock_helper.rb +84 -84
  54. data/lib/fog/test_helpers/succeeds_helper.rb +2 -2
  55. data/lib/fog/test_helpers/types_helper.rb +1 -0
  56. data/lib/fog/vpn.rb +0 -12
  57. data/lib/tasks/test_task.rb +4 -5
  58. metadata +58 -85
  59. data/.travis.yml +0 -39
  60. data/spec/compute/models/server_spec.rb +0 -229
  61. data/spec/compute_spec.rb +0 -95
  62. data/spec/connection_spec.rb +0 -105
  63. data/spec/core/cache_spec.rb +0 -191
  64. data/spec/core/model_spec.rb +0 -36
  65. data/spec/core/stringify_keys_spec.rb +0 -38
  66. data/spec/core/whitelist_keys_spec.rb +0 -36
  67. data/spec/credentials_spec.rb +0 -88
  68. data/spec/current_machine_spec.rb +0 -36
  69. data/spec/fake_app/fake_service.rb +0 -18
  70. data/spec/fake_app/models/collection.rb +0 -5
  71. data/spec/fake_app/models/model.rb +0 -2
  72. data/spec/fake_app/requests/request.rb +0 -11
  73. data/spec/fog_attribute_spec.rb +0 -549
  74. data/spec/formatador_spec.rb +0 -154
  75. data/spec/identity_spec.rb +0 -95
  76. data/spec/mocking_spec.rb +0 -84
  77. data/spec/service_spec.rb +0 -201
  78. data/spec/spec_helper.rb +0 -19
  79. data/spec/storage_spec.rb +0 -114
  80. data/spec/test_helpers/formats_helper_spec.rb +0 -121
  81. data/spec/test_helpers/schema_validator_spec.rb +0 -101
  82. data/spec/timeout_spec.rb +0 -20
  83. data/spec/utils_spec.rb +0 -29
  84. data/spec/uuid_spec.rb +0 -11
  85. data/spec/wait_for_spec.rb +0 -30
@@ -8,9 +8,22 @@ module Fog
8
8
  end
9
9
 
10
10
  module Provider
11
- def self.extended(base)
12
- provider = base.to_s.split("::").last
13
- Fog.providers[provider.downcase.to_sym] = provider
11
+ class << self
12
+ def extended(base)
13
+ provider = base.to_s.split("::").last
14
+ Fog.providers[provider.downcase.to_sym] = provider
15
+ Fog.providers[underscore_name(provider).to_sym] = provider
16
+ end
17
+
18
+ private
19
+
20
+ def underscore_name(string)
21
+ string.gsub("::", "/")
22
+ .gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
23
+ .gsub(/([a-z\d])([A-Z])/,'\1_\2')
24
+ .tr("-", "_")
25
+ .downcase
26
+ end
14
27
  end
15
28
 
16
29
  def [](service_key)
@@ -21,11 +34,31 @@ module Fog
21
34
  Fog.services[new_service] ||= []
22
35
  Fog.services[new_service] |= [to_s.split("::").last.downcase.to_sym]
23
36
  @services_registry ||= {}
24
- @services_registry[new_service] = [to_s, constant_string].join("::")
37
+ @services_registry[new_service] = service_klass(constant_string)
25
38
  end
26
39
 
27
40
  def services
28
41
  @services_registry.keys
29
42
  end
43
+
44
+ # Returns service constant path, with provider, as string. If
45
+ # "provider::service" is defined (the preferred format) then it returns that
46
+ # string, otherwise it returns the deprecated string "service::provider".
47
+ def service_klass(constant_string)
48
+ if const_defined?([to_s, constant_string].join("::"))
49
+ [to_s, constant_string].join("::")
50
+ else
51
+ provider = to_s.split("::").last
52
+ Fog::Logger.deprecation("Unable to load #{[to_s, constant_string].join('::')}")
53
+ Fog::Logger.deprecation(
54
+ format(
55
+ Fog::ServicesMixin::E_SERVICE_PROVIDER_CONSTANT,
56
+ service: constant_string,
57
+ provider: provider
58
+ )
59
+ )
60
+ ["Fog", constant_string, provider].join("::")
61
+ end
62
+ end
30
63
  end
31
64
  end
data/lib/fog/core/scp.rb CHANGED
@@ -22,19 +22,23 @@ module Fog
22
22
  end
23
23
 
24
24
  def upload(local_path, remote_path, upload_options = {})
25
- self.class.data[@address] << { :username => @username,
26
- :options => @options,
27
- :local_path => local_path,
28
- :remote_path => remote_path,
29
- :upload_options => upload_options }
25
+ self.class.data[@address] << {
26
+ username: @username,
27
+ options: @options,
28
+ local_path: local_path,
29
+ remote_path: remote_path,
30
+ upload_options: upload_options
31
+ }
30
32
  end
31
33
 
32
34
  def download(remote_path, local_path, download_options = {})
33
- self.class.data[@address] << { :username => @username,
34
- :options => @options,
35
- :remote_path => remote_path,
36
- :local_path => local_path,
37
- :download_options => download_options }
35
+ self.class.data[@address] << {
36
+ username: @username,
37
+ options: @options,
38
+ remote_path: remote_path,
39
+ local_path: local_path,
40
+ download_options: download_options
41
+ }
38
42
  end
39
43
  end
40
44
 
@@ -64,8 +68,9 @@ module Fog
64
68
 
65
69
  @address = address
66
70
  @username = username
67
- @options = { :paranoid => false, :verify_host_key => false }.merge(options)
71
+ @options = { paranoid: false, verify_host_key: :never }.merge(options)
68
72
  @options.delete(:paranoid) if Net::SSH::VALID_OPTIONS.include? :verify_host_key
73
+ @options[:verify_host_key] = false unless Net::SSH::Verifiers.const_defined?(:Never)
69
74
  end
70
75
 
71
76
  def upload(local_path, remote_path, upload_options = {}, &block)
@@ -11,7 +11,7 @@ module Fog
11
11
 
12
12
  module NoLeakInspector
13
13
  def inspect
14
- "#<#{self.class}:#{object_id} #{(instance_variables - service.secrets).map { |iv| [iv, instance_variable_get(iv).inspect].join("=") }.join(" ")}>"
14
+ "#<#{self.class}:#{object_id} #{(instance_variables - service.secrets).map { |iv| [iv, instance_variable_get(iv).inspect].join('=') }.join(' ')}>"
15
15
  end
16
16
  end
17
17
 
@@ -119,7 +119,7 @@ module Fog
119
119
  # @deprecated
120
120
  def fetch_credentials(_options)
121
121
  # attempt to load credentials from config file
122
- Fog.credentials.reject { |key, _value| !(recognized | requirements).include?(key) }
122
+ Fog.credentials.select { |key, _value| (recognized | requirements).include?(key) }
123
123
  rescue ::Fog::Errors::LoadError
124
124
  # if there are no configured credentials, do nothing
125
125
  {}
@@ -212,7 +212,7 @@ module Fog
212
212
  @secrets ||= []
213
213
  else
214
214
  args.reduce(secrets) do |secrets, secret|
215
- secrets << "@#{secret}".to_sym
215
+ secrets << :"@#{secret}"
216
216
  end
217
217
  end
218
218
  end
@@ -241,13 +241,13 @@ module Fog
241
241
  missing = requirements - keys
242
242
 
243
243
  unless missing.empty?
244
- raise ArgumentError, "Missing required arguments: #{missing.join(", ")}"
244
+ raise ArgumentError, "Missing required arguments: #{missing.join(', ')}"
245
245
  end
246
246
 
247
247
  unless recognizes.empty?
248
248
  unrecognized = options.keys - requirements - recognized
249
249
  unless unrecognized.empty?
250
- Fog::Logger.warning("Unrecognized arguments: #{unrecognized.join(", ")}")
250
+ Fog::Logger.warning("Unrecognized arguments: #{unrecognized.join(', ')}")
251
251
  end
252
252
  end
253
253
  end
@@ -1,21 +1,37 @@
1
1
  module Fog
2
2
  module ServicesMixin
3
+ E_SERVICE_PROVIDER_CONSTANT = <<-EOS.gsub(/\s+/, " ").strip.freeze
4
+ Falling back to deprecated constant Fog::%<service>s::%<provider>s. The
5
+ preferred format of service provider constants has changed from
6
+ service::provider to provider::service. Please update this service
7
+ provider to use the preferred format.
8
+ EOS
9
+ E_SERVICE_PROVIDER_PATH = <<-EOS.gsub(/\s+/, " ").strip.freeze
10
+ Falling back to deprecated path fog/%<service>s/%<provider>s. The
11
+ preferred file path format has changed from service/provider to
12
+ provider/service. Please update this service provider to use the preferred
13
+ format.
14
+ EOS
15
+
3
16
  def [](provider)
4
- new(:provider => provider)
17
+ new(provider: provider)
5
18
  end
6
19
 
7
20
  def new(attributes)
8
- attributes = attributes.dup # Prevent delete from having side effects
9
- provider = attributes.delete(:provider).to_s.downcase.to_sym
10
- provider_name = Fog.providers[provider]
21
+ attributes = attributes.dup # Prevent delete from having side effects
22
+ provider = attributes.delete(:provider).to_s.downcase.to_sym
23
+ provider_alias = check_provider_alias(provider)
24
+ provider_name = Fog.providers[provider_alias]
11
25
 
12
- raise ArgumentError, "#{provider} is not a recognized provider" unless providers.include?(provider)
26
+ raise ArgumentError, "#{provider_alias} is not a recognized provider" unless providers.include?(provider) || providers.include?(provider_alias)
13
27
 
14
- require_service_provider_library(service_name.downcase, provider)
28
+ require_service_provider_library(service_name.downcase, provider_alias)
15
29
  spc = service_provider_constant(service_name, provider_name)
16
30
  spc.new(attributes)
17
- rescue LoadError, NameError # Only rescue errors in finding the libraries, allow connection errors through to the caller
18
- raise Fog::Service::NotFound, "#{provider} has no #{service_name.downcase} service"
31
+ rescue LoadError, NameError => e # Only rescue errors in finding the libraries, allow connection errors through to the caller
32
+ Fog::Logger.warning("Error while loading provider #{provider_alias}: #{e.message}")
33
+ Fog::Logger.debug("backtrace: #{e.backtrace.join("\n")}")
34
+ raise Fog::Service::NotFound, "#{provider_alias} has no #{service_name.downcase} service"
19
35
  end
20
36
 
21
37
  def providers
@@ -24,16 +40,28 @@ module Fog
24
40
 
25
41
  private
26
42
 
43
+ # This method should be removed once all providers are extracted.
44
+ # Bundler will correctly require all dependencies automatically and thus
45
+ # fog-core wont need to know any specifics providers. Each provider will
46
+ # have to load its dependencies.
27
47
  def require_service_provider_library(service, provider)
28
48
  require "fog/#{provider}/#{service}"
29
49
  rescue LoadError # Try to require the service provider in an alternate location
50
+ Fog::Logger.deprecation("Unable to require fog/#{provider}/#{service}")
51
+ Fog::Logger.deprecation(
52
+ format(E_SERVICE_PROVIDER_PATH, service: service, provider: provider)
53
+ )
30
54
  require "fog/#{service}/#{provider}"
31
55
  end
32
56
 
33
57
  def service_provider_constant(service_name, provider_name)
34
- Fog.const_get(service_name).const_get(*const_get_args(provider_name))
35
- rescue NameError # Try to find the constant from in an alternate location
36
58
  Fog.const_get(provider_name).const_get(*const_get_args(service_name))
59
+ rescue NameError # Try to find the constant from in an alternate location
60
+ Fog::Logger.deprecation("Unable to load Fog::#{provider_name}::#{service_name}")
61
+ Fog::Logger.deprecation(
62
+ format(E_SERVICE_PROVIDER_CONSTANT, service: service_name, provider: provider_name)
63
+ )
64
+ Fog.const_get(service_name).const_get(*const_get_args(provider_name))
37
65
  end
38
66
 
39
67
  def const_get_args(*args)
@@ -43,5 +71,29 @@ module Fog
43
71
  def service_name
44
72
  name.split("Fog::").last
45
73
  end
74
+
75
+ def check_provider_alias(provider)
76
+ case provider
77
+ when :baremetalcloud
78
+ Fog::Logger.deprecation(":baremetalcloud is deprecated. Use :bare_metal_cloud instead!")
79
+ :bare_metal_cloud
80
+ when :gogrid
81
+ Fog::Logger.deprecation(":gogrid is deprecated. Use :go_grid instead!")
82
+ :go_grid
83
+ when :internetarchive
84
+ Fog::Logger.deprecation(":internetarchive is deprecated. Use :internet_archive instead!")
85
+ :internet_archive
86
+ when :new_servers
87
+ Fog::Logger.deprecation(":new_servers is deprecated. Use :bare_metal_cloud instead!")
88
+ :bare_metal_cloud
89
+ when :stormondemand
90
+ Fog::Logger.deprecation(":stormondemand is deprecated. Use :storm_on_demand instead!")
91
+ :storm_on_demand
92
+ when :vclouddirector
93
+ Fog::Logger.deprecation(":vclouddirector is deprecated. Use :vcloud_director instead!")
94
+ :vcloud_director
95
+ else provider
96
+ end
97
+ end
46
98
  end
47
99
  end
data/lib/fog/core/ssh.rb CHANGED
@@ -28,38 +28,16 @@ module Fog
28
28
  end
29
29
 
30
30
  def run(commands, &_blk)
31
- self.class.data[@address] << { :commands => commands, :username => @username, :options => @options }
31
+ self.class.data[@address] << { commands: commands, username: @username, options: @options }
32
32
  end
33
33
  end
34
34
 
35
35
  class Real
36
36
  def initialize(address, username, options)
37
- begin
38
- require "net/ssh"
39
- rescue LoadError
40
- Fog::Logger.warning("'net/ssh' missing, please install and try again.")
41
- exit(1)
42
- end
43
-
44
- key_manager = Net::SSH::Authentication::KeyManager.new(nil, options)
45
-
46
- unless options[:key_data] || options[:keys] || options[:password] || key_manager.agent
47
- raise ArgumentError, ":key_data, :keys, :password or a loaded ssh-agent is required to initialize SSH"
48
- end
49
-
50
- options[:timeout] ||= 30
51
- if options[:key_data] || options[:keys]
52
- options[:keys_only] = true
53
- # Explicitly set these so net-ssh doesn"t add the default keys
54
- # as seen at https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/authentication/session.rb#L131-146
55
- options[:keys] = [] unless options[:keys]
56
- options[:key_data] = [] unless options[:key_data]
57
- end
58
-
37
+ assert_net_ssh_loaded
59
38
  @address = address
60
39
  @username = username
61
- @options = { :paranoid => false, :verify_host_key => false }.merge(options)
62
- @options.delete(:paranoid) if Net::SSH::VALID_OPTIONS.include? :verify_host_key
40
+ @options = build_options(options)
63
41
  end
64
42
 
65
43
  def run(commands, &blk)
@@ -83,6 +61,7 @@ module Fog
83
61
 
84
62
  channel.on_extended_data do |_ch, type, data|
85
63
  next unless type == 1
64
+
86
65
  result.stderr << data
87
66
  yield ["", data] if blk
88
67
  end
@@ -107,6 +86,51 @@ module Fog
107
86
  end
108
87
  results
109
88
  end
89
+
90
+ private
91
+
92
+ def assert_net_ssh_loaded
93
+ begin
94
+ require "net/ssh"
95
+ rescue LoadError
96
+ Fog::Logger.warning("'net/ssh' missing, please install and try again.")
97
+ exit(1)
98
+ end
99
+ end
100
+
101
+ # Modifies the given `options` hash AND returns a new hash.
102
+ # TODO: Probably shouldn't modify the given hash.
103
+ def build_options(options)
104
+ validate_options(options)
105
+ merge_default_options_into(options)
106
+ end
107
+
108
+ def merge_default_options_into(options)
109
+ options[:timeout] ||= 30
110
+ if options[:key_data] || options[:keys]
111
+ options[:keys_only] = true
112
+ # Explicitly set these so net-ssh doesn"t add the default keys
113
+ # as seen at https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/authentication/session.rb#L131-146
114
+ options[:keys] = [] unless options[:keys]
115
+ options[:key_data] = [] unless options[:key_data]
116
+ end
117
+
118
+ # net-ssh has deprecated :paranoid in favor of :verify_host_key
119
+ # https://github.com/net-ssh/net-ssh/pull/524
120
+ opts = { paranoid: false, verify_host_key: :never }.merge(options)
121
+ if Net::SSH::VALID_OPTIONS.include? :verify_host_key
122
+ opts.delete(:paranoid)
123
+ end
124
+ opts[:verify_host_key] = false unless Net::SSH::Verifiers.const_defined?(:Never)
125
+ opts
126
+ end
127
+
128
+ def validate_options(options)
129
+ key_manager = Net::SSH::Authentication::KeyManager.new(nil, options)
130
+ unless options[:key_data] || options[:keys] || options[:password] || key_manager.agent
131
+ raise ArgumentError, ":key_data, :keys, :password or a loaded ssh-agent is required to initialize SSH"
132
+ end
133
+ end
110
134
  end
111
135
 
112
136
  class Result
@@ -7,8 +7,6 @@ module Fog
7
7
  end
8
8
  end
9
9
 
10
- private
11
-
12
10
  # http://devblog.avdi.org/2009/11/20/hash-transforms-in-ruby/
13
11
  def self.transform_hash(original, &block)
14
12
  original.reduce({}) do |result, (key, value)|
data/lib/fog/core/time.rb CHANGED
@@ -2,8 +2,8 @@ require "time"
2
2
 
3
3
  module Fog
4
4
  class Time < ::Time
5
- DAYS = %w(Sun Mon Tue Wed Thu Fri Sat)
6
- MONTHS = %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
5
+ DAYS = %w(Sun Mon Tue Wed Thu Fri Sat).freeze
6
+ MONTHS = %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec).freeze
7
7
 
8
8
  def self.now
9
9
  at(::Time.now - offset)
data/lib/fog/core/uuid.rb CHANGED
@@ -4,16 +4,10 @@ module Fog
4
4
  class UUID
5
5
  class << self
6
6
  def uuid
7
- if supported?
8
- SecureRandom.uuid
9
- else
10
- ary = SecureRandom.random_bytes(16).unpack("NnnnnN")
11
- ary[2] = (ary[2] & 0x0fff) | 0x4000
12
- ary[3] = (ary[3] & 0x3fff) | 0x8000
13
- "%08x-%04x-%04x-%04x-%04x%08x" % ary
14
- end
7
+ SecureRandom.uuid
15
8
  end
16
9
 
10
+ # :nodoc: This method is used by other plugins, so preserve it for the compatibility
17
11
  def supported?
18
12
  SecureRandom.respond_to?(:uuid)
19
13
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fog
2
4
  module Core
3
- VERSION = "2.1.0"
5
+ VERSION = "2.6.0"
4
6
  end
5
7
  end
@@ -8,9 +8,10 @@ module Fog
8
8
  if duration > timeout
9
9
  raise Errors::TimeoutError, "The specified wait_for timeout (#{timeout} seconds) was exceeded"
10
10
  end
11
+
11
12
  sleep(interval.respond_to?(:call) ? interval.call(retries += 1).to_f : interval.to_f)
12
13
  duration = Time.now - start
13
14
  end
14
- { :duration => duration }
15
+ { duration: duration }
15
16
  end
16
17
  end
@@ -22,6 +22,7 @@ module Fog
22
22
 
23
23
  def self.timeout=(timeout)
24
24
  raise ArgumentError, "timeout must be non-negative" unless timeout >= 0
25
+
25
26
  @timeout = timeout
26
27
  end
27
28
 
@@ -33,6 +34,7 @@ module Fog
33
34
 
34
35
  def self.max_interval=(interval)
35
36
  raise ArgumentError, "interval must be non-negative" unless interval >= 0
37
+
36
38
  @max_interval = interval
37
39
  end
38
40
  end
data/lib/fog/core.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # external core dependencies
2
- require "base64"
3
2
  require "cgi"
4
3
  require "uri"
5
4
  require "excon"
@@ -11,67 +10,66 @@ require "timeout"
11
10
  require "ipaddr"
12
11
 
13
12
  # internal core dependencies
14
- require File.expand_path('../core/version', __FILE__)
13
+ require File.expand_path("core/version", __dir__)
15
14
 
16
15
  # Mixins
17
- require File.expand_path('../core/services_mixin', __FILE__)
16
+ require File.expand_path("core/services_mixin", __dir__)
18
17
 
19
- require File.expand_path('../core/attributes', __FILE__)
20
- require File.expand_path('../core/attributes/default', __FILE__)
21
- require File.expand_path('../core/attributes/array', __FILE__)
22
- require File.expand_path('../core/attributes/boolean', __FILE__)
23
- require File.expand_path('../core/attributes/float', __FILE__)
24
- require File.expand_path('../core/attributes/integer', __FILE__)
25
- require File.expand_path('../core/attributes/string', __FILE__)
26
- require File.expand_path('../core/attributes/time', __FILE__)
27
- require File.expand_path('../core/attributes/timestamp', __FILE__)
28
- require File.expand_path('../core/associations/default', __FILE__)
29
- require File.expand_path('../core/associations/many_identities', __FILE__)
30
- require File.expand_path('../core/associations/many_models', __FILE__)
31
- require File.expand_path('../core/associations/one_model', __FILE__)
32
- require File.expand_path('../core/associations/one_identity', __FILE__)
33
- require File.expand_path('../core/collection', __FILE__)
34
- require File.expand_path('../core/association', __FILE__)
35
- require File.expand_path('../core/connection', __FILE__)
36
- require File.expand_path('../core/credentials', __FILE__)
37
- require File.expand_path('../core/current_machine', __FILE__)
38
- require File.expand_path('../core/deprecation', __FILE__)
39
- require File.expand_path('../core/errors', __FILE__)
40
- require File.expand_path('../core/hmac', __FILE__)
41
- require File.expand_path('../core/logger', __FILE__)
42
- require File.expand_path('../core/model', __FILE__)
43
- require File.expand_path('../core/mock', __FILE__)
44
- require File.expand_path('../core/provider', __FILE__)
45
- require File.expand_path('../core/service', __FILE__)
46
- require File.expand_path('../core/ssh', __FILE__)
47
- require File.expand_path('../core/scp', __FILE__)
48
- require File.expand_path('../core/time', __FILE__)
49
- require File.expand_path('../core/utils', __FILE__)
50
- require File.expand_path('../core/wait_for', __FILE__)
51
- require File.expand_path('../core/wait_for_defaults', __FILE__)
52
- require File.expand_path('../core/uuid', __FILE__)
53
- require File.expand_path('../core/stringify_keys', __FILE__)
54
- require File.expand_path('../core/whitelist_keys', __FILE__)
55
-
56
- require File.expand_path('../account', __FILE__)
57
- require File.expand_path('../baremetal', __FILE__)
58
- require File.expand_path('../billing', __FILE__)
59
- require File.expand_path('../cdn', __FILE__)
60
- require File.expand_path('../compute', __FILE__)
61
- require File.expand_path('../dns', __FILE__)
62
- require File.expand_path('../identity', __FILE__)
63
- require File.expand_path('../image', __FILE__)
64
- require File.expand_path('../introspection', __FILE__)
65
- require File.expand_path('../metering', __FILE__)
66
- require File.expand_path('../monitoring', __FILE__)
67
- require File.expand_path('../nfv', __FILE__)
68
- require File.expand_path('../network', __FILE__)
69
- require File.expand_path('../orchestration', __FILE__)
70
- require File.expand_path('../storage', __FILE__)
71
- require File.expand_path('../support', __FILE__)
72
- require File.expand_path('../volume', __FILE__)
73
- require File.expand_path('../vpn', __FILE__)
18
+ require File.expand_path("core/attributes", __dir__)
19
+ require File.expand_path("core/attributes/default", __dir__)
20
+ require File.expand_path("core/attributes/array", __dir__)
21
+ require File.expand_path("core/attributes/boolean", __dir__)
22
+ require File.expand_path("core/attributes/float", __dir__)
23
+ require File.expand_path("core/attributes/integer", __dir__)
24
+ require File.expand_path("core/attributes/string", __dir__)
25
+ require File.expand_path("core/attributes/time", __dir__)
26
+ require File.expand_path("core/attributes/timestamp", __dir__)
27
+ require File.expand_path("core/associations/default", __dir__)
28
+ require File.expand_path("core/associations/many_identities", __dir__)
29
+ require File.expand_path("core/associations/many_models", __dir__)
30
+ require File.expand_path("core/associations/one_model", __dir__)
31
+ require File.expand_path("core/associations/one_identity", __dir__)
32
+ require File.expand_path("core/collection", __dir__)
33
+ require File.expand_path("core/association", __dir__)
34
+ require File.expand_path("core/connection", __dir__)
35
+ require File.expand_path("core/credentials", __dir__)
36
+ require File.expand_path("core/current_machine", __dir__)
37
+ require File.expand_path("core/deprecation", __dir__)
38
+ require File.expand_path("core/errors", __dir__)
39
+ require File.expand_path("core/hmac", __dir__)
40
+ require File.expand_path("core/logger", __dir__)
41
+ require File.expand_path("core/model", __dir__)
42
+ require File.expand_path("core/mock", __dir__)
43
+ require File.expand_path("core/provider", __dir__)
44
+ require File.expand_path("core/service", __dir__)
45
+ require File.expand_path("core/ssh", __dir__)
46
+ require File.expand_path("core/scp", __dir__)
47
+ require File.expand_path("core/time", __dir__)
48
+ require File.expand_path("core/utils", __dir__)
49
+ require File.expand_path("core/wait_for", __dir__)
50
+ require File.expand_path("core/wait_for_defaults", __dir__)
51
+ require File.expand_path("core/uuid", __dir__)
52
+ require File.expand_path("core/stringify_keys", __dir__)
53
+ require File.expand_path("core/whitelist_keys", __dir__)
74
54
 
55
+ require File.expand_path("account", __dir__)
56
+ require File.expand_path("baremetal", __dir__)
57
+ require File.expand_path("billing", __dir__)
58
+ require File.expand_path("cdn", __dir__)
59
+ require File.expand_path("compute", __dir__)
60
+ require File.expand_path("dns", __dir__)
61
+ require File.expand_path("identity", __dir__)
62
+ require File.expand_path("image", __dir__)
63
+ require File.expand_path("introspection", __dir__)
64
+ require File.expand_path("metering", __dir__)
65
+ require File.expand_path("monitoring", __dir__)
66
+ require File.expand_path("nfv", __dir__)
67
+ require File.expand_path("network", __dir__)
68
+ require File.expand_path("orchestration", __dir__)
69
+ require File.expand_path("storage", __dir__)
70
+ require File.expand_path("support", __dir__)
71
+ require File.expand_path("volume", __dir__)
72
+ require File.expand_path("vpn", __dir__)
75
73
 
76
74
  # Utility
77
- require File.expand_path('../formatador', __FILE__)
75
+ require File.expand_path("formatador", __dir__)
data/lib/fog/dns.rb CHANGED
@@ -2,17 +2,6 @@ module Fog
2
2
  module DNS
3
3
  extend Fog::ServicesMixin
4
4
 
5
- def self.new(orig_attributes)
6
- attributes = orig_attributes.dup # prevent delete from having side effects
7
- case attributes.delete(:provider).to_s.downcase.to_sym
8
- when :stormondemand
9
- require "fog/dns/storm_on_demand"
10
- Fog::DNS::StormOnDemand.new(attributes)
11
- else
12
- super(orig_attributes)
13
- end
14
- end
15
-
16
5
  def self.zones
17
6
  zones = []
18
7
  providers.each do |provider|
@@ -9,8 +9,8 @@ module Fog
9
9
  Thread.current[:formatador] ||= ::Formatador.new
10
10
  end
11
11
 
12
- def self.format(object, opts = { :include_nested => true })
13
- string = init_string(object)
12
+ def self.format(object, opts = { include_nested: true })
13
+ string = +init_string(object)
14
14
  indent { string << object_string(object, opts) }
15
15
  string << "#{indentation}>"
16
16
  end
@@ -32,11 +32,9 @@ module Fog
32
32
  end
33
33
 
34
34
  def self.redisplay_progressbar(current, total, options = {})
35
- ::Formatador.redisplay_progressbar(current, total, options = {})
35
+ ::Formatador.redisplay_progressbar(current, total, options)
36
36
  end
37
37
 
38
- private
39
-
40
38
  def self.indent(&block)
41
39
  formatador.indent(&block)
42
40
  end
@@ -50,13 +48,14 @@ module Fog
50
48
  end
51
49
 
52
50
  def self.object_string(object, opts)
53
- string = "#{attribute_string(object)}"
54
- string << "#{nested_objects_string(object)}" if opts[:include_nested]
51
+ string = +attribute_string(object).to_s
52
+ string << nested_objects_string(object).to_s if opts[:include_nested]
55
53
  string
56
54
  end
57
55
 
58
56
  def self.attribute_string(object)
59
57
  return "" unless object.class.respond_to?(:attributes)
58
+
60
59
  if object.class.attributes.empty?
61
60
  ""
62
61
  else
@@ -68,7 +67,8 @@ module Fog
68
67
  nested = ""
69
68
  return nested if object.respond_to?(:empty) and object.empty?
70
69
  return nested unless object.is_a?(Enumerable)
71
- nested = "#{indentation}[\n"
70
+
71
+ nested = +"#{indentation}[\n"
72
72
  indent { nested << indentation + inspect_object(object) }
73
73
  nested << "#{indentation}\n#{indentation}]\n"
74
74
  end
@@ -82,6 +82,7 @@ module Fog
82
82
 
83
83
  def self.inspect_object(object)
84
84
  return "" unless object.is_a?(Enumerable)
85
+
85
86
  object.map { |o| indentation + o.inspect }.join(", \n#{indentation}")
86
87
  end
87
88
  end