cachers 4.1.0.2 → 5.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +114 -0
- data/Rakefile +1 -3
- data/lib/cachers.rb +2 -2
- data/lib/cachers/concern.rb +3 -2
- data/lib/cachers/dsl.rb +1 -1
- data/lib/cachers/extensions/active_record/base.rb +1 -1
- data/lib/cachers/railtie.rb +0 -6
- data/lib/cachers/version.rb +1 -1
- data/lib/generators/cachers/install/install_generator.rb +1 -1
- data/{test/dummy/config → lib/generators/cachers/install/templates}/redis.yml +0 -0
- metadata +17 -114
- data/lib/generators/cachers/install/templates/configuration.yml +0 -15
- data/test/dummy/Rakefile +0 -5
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/dummy/app/cachers/user_cacher.rb +0 -24
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/models/user.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -12
- data/test/dummy/bin/bundle +0 -4
- data/test/dummy/bin/rails +0 -5
- data/test/dummy/bin/rake +0 -5
- data/test/dummy/bin/setup +0 -30
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -25
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.yml +0 -10
- data/test/dummy/config/database.yml.travis +0 -3
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -41
- data/test/dummy/config/environments/production.rb +0 -79
- data/test/dummy/config/environments/test.rb +0 -42
- data/test/dummy/config/initializers/assets.rb +0 -11
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -56
- data/test/dummy/config/secrets.yml +0 -22
- data/test/dummy/db/migrate/20160918232127_create_users.rb +0 -9
- data/test/dummy/db/schema.rb +0 -25
- data/test/dummy/log/development.log +0 -21
- data/test/dummy/log/test.log +0 -2007
- data/test/dummy/public/404.html +0 -61
- data/test/dummy/public/422.html +0 -61
- data/test/dummy/public/500.html +0 -60
- data/test/dummy/public/favicon.ico +0 -0
- data/test/generator_test.rb +0 -25
- data/test/model_test.rb +0 -27
- data/test/record_test.rb +0 -29
- data/test/task_test.rb +0 -35
- data/test/test_helper.rb +0 -20
data/test/dummy/public/404.html
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
div.dialog {
|
15
|
-
width: 95%;
|
16
|
-
max-width: 33em;
|
17
|
-
margin: 4em auto 0;
|
18
|
-
}
|
19
|
-
div.dialog > div {
|
20
|
-
border: 1px solid #CCC;
|
21
|
-
border-right-color: #999;
|
22
|
-
border-left-color: #999;
|
23
|
-
border-bottom-color: #BBB;
|
24
|
-
border-top: #B00100 solid 4px;
|
25
|
-
border-top-left-radius: 9px;
|
26
|
-
border-top-right-radius: 9px;
|
27
|
-
background-color: white;
|
28
|
-
padding: 7px 12% 0;
|
29
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
30
|
-
}
|
31
|
-
h1 {
|
32
|
-
font-size: 100%;
|
33
|
-
color: #730E15;
|
34
|
-
line-height: 1.5em;
|
35
|
-
}
|
36
|
-
div.dialog > p {
|
37
|
-
margin: 0 0 1em;
|
38
|
-
padding: 1em;
|
39
|
-
background-color: #F7F7F7;
|
40
|
-
border: 1px solid #CCC;
|
41
|
-
border-right-color: #999;
|
42
|
-
border-left-color: #999;
|
43
|
-
border-bottom-color: #999;
|
44
|
-
border-bottom-left-radius: 4px;
|
45
|
-
border-bottom-right-radius: 4px;
|
46
|
-
border-top-color: #DADADA;
|
47
|
-
color: #666;
|
48
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
49
|
-
}
|
50
|
-
</style>
|
51
|
-
</head>
|
52
|
-
<body>
|
53
|
-
<div class="dialog">
|
54
|
-
<div>
|
55
|
-
<h1>The page you were looking for doesn't exist.</h1>
|
56
|
-
<p>You may have mistyped the address or the page may have moved.</p>
|
57
|
-
</div>
|
58
|
-
<p>If you are the application owner check the logs for more information.</p>
|
59
|
-
</div>
|
60
|
-
</body>
|
61
|
-
</html>
|
data/test/dummy/public/422.html
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
div.dialog {
|
15
|
-
width: 95%;
|
16
|
-
max-width: 33em;
|
17
|
-
margin: 4em auto 0;
|
18
|
-
}
|
19
|
-
div.dialog > div {
|
20
|
-
border: 1px solid #CCC;
|
21
|
-
border-right-color: #999;
|
22
|
-
border-left-color: #999;
|
23
|
-
border-bottom-color: #BBB;
|
24
|
-
border-top: #B00100 solid 4px;
|
25
|
-
border-top-left-radius: 9px;
|
26
|
-
border-top-right-radius: 9px;
|
27
|
-
background-color: white;
|
28
|
-
padding: 7px 12% 0;
|
29
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
30
|
-
}
|
31
|
-
h1 {
|
32
|
-
font-size: 100%;
|
33
|
-
color: #730E15;
|
34
|
-
line-height: 1.5em;
|
35
|
-
}
|
36
|
-
div.dialog > p {
|
37
|
-
margin: 0 0 1em;
|
38
|
-
padding: 1em;
|
39
|
-
background-color: #F7F7F7;
|
40
|
-
border: 1px solid #CCC;
|
41
|
-
border-right-color: #999;
|
42
|
-
border-left-color: #999;
|
43
|
-
border-bottom-color: #999;
|
44
|
-
border-bottom-left-radius: 4px;
|
45
|
-
border-bottom-right-radius: 4px;
|
46
|
-
border-top-color: #DADADA;
|
47
|
-
color: #666;
|
48
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
49
|
-
}
|
50
|
-
</style>
|
51
|
-
</head>
|
52
|
-
<body>
|
53
|
-
<div class="dialog">
|
54
|
-
<div>
|
55
|
-
<h1>The change you wanted was rejected.</h1>
|
56
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
57
|
-
</div>
|
58
|
-
<p>If you are the application owner check the logs for more information.</p>
|
59
|
-
</div>
|
60
|
-
</body>
|
61
|
-
</html>
|
data/test/dummy/public/500.html
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
div.dialog {
|
15
|
-
width: 95%;
|
16
|
-
max-width: 33em;
|
17
|
-
margin: 4em auto 0;
|
18
|
-
}
|
19
|
-
div.dialog > div {
|
20
|
-
border: 1px solid #CCC;
|
21
|
-
border-right-color: #999;
|
22
|
-
border-left-color: #999;
|
23
|
-
border-bottom-color: #BBB;
|
24
|
-
border-top: #B00100 solid 4px;
|
25
|
-
border-top-left-radius: 9px;
|
26
|
-
border-top-right-radius: 9px;
|
27
|
-
background-color: white;
|
28
|
-
padding: 7px 12% 0;
|
29
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
30
|
-
}
|
31
|
-
h1 {
|
32
|
-
font-size: 100%;
|
33
|
-
color: #730E15;
|
34
|
-
line-height: 1.5em;
|
35
|
-
}
|
36
|
-
div.dialog > p {
|
37
|
-
margin: 0 0 1em;
|
38
|
-
padding: 1em;
|
39
|
-
background-color: #F7F7F7;
|
40
|
-
border: 1px solid #CCC;
|
41
|
-
border-right-color: #999;
|
42
|
-
border-left-color: #999;
|
43
|
-
border-bottom-color: #999;
|
44
|
-
border-bottom-left-radius: 4px;
|
45
|
-
border-bottom-right-radius: 4px;
|
46
|
-
border-top-color: #DADADA;
|
47
|
-
color: #666;
|
48
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
49
|
-
}
|
50
|
-
</style>
|
51
|
-
</head>
|
52
|
-
<body>
|
53
|
-
<div class="dialog">
|
54
|
-
<div>
|
55
|
-
<h1>We're sorry, but something went wrong.</h1>
|
56
|
-
</div>
|
57
|
-
<p>If you are the application owner check the logs for more information.</p>
|
58
|
-
</div>
|
59
|
-
</body>
|
60
|
-
</html>
|
File without changes
|
data/test/generator_test.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'rails/generators'
|
3
|
-
require 'generators/cachers/cacher/cacher_generator'
|
4
|
-
require 'generators/cachers/install/install_generator'
|
5
|
-
|
6
|
-
class GeneratorsTest < Rails::Generators::TestCase
|
7
|
-
destination Rails.root.join('tmp')
|
8
|
-
|
9
|
-
teardown do
|
10
|
-
FileUtils.rm_rf destination_root
|
11
|
-
end
|
12
|
-
|
13
|
-
test 'cacher' do
|
14
|
-
self.class.tests Cachers::Generators::CacherGenerator
|
15
|
-
run_generator %w(user)
|
16
|
-
assert_file 'app/cachers/user_cacher.rb'
|
17
|
-
end
|
18
|
-
|
19
|
-
test 'install' do
|
20
|
-
self.class.tests Cachers::Generators::InstallGenerator
|
21
|
-
run_generator
|
22
|
-
assert_file 'config/redis.yml'
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
data/test/model_test.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class RecordTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
test 'callbacks' do
|
6
|
-
user = User.create(name: 'mike')
|
7
|
-
user.cache
|
8
|
-
key = "users/#{user.name}"
|
9
|
-
assert_equal user.id, client.get(key).to_i
|
10
|
-
assert User.cached?(user)
|
11
|
-
|
12
|
-
user.update name: 'john'
|
13
|
-
old_key = key
|
14
|
-
key = "users/#{user.name}"
|
15
|
-
user.recache
|
16
|
-
assert_nil client.get(old_key)
|
17
|
-
assert_equal user.id, client.get(key).to_i
|
18
|
-
assert User.cached?(user)
|
19
|
-
|
20
|
-
user.destroy
|
21
|
-
user.uncache
|
22
|
-
assert_nil client.get(old_key)
|
23
|
-
assert_nil client.get(key)
|
24
|
-
assert_not User.cached?(user)
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
data/test/record_test.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ModelTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
test 'callbacks' do
|
6
|
-
user = User.create(name: 'mike')
|
7
|
-
user.cache
|
8
|
-
key = "users/#{user.name}"
|
9
|
-
assert_equal user.id, client.get(key).to_i
|
10
|
-
|
11
|
-
user.update name: 'john'
|
12
|
-
old_key = key
|
13
|
-
key = "users/#{user.name}"
|
14
|
-
user.recache
|
15
|
-
assert_nil client.get(old_key)
|
16
|
-
assert_equal user.id, client.get(key).to_i
|
17
|
-
|
18
|
-
user.destroy
|
19
|
-
user.uncache
|
20
|
-
assert_nil client.get(old_key)
|
21
|
-
assert_nil client.get(key)
|
22
|
-
assert_not User.cached?(user)
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'singleton' do
|
26
|
-
assert_not User.cached?(User.new)
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
data/test/task_test.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class TaskTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
load File.expand_path('../../lib/tasks/cachers.rake', __FILE__)
|
7
|
-
Rake::Task.define_task :environment
|
8
|
-
end
|
9
|
-
|
10
|
-
test 'all' do
|
11
|
-
users = %w(mike john).map do |name|
|
12
|
-
User.create name: name
|
13
|
-
end
|
14
|
-
silence_stream(STDOUT) do
|
15
|
-
Rake::Task['cachers:cache'].invoke
|
16
|
-
end
|
17
|
-
users.each do |user|
|
18
|
-
assert_equal user.id, client.get("users/#{user.name}").to_i
|
19
|
-
end
|
20
|
-
|
21
|
-
client.flushall
|
22
|
-
silence_stream(STDOUT) do
|
23
|
-
Rake::Task['cachers:recache'].invoke
|
24
|
-
end
|
25
|
-
users.each do |user|
|
26
|
-
assert_equal user.id, client.get("users/#{user.name}").to_i
|
27
|
-
end
|
28
|
-
|
29
|
-
silence_stream(STDOUT) do
|
30
|
-
Rake::Task['cachers:uncache'].invoke
|
31
|
-
end
|
32
|
-
assert_equal 0, client.keys.size
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# Configure Rails Environment
|
2
|
-
ENV['RAILS_ENV'] = 'test'
|
3
|
-
|
4
|
-
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
5
|
-
ActiveRecord::Migrator.migrations_paths = [File.expand_path('../dummy/db/migrate', __FILE__)]
|
6
|
-
require 'rails/test_help'
|
7
|
-
|
8
|
-
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
9
|
-
# to be shown.
|
10
|
-
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
11
|
-
|
12
|
-
# Load support files
|
13
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
14
|
-
|
15
|
-
# Add client shortcut.
|
16
|
-
class ActiveSupport::TestCase
|
17
|
-
def client
|
18
|
-
Cachers.client
|
19
|
-
end
|
20
|
-
end
|