saws 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/saws/base.rb ADDED
@@ -0,0 +1,26 @@
1
+ class SAWS::Base
2
+
3
+ class << self
4
+
5
+ def proxy(klass = nil)
6
+ @_proxy = klass if klass
7
+ @_proxy ||= "Fog::AWS::#{name.demodulize}".constantize
8
+ end
9
+
10
+ end
11
+
12
+ def initialize(options = {})
13
+ @proxy = self.class.proxy.new SAWS.connection_options.merge(options)
14
+ end
15
+
16
+ def respond_to?(*a)
17
+ super || @proxy.respond_to?(*a)
18
+ end
19
+
20
+ private
21
+
22
+ def method_missing(sym, *a, &b)
23
+ @proxy.respond_to?(sym) ? @proxy.send(sym, *a, &b) : super
24
+ end
25
+
26
+ end
data/lib/saws/cli.rb ADDED
@@ -0,0 +1,30 @@
1
+ module SAWS::CLI
2
+ extend self
3
+
4
+ def options
5
+ @options ||= parse_options
6
+ end
7
+
8
+ private
9
+
10
+ def parse_options
11
+ path = ENV['AWS_SECRET'] || File.expand_path(".awssecret", ENV['HOME'])
12
+ file = File.readable?(path) ? File.read(path).lines.map(&:strip) : []
13
+
14
+ opts = Trollop::options do
15
+ opt "aws-access-key-id", "AWS access key ID", :short => 'K', :type => :string
16
+ opt "aws-secret-access-key", "AWS secret access key", :short => 'S', :type => :string
17
+ opt "region", "Your AWS region", :short => 'R', :default => "us-east-1"
18
+ end.with_indifferent_access
19
+
20
+ opts["aws-access-key-id"] ||= ENV['AWS_ACCESS_KEY_ID'] || file[0]
21
+ opts["aws-secret-access-key"] ||= ENV['AWS_SECRET_ACCESS_KEY'] || file[1]
22
+
23
+ opts.except("help").each do |key, value|
24
+ Trollop::die key, "cannot be blank" if value.blank?
25
+ end
26
+
27
+ opts
28
+ end
29
+
30
+ end
data/lib/saws/rds.rb ADDED
@@ -0,0 +1,2 @@
1
+ class SAWS::RDS < SAWS::Base
2
+ end
data/lib/saws.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ require 'fog'
3
+ require 'trollop'
4
+ require 'active_support/core_ext/object/blank'
5
+ require 'active_support/core_ext/object/try'
6
+ require 'active_support/core_ext/hash/slice'
7
+ require 'active_support/core_ext/hash/except'
8
+ require 'active_support/core_ext/hash/keys'
9
+ require 'active_support/core_ext/hash/reverse_merge'
10
+ require 'active_support/core_ext/hash/indifferent_access'
11
+ require 'active_support/core_ext/string/inflections'
12
+
13
+ module SAWS
14
+ extend self
15
+
16
+ autoload 'CLI', 'saws/cli'
17
+ autoload 'Base', 'saws/base'
18
+ autoload 'RDS', 'saws/rds'
19
+
20
+ def connection_options
21
+ @connection_options ||= CLI.options.slice(:region).merge(
22
+ :aws_access_key_id => CLI.options["aws-access-key-id"],
23
+ :aws_secret_access_key => CLI.options["aws-secret-access-key"]
24
+ ).symbolize_keys
25
+ end
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: saws
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Dimitrij Denissenko
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-08-17 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: activesupport
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: fog
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: trollop
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ type: :runtime
61
+ version_requirements: *id003
62
+ description:
63
+ email: dimitrij@blacksquaremedia.com
64
+ executables: []
65
+
66
+ extensions: []
67
+
68
+ extra_rdoc_files: []
69
+
70
+ files:
71
+ - lib/saws/rds.rb
72
+ - lib/saws/base.rb
73
+ - lib/saws/cli.rb
74
+ - lib/saws.rb
75
+ homepage: https://github.com/bsm/saws
76
+ licenses: []
77
+
78
+ post_install_message:
79
+ rdoc_options: []
80
+
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 57
89
+ segments:
90
+ - 1
91
+ - 8
92
+ - 7
93
+ version: 1.8.7
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ hash: 23
100
+ segments:
101
+ - 1
102
+ - 3
103
+ - 6
104
+ version: 1.3.6
105
+ requirements: []
106
+
107
+ rubyforge_project:
108
+ rubygems_version: 1.8.5
109
+ signing_key:
110
+ specification_version: 3
111
+ summary: Simple AWS scripting with Fog
112
+ test_files: []
113
+