fake_sqs 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -60,7 +60,7 @@ let it talk to Fake SQS.
60
60
  AWS.config(
61
61
  :use_ssl => false,
62
62
  :sqs_endpoint => "localhost",
63
- :sqs_port => 4567,
63
+ :sqs_port => 4568,
64
64
  :access_key_id => "access key id",
65
65
  :secret_access_key => "secret access key"
66
66
  )
@@ -73,7 +73,7 @@ To reset the entire server, during tests for example, send a DELETE request to
73
73
  the server. For example:
74
74
 
75
75
  ```
76
- $ curl -X DELETE http://localhost:4567/
76
+ $ curl -X DELETE http://localhost:4568/
77
77
  ```
78
78
 
79
79
  Within SQS, after receiving, messages will be available again automatically
@@ -81,7 +81,7 @@ after a certain time. While this is not implemented (for now at least), you can
81
81
  trigger this behavior at at will, with a PUT request.
82
82
 
83
83
  ```
84
- $ curl -X PUT http://localhost:4567/
84
+ $ curl -X PUT http://localhost:4568/
85
85
  ```
86
86
 
87
87
 
data/bin/fake_sqs CHANGED
@@ -3,11 +3,11 @@
3
3
  require 'fake_sqs'
4
4
  require 'optparse'
5
5
 
6
- options = { :port => 4567, :host => "0.0.0.0", :verbose => false }
6
+ options = { :port => 4568, :host => "0.0.0.0", :verbose => false, :daemonize => false }
7
7
 
8
8
  parser = OptionParser.new do |o|
9
9
 
10
- o.on "-p", "--port PORT", Integer, "Port to use (default: 4567)" do |port|
10
+ o.on "-p", "--port PORT", Integer, "Port to use (default: #{options[:port]})" do |port|
11
11
  options[:port] = port
12
12
  end
13
13
 
@@ -15,10 +15,18 @@ parser = OptionParser.new do |o|
15
15
  options[:host] = host
16
16
  end
17
17
 
18
- o.on "-s", "--server SERVER", ['thin', 'mongrel', 'webrick'], "Server to use: thin, mongrel or webrick" do |server|
18
+ o.on "-s", "--server SERVER", ['thin', 'mongrel', 'webrick'], "Server to use: thin, mongrel or webrick (by default Sinatra chooses the best available)" do |server|
19
19
  options[:server] = server
20
20
  end
21
21
 
22
+ o.on "-P", "--pid PIDFILE", "Where to write the pid" do |pid|
23
+ options[:pid] = pid
24
+ end
25
+
26
+ o.on "-d", "--[no-]daemonize", "Detaches the process" do |daemonize|
27
+ options[:daemonize] = daemonize
28
+ end
29
+
22
30
  o.on "-v", "--[no]-verbose", "Shows input parameters and output XML" do |verbose|
23
31
  options[:verbose] = verbose
24
32
  end
@@ -44,6 +52,24 @@ if options[:verbose]
44
52
  app.use FakeSQS::ShowOutput
45
53
  end
46
54
 
55
+ if options[:daemonize]
56
+ Process.daemon(true, true)
57
+ end
58
+
59
+ if (pid = options[:pid])
60
+ if File.exist?(pid)
61
+ existing_pid = File.open(pid, 'r').read.chomp.to_i
62
+ running = Process.getpgid(existing_pid) rescue false
63
+ if running
64
+ warn "Error, Process #{existing_pid} already running"
65
+ exit 1
66
+ else
67
+ warn "Cleaning up stale pid at #{pid}"
68
+ end
69
+ end
70
+ File.open(pid, 'w') { |f| f.write(Process.pid) }
71
+ end
72
+
47
73
  app.set :port, options[:port]
48
74
  app.set :bind, options[:host]
49
75
  app.set :server, options[:server] if options[:server]
@@ -1,3 +1,3 @@
1
1
  module FakeSQS
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -6,21 +6,21 @@ describe "Actions for Queues", :acceptance do
6
6
 
7
7
  specify "CreateQueue" do
8
8
  queue = sqs.queues.create("test-create-queue")
9
- queue.url.should eq "http://0.0.0.0:4567/test-create-queue"
9
+ queue.url.should eq "http://0.0.0.0:4568/test-create-queue"
10
10
  end
11
11
 
12
12
  specify "GetQueueUrl" do
13
13
  sqs.queues.create("test-get-queue-url")
14
14
  queue = sqs.queues.named("test-get-queue-url")
15
- queue.url.should eq "http://0.0.0.0:4567/test-get-queue-url"
15
+ queue.url.should eq "http://0.0.0.0:4568/test-get-queue-url"
16
16
  end
17
17
 
18
18
  specify "ListQueues" do
19
19
  sqs.queues.create("test-list-1")
20
20
  sqs.queues.create("test-list-2")
21
21
  queues = sqs.queues.map(&:url).should eq [
22
- "http://0.0.0.0:4567/test-list-1",
23
- "http://0.0.0.0:4567/test-list-2"
22
+ "http://0.0.0.0:4568/test-list-1",
23
+ "http://0.0.0.0:4568/test-list-2"
24
24
  ]
25
25
  end
26
26
 
@@ -29,8 +29,8 @@ describe "Actions for Queues", :acceptance do
29
29
  sqs.queues.create("test-list-2")
30
30
  sqs.queues.create("other-list-3")
31
31
  queues = sqs.queues.with_prefix("test").map(&:url).should eq [
32
- "http://0.0.0.0:4567/test-list-1",
33
- "http://0.0.0.0:4567/test-list-2"
32
+ "http://0.0.0.0:4568/test-list-1",
33
+ "http://0.0.0.0:4568/test-list-2"
34
34
  ]
35
35
  end
36
36
 
data/spec/support/aws.rb CHANGED
@@ -14,7 +14,7 @@ class FakeServer
14
14
 
15
15
  attr_reader :url
16
16
 
17
- def initialize(url = "http://0.0.0.0:4567")
17
+ def initialize(url = "http://0.0.0.0:4568")
18
18
  @url = url
19
19
  end
20
20
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fake_sqs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-11 00:00:00.000000000 Z
12
+ date: 2013-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra