nimble_nodes 0.2.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -1,8 +1,10 @@
1
- = Coming Soon: NimbleNodes
1
+ = Client Gem for NimbleNodes.com Subscribers
2
2
 
3
- Automatic scaling for Heroku Dynos (and Delayed Job Workers coming soon). See http://nimblenodes.com for more information.
3
+ Scale your Heroku app's dynos according to demand.
4
4
 
5
- Rack middleware sits on top of all requests and watches the number of Dynos in use and the size of the RequestQueue. Depending on the settings entered at http://nimblenodes.com reports are posted over to the server. The server then calculates the needed adjustments and handles all communications with Heroku.
5
+ Rack middleware sits on top of all requests and watches the number of Dynos in use and the number of pending requests. Depending on the settings entered at http://nimblenodes.com/my/dynos JSON reports are posted over to the server. The server then calculates the needed adjustments and handles all communications with Heroku.
6
+
7
+ See http://nimblenodes.com for more information.
6
8
 
7
9
  = Installation
8
10
 
@@ -16,18 +18,21 @@ In config/enviroment.rb
16
18
 
17
19
  config.gem 'nimble_nodes'
18
20
 
19
- === Rails 2.3
21
+ === Rails >= 2.3
20
22
 
21
23
  In config/initializers/nimble_nodes.rb
22
24
 
23
25
  ActionController::Dispatcher.middleware.use(NimbleNodes::Middleware)
24
26
 
25
- === Previous Rails Versions
27
+ === Rails < 2.3
26
28
 
27
29
  In app/controllers/application_controller.rb
28
30
 
29
31
  before_filter :monitor_heroku_app
30
32
 
33
+ == Other Rack Apps
34
+
35
+ All other Rack based apps *should* work using the NimbleNodes::Middleware. Please let us know if you need help getting it to work w/ a specific framework.
31
36
 
32
37
  = Copyright
33
38
 
data/Rakefile CHANGED
@@ -5,12 +5,12 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "nimble_nodes"
8
- gem.summary = "coming soon"
9
- gem.description = "coming soon"
8
+ gem.summary = "Connect your Heroku app to http://nimblenodes.com and automatically scale your Dynos to demand"
9
+ gem.description = "Scale your Heroku Dynos to demand at http://nimblenodes.com"
10
10
  gem.email = "jordan@digitalignition.com"
11
- gem.homepage = "http://github.com/glasner/nimble_nodes"
11
+ gem.homepage = "http://nimblenodes.com"
12
12
  gem.authors = ["Jordan Glasner"]
13
- gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
13
+ gem.add_development_dependency "shoulda", ">= 0"
14
14
  gem.add_development_dependency "mocha"
15
15
  gem.add_development_dependency "fakeweb"
16
16
  gem.add_dependency "json"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.9.0
@@ -16,7 +16,7 @@ module NimbleNodes
16
16
 
17
17
  # returns true if report needs to be posted to server
18
18
  def post?
19
- return true
19
+ # return true
20
20
  dynos_maxed_out? or queue_depth_too_long? or queue_depth_too_short? or idle_dynos?
21
21
  end
22
22
 
@@ -10,7 +10,7 @@ module NimbleNodes
10
10
  def self.get(path)
11
11
  begin
12
12
  path = NimbleNodes::App.path(path)
13
- uri = uri_with_token(path)
13
+ uri = NimbleNodes::Server.uri_with_token(path)
14
14
  path = uri.route_from(NimbleNodes::Server.url[0..-2]).to_s
15
15
  request = Net::HTTP::Get.new(path)
16
16
  return Net::HTTP.start(uri.host, uri.port) {|http| http.request(request)}.body
data/nimble_nodes.gemspec CHANGED
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{nimble_nodes}
8
- s.version = "0.2.0"
8
+ s.version = "0.9.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jordan Glasner"]
12
- s.date = %q{2010-04-04}
13
- s.description = %q{coming soon}
12
+ s.date = %q{2010-04-06}
13
+ s.description = %q{Scale your Heroku Dynos to demand at http://nimblenodes.com}
14
14
  s.email = %q{jordan@digitalignition.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
@@ -37,18 +37,20 @@ Gem::Specification.new do |s|
37
37
  "test/unit/test_app.rb",
38
38
  "test/unit/test_dynos.rb",
39
39
  "test/unit/test_nimble_nodes.rb",
40
+ "test/unit/test_server.rb",
40
41
  "test/unit/test_settings.rb"
41
42
  ]
42
- s.homepage = %q{http://github.com/glasner/nimble_nodes}
43
+ s.homepage = %q{http://nimblenodes.com}
43
44
  s.rdoc_options = ["--charset=UTF-8"]
44
45
  s.require_paths = ["lib"]
45
46
  s.rubygems_version = %q{1.3.5}
46
- s.summary = %q{coming soon}
47
+ s.summary = %q{Connect your Heroku app to http://nimblenodes.com and automatically scale your Dynos to demand}
47
48
  s.test_files = [
48
49
  "test/helper.rb",
49
50
  "test/unit/test_app.rb",
50
51
  "test/unit/test_dynos.rb",
51
52
  "test/unit/test_nimble_nodes.rb",
53
+ "test/unit/test_server.rb",
52
54
  "test/unit/test_settings.rb"
53
55
  ]
54
56
 
@@ -57,18 +59,18 @@ Gem::Specification.new do |s|
57
59
  s.specification_version = 3
58
60
 
59
61
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
60
- s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
62
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
61
63
  s.add_development_dependency(%q<mocha>, [">= 0"])
62
64
  s.add_development_dependency(%q<fakeweb>, [">= 0"])
63
65
  s.add_runtime_dependency(%q<json>, [">= 0"])
64
66
  else
65
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
67
+ s.add_dependency(%q<shoulda>, [">= 0"])
66
68
  s.add_dependency(%q<mocha>, [">= 0"])
67
69
  s.add_dependency(%q<fakeweb>, [">= 0"])
68
70
  s.add_dependency(%q<json>, [">= 0"])
69
71
  end
70
72
  else
71
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
73
+ s.add_dependency(%q<shoulda>, [">= 0"])
72
74
  s.add_dependency(%q<mocha>, [">= 0"])
73
75
  s.add_dependency(%q<fakeweb>, [">= 0"])
74
76
  s.add_dependency(%q<json>, [">= 0"])
data/test/helper.rb CHANGED
@@ -8,4 +8,19 @@ require 'fakeweb'
8
8
  require File.expand_path(File.dirname(__FILE__)) + '/../lib/nimble_nodes'
9
9
 
10
10
  class Test::Unit::TestCase
11
+
12
+ def setup_installed_app
13
+ NimbleNodes::App.stubs({
14
+ :name => "nimble-nodes-test",
15
+ :token => 'test'
16
+ })
17
+ end
18
+
19
+ def setup_invalid_app
20
+ NimbleNodes::App.stubs({
21
+ :name => nil,
22
+ :token => nil
23
+ })
24
+ end
25
+
11
26
  end
@@ -31,10 +31,7 @@ class TestDynos < Test::Unit::TestCase
31
31
  context "App setup at NimbleNodes" do
32
32
 
33
33
  setup {
34
- NimbleNodes::App.stubs({
35
- :name => 'nimble-nodes-test',
36
- :token => 'token'
37
- })
34
+ setup_installed_app
38
35
  @module.stubs(:settings).returns({
39
36
  'paused_at' => nil,
40
37
  'min' => 1,
@@ -6,46 +6,11 @@ class TestNimbleNodes < Test::Unit::TestCase
6
6
  context "NimbleNodes module" do
7
7
  setup { @module = NimbleNodes }
8
8
 
9
- context "in a Rails app" do
10
-
11
- setup { NimbleNodes::App.stubs(:rails?).returns(true) }
12
-
13
- context "pre 2.3" do
14
- setup { NimbleNodes::App.stubs(:rails_version).returns(2.2) }
15
-
16
- should "use NimbleNodes::Filter as reporter" do
17
- assert_equal 'filter', @module.reporter.split('/').last
18
- end
19
-
20
- end
21
-
22
- context "2.3 or later" do
23
- setup { NimbleNodes::App.stubs(:rails_version).returns(2.3) }
24
-
25
- should "use NimbleNodes::Middleware as reporter" do
26
- assert_equal 'middleware', @module.reporter.split('/').last
27
- end
28
-
29
- end
30
-
31
- end
32
-
33
- context "in a non-Rails app" do
34
- setup { NimbleNodes::App.stubs(:rails?).returns(false) }
35
-
36
- should "use NimbleNodes::Middleware" do
37
- assert_equal 'middleware8', @module.reporter.split('/').last
38
- end
39
-
40
- end
41
9
 
42
10
  context "App installed at NimbleNodes" do
43
11
 
44
12
  setup {
45
- NimbleNodes::App.stubs({
46
- :name => 'nimble-nodes-test',
47
- :token => 'token'
48
- })
13
+ setup_installed_app
49
14
  }
50
15
 
51
16
  context "not paused" do
@@ -0,0 +1,80 @@
1
+ require File.expand_path(File.dirname(__FILE__)) + '/../helper'
2
+
3
+ class Test::Unit::TestCase
4
+
5
+ def self.should_not_raise_anything_on_get
6
+
7
+ should "catch all errors from creating path" do
8
+ NimbleNodes::App.expects(:path).raises(ArgumentError)
9
+ assert_nothing_raised { @module.get('/settings.json') }
10
+ end
11
+
12
+ should "catch all errors from concatenating URL" do
13
+ NimbleNodes::Server.expects(:url).raises(ArgumentError)
14
+ assert_nothing_raised { @module.get('/settings.json') }
15
+ end
16
+
17
+ should "catch all errors from parsing URI" do
18
+ NimbleNodes::Server.stubs(:uri_with_token).raises(ArgumentError)
19
+ assert_nothing_raised { @module.get('/settings.json') }
20
+ end
21
+
22
+ should "catch all errors from Net::HTTP" do
23
+ Net::HTTP.stubs(:start).raises(Net::HTTPError)
24
+ assert_nothing_raised { @module.get('/settings.json') }
25
+ end
26
+ end
27
+
28
+ def self.should_not_raise_anything_on_post
29
+
30
+ should "catch all errors from creating path" do
31
+ NimbleNodes::App.expects(:path).raises(ArgumentError)
32
+ assert_nothing_raised { @module.post('/',{}) }
33
+ end
34
+
35
+ should "catch all errors from concatenating URL" do
36
+ NimbleNodes::Server.expects(:url).raises(ArgumentError)
37
+ assert_nothing_raised { @module.post('/',{}) }
38
+ end
39
+
40
+ should "catch all errors from parsing URI" do
41
+ NimbleNodes::Server.stubs(:uri_with_token).raises(ArgumentError)
42
+ assert_nothing_raised { @module.post('/',{}) }
43
+ end
44
+
45
+ should "catch all errors from Net::HTTP" do
46
+ Net::HTTP.stubs(:start).raises(Net::HTTPError)
47
+ assert_nothing_raised { @module.post('/',{}) }
48
+ end
49
+ end
50
+
51
+ end
52
+
53
+ class TestServer < Test::Unit::TestCase
54
+
55
+ context "Server" do
56
+
57
+ setup {
58
+ @module = NimbleNodes::Server
59
+ }
60
+
61
+ context "App is installed at NimbleNodes.com" do
62
+
63
+ setup { setup_installed_app }
64
+
65
+ should_not_raise_anything_on_get
66
+ should_not_raise_anything_on_post
67
+ end
68
+
69
+ context "App isn't installed at NimbleNodes.com" do
70
+ setup { setup_invalid_app }
71
+
72
+ should_not_raise_anything_on_get
73
+ should_not_raise_anything_on_post
74
+ end
75
+
76
+
77
+
78
+ end
79
+
80
+ end
@@ -2,6 +2,8 @@ require File.expand_path(File.dirname(__FILE__)) + '/../helper'
2
2
 
3
3
  class Test::Unit::TestCase
4
4
 
5
+
6
+
5
7
  def self.should_not_raise_any_errors_when_fetching_from_server
6
8
  should "not raise any errors when fetching from server" do
7
9
  assert_nothing_raised { @module.fetch_from_server }
@@ -28,10 +30,7 @@ class TestSettings < Test::Unit::TestCase
28
30
 
29
31
  context "App is installed at NimbleNodes.com" do
30
32
  setup do
31
- NimbleNodes::App.stubs({
32
- :name => "nimble-nodes-test",
33
- :token => 'test'
34
- })
33
+ setup_installed_app
35
34
  end
36
35
 
37
36
  context "server responds with JSON" do
@@ -42,11 +41,11 @@ class TestSettings < Test::Unit::TestCase
42
41
  NimbleNodes::Server.expects(:get).returns(@json)
43
42
  }
44
43
 
45
- should "only fetch from server once" do
46
- @module.expects(:fetch_from_server).once
47
- @module['paused_at']
48
- @module['dynos_pool']
49
- end
44
+ # should "only fetch from server once" do
45
+ # @module.expects(:fetch_from_server).once
46
+ # @module['paused_at']
47
+ # @module['dynos_pool']
48
+ # end
50
49
 
51
50
  should "save parsed parsed response in cache" do
52
51
  cached = @module.cache
@@ -75,10 +74,7 @@ class TestSettings < Test::Unit::TestCase
75
74
  context "App is *not* installed at NimbleNodes.com" do
76
75
 
77
76
  setup {
78
- NimbleNodes::App.stubs({
79
- :name => nil,
80
- :token => nil
81
- })
77
+ setup_invalid_app
82
78
  NimbleNodes::Server.expects(:get).returns(nil)
83
79
  }
84
80
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nimble_nodes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Glasner
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-04-04 00:00:00 -04:00
12
+ date: 2010-04-06 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: thoughtbot-shoulda
16
+ name: shoulda
17
17
  type: :development
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
@@ -52,7 +52,7 @@ dependencies:
52
52
  - !ruby/object:Gem::Version
53
53
  version: "0"
54
54
  version:
55
- description: coming soon
55
+ description: Scale your Heroku Dynos to demand at http://nimblenodes.com
56
56
  email: jordan@digitalignition.com
57
57
  executables: []
58
58
 
@@ -82,9 +82,10 @@ files:
82
82
  - test/unit/test_app.rb
83
83
  - test/unit/test_dynos.rb
84
84
  - test/unit/test_nimble_nodes.rb
85
+ - test/unit/test_server.rb
85
86
  - test/unit/test_settings.rb
86
87
  has_rdoc: true
87
- homepage: http://github.com/glasner/nimble_nodes
88
+ homepage: http://nimblenodes.com
88
89
  licenses: []
89
90
 
90
91
  post_install_message:
@@ -110,10 +111,11 @@ rubyforge_project:
110
111
  rubygems_version: 1.3.5
111
112
  signing_key:
112
113
  specification_version: 3
113
- summary: coming soon
114
+ summary: Connect your Heroku app to http://nimblenodes.com and automatically scale your Dynos to demand
114
115
  test_files:
115
116
  - test/helper.rb
116
117
  - test/unit/test_app.rb
117
118
  - test/unit/test_dynos.rb
118
119
  - test/unit/test_nimble_nodes.rb
120
+ - test/unit/test_server.rb
119
121
  - test/unit/test_settings.rb