Class: Cliaws::Cli::Sqs
- Inherits:
-
Thor
- Object
- Thor
- Cliaws::Cli::Sqs
- Defined in:
- lib/cliaws/cli/sqs.rb
Instance Method Summary collapse
- #create(queue_name) ⇒ Object
- #delete(queue_name) ⇒ Object
- #info(queue_name) ⇒ Object
- #list(prefix = nil) ⇒ Object
- #pop(queue_name) ⇒ Object
- #push(queue_name, local_file = nil) ⇒ Object
- #receive(queue_name) ⇒ Object
- #size(queue_name) ⇒ Object
Instance Method Details
#create(queue_name) ⇒ Object
11 12 13 14 |
# File 'lib/cliaws/cli/sqs.rb', line 11 def create(queue_name) Cliaws.sqs.create(queue_name) puts "Created #{queue_name}" end |
#delete(queue_name) ⇒ Object
18 19 20 21 |
# File 'lib/cliaws/cli/sqs.rb', line 18 def delete(queue_name) Cliaws.sqs.delete(queue_name, [:force]) puts "Queue #{queue_name} deleted" end |
#info(queue_name) ⇒ Object
66 67 68 69 70 |
# File 'lib/cliaws/cli/sqs.rb', line 66 def info(queue_name) info = Cliaws.sqs.info(queue_name) data = {"Visibility" => info[:visibility_timeout], "Number of messages" => info[:size]} puts data.to_yaml end |
#list(prefix = nil) ⇒ Object
24 25 26 |
# File 'lib/cliaws/cli/sqs.rb', line 24 def list(prefix=nil) puts Cliaws.sqs.list(prefix).map {|q| q.name} end |
#pop(queue_name) ⇒ Object
40 41 42 43 |
# File 'lib/cliaws/cli/sqs.rb', line 40 def pop(queue_name) = Cliaws.sqs.pop(queue_name) puts if end |
#push(queue_name, local_file = nil) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cliaws/cli/sqs.rb', line 51 def push(queue_name, local_file=nil) raise ArgumentError, "Cannot give both --data and LOCAL_FILE" if [:data] && local_file data = case when local_file File.read(local_file) when [:data] [:data] else STDIN.read end Cliaws.sqs.push(queue_name, data) puts "Pushed #{data.size} bytes to queue #{queue_name}" end |