Skip to content

Commit

Permalink
Merge pull request fog#80 from zertico/rubocop
Browse files Browse the repository at this point in the history
More Rubocop warnings fixed
  • Loading branch information
nirvdrum committed Sep 9, 2014
2 parents 759db14 + 86daba8 commit aad1cce
Show file tree
Hide file tree
Showing 30 changed files with 311 additions and 312 deletions.
17 changes: 16 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
Metrics/LineLength:
Enabled: false

Style/EachWithObject:
Enabled: false

Style/Encoding:
EnforcedStyle: when_needed

Style/HashSyntax:
Enabled: false
EnforcedStyle: hash_rockets

Style/SignalException:
EnforcedStyle: only_raise

Style/StringLiterals:
EnforcedStyle: double_quotes
4 changes: 2 additions & 2 deletions lib/fog/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ def self.new(attributes)
provider = attributes.delete(:provider).to_s.downcase.to_sym

if provider == :stormondemand
require 'fog/storm_on_demand/account'
require "fog/storm_on_demand/account"
Fog::Account::StormOnDemand.new(attributes)
else
fail ArgumentError, "#{provider} has no account service"
raise ArgumentError, "#{provider} has no account service"
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/fog/billing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def self.new(attributes)
attributes = attributes.dup
provider = attributes.delete(:provider).to_s.downcase.to_sym
if provider == :stormondemand
require 'fog/storm_on_demand/billing'
require "fog/storm_on_demand/billing"
Fog::Billing::StormOnDemand.new(attributes)
else
fail ArgumentError, "#{provider} has no billing service"
raise ArgumentError, "#{provider} has no billing service"
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/fog/cdn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def self.new(attributes)
require "fog/#{provider}/cdn"
return Fog::CDN.const_get(Fog.providers[provider]).new(attributes)
end
fail ArgumentError, "#{provider} is not a recognized cdn provider"
raise ArgumentError, "#{provider} is not a recognized cdn provider"
end

def self.providers
Expand Down
28 changes: 14 additions & 14 deletions lib/fog/compute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,45 @@ def self.new(attributes)

case provider
when :gogrid
require 'fog/go_grid/compute'
require "fog/go_grid/compute"
Fog::Compute::GoGrid.new(attributes)
when :hp
version = attributes.delete(:version)
version = version.to_s.downcase.to_sym unless version.nil?
if version == :v2
require 'fog/hp/compute_v2'
require "fog/hp/compute_v2"
Fog::Compute::HPV2.new(attributes)
else
Fog::Logger.deprecation 'HP Cloud Compute V1 service will be soon deprecated. Please use `:version => v2` attribute to use HP Cloud Compute V2 service.'
require 'fog/hp/compute'
Fog::Logger.deprecation "HP Cloud Compute V1 service will be soon deprecated. Please use `:version => v2` attribute to use HP Cloud Compute V2 service."
require "fog/hp/compute"
Fog::Compute::HP.new(attributes)
end
when :new_servers
require 'fog/bare_metal_cloud/compute'
Fog::Logger.deprecation '`new_servers` is deprecated. Please use `bare_metal_cloud` instead.'
require "fog/bare_metal_cloud/compute"
Fog::Logger.deprecation "`new_servers` is deprecated. Please use `bare_metal_cloud` instead."
Fog::Compute::BareMetalCloud.new(attributes)
when :baremetalcloud
require 'fog/bare_metal_cloud/compute'
require "fog/bare_metal_cloud/compute"
Fog::Compute::BareMetalCloud.new(attributes)
when :rackspace
version = attributes.delete(:version)
version = version.to_s.downcase.to_sym unless version.nil?
if version == :v1
Fog::Logger.deprecation 'First Gen Cloud Servers are deprecated. Please use `:version => :v2` attribute to use Next Gen Cloud Servers.'
require 'fog/rackspace/compute'
Fog::Logger.deprecation "First Gen Cloud Servers are deprecated. Please use `:version => :v2` attribute to use Next Gen Cloud Servers."
require "fog/rackspace/compute"
Fog::Compute::Rackspace.new(attributes)
else
require 'fog/rackspace/compute_v2'
require "fog/rackspace/compute_v2"
Fog::Compute::RackspaceV2.new(attributes)
end
when :stormondemand
require 'fog/storm_on_demand/compute'
require "fog/storm_on_demand/compute"
Fog::Compute::StormOnDemand.new(attributes)
when :vcloud
require 'fog/vcloud/compute'
require "fog/vcloud/compute"
Fog::Vcloud::Compute.new(attributes)
when :vclouddirector
require 'fog/vcloud_director/compute'
require "fog/vcloud_director/compute"
Fog::Compute::VcloudDirector.new(attributes)
else
if providers.include?(provider)
Expand All @@ -59,7 +59,7 @@ def self.new(attributes)
Fog.const_get(Fog.providers[provider])::Compute
end.new(attributes)
else
fail ArgumentError, "#{provider} is not a recognized compute provider"
raise ArgumentError, "#{provider} is not a recognized compute provider"
end
end
end
Expand Down
18 changes: 9 additions & 9 deletions lib/fog/compute/models/server.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
require 'fog/core/model'
require "fog/core/model"

module Fog
module Compute
class Server < Fog::Model
attr_writer :username, :private_key, :private_key_path, :public_key, :public_key_path, :ssh_port, :ssh_options
# Sets the proc used to determine the IP Address used for ssh/scp interactions.
# @example
# service.servers.bootstrap :name => 'bootstrap-server',
# service.servers.bootstrap :name => "bootstrap-server",
# :flavor_id => service.flavors.first.id,
# :image_id => service.images.find {|img| img.name =~ /Ubuntu/}.id,
# :public_key_path => '~/.ssh/fog_rsa.pub',
# :private_key_path => '~/.ssh/fog_rsa',
# :public_key_path => "~/.ssh/fog_rsa.pub",
# :private_key_path => "~/.ssh/fog_rsa",
# :ssh_ip_address => Proc.new {|server| server.private_ip_address }
#
# @note By default scp/ssh will use the public_ip_address if this proc is not set.
attr_writer :ssh_ip_address

def username
@username ||= 'root'
@username ||= "root"
end

def private_key_path
Expand Down Expand Up @@ -65,7 +65,7 @@ def ssh_options
end

def scp(local_path, remote_path, upload_options = {})
require 'net/scp'
require "net/scp"
requires :ssh_ip_address, :username

Fog::SCP.new(ssh_ip_address, username, ssh_options).upload(local_path, remote_path, upload_options)
Expand All @@ -74,14 +74,14 @@ def scp(local_path, remote_path, upload_options = {})
alias_method :scp_upload, :scp

def scp_download(remote_path, local_path, download_options = {})
require 'net/scp'
require "net/scp"
requires :ssh_ip_address, :username

Fog::SCP.new(ssh_ip_address, username, ssh_options).download(remote_path, local_path, download_options)
end

def ssh(commands, options = {}, &blk)
require 'net/ssh'
require "net/ssh"
requires :ssh_ip_address, :username

options = ssh_options.merge(options)
Expand All @@ -90,7 +90,7 @@ def ssh(commands, options = {}, &blk)
end

def sshable?(options = {})
ready? && !ssh_ip_address.nil? && !!Timeout.timeout(8) { ssh('pwd', options) }
ready? && !ssh_ip_address.nil? && !!Timeout.timeout(8) { ssh("pwd", options) }
rescue SystemCallError, Net::SSH::AuthenticationFailed, Net::SSH::Disconnect, Timeout::Error
false
end
Expand Down
122 changes: 61 additions & 61 deletions lib/fog/core.rb
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
# external core dependencies
require 'base64'
require 'cgi'
require 'uri'
require 'excon'
require 'fileutils'
require 'formatador'
require 'openssl'
require 'time'
require 'timeout'
require 'ipaddr'
require "base64"
require "cgi"
require "uri"
require "excon"
require "fileutils"
require "formatador"
require "openssl"
require "time"
require "timeout"
require "ipaddr"

# internal core dependencies
require 'fog/core/version'
require "fog/core/version"

require 'fog/core/attributes'
require 'fog/core/attributes/default'
require 'fog/core/attributes/array'
require 'fog/core/attributes/boolean'
require 'fog/core/attributes/float'
require 'fog/core/attributes/integer'
require 'fog/core/attributes/string'
require 'fog/core/attributes/time'
require 'fog/core/attributes/timestamp'
require 'fog/core/associations/default'
require 'fog/core/associations/many_identities'
require 'fog/core/associations/many_models'
require 'fog/core/associations/one_model'
require 'fog/core/associations/one_identity'
require 'fog/core/collection'
require 'fog/core/connection'
require 'fog/core/credentials'
require 'fog/core/current_machine'
require 'fog/core/deprecation'
require 'fog/core/errors'
require 'fog/core/hmac'
require 'fog/core/logger'
require 'fog/core/model'
require 'fog/core/mock'
require 'fog/core/provider'
require 'fog/core/service'
require 'fog/core/ssh'
require 'fog/core/scp'
require 'fog/core/time'
require 'fog/core/utils'
require 'fog/core/wait_for'
require 'fog/core/wait_for_defaults'
require 'fog/core/uuid'
require 'fog/core/stringify_keys'
require 'fog/core/whitelist_keys'
require "fog/core/attributes"
require "fog/core/attributes/default"
require "fog/core/attributes/array"
require "fog/core/attributes/boolean"
require "fog/core/attributes/float"
require "fog/core/attributes/integer"
require "fog/core/attributes/string"
require "fog/core/attributes/time"
require "fog/core/attributes/timestamp"
require "fog/core/associations/default"
require "fog/core/associations/many_identities"
require "fog/core/associations/many_models"
require "fog/core/associations/one_model"
require "fog/core/associations/one_identity"
require "fog/core/collection"
require "fog/core/connection"
require "fog/core/credentials"
require "fog/core/current_machine"
require "fog/core/deprecation"
require "fog/core/errors"
require "fog/core/hmac"
require "fog/core/logger"
require "fog/core/model"
require "fog/core/mock"
require "fog/core/provider"
require "fog/core/service"
require "fog/core/ssh"
require "fog/core/scp"
require "fog/core/time"
require "fog/core/utils"
require "fog/core/wait_for"
require "fog/core/wait_for_defaults"
require "fog/core/uuid"
require "fog/core/stringify_keys"
require "fog/core/whitelist_keys"

# service wrappers
require 'fog/account'
require 'fog/billing'
require 'fog/cdn'
require 'fog/compute'
require 'fog/dns'
require 'fog/identity'
require 'fog/image'
require 'fog/metering'
require 'fog/monitoring'
require 'fog/network'
require 'fog/orchestration'
require 'fog/storage'
require 'fog/support'
require 'fog/volume'
require 'fog/vpn'
require "fog/account"
require "fog/billing"
require "fog/cdn"
require "fog/compute"
require "fog/dns"
require "fog/identity"
require "fog/image"
require "fog/metering"
require "fog/monitoring"
require "fog/network"
require "fog/orchestration"
require "fog/storage"
require "fog/support"
require "fog/volume"
require "fog/vpn"
Loading

0 comments on commit aad1cce

Please sign in to comment.