rate_limiter 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +6 -0
- data/LICENSE.txt +20 -0
- data/README.md +18 -11
- data/lib/generators/rate_limiter/install_generator.rb +22 -0
- data/lib/generators/rate_limiter/templates/rate_limiter.rb +6 -0
- data/lib/rate_limiter.rb +51 -51
- data/lib/rate_limiter/config.rb +18 -3
- data/lib/rate_limiter/frameworks/rails.rb +3 -0
- data/lib/rate_limiter/frameworks/rails/controller.rb +69 -0
- data/lib/rate_limiter/model.rb +30 -48
- data/lib/rate_limiter/model_config.rb +34 -0
- data/lib/rate_limiter/request.rb +112 -0
- data/lib/rate_limiter/throttle.rb +79 -0
- data/lib/rate_limiter/validator.rb +29 -0
- data/lib/rate_limiter/version.rb +3 -1
- data/rate_limiter.gemspec +24 -18
- metadata +98 -183
- data/.gitignore +0 -11
- data/.rspec +0 -3
- data/.rvmrc +0 -80
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -150
- data/Rakefile +0 -6
- data/lib/rate_limiter/controller.rb +0 -36
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/assets/images/rails.png +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -15
- data/spec/dummy/app/assets/stylesheets/application.css +0 -13
- data/spec/dummy/app/controllers/application_controller.rb +0 -7
- data/spec/dummy/app/controllers/messages_controller.rb +0 -75
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/message.rb +0 -5
- data/spec/dummy/app/views/layouts/application.html.erb +0 -15
- data/spec/dummy/app/views/messages/_form.html.erb +0 -22
- data/spec/dummy/app/views/messages/_message.html.erb +0 -8
- data/spec/dummy/app/views/messages/edit.html.erb +0 -3
- data/spec/dummy/app/views/messages/index.html.erb +0 -6
- data/spec/dummy/app/views/messages/new.html.erb +0 -3
- data/spec/dummy/app/views/messages/show.html.erb +0 -4
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -70
- data/spec/dummy/config/boot.rb +0 -11
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -37
- data/spec/dummy/config/environments/production.rb +0 -67
- data/spec/dummy/config/environments/test.rb +0 -37
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/inflections.rb +0 -15
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -5
- data/spec/dummy/db/migrate/20121213101512_create_messages.rb +0 -21
- data/spec/dummy/db/schema.rb +0 -33
- data/spec/dummy/db/seeds.rb +0 -7
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/lib/tasks/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -25
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/rate_limiter/model_spec.rb +0 -20
- data/spec/rate_limiter_spec.rb +0 -10
- data/spec/spec_helper.rb +0 -30
data/spec/dummy/db/seeds.rb
DELETED
@@ -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
|
data/spec/dummy/log/.gitkeep
DELETED
File without changes
|
data/spec/dummy/public/404.html
DELETED
@@ -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>
|
data/spec/dummy/public/422.html
DELETED
@@ -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>
|
data/spec/dummy/public/500.html
DELETED
@@ -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
|
data/spec/dummy/script/rails
DELETED
@@ -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
|
data/spec/rate_limiter_spec.rb
DELETED
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
|