mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
move config to saner place, only parse it once
This commit is contained in:
parent
dbc9ebfb04
commit
ab0ba1e2dd
3 changed files with 16 additions and 16 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@
|
||||||
coverage
|
coverage
|
||||||
rdoc
|
rdoc
|
||||||
pkg
|
pkg
|
||||||
|
spec/credentials.yml
|
|
@ -0,0 +1 @@
|
||||||
|
require "#{File.dirname(__FILE__)}/fog/aws"
|
|
@ -1,41 +1,39 @@
|
||||||
require 'spec'
|
require 'spec'
|
||||||
|
|
||||||
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
require "#{File.dirname(__FILE__)}/../lib/fog"
|
||||||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
||||||
require 'fog'
|
|
||||||
|
|
||||||
Spec::Runner.configure do |config|
|
Spec::Runner.configure do |config|
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'fog/aws'
|
def credentials
|
||||||
|
@credentials ||= begin
|
||||||
|
credentials_path = "#{File.dirname(__FILE__)}/credentials.yml"
|
||||||
|
credentials_data = File.open(credentials_path).read
|
||||||
|
YAML.load(credentials_data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def ec2
|
def ec2
|
||||||
@ec2 ||= begin
|
@ec2 ||= begin
|
||||||
data = File.open(File.expand_path('~/.s3conf/s3config.yml')).read
|
|
||||||
config = YAML.load(data)
|
|
||||||
Fog::AWS::EC2.new(
|
Fog::AWS::EC2.new(
|
||||||
:aws_access_key_id => config['aws_access_key_id'],
|
:aws_access_key_id => credentials['aws_access_key_id'],
|
||||||
:aws_secret_access_key => config['aws_secret_access_key']
|
:aws_secret_access_key => credentials['aws_secret_access_key']
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def sdb
|
def sdb
|
||||||
@sdb ||= begin
|
@sdb ||= begin
|
||||||
data = File.open(File.expand_path('~/.s3conf/s3config.yml')).read
|
|
||||||
config = YAML.load(data)
|
|
||||||
Fog::AWS::SimpleDB.new(
|
Fog::AWS::SimpleDB.new(
|
||||||
:aws_access_key_id => config['aws_access_key_id'],
|
:aws_access_key_id => credentials['aws_access_key_id'],
|
||||||
:aws_secret_access_key => config['aws_secret_access_key']
|
:aws_secret_access_key => credentials['aws_secret_access_key']
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def s3
|
def s3
|
||||||
@s3 ||= begin
|
@s3 ||= begin
|
||||||
data = File.open(File.expand_path('~/.s3conf/s3config.yml')).read
|
|
||||||
config = YAML.load(data)
|
|
||||||
Fog::AWS::S3.new(
|
Fog::AWS::S3.new(
|
||||||
:aws_access_key_id => config['aws_access_key_id'],
|
:aws_access_key_id => credentials['aws_access_key_id'],
|
||||||
:aws_secret_access_key => config['aws_secret_access_key']
|
:aws_secret_access_key => credentials['aws_secret_access_key']
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue