aeden-aws-tools 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
- config/amazon.yml
1
+ config/amazon.yml
2
+ rdoc
@@ -1 +1,9 @@
1
- Tools that help with gathering data and doing other things with Amazon Web Services. These tools require ruby and the Right AWS library to function.
1
+ Tools that help with gathering data and doing other things with Amazon Web Services. These tools require ruby and the Right AWS library to function.
2
+
3
+ == Queue Length
4
+
5
+ Use <code>bin/queue_length queue_name</code> to print the length of any queue.
6
+
7
+ == Queue Peek
8
+
9
+ Use <code>bin/queue_peek queue_name</code> to pretty print all of the messages in any queue. The body of each message is assumed to be Base64 encoded and is a JSON document.
@@ -0,0 +1,9 @@
1
+ Tools that help with gathering data and doing other things with Amazon Web Services. These tools require ruby and the Right AWS library to function.
2
+
3
+ h2. Queue Length
4
+
5
+ Use <code>bin/queue_length queue_name</code> to print the length of any queue.
6
+
7
+ h2. Queue Peek
8
+
9
+ Use <code>bin/queue_peek queue_name</code> to pretty print all of the messages in any queue. The body of each message is assumed to be Base64 encoded and is a JSON document.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{aws-tools}
5
- s.version = "0.0.2"
5
+ s.version = "0.0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Anthony Eden"]
@@ -12,14 +12,14 @@ Gem::Specification.new do |s|
12
12
  s.executables = ["queue_length", "queue_peek"]
13
13
  s.extra_rdoc_files = [
14
14
  "LICENSE",
15
- "README.markdown",
16
- "README.rdoc"
15
+ "README.rdoc",
16
+ "README.textile"
17
17
  ]
18
18
  s.files = [
19
19
  ".gitignore",
20
20
  "LICENSE",
21
- "README.markdown",
22
21
  "README.rdoc",
22
+ "README.textile",
23
23
  "Rakefile",
24
24
  "VERSION",
25
25
  "aws-tools.gemspec",
@@ -27,8 +27,10 @@ Gem::Specification.new do |s|
27
27
  "bin/queue_peek",
28
28
  "config/amazon.example.yml",
29
29
  "lib/aws_config.rb",
30
+ "lib/aws_tools.rb",
30
31
  "lib/queue_length.rb",
31
32
  "lib/queue_peek.rb",
33
+ "lib/queueable.rb",
32
34
  "lib/ssl_no_verify.rb"
33
35
  ]
34
36
  s.has_rdoc = true
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require File.dirname(__FILE__) + '/../lib/queue_length'
3
+ require File.dirname(__FILE__) + '/../lib/queue_length'
4
+
5
+ QueueLength.new.execute(ARGV.pop)
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require File.dirname(__FILE__) + '/../lib/queue_peek'
3
+ require File.dirname(__FILE__) + '/../lib/queue_peek'
4
+
5
+ QueuePeek.new.execute(ARGV.pop)
@@ -1,12 +1,16 @@
1
+ # Provides access to the Amazon AWS configuration in config/amazon.yml
1
2
  class AwsConfig
3
+ # Get the AWS credentials from the config (key: credentials)
2
4
  def self.credentials
3
5
  config['credentials']
4
6
  end
5
7
 
8
+ # Get the config YAML
6
9
  def self.config
7
10
  @config ||= YAML.load(config_file)
8
11
  end
9
12
 
13
+ # Get the config File object
10
14
  def self.config_file
11
15
  @config_file ||= File.new(File.join(File.dirname(__FILE__), "/../config/amazon.yml"))
12
16
  end
@@ -0,0 +1,9 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+
3
+ require 'ssl_no_verify'
4
+
5
+ require 'rubygems'
6
+ require 'right_aws'
7
+ require 'aws_config'
8
+ require 'queueable'
9
+ require 'json'
@@ -1,16 +1,11 @@
1
- $:.unshift(File.dirname(__FILE__))
1
+ require File.dirname(__FILE__) + '/aws_tools'
2
2
 
3
- require 'ssl_no_verify'
3
+ # Class for getting the length of a specific SQS queue.
4
+ class QueueLength
5
+ include Queueable
6
+ # Print the queue length
7
+ def execute(queue_name)
8
+ puts queue(queue_name).size()
9
+ end
10
+ end
4
11
 
5
- require 'rubygems'
6
- require 'right_aws'
7
- require 'aws_config'
8
-
9
- queue_name = ARGV.pop
10
-
11
- sqs = RightAws::SqsGen2.new(
12
- AwsConfig.credentials["access_key_id"],
13
- AwsConfig.credentials["secret_access_key"],
14
- :logger => Logger.new(nil)
15
- )
16
- puts sqs.queue(queue_name).size()
@@ -1,21 +1,14 @@
1
- $:.unshift(File.dirname(__FILE__))
2
-
3
- require 'ssl_no_verify'
4
-
5
- require 'rubygems'
6
- require 'right_aws'
7
- require 'json'
8
- require 'aws_config'
9
-
10
- queue_name = ARGV.pop
11
- RAILS_ENV = ARGV.pop
12
-
13
- sqs = RightAws::SqsGen2.new(
14
- AwsConfig.credentials["access_key_id"],
15
- AwsConfig.credentials["secret_access_key"],
16
- :logger => Logger.new(nil)
17
- )
18
-
19
- while(m = sqs.queue(queue_name).receive(1))
20
- pp JSON.parse(Base64.decode64(m.body))
1
+ require File.dirname(__FILE__) + '/aws_tools'
2
+
3
+ # Class for peeking into queues.
4
+ class QueuePeek
5
+ include Queueable
6
+ # Execute a queue peek on the given queue_name. Assumes that messages
7
+ # are Base64 encoded and JSON documents. Each message body in the queue
8
+ # will be parsed and pretty-printed.
9
+ def execute(queue_name)
10
+ while(m = queue(queue_name).receive(1))
11
+ pp JSON.parse(Base64.decode64(m.body))
12
+ end
13
+ end
21
14
  end
@@ -0,0 +1,20 @@
1
+ require 'aws_config'
2
+
3
+ # Module that can be mixed into a class provideing access to SQS
4
+ # queues.
5
+ module Queueable
6
+ # Get the SQS queue by name
7
+ def queue(name)
8
+ sqs.queue(name)
9
+ end
10
+
11
+ private
12
+ # Get the SQS access point.
13
+ def sqs
14
+ RightAws::SqsGen2.new(
15
+ AwsConfig.credentials["access_key_id"],
16
+ AwsConfig.credentials["secret_access_key"],
17
+ :logger => Logger.new(nil)
18
+ )
19
+ end
20
+ end
@@ -1,9 +1,11 @@
1
1
  require 'net/http'
2
- class Net::HTTP
3
- alias_method :old_initialize, :initialize
4
- def initialize(*args)
5
- old_initialize(*args)
6
- @ssl_context = OpenSSL::SSL::SSLContext.new
7
- @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
2
+ module Net #:nodoc:
3
+ class HTTP #:nodoc:
4
+ alias_method :old_initialize, :initialize
5
+ def initialize(*args)
6
+ old_initialize(*args)
7
+ @ssl_context = OpenSSL::SSL::SSLContext.new
8
+ @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
9
+ end
8
10
  end
9
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aeden-aws-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Eden
@@ -22,13 +22,13 @@ extensions: []
22
22
 
23
23
  extra_rdoc_files:
24
24
  - LICENSE
25
- - README.markdown
26
25
  - README.rdoc
26
+ - README.textile
27
27
  files:
28
28
  - .gitignore
29
29
  - LICENSE
30
- - README.markdown
31
30
  - README.rdoc
31
+ - README.textile
32
32
  - Rakefile
33
33
  - VERSION
34
34
  - aws-tools.gemspec
@@ -36,8 +36,10 @@ files:
36
36
  - bin/queue_peek
37
37
  - config/amazon.example.yml
38
38
  - lib/aws_config.rb
39
+ - lib/aws_tools.rb
39
40
  - lib/queue_length.rb
40
41
  - lib/queue_peek.rb
42
+ - lib/queueable.rb
41
43
  - lib/ssl_no_verify.rb
42
44
  has_rdoc: true
43
45
  homepage: http://github.com/aeden/aws-tools
@@ -1 +0,0 @@
1
- Tools that help with gathering data and doing other things with Amazon Web Services. These tools require ruby and the Right AWS library to function.