Skip to content
This repository

Remove more warnings #905

Merged
merged 31 commits into from almost 2 years ago

4 participants

James Herdman Wesley Beary Alex Rodionov Edward Muller
James Herdman

This branch is not done. I'm simply making it available to show some visibility into some work I'm doing on removing warnings in Fog, especially since this work touches so many files.

The biggest remaining problem is a circular dependency issue mentioned in issue #904.

Would someone mind looking over what's done so far to see if anything is out of sorts?

Edward Muller freeformz commented on the diff May 14, 2012
lib/fog/libvirt/compute.rb
... ...
@@ -58,7 +58,10 @@ def initialize(options={})
58 58
         end
59 59
 
60 60
         private
61  
-        attr_reader :client
  61
+
  62
+        def client
  63
+          return @client if defined?(@client)
3
Edward Muller Collaborator
freeformz added a note May 14, 2012

What's wrong with attr_reader here?

or at least just

def client
  @client
end
James Herdman
jherdman added a note May 14, 2012

Ruby will complain about the use of attr_reader. The problem with your solution is that Ruby will complain about @client being uninitialized. Here are some examples from IRB:

irb(main):001:0> class Foo
irb(main):002:1>   private
irb(main):003:1>   attr_reader :client
irb(main):004:1>   end
(irb):3: warning: private attribute?

And...

irb(main):001:0> class Foo
irb(main):002:1>   private
irb(main):003:1>   def client
irb(main):004:2>     @client
irb(main):005:2>     end
irb(main):006:1>   end
=> nil
irb(main):007:0> f = Foo.new
=> #<Foo:0x007fbaa988b970>
irb(main):008:0> f.send :client
(irb):4: warning: instance variable @client not initialized

Proof of my solution...

irb(main):001:0> class Foo
irb(main):002:1>   private
irb(main):003:1>   def client 
irb(main):004:2>     return @client if defined?(@client)
irb(main):005:2>     end
irb(main):006:1>   end
=> nil
irb(main):007:0> f = Foo.new
=> #<Foo:0x007f99fb851000>
irb(main):008:0> f.send :client
=> nil
Edward Muller Collaborator
freeformz added a note May 14, 2012

Ahh yes ... -w ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Wesley Beary
Owner
geemus commented May 15, 2012

Looks good so far, let me know when you are ready for a final review/merge.

James Herdman

@geemus as far as I can tell I've removed all warnings except the following:

/Users/james/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/forwardable.rb:199: warning: method redefined; discarding old close
/Users/james/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/forwardable.rb:199: warning: previous definition of close was here
/Users/james/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/forwardable.rb:199: warning: method redefined; discarding old readline
/Users/james/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/forwardable.rb:199: warning: previous definition of readline was here

These appear to be within Ruby itself.

Can you check over the circular require changes? It touches a lot of files.

Wesley Beary
Owner
geemus commented May 15, 2012

I think there might be problems with the circular reference removal as it stands. In particular, the reason a lot of that is in there is from how lib/fog/compute and the like do their requires.

ie: https://github.com/fog/fog/blob/master/lib/fog/compute.rb#L12

Due to the nature of the beast I think this is fixable, that line (and those like it) could probably be changed to require the aws file directly or perhaps the service definitions should be changed to not also require. In any event, I'm not certain the current approach will solve it appropriately (without causing issues for some use cases).

Wesley Beary geemus referenced this pull request May 15, 2012
Closed

Interesting Comment in Code #904

James Herdman

Is there a particular reason Ruby's autoload isn't being used?

Wesley Beary
Owner
geemus commented May 15, 2012

@jherdman - there were (at least historically) concerns with its compatibility across different interpreters (jruby vs mri vs rubinius) and lack of thread safety in some earlier versions.

Alex Rodionov
p0deje commented May 15, 2012

@jherdman I can't find the link, but a couple of months ago Matz mentioned that autoload will be deprecated in Ruby 2.0.

James Herdman

@p0deje I don't think we need to worry about that for a while. Matz has said it will be deprecated in 3.0.

James Herdman

@geemus would autoload be desirable if we can show that it's compatible across JRuby, MRI and Rubinius, or would you rather a different strategy for requiring files? I'm indifferent as to the shape of the final solution so long as circular requires are resolved.

Wesley Beary
Owner
geemus commented May 16, 2012

@jherdman - I would somewhat prefer to not use autoload given that there have been and will be issues with it (granted we might be in a window of it not having issues, it seems like it may be more trouble than it is worth). Part of the complication is the desire to allow either require "fog/compute" or require "fog/aws/compute" to be valid (and several other similar permutations). As such I'm not exactly sure what the correct approach is. Perhaps the service method should check to see if something is already loaded before doing the require. Overall I hadn't really worried about it too much as require ought to be a no-op in this case, but I don't generally think to run with warnings on. Not entirely certain what the best approach is here. Thanks for bringing attention to it. I may need to think about it a bit, but I'm certainly open to suggestions. If it ends up that autoload is the only real option we can discuss, but it seems troublesome.

James Herdman

@geemus I think what I'm going to do is drop the commit that "fixes" the circular references to get some of these fixes in. Circular references may take a little more work... I'm still not sure of the solution either. I think it'll require some discussion on Fog use cases. Thoughts?

Wesley Beary
Owner
geemus commented May 24, 2012

@jherdman - yeah, I think that sounds good. Would be good to get the other fixes in, but yeah I think the circular reference portion needs a bit more discussion. Thanks!

James Herdman

@geemus this branch should be ready now. I'll open an issue for the circular reference problem.

Can someone run the tests on this branch to make sure everything is passing? I saw some fails, but I'm not sure if they're known issues, or if they're because of additional configuration required to run all tests — I've had this problem in the past.

James Herdman jherdman referenced this pull request May 24, 2012
Closed

Circular References Found #929

Wesley Beary
Owner
geemus commented May 28, 2012

@jherdman - I can take it from here for now. The tests ought to pass. Missing configuration should result in pending (not failing) tests. So feel free to post new issues for any failures you see and we can get those adressed as well. Thanks!

Wesley Beary geemus merged commit 8992b32 into from May 28, 2012
Wesley Beary geemus closed this May 28, 2012
Alan Ivey alanthing referenced this pull request from a commit February 21, 2013
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 31 unique commits by 1 author.

May 26, 2012
James Herdman Remove unused variable bd948fe
James Herdman Fix indentation warning fa31f91
James Herdman Remove unnecessary full path usage with require
'fog/core' is already in the load path. No need to go to these extents.
b0a7473
James Herdman Remove unused variable 441dec4
James Herdman Remove unused accessor b71ff66
James Herdman Silence warning regarding splat operator aa493ed
James Herdman Remove unused variable 4919347
James Herdman Remove unused variable 641c6c1
James Herdman Silence warnings about potentially private attribute 101439b
James Herdman Remove unused variable 39cf7bb
James Herdman Silence warning about potentially private attribute dca5ed4
James Herdman Remove unused variable 15262af
James Herdman Remove unused variable b8044a9
James Herdman Remove unused variable d5a417d
James Herdman Remove unused variable 2065e8f
James Herdman Remove unused variable 7baeec2
James Herdman Remove unused variable a3ca181
James Herdman Remove unused variable 2988984
James Herdman Remove unused variable 8cf3916
James Herdman Remove unused variable 110358a
James Herdman Remove unused variable 5f95596
James Herdman Remove unused variable 22bdeba
James Herdman Remove unused variable c5ee16d
James Herdman Remove unused variable 700fd77
James Herdman Remove duplicate require ac4180e
James Herdman Remove unused variable d7539ea
James Herdman Remove unused variable ed3394d
James Herdman Remove unused variable 85e4d79
James Herdman Remove absolute path when requiring 97b16d0
James Herdman Remove unused variable ebe7af8
James Herdman Remove duplicate Mock class definition a3c92dc
This page is out of date. Refresh to see the latest.

Showing 91 changed files with 135 additions and 169 deletions. Show diff stats Hide diff stats

  1. 2  lib/fog/aws.rb
  2. 3  lib/fog/aws/auto_scaling.rb
  3. 20  lib/fog/aws/beanstalk.rb
  4. 4  lib/fog/aws/cdn.rb
  5. 2  lib/fog/aws/cloud_formation.rb
  6. 4  lib/fog/aws/cloud_watch.rb
  7. 2  lib/fog/aws/compute.rb
  8. 4  lib/fog/aws/dns.rb
  9. 4  lib/fog/aws/dynamodb.rb
  10. 4  lib/fog/aws/elb.rb
  11. 18  lib/fog/aws/emr.rb
  12. 2  lib/fog/aws/iam.rb
  13. 3  lib/fog/aws/rds.rb
  14. 2  lib/fog/aws/ses.rb
  15. 2  lib/fog/aws/simpledb.rb
  16. 2  lib/fog/aws/sns.rb
  17. 3  lib/fog/aws/sqs.rb
  18. 4  lib/fog/aws/storage.rb
  19. 2  lib/fog/aws/sts.rb
  20. 2  lib/fog/bare_metal_cloud.rb
  21. 2  lib/fog/bare_metal_cloud/compute.rb
  22. 2  lib/fog/bluebox.rb
  23. 2  lib/fog/bluebox/compute.rb
  24. 4  lib/fog/bluebox/dns.rb
  25. 2  lib/fog/brightbox.rb
  26. 4  lib/fog/brightbox/compute.rb
  27. 40  lib/fog/cloudstack/compute.rb
  28. 2  lib/fog/core/collection.rb
  29. 4  lib/fog/core/errors.rb
  30. 2  lib/fog/dnsimple.rb
  31. 2  lib/fog/dnsimple/dns.rb
  32. 2  lib/fog/dnsmadeeasy.rb
  33. 4  lib/fog/dnsmadeeasy/dns.rb
  34. 2  lib/fog/dynect.rb
  35. 2  lib/fog/dynect/dns.rb
  36. 2  lib/fog/ecloud.rb
  37. 4  lib/fog/ecloud/compute.rb
  38. 2  lib/fog/go_grid.rb
  39. 2  lib/fog/go_grid/compute.rb
  40. 2  lib/fog/google.rb
  41. 4  lib/fog/google/storage.rb
  42. 2  lib/fog/hp.rb
  43. 2  lib/fog/hp/cdn.rb
  44. 2  lib/fog/hp/compute.rb
  45. 2  lib/fog/hp/storage.rb
  46. 2  lib/fog/ibm.rb
  47. 2  lib/fog/ibm/compute.rb
  48. 2  lib/fog/ibm/storage.rb
  49. 4  lib/fog/joyent/compute.rb
  50. 2  lib/fog/libvirt.rb
  51. 7  lib/fog/libvirt/compute.rb
  52. 2  lib/fog/linode.rb
  53. 2  lib/fog/linode/compute.rb
  54. 2  lib/fog/linode/dns.rb
  55. 2  lib/fog/local.rb
  56. 2  lib/fog/local/storage.rb
  57. 2  lib/fog/ninefold.rb
  58. 2  lib/fog/ninefold/compute.rb
  59. 4  lib/fog/ninefold/storage.rb
  60. 2  lib/fog/openstack.rb
  61. 1  lib/fog/openstack/compute.rb
  62. 1  lib/fog/openstack/identity.rb
  63. 1  lib/fog/openstack/image.rb
  64. 1  lib/fog/openstack/volume.rb
  65. 15  lib/fog/ovirt/compute.rb
  66. 1  lib/fog/providers.rb
  67. 2  lib/fog/rackspace.rb
  68. 2  lib/fog/rackspace/cdn.rb
  69. 2  lib/fog/rackspace/compute.rb
  70. 2  lib/fog/rackspace/dns.rb
  71. 2  lib/fog/rackspace/load_balancers.rb
  72. 2  lib/fog/rackspace/storage.rb
  73. 2  lib/fog/slicehost.rb
  74. 2  lib/fog/slicehost/compute.rb
  75. 2  lib/fog/slicehost/dns.rb
  76. 2  lib/fog/storm_on_demand.rb
  77. 2  lib/fog/storm_on_demand/compute.rb
  78. 2  lib/fog/terremark.rb
  79. 2  lib/fog/terremark/shared.rb
  80. 2  lib/fog/vcloud.rb
  81. 4  lib/fog/vcloud/compute.rb
  82. 2  lib/fog/virtual_box.rb
  83. 2  lib/fog/virtual_box/compute.rb
  84. 2  lib/fog/vmfusion.rb
  85. 2  lib/fog/vmfusion/compute.rb
  86. 2  lib/fog/voxel.rb
  87. 2  lib/fog/voxel/compute.rb
  88. 2  lib/fog/vsphere/compute.rb
  89. 6  lib/fog/xenserver/compute.rb
  90. 2  lib/fog/zerigo.rb
  91. 2  lib/fog/zerigo/dns.rb
2  lib/fog/aws.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module AWS
3  lib/fog/aws/auto_scaling.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 
3 3
 module Fog
4 4
   module AWS
@@ -145,7 +145,6 @@ class Mock
145 145
 
146 146
         def self.data
147 147
           @data ||= Hash.new do |hash, region|
148  
-            owner_id = Fog::AWS::Mock.owner_id
149 148
             hash[region] = Hash.new do |region_hash, key|
150 149
               region_hash[key] = {
151 150
                 :adjustment_types => [
20  lib/fog/aws/beanstalk.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 
3 3
 module Fog
4 4
   module AWS
@@ -109,15 +109,15 @@ def request(params)
109 109
           )
110 110
 
111 111
           begin
112  
-            response = @connection.request({
113  
-                                               :body       => body,
114  
-                                               :expects    => 200,
115  
-                                               :headers    => { 'Content-Type' => 'application/x-www-form-urlencoded' },
116  
-                                               :idempotent => idempotent,
117  
-                                               :host       => @host,
118  
-                                               :method     => 'POST',
119  
-                                               :parser     => parser
120  
-                                           })
  112
+            @connection.request({
  113
+                :body       => body,
  114
+                :expects    => 200,
  115
+                :headers    => { 'Content-Type' => 'application/x-www-form-urlencoded' },
  116
+                :idempotent => idempotent,
  117
+                :host       => @host,
  118
+                :method     => 'POST',
  119
+                :parser     => parser
  120
+            })
121 121
           rescue Excon::Errors::HTTPStatusError => error
122 122
             if match = error.response.body.match(/<Code>(.*)<\/Code>[ \t\n]*<Message>(.*)<\/Message>/)
123 123
               raise case match[1].split('.').last
4  lib/fog/aws/cdn.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 require 'fog/cdn'
3 3
 
4 4
 module Fog
@@ -112,7 +112,7 @@ def request(params, &block)
112 112
         def signature(params)
113 113
           string_to_sign = params[:headers]['Date']
114 114
           signed_string = @hmac.sign(string_to_sign)
115  
-          signature = Base64.encode64(signed_string).chomp!
  115
+          Base64.encode64(signed_string).chomp!
116 116
         end
117 117
       end
118 118
     end
2  lib/fog/aws/cloud_formation.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 
3 3
 module Fog
4 4
   module AWS
4  lib/fog/aws/cloud_watch.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 
3 3
 module Fog
4 4
   module AWS
@@ -98,7 +98,7 @@ def request(params)
98 98
             }
99 99
           )
100 100
 
101  
-          response = @connection.request({
  101
+          @connection.request({
102 102
             :body       => body,
103 103
             :expects    => 200,
104 104
             :headers    => { 'Content-Type' => 'application/x-www-form-urlencoded' },
2  lib/fog/aws/compute.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 require 'fog/compute'
3 3
 
4 4
 module Fog
4  lib/fog/aws/dns.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 require 'fog/dns'
3 3
 
4 4
 module Fog
@@ -111,7 +111,7 @@ def request(params, &block)
111 111
         def signature(params)
112 112
           string_to_sign = params[:headers]['Date']
113 113
           signed_string = @hmac.sign(string_to_sign)
114  
-          signature = Base64.encode64(signed_string).chomp!
  114
+          Base64.encode64(signed_string).chomp!
115 115
         end
116 116
       end
117 117
     end
4  lib/fog/aws/dynamodb.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 
3 3
 module Fog
4 4
   module AWS
@@ -106,12 +106,12 @@ def reload
106 106
         def request(params)
107 107
           idempotent = params.delete(:idempotent)
108 108
 
109  
-          now = Fog::Time.now
110 109
           headers = {
111 110
             'Content-Type'          => 'application/x-amz-json-1.0',
112 111
             'x-amz-date'            => Fog::Time.now.to_date_header,
113 112
             'x-amz-security-token'  => @aws_session_token
114 113
           }.merge(params[:headers])
  114
+
115 115
           headers['x-amzn-authorization']  = signed_authorization_header(params, headers)
116 116
 
117 117
           response = @connection.request({
4  lib/fog/aws/elb.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 
3 3
 module Fog
4 4
   module AWS
@@ -152,7 +152,7 @@ def request(params)
152 152
           }
153 153
           )
154 154
 
155  
-          response = @connection.request({
  155
+          @connection.request({
156 156
             :body       => body,
157 157
             :expects    => 200,
158 158
             :headers    => { 'Content-Type' => 'application/x-www-form-urlencoded' },
18  lib/fog/aws/emr.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 
3 3
 module Fog
4 4
   module AWS
@@ -109,20 +109,8 @@ def request(params)
109 109
               :method     => 'POST',
110 110
               :parser     => parser
111 111
             })
112  
-          rescue Excon::Errors::HTTPStatusError => error
113  
-            if match = error.message.match(/<Code>(.*)<\/Code>[\s\\\w]+<Message>(.*)<\/Message>/m)
114  
-              # case match[1].split('.').last
115  
-              # when 'DBInstanceNotFound', 'DBParameterGroupNotFound', 'DBSnapshotNotFound', 'DBSecurityGroupNotFound'
116  
-              #   raise Fog::AWS::RDS::NotFound.slurp(error, match[2])
117  
-              # when 'DBParameterGroupAlreadyExists'
118  
-              #   raise Fog::AWS::RDS::IdentifierTaken.slurp(error, match[2])
119  
-              # else
120  
-              #   raise
121  
-              # end
122  
-              raise
123  
-            else
124  
-              raise
125  
-            end
  112
+          rescue Excon::Errors::HTTPStatusError
  113
+            raise
126 114
           end
127 115
 
128 116
           response
2  lib/fog/aws/iam.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 
3 3
 module Fog
4 4
   module AWS
3  lib/fog/aws/rds.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 
3 3
 module Fog
4 4
   module AWS
@@ -61,7 +61,6 @@ class Mock
61 61
 
62 62
         def self.data
63 63
           @data ||= Hash.new do |hash, region|
64  
-            owner_id = Fog::AWS::Mock.owner_id
65 64
             hash[region] = Hash.new do |region_hash, key|
66 65
               region_hash[key] = {
67 66
                 :servers => {},
2  lib/fog/aws/ses.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 
3 3
 module Fog
4 4
   module AWS
2  lib/fog/aws/simpledb.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 
3 3
 module Fog
4 4
   module AWS
2  lib/fog/aws/sns.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 
3 3
 module Fog
4 4
   module AWS
3  lib/fog/aws/sqs.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 
3 3
 module Fog
4 4
   module AWS
@@ -21,7 +21,6 @@ class SQS < Fog::Service
21 21
       class Mock
22 22
         def self.data
23 23
           @data ||= Hash.new do |hash, region|
24  
-            owner_id = Fog::AWS::Mock.owner_id
25 24
             hash[region] = Hash.new do |region_hash, key|
26 25
               region_hash[key] = {
27 26
                 :owner_id => Fog::AWS::Mock.owner_id,
4  lib/fog/aws/storage.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 require 'fog/storage'
3 3
 
4 4
 module Fog
@@ -352,7 +352,7 @@ def signature(params)
352 352
           string_to_sign << canonical_resource
353 353
 
354 354
           signed_string = @hmac.sign(string_to_sign)
355  
-          signature = Base64.encode64(signed_string).chomp!
  355
+          Base64.encode64(signed_string).chomp!
356 356
         end
357 357
 
358 358
         private
2  lib/fog/aws/sts.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
  1
+require 'fog/aws'
2 2
 
3 3
 module Fog
4 4
   module AWS
2  lib/fog/bare_metal_cloud.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module BareMetalCloud
2  lib/fog/bare_metal_cloud/compute.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'bare_metal_cloud'))
  1
+require 'fog/bare_metal_cloud'
2 2
 require 'fog/compute'
3 3
 
4 4
 module Fog
2  lib/fog/bluebox.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module Bluebox
2  lib/fog/bluebox/compute.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'bluebox'))
  1
+require 'fog/bluebox'
2 2
 require 'fog/compute'
3 3
 
4 4
 module Fog
4  lib/fog/bluebox/dns.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'bluebox'))
  1
+require 'fog/bluebox'
2 2
 require 'fog/dns'
3 3
 
4 4
 module Fog
@@ -101,4 +101,4 @@ def auth_header
101 101
       end
102 102
     end
103 103
   end
104  
-end
  104
+end
2  lib/fog/brightbox.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module Brightbox
4  lib/fog/brightbox/compute.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'brightbox'))
  1
+require 'fog/brightbox'
2 2
 require 'fog/compute'
3 3
 
4 4
 module Fog
@@ -165,7 +165,7 @@ def make_request(params)
165 165
           begin
166 166
             get_oauth_token if @oauth_token.nil?
167 167
             response = authenticated_request(params)
168  
-          rescue Excon::Errors::Unauthorized => e
  168
+          rescue Excon::Errors::Unauthorized
169 169
             get_oauth_token
170 170
             response = authenticated_request(params)
171 171
           end
40  lib/fog/cloudstack/compute.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'cloudstack'))
  1
+require 'fog/cloudstack'
2 2
 require 'fog/compute'
3 3
 require 'digest/md5'
4 4
 
@@ -123,32 +123,6 @@ class Unauthorized < Fog::Compute::Cloudstack::Error; end
123 123
       request :update_resource_count
124 124
       request :update_virtual_machine
125 125
 
126  
-      class Mock
127  
-
128  
-        def self.data
129  
-          @data ||= Hash.new do |hash, key|
130  
-            hash[key] = {}
131  
-          end
132  
-        end
133  
-
134  
-        def self.reset
135  
-          @data = nil
136  
-        end
137  
-
138  
-        def initialize(options={})
139  
-          @cloudstack_api_key = options[:cloudstack_api_key]
140  
-        end
141  
-
142  
-        def data
143  
-          self.class.data[@cloudstack_api_key]
144  
-        end
145  
-
146  
-        def reset_data
147  
-          self.class.data.delete(@cloudstack_api_key)
148  
-        end
149  
-
150  
-      end
151  
-
152 126
       class Real
153 127
 
154 128
         def initialize(options={})
@@ -240,7 +214,7 @@ def authorize_api_keys(params)
240 214
 
241 215
         def issue_request(params={},headers={},method='GET',expects=200)
242 216
           begin
243  
-            response = @connection.request({
  217
+            @connection.request({
244 218
               :query => params,
245 219
               :headers => headers,
246 220
               :method => method,
@@ -267,6 +241,10 @@ def issue_request(params={},headers={},method='GET',expects=200)
267 241
       end # Real
268 242
 
269 243
       class Mock
  244
+        def initialize(options={})
  245
+          @cloudstack_api_key = options[:cloudstack_api_key]
  246
+        end
  247
+
270 248
         def self.data
271 249
           @data ||= begin
272 250
             rc_options = Fog.credentials[:cloudstack] || {}
@@ -437,12 +415,16 @@ def self.data
437 415
         end
438 416
 
439 417
         def self.reset
440  
-          @data= nil
  418
+          @data = nil
441 419
         end
442 420
 
443 421
         def data
444 422
           self.class.data
445 423
         end
  424
+
  425
+        def reset_data
  426
+          self.class.data.delete(@cloudstack_api_key)
  427
+        end
446 428
       end
447 429
     end # Cloudstack
448 430
   end # Compute
2  lib/fog/core/collection.rb
@@ -24,7 +24,7 @@ def #{method}(*args)
24 24
             lazy_load
25 25
           end
26 26
           data = super
27  
-          result = self.clone.clear.concat(data)
  27
+          self.clone.clear.concat(data)
28 28
         end
29 29
       EOS
30 30
     end
4  lib/fog/core/errors.rb
@@ -95,8 +95,8 @@ def self.missing_credentials
95 95
 #######################################################
96 96
 
97 97
     YML
98  
-    raise(Fog::Errors::LoadError.new(missing_credentials_message))
99  
-  end
  98
+      raise(Fog::Errors::LoadError.new(missing_credentials_message))
  99
+    end
100 100
 
101 101
   end
102 102
 end
2  lib/fog/dnsimple.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module DNSimple
2  lib/fog/dnsimple/dns.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'dnsimple'))
  1
+require 'fog/dnsimple'
2 2
 require 'fog/dns'
3 3
 
4 4
 module Fog
2  lib/fog/dnsmadeeasy.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module DNSMadeEasy
4  lib/fog/dnsmadeeasy/dns.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'dnsmadeeasy'))
  1
+require 'fog/dnsmadeeasy'
2 2
 require 'fog/dns'
3 3
 
4 4
 module Fog
@@ -127,7 +127,7 @@ def request(params)
127 127
 
128 128
         def signature(params)
129 129
           string_to_sign = params[:headers]['x-dnsme-requestDate']
130  
-          signed_string = OpenSSL::HMAC.hexdigest('sha1', @dnsmadeeasy_secret_key, string_to_sign)
  130
+          OpenSSL::HMAC.hexdigest('sha1', @dnsmadeeasy_secret_key, string_to_sign)
131 131
         end
132 132
       end
133 133
     end
2  lib/fog/dynect.rb
... ...
@@ -1,6 +1,6 @@
1 1
 require 'nokogiri'
2 2
 
3  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  3
+require 'fog/core'
4 4
 require 'fog/core/parser'
5 5
 
6 6
 module Fog
2  lib/fog/dynect/dns.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'dynect'))
  1
+require 'fog/dynect'
2 2
 require 'fog/dns'
3 3
 
4 4
 module Fog
2  lib/fog/ecloud.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module Ecloud
4  lib/fog/ecloud/compute.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'ecloud'))
  1
+require 'fog/ecloud'
2 2
 require 'ipaddr'
3 3
 
4 4
 class IPAddr
@@ -1181,7 +1181,7 @@ def request(params)
1181 1181
           end
1182 1182
           begin
1183 1183
             do_request(params)
1184  
-          rescue Excon::Errors::Unauthorized => e
  1184
+          rescue Excon::Errors::Unauthorized
1185 1185
             do_login
1186 1186
             do_request(params)
1187 1187
           end
2  lib/fog/go_grid.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module GoGrid
2  lib/fog/go_grid/compute.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'go_grid'))
  1
+require 'fog/go_grid'
2 2
 require 'fog/compute'
3 3
 
4 4
 module Fog
2  lib/fog/google.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module Google
4  lib/fog/google/storage.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'google'))
  1
+require 'fog/google'
2 2
 require 'fog/storage'
3 3
 
4 4
 module Fog
@@ -251,7 +251,7 @@ def signature(params)
251 251
           string_to_sign << "#{canonical_resource}"
252 252
 
253 253
           signed_string = @hmac.sign(string_to_sign)
254  
-          signature = Base64.encode64(signed_string).chomp!
  254
+          Base64.encode64(signed_string).chomp!
255 255
         end
256 256
 
257 257
 
2  lib/fog/hp.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module HP
2  lib/fog/hp/cdn.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'hp'))
  1
+require 'fog/hp'
2 2
 require 'fog/cdn'
3 3
 
4 4
 module Fog
2  lib/fog/hp/compute.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'hp'))
  1
+require 'fog/hp'
2 2
 require 'fog/compute'
3 3
 
4 4
 module Fog
2  lib/fog/hp/storage.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'hp'))
  1
+require 'fog/hp'
2 2
 require 'fog/storage'
3 3
 
4 4
 module Fog
2  lib/fog/ibm.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module IBM
2  lib/fog/ibm/compute.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'ibm'))
  1
+require 'fog/ibm'
2 2
 require 'fog/compute'
3 3
 
4 4
 module Fog
2  lib/fog/ibm/storage.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'ibm'))
  1
+require 'fog/ibm'
2 2
 require 'fog/storage'
3 3
 
4 4
 module Fog
4  lib/fog/joyent/compute.rb
... ...
@@ -1,5 +1,5 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'joyent'))
2  
-require File.expand_path(File.join(File.dirname(__FILE__), 'errors'))
  1
+require 'fog/joyent'
  2
+require 'fog/joyent/errors'
3 3
 require 'fog/compute'
4 4
 
5 5
 module Fog
2  lib/fog/libvirt.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module Libvirt
7  lib/fog/libvirt/compute.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'libvirt'))
  1
+require 'fog/libvirt'
2 2
 require 'fog/compute'
3 3
 require 'fog/libvirt/models/compute/util/util'
4 4
 require 'fog/libvirt/models/compute/util/uri'
@@ -58,7 +58,10 @@ def initialize(options={})
58 58
         end
59 59
 
60 60
         private
61  
-        attr_reader :client
  61
+
  62
+        def client
  63
+          return @client if defined?(@client)
  64
+        end
62 65
 
63 66
         #read mocks xml
64 67
         def read_xml(file_name)
2  lib/fog/linode.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module Linode
2  lib/fog/linode/compute.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'linode'))
  1
+require 'fog/linode'
2 2
 require 'fog/compute'
3 3
 
4 4
 module Fog
2  lib/fog/linode/dns.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'linode'))
  1
+require 'fog/linode'
2 2
 require 'fog/dns'
3 3
 
4 4
 module Fog
2  lib/fog/local.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module Local
2  lib/fog/local/storage.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'storage'))
  1
+require 'fog/local/storage'
2 2
 require 'fog/storage'
3 3
 
4 4
 module Fog
2  lib/fog/ninefold.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module Ninefold
2  lib/fog/ninefold/compute.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'ninefold'))
  1
+require 'fog/ninefold'
2 2
 require 'fog/compute'
3 3
 
4 4
 module Fog
4  lib/fog/ninefold/storage.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'ninefold'))
  1
+require 'fog/ninefold'
2 2
 require 'fog/storage'
3 3
 
4 4
 module Fog
@@ -116,7 +116,7 @@ def request(params, &block)
116 116
             end
117 117
           }
118 118
           header_arr = customheaders.sort()
119  
-          first = true
  119
+
120 120
           header_arr.each { |key,value|
121 121
             # Values are lowercase and whitespace-normalized
122 122
             signstring += key + ":" + value.strip.chomp.squeeze( " " ) + "\n"
2  lib/fog/openstack.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module OpenStack
1  lib/fog/openstack/compute.rb
... ...
@@ -1,4 +1,3 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'openstack'))
2 1
 require 'fog/compute'
3 2
 require 'fog/openstack'
4 3
 
1  lib/fog/openstack/identity.rb
... ...
@@ -1,4 +1,3 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'openstack'))
2 1
 require 'fog/openstack'
3 2
 
4 3
 module Fog
1  lib/fog/openstack/image.rb
... ...
@@ -1,4 +1,3 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'openstack'))
2 1
 require 'fog/openstack'
3 2
 
4 3
 module Fog
1  lib/fog/openstack/volume.rb
... ...
@@ -1,4 +1,3 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'openstack'))
2 1
 require 'fog/openstack'
3 2
 
4 3
 module Fog
15  lib/fog/ovirt/compute.rb
... ...
@@ -1,4 +1,3 @@
1  
-
2 1
 module Fog
3 2
   module Compute
4 3
     class Ovirt < Fog::Service
@@ -74,13 +73,14 @@ class Mock
74 73
 
75 74
         def initialize(options={})
76 75
           require 'rbovirt'
77  
-          username = options[:ovirt_username]
78  
-          password = options[:ovirt_password]
79  
-          url      = options[:ovirt_url]
80 76
         end
81 77
 
82 78
         private
83  
-        attr_reader :client
  79
+
  80
+        def client
  81
+          return @client if defined?(@client)
  82
+        end
  83
+
84 84
         #read mocks xml
85 85
         def read_xml(file_name)
86 86
           file_path = File.join(File.dirname(__FILE__),"requests","compute","mock_files",file_name)
@@ -106,7 +106,10 @@ def initialize(options={})
106 106
         end
107 107
 
108 108
         private
109  
-        attr_reader :client
  109
+
  110
+        def client
  111
+          @client
  112
+        end
110 113
       end
111 114
     end
112 115
   end
1  lib/fog/providers.rb
@@ -30,4 +30,3 @@
30 30
 require 'fog/voxel'
31 31
 require 'fog/xenserver'
32 32
 require 'fog/zerigo'
33  
-require 'fog/zerigo'
2  lib/fog/rackspace.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module Rackspace
2  lib/fog/rackspace/cdn.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rackspace'))
  1
+require 'fog/rackspace'
2 2
 require 'fog/cdn'
3 3
 
4 4
 module Fog
2  lib/fog/rackspace/compute.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rackspace'))
  1
+require 'fog/rackspace'
2 2
 require 'fog/compute'
3 3
 
4 4
 module Fog
2  lib/fog/rackspace/dns.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rackspace'))
  1
+require 'fog/rackspace'
2 2
 require 'fog/dns'
3 3
 
4 4
 module Fog
2  lib/fog/rackspace/load_balancers.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rackspace'))
  1
+require 'fog/rackspace'
2 2
 
3 3
 module Fog
4 4
   module Rackspace
2  lib/fog/rackspace/storage.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'rackspace'))
  1
+require 'fog/rackspace'
2 2
 require 'fog/storage'
3 3
 
4 4
 module Fog
2  lib/fog/slicehost.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module Slicehost
2  lib/fog/slicehost/compute.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'slicehost'))
  1
+require 'fog/slicehost'
2 2
 require 'fog/compute'
3 3
 
4 4
 module Fog
2  lib/fog/slicehost/dns.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'slicehost'))
  1
+require 'fog/slicehost'
2 2
 require 'fog/dns'
3 3
 
4 4
 module Fog
2  lib/fog/storm_on_demand.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 module Fog
4 4
   module StormOnDemand
2  lib/fog/storm_on_demand/compute.rb
... ...
@@ -1,4 +1,4 @@
1  
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'storm_on_demand'))
  1
+require 'fog/storm_on_demand'
2 2
 require 'fog/compute'
3 3
 
4 4
 module Fog
2  lib/fog/terremark.rb
... ...
@@ -1,4 +1,4 @@
1  
-require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
  1
+require 'fog/core'
2 2
 
3 3
 require 'fog/terremark/shared'
4 4
 require 'fog/terremark/parser'
2  lib/fog/terremark/shared.rb
@@ -61,7 +61,7 @@ def request(params)
61 61
           end
62 62
           begin
63 63
             do_request(params)
64  
-          rescue Excon::Errors::Unauthorized => e
  64
+          rescue Excon::Errors::Unauthorized
65 65
             @cookie = auth_token
66 66
             do_request(params)
67 67
           end
2  lib/fog/vcloud.rb