divert 0.7 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cba1c827e07f87856cd4597bb5ec0f45b0153cd
4
- data.tar.gz: b1e023261ff5c5569d15f81b0cd6fc522e13271e
3
+ metadata.gz: 16f5b5e662bdbbb632e00019f1e86196f5120875
4
+ data.tar.gz: 5f92cbb7f07b6d07d95ff743681cc8461efae889
5
5
  SHA512:
6
- metadata.gz: 6160e4e2fda7c543bd283eec79b4130e1b88f69e751b02aa4b89cefa57cbe6da5d24fb3e98c7785b2260d60db49956ba7207eaa54822734b77438893c622fe72
7
- data.tar.gz: 7b4f77a96f4ef73b806a317d5ab19a4c2a7284cf32f3ec8212050750f0c8b8c69232e29cd29711163c1c34830a485ee172e9e79e583f130021221e3e29a696c8
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 rout added catches anything so needs to go last.
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
@@ -0,0 +1,9 @@
1
+ module Divert
2
+ class Configuration
3
+ attr_accessor :save_to_db
4
+
5
+ def initialize
6
+ @save_to_db = true
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Divert
2
- VERSION = "0.7"
2
+ VERSION = "0.8"
3
3
  end
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 request.fullpath)
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.7'
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-07-03 00:00:00.000000000 Z
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
Binary file
@@ -1,4 +0,0 @@
1
-  (1.6ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
2
-  (0.5ms) select sqlite_version(*)
3
-  (1.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
4
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
@@ -1,69 +0,0 @@
1
-  (0.1ms) begin transaction
2
- ----------------------
3
- DivertTest: test_truth
4
- ----------------------
5
-  (0.1ms) rollback transaction
6
-  (1.2ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
7
-  (0.1ms) select sqlite_version(*)
8
-  (1.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
9
-  (0.2ms) SELECT version FROM "schema_migrations"
10
-  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
11
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
12
-  (0.3ms) begin transaction
13
- ----------------------
14
- DivertTest: test_truth
15
- ----------------------
16
-  (0.1ms) rollback transaction
17
- ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
18
-  (1.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
19
-  (0.2ms) select sqlite_version(*)
20
-  (1.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
21
-  (0.2ms) SELECT version FROM "schema_migrations"
22
-  (1.2ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
23
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
24
- ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
25
-  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
26
-  (0.1ms) select sqlite_version(*)
27
-  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
28
-  (0.1ms) SELECT version FROM "schema_migrations"
29
-  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
30
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
31
-  (0.1ms) begin transaction
32
- ----------------------
33
- DivertTest: test_truth
34
- ----------------------
35
-  (0.0ms) rollback transaction
36
- ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
37
-  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
38
-  (0.1ms) select sqlite_version(*)
39
-  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
40
-  (0.2ms) SELECT version FROM "schema_migrations"
41
-  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
42
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
43
- ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
44
-  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
45
-  (0.1ms) select sqlite_version(*)
46
-  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
47
-  (0.1ms) SELECT version FROM "schema_migrations"
48
-  (1.0ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
49
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
50
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
51
-  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
52
-  (0.1ms) select sqlite_version(*)
53
-  (1.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
54
-  (0.2ms) SELECT version FROM "schema_migrations"
55
-  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
56
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
57
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
58
-  (1.3ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
59
-  (0.1ms) select sqlite_version(*)
60
-  (1.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
61
-  (0.2ms) SELECT version FROM "schema_migrations"
62
-  (1.2ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
63
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
64
- ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
65
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
66
- ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
67
- ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
68
- ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
69
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"