rate_limiter 0.0.6 → 0.1.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.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +6 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.md +18 -11
  5. data/lib/generators/rate_limiter/install_generator.rb +22 -0
  6. data/lib/generators/rate_limiter/templates/rate_limiter.rb +6 -0
  7. data/lib/rate_limiter.rb +51 -51
  8. data/lib/rate_limiter/config.rb +18 -3
  9. data/lib/rate_limiter/frameworks/rails.rb +3 -0
  10. data/lib/rate_limiter/frameworks/rails/controller.rb +69 -0
  11. data/lib/rate_limiter/model.rb +30 -48
  12. data/lib/rate_limiter/model_config.rb +34 -0
  13. data/lib/rate_limiter/request.rb +112 -0
  14. data/lib/rate_limiter/throttle.rb +79 -0
  15. data/lib/rate_limiter/validator.rb +29 -0
  16. data/lib/rate_limiter/version.rb +3 -1
  17. data/rate_limiter.gemspec +24 -18
  18. metadata +98 -183
  19. data/.gitignore +0 -11
  20. data/.rspec +0 -3
  21. data/.rvmrc +0 -80
  22. data/Gemfile +0 -3
  23. data/Gemfile.lock +0 -150
  24. data/Rakefile +0 -6
  25. data/lib/rate_limiter/controller.rb +0 -36
  26. data/spec/dummy/Rakefile +0 -7
  27. data/spec/dummy/app/assets/images/rails.png +0 -0
  28. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  29. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  30. data/spec/dummy/app/controllers/application_controller.rb +0 -7
  31. data/spec/dummy/app/controllers/messages_controller.rb +0 -75
  32. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  33. data/spec/dummy/app/mailers/.gitkeep +0 -0
  34. data/spec/dummy/app/models/message.rb +0 -5
  35. data/spec/dummy/app/views/layouts/application.html.erb +0 -15
  36. data/spec/dummy/app/views/messages/_form.html.erb +0 -22
  37. data/spec/dummy/app/views/messages/_message.html.erb +0 -8
  38. data/spec/dummy/app/views/messages/edit.html.erb +0 -3
  39. data/spec/dummy/app/views/messages/index.html.erb +0 -6
  40. data/spec/dummy/app/views/messages/new.html.erb +0 -3
  41. data/spec/dummy/app/views/messages/show.html.erb +0 -4
  42. data/spec/dummy/config.ru +0 -4
  43. data/spec/dummy/config/application.rb +0 -70
  44. data/spec/dummy/config/boot.rb +0 -11
  45. data/spec/dummy/config/database.yml +0 -25
  46. data/spec/dummy/config/environment.rb +0 -5
  47. data/spec/dummy/config/environments/development.rb +0 -37
  48. data/spec/dummy/config/environments/production.rb +0 -67
  49. data/spec/dummy/config/environments/test.rb +0 -37
  50. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  51. data/spec/dummy/config/initializers/inflections.rb +0 -15
  52. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  53. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  54. data/spec/dummy/config/initializers/session_store.rb +0 -8
  55. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  56. data/spec/dummy/config/locales/en.yml +0 -5
  57. data/spec/dummy/config/routes.rb +0 -5
  58. data/spec/dummy/db/migrate/20121213101512_create_messages.rb +0 -21
  59. data/spec/dummy/db/schema.rb +0 -33
  60. data/spec/dummy/db/seeds.rb +0 -7
  61. data/spec/dummy/lib/assets/.gitkeep +0 -0
  62. data/spec/dummy/lib/tasks/.gitkeep +0 -0
  63. data/spec/dummy/log/.gitkeep +0 -0
  64. data/spec/dummy/public/404.html +0 -26
  65. data/spec/dummy/public/422.html +0 -26
  66. data/spec/dummy/public/500.html +0 -25
  67. data/spec/dummy/public/favicon.ico +0 -0
  68. data/spec/dummy/script/rails +0 -6
  69. data/spec/rate_limiter/model_spec.rb +0 -20
  70. data/spec/rate_limiter_spec.rb +0 -10
  71. data/spec/spec_helper.rb +0 -30
@@ -1,7 +0,0 @@
1
- # This file should contain all the record creation needed to seed the database with its default values.
2
- # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
- #
4
- # Examples:
5
- #
6
- # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
- # Mayor.create(name: 'Emanuel', city: cities.first)
File without changes
File without changes
File without changes
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/404.html -->
21
- <div class="dialog">
22
- <h1>The page you were looking for doesn't exist.</h1>
23
- <p>You may have mistyped the address or the page may have moved.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/422.html -->
21
- <div class="dialog">
22
- <h1>The change you wanted was rejected.</h1>
23
- <p>Maybe you tried to change something you didn't have access to.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/500.html -->
21
- <div class="dialog">
22
- <h1>We're sorry, but something went wrong.</h1>
23
- </div>
24
- </body>
25
- </html>
File without changes
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'
@@ -1,20 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper.rb'
3
-
4
- describe RateLimiter::Model do
5
- it 'prevents a model from being saved too soon' do
6
- message1 = Message.new
7
-
8
- message1.ip_address = '127.0.0.1'
9
-
10
- message1.save
11
-
12
- message2 = Message.new
13
-
14
- message2.ip_address = '127.0.0.1'
15
-
16
- message2.save
17
-
18
- message2.errors.count.should eq(1)
19
- end
20
- end
@@ -1,10 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper.rb'
3
-
4
- describe RateLimiter do
5
- describe 'Sanity Test' do
6
- it 'should be a Module' do
7
- RateLimiter.should be_a(Module)
8
- end
9
- end
10
- end
data/spec/spec_helper.rb DELETED
@@ -1,30 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ENV['RAILS_ENV'] = 'test'
4
-
5
- require File.expand_path('../dummy/config/environment.rb', __FILE__)
6
- require 'rspec/rails'
7
- require 'shoulda/matchers/integrations/rspec'
8
- require 'capybara/rspec'
9
- require 'database_cleaner'
10
-
11
- Rails.backtrace_cleaner.remove_silencers!
12
-
13
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
14
-
15
- RSpec.configure do |config|
16
- config.mock_with :rspec
17
-
18
- config.before :suite do
19
- DatabaseCleaner.strategy = :transaction
20
- DatabaseCleaner.clean_with :truncation
21
- end
22
-
23
- config.before :each do
24
- DatabaseCleaner.start
25
- end
26
-
27
- config.after :each do
28
- DatabaseCleaner.clean
29
- end
30
- end