divert 0.7 → 0.8
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.
- checksums.yaml +4 -4
- data/README.rdoc +6 -1
- data/lib/divert/configuration.rb +9 -0
- data/lib/divert/version.rb +1 -1
- data/lib/divert.rb +16 -1
- metadata +3 -10
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -4
- data/test/dummy/log/test.log +0 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16f5b5e662bdbbb632e00019f1e86196f5120875
|
4
|
+
data.tar.gz: 5f92cbb7f07b6d07d95ff743681cc8461efae889
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a84c3129f19d06790c80321eca99a1dfa40cf35ec296cf120178412873205b7a78d1e22ab978724c0da88b08b68c25043b0991319092dfc28e49252e5ad01ed
|
7
|
+
data.tar.gz: 1ba5c7dd0ed80d7d388aae650b1b45431732baf6d3c85e0e5a98a0863601b1334ea657ec99f577d9477927e2b43394861365bfc207af99f3220881bca98d9f55
|
data/README.rdoc
CHANGED
@@ -12,7 +12,7 @@ Install the migrations with
|
|
12
12
|
Then add:
|
13
13
|
divert_with :controller_name
|
14
14
|
to the END of your routes file.
|
15
|
-
The
|
15
|
+
The route added catches anything so needs to go last.
|
16
16
|
|
17
17
|
Finally add:
|
18
18
|
include Divert
|
@@ -21,3 +21,8 @@ to the controller specified in the above route.
|
|
21
21
|
It will not interfere with actions defined in that controller
|
22
22
|
or view files that don't have an action defined.
|
23
23
|
Cos it's nice like that.
|
24
|
+
|
25
|
+
By default, Divert will hit the database to find or create a record. To turn off this behaviour, add this following configuration code in your `config/initializers/divert.rb` :
|
26
|
+
Divert.configure do |config|
|
27
|
+
config.save_to_db = false
|
28
|
+
end
|
data/lib/divert/version.rb
CHANGED
data/lib/divert.rb
CHANGED
@@ -1,7 +1,22 @@
|
|
1
1
|
require "divert/engine"
|
2
|
+
require "divert/configuration"
|
2
3
|
|
3
4
|
module Divert
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_accessor :configuration
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.configuration
|
11
|
+
@configuration ||= Configuration.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configure
|
15
|
+
yield(configuration)
|
16
|
+
end
|
17
|
+
|
4
18
|
def action_missing path = nil
|
19
|
+
|
5
20
|
path ||= params[:path]
|
6
21
|
if action_methods.include? path
|
7
22
|
send path and return
|
@@ -11,7 +26,7 @@ module Divert
|
|
11
26
|
render "#{controller_name}/#{path}" and return
|
12
27
|
end
|
13
28
|
|
14
|
-
if (redirect = Redirect.hit
|
29
|
+
if Divert.configuration.save_to_db && (redirect = Redirect.hit(request.fullpath))
|
15
30
|
redirect_to redirect
|
16
31
|
else
|
17
32
|
unless template_exists? 'divert', [controller_name]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: divert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.8'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Butler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- app/models/divert/redirect.rb
|
53
53
|
- db/migrate/20130311224617_create_divert_redirects.rb
|
54
54
|
- lib/divert.rb
|
55
|
+
- lib/divert/configuration.rb
|
55
56
|
- lib/divert/engine.rb
|
56
57
|
- lib/divert/version.rb
|
57
58
|
- test/divert_test.rb
|
@@ -78,10 +79,6 @@ files:
|
|
78
79
|
- test/dummy/config/initializers/wrap_parameters.rb
|
79
80
|
- test/dummy/config/locales/en.yml
|
80
81
|
- test/dummy/config/routes.rb
|
81
|
-
- test/dummy/db/development.sqlite3
|
82
|
-
- test/dummy/db/test.sqlite3
|
83
|
-
- test/dummy/log/development.log
|
84
|
-
- test/dummy/log/test.log
|
85
82
|
- test/dummy/public/404.html
|
86
83
|
- test/dummy/public/422.html
|
87
84
|
- test/dummy/public/500.html
|
@@ -139,10 +136,6 @@ test_files:
|
|
139
136
|
- test/dummy/config/locales/en.yml
|
140
137
|
- test/dummy/config/routes.rb
|
141
138
|
- test/dummy/config.ru
|
142
|
-
- test/dummy/db/development.sqlite3
|
143
|
-
- test/dummy/db/test.sqlite3
|
144
|
-
- test/dummy/log/development.log
|
145
|
-
- test/dummy/log/test.log
|
146
139
|
- test/dummy/public/404.html
|
147
140
|
- test/dummy/public/422.html
|
148
141
|
- test/dummy/public/500.html
|
Binary file
|
data/test/dummy/db/test.sqlite3
DELETED
Binary file
|
@@ -1,4 +0,0 @@
|
|
1
|
-
[1m[36m (1.6ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
2
|
-
[1m[35m (0.5ms)[0m select sqlite_version(*)
|
3
|
-
[1m[36m (1.7ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
4
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
data/test/dummy/log/test.log
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
2
|
-
----------------------
|
3
|
-
DivertTest: test_truth
|
4
|
-
----------------------
|
5
|
-
[1m[35m (0.1ms)[0m rollback transaction
|
6
|
-
[1m[36m (1.2ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
7
|
-
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
8
|
-
[1m[36m (1.4ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
9
|
-
[1m[35m (0.2ms)[0m SELECT version FROM "schema_migrations"
|
10
|
-
[1m[36m (1.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
11
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
12
|
-
[1m[35m (0.3ms)[0m begin transaction
|
13
|
-
----------------------
|
14
|
-
DivertTest: test_truth
|
15
|
-
----------------------
|
16
|
-
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
17
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.4ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
18
|
-
[1m[36m (1.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
19
|
-
[1m[35m (0.2ms)[0m select sqlite_version(*)
|
20
|
-
[1m[36m (1.2ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
21
|
-
[1m[35m (0.2ms)[0m SELECT version FROM "schema_migrations"
|
22
|
-
[1m[36m (1.2ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
23
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
24
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.5ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
25
|
-
[1m[36m (1.0ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
26
|
-
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
27
|
-
[1m[36m (0.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
28
|
-
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
29
|
-
[1m[36m (0.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
30
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
31
|
-
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
32
|
-
----------------------
|
33
|
-
DivertTest: test_truth
|
34
|
-
----------------------
|
35
|
-
[1m[35m (0.0ms)[0m rollback transaction
|
36
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.6ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
37
|
-
[1m[36m (1.0ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
38
|
-
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
39
|
-
[1m[36m (0.9ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
40
|
-
[1m[35m (0.2ms)[0m SELECT version FROM "schema_migrations"
|
41
|
-
[1m[36m (0.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
42
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
43
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.6ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
44
|
-
[1m[36m (1.1ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
45
|
-
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
46
|
-
[1m[36m (1.0ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
47
|
-
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
48
|
-
[1m[36m (1.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
49
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
50
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
51
|
-
[1m[36m (1.1ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
52
|
-
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
53
|
-
[1m[36m (1.3ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
54
|
-
[1m[35m (0.2ms)[0m SELECT version FROM "schema_migrations"
|
55
|
-
[1m[36m (0.9ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
56
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
57
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
58
|
-
[1m[36m (1.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
59
|
-
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
60
|
-
[1m[36m (1.3ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
61
|
-
[1m[35m (0.2ms)[0m SELECT version FROM "schema_migrations"
|
62
|
-
[1m[36m (1.2ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('0')[0m
|
63
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
64
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.5ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
65
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
66
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.6ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
67
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.2ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
68
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.6ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
69
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|