cachers 0.1.1 → 4.0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,67 +1,61 @@
1
1
  <!DOCTYPE html>
2
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
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/404.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The page you were looking for doesn't exist.</h1>
62
- <p>You may have mistyped the address or the page may have moved.</p>
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>
63
59
  </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
60
+ </body>
67
61
  </html>
@@ -1,67 +1,61 @@
1
1
  <!DOCTYPE html>
2
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
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/422.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The change you wanted was rejected.</h1>
62
- <p>Maybe you tried to change something you didn't have access to.</p>
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>
63
59
  </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
60
+ </body>
67
61
  </html>
@@ -1,66 +1,60 @@
1
1
  <!DOCTYPE html>
2
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
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/500.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>We're sorry, but something went wrong.</h1>
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>
62
58
  </div>
63
- <p>If you are the application owner check the logs for more information.</p>
64
- </div>
65
- </body>
59
+ </body>
66
60
  </html>
@@ -1,17 +1,16 @@
1
1
  require 'test_helper'
2
2
  require 'rails/generators'
3
- require 'generators/cachers/cacher_generator'
3
+ require 'generators/cacher/cacher_generator'
4
4
 
5
5
  class GeneratorsTest < Rails::Generators::TestCase
6
-
7
- tests Cachers::Generators::CacherGenerator
8
6
  destination Rails.root.join('tmp')
9
7
 
10
8
  teardown do
11
9
  FileUtils.rm_rf destination_root
12
10
  end
13
11
 
14
- test 'file generation' do
12
+ test 'cacher' do
13
+ self.class.tests Cachers::Generators::CacherGenerator
15
14
  run_generator %w(user)
16
15
  assert_file 'app/cachers/user_cacher.rb'
17
16
  end
data/test/record_test.rb CHANGED
@@ -2,19 +2,22 @@ require 'test_helper'
2
2
 
3
3
  class RecordTest < ActiveSupport::TestCase
4
4
 
5
- # NOTE: Callbacks not called in tests until rails 5
6
5
  test 'callbacks' do
7
6
  user = User.create(name: 'mike')
8
7
  user.cache
9
- key = "users/#{user.id}"
10
- assert_equal 'mike', $redis.get(key)
8
+ key = "users/#{user.name}"
9
+ assert_equal user.id, $redis.get(key).to_i
11
10
 
12
11
  user.update name: 'john'
12
+ old_key = key
13
+ key = "users/#{user.name}"
13
14
  user.recache
14
- assert_equal 'john', $redis.get(key)
15
+ assert_nil $redis.get(old_key)
16
+ assert_equal user.id, $redis.get(key).to_i
15
17
 
16
18
  user.destroy
17
19
  user.uncache
20
+ assert_nil $redis.get(old_key)
18
21
  assert_nil $redis.get(key)
19
22
  end
20
23
 
data/test/task_test.rb ADDED
@@ -0,0 +1,35 @@
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, $redis.get("users/#{user.name}").to_i
19
+ end
20
+
21
+ $redis.flushall
22
+ silence_stream(STDOUT) do
23
+ Rake::Task['cachers:recache'].invoke
24
+ end
25
+ users.each do |user|
26
+ assert_equal user.id, $redis.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, $redis.keys.size
33
+ end
34
+
35
+ end
data/test/test_helper.rb CHANGED
@@ -11,10 +11,3 @@ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
11
11
 
12
12
  # Load support files
13
13
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
14
-
15
- # Clear redis database
16
- class ActiveSupport::TestCase
17
- def teardown
18
- $redis.flushall
19
- end
20
- end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cachers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 4.0.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmontossi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-17 00:00:00.000000000 Z
11
+ date: 2016-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -58,9 +58,9 @@ dependencies:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '3.2'
61
- description: Extracts models cache logic into separate classes in rails.
61
+ description: Dedicated classes to abstract cache logic in rails.
62
62
  email:
63
- - mmontossi@buyin.io
63
+ - mmontossi@gmail.com
64
64
  executables: []
65
65
  extensions: []
66
66
  extra_rdoc_files: []
@@ -72,8 +72,8 @@ files:
72
72
  - lib/cachers/concern.rb
73
73
  - lib/cachers/railtie.rb
74
74
  - lib/cachers/version.rb
75
- - lib/generators/cachers/cacher_generator.rb
76
- - lib/generators/cachers/templates/cacher.rb
75
+ - lib/generators/cacher/cacher_generator.rb
76
+ - lib/generators/cacher/templates/cacher.rb
77
77
  - lib/tasks/cachers.rake
78
78
  - test/dummy/Rakefile
79
79
  - test/dummy/app/assets/javascripts/application.js
@@ -109,8 +109,6 @@ files:
109
109
  - test/dummy/config/routes.rb
110
110
  - test/dummy/config/secrets.yml
111
111
  - test/dummy/db/migrate/20160918232127_create_users.rb
112
- - test/dummy/db/schema.rb
113
- - test/dummy/log/development.log
114
112
  - test/dummy/log/test.log
115
113
  - test/dummy/public/404.html
116
114
  - test/dummy/public/422.html
@@ -118,7 +116,7 @@ files:
118
116
  - test/dummy/public/favicon.ico
119
117
  - test/generator_test.rb
120
118
  - test/record_test.rb
121
- - test/tasks_test.rb
119
+ - test/task_test.rb
122
120
  - test/test_helper.rb
123
121
  homepage: https://github.com/mmontossi/cachers
124
122
  licenses:
@@ -178,8 +176,6 @@ test_files:
178
176
  - test/dummy/config/secrets.yml
179
177
  - test/dummy/config.ru
180
178
  - test/dummy/db/migrate/20160918232127_create_users.rb
181
- - test/dummy/db/schema.rb
182
- - test/dummy/log/development.log
183
179
  - test/dummy/log/test.log
184
180
  - test/dummy/public/404.html
185
181
  - test/dummy/public/422.html
@@ -188,5 +184,5 @@ test_files:
188
184
  - test/dummy/Rakefile
189
185
  - test/generator_test.rb
190
186
  - test/record_test.rb
191
- - test/tasks_test.rb
187
+ - test/task_test.rb
192
188
  - test/test_helper.rb
@@ -1,25 +0,0 @@
1
- # encoding: UTF-8
2
- # This file is auto-generated from the current state of the database. Instead
3
- # of editing this file, please use the migrations feature of Active Record to
4
- # incrementally modify your database, and then regenerate this schema definition.
5
- #
6
- # Note that this schema.rb definition is the authoritative source for your
7
- # database schema. If you need to create the application database on another
8
- # system, you should be using db:schema:load, not running all the migrations
9
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
- # you'll amass, the slower it'll run and the greater likelihood for issues).
11
- #
12
- # It's strongly recommended that you check this file into your version control system.
13
-
14
- ActiveRecord::Schema.define(version: 20160918232127) do
15
-
16
- # These are extensions that must be enabled in order to support this database
17
- enable_extension "plpgsql"
18
-
19
- create_table "users", force: :cascade do |t|
20
- t.string "name"
21
- t.datetime "created_at", null: false
22
- t.datetime "updated_at", null: false
23
- end
24
-
25
- end
@@ -1,35 +0,0 @@
1
-  (19.9ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
2
-  (4.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
4
- Migrating to CreateUsers (20160918232127)
5
-  (0.2ms) BEGIN
6
-  (14.2ms) CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
7
- SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20160918232127"]]
8
-  (6.4ms) COMMIT
9
- ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
10
-  (3.3ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
11
- FROM pg_constraint c
12
- JOIN pg_class t1 ON c.conrelid = t1.oid
13
- JOIN pg_class t2 ON c.confrelid = t2.oid
14
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
15
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
16
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
17
- WHERE c.contype = 'f'
18
- AND t1.relname = 'users'
19
- AND t3.nspname = ANY (current_schemas(false))
20
- ORDER BY c.conname
21
- 
22
- ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
23
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
24
-  (3.2ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
25
- FROM pg_constraint c
26
- JOIN pg_class t1 ON c.conrelid = t1.oid
27
- JOIN pg_class t2 ON c.confrelid = t2.oid
28
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
29
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
30
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
31
- WHERE c.contype = 'f'
32
- AND t1.relname = 'users'
33
- AND t3.nspname = ANY (current_schemas(false))
34
- ORDER BY c.conname
35
- 
data/test/tasks_test.rb DELETED
@@ -1,29 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TasksTest < 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 'tasks' do
11
- users = %w(mike john).map do |name|
12
- User.create name: name
13
- end
14
- Rake::Task['cachers:cache'].invoke
15
- users.each do |user|
16
- assert_equal user.name, $redis.get("users/#{user.id}")
17
- end
18
-
19
- $redis.flushall
20
- Rake::Task['cachers:recache'].invoke
21
- users.each do |user|
22
- assert_equal user.name, $redis.get("users/#{user.id}")
23
- end
24
-
25
- Rake::Task['cachers:uncache'].invoke
26
- assert_equal 0, $redis.keys.size
27
- end
28
-
29
- end