swirl 1.3 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/swirl/ec2.rb +13 -4
  2. metadata +2 -2
@@ -21,13 +21,22 @@ module Swirl
21
21
 
22
22
  def self.options(name=:default, file="~/.swirl")
23
23
  file = File.expand_path(file)
24
- return {} if !File.exists?(file)
25
- YAML.load_file(file)[name]
24
+ config = YAML.load_file(file)
25
+ fail "Undefined account '#{name.inspect}'" if !config.has_key?(name)
26
+ config[name]
26
27
  end
27
28
 
28
29
  def initialize(options={}, file="~/.swirl")
29
- account = options.fetch(:account) { :default }
30
- options = self.class.options(account, file).merge(options)
30
+
31
+ if !File.exists?(file)
32
+ account = options[:account] || :default
33
+ options = self.class.options(account, file).merge(options)
34
+ elsif ENV["AWS_ACCESS_KEY_ID"] && ENV["AWS_SECRET_ACCESS_KEY"]
35
+ options[:aws_access_key_id] = ENV["AWS_ACCESS_KEY_ID"]
36
+ options[:aws_secret_access_key] = ENV["AWS_SECRET_ACCESS_KEY"]
37
+ else
38
+ fail "Credentials not set! See Swirl's README"
39
+ end
31
40
 
32
41
  @aws_access_key_id = options[:aws_access_key_id]
33
42
  @aws_secret_access_key = options[:aws_secret_access_key]
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 3
8
- version: "1.3"
7
+ - 4
8
+ version: "1.4"
9
9
  platform: ruby
10
10
  authors:
11
11
  - Blake Mizerany