katgut 0.0.3 → 0.0.4
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.md +1 -0
- data/app/models/katgut/rule.rb +8 -0
- data/lib/katgut/version.rb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +26 -0
- data/spec/dummy/log/test.log +2540 -0
- data/spec/models/katgut/rule_spec.rb +30 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e8469080830bb56b0884964cbf8b07ab6439fea
|
4
|
+
data.tar.gz: 0e77c797ec4131e6f658e93948adc3b4e2552afd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 945fe64304cdeeea0cf2b922ebadc932c589f7a4efe587254b6dc9985549abc0e95e581e3a3a937a9c014f91b0c23d55f8d8483a06958602962f437a38027b56
|
7
|
+
data.tar.gz: f78bf1a6b05833574776909cf5b600e7e53ed48b21793a2053576c08b316f630fa1a324b8efc36349c4afe27a1076d8306e3c527a1f9960bde81f682f9d1d15f
|
data/README.md
CHANGED
@@ -50,6 +50,7 @@ The redirection rules will be stored in `katgut_rules` table. A rule is a set of
|
|
50
50
|
### `source`
|
51
51
|
Set a unique key to determine which rule should be used to redirect the request.
|
52
52
|
Only word characters and hyphens\(`[^a-zA-Z0-9_\-]`) are allowed and at least 5 characters needed.
|
53
|
+
If you don't give any value for the `source` attribute, katgut generates a random value automatically.
|
53
54
|
|
54
55
|
```
|
55
56
|
/mount_point/:source
|
data/app/models/katgut/rule.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
1
3
|
module Katgut
|
2
4
|
class Rule < ActiveRecord::Base
|
3
5
|
ALLOWED_SCHEMES = [:https, :http]
|
@@ -17,6 +19,8 @@ module Katgut
|
|
17
19
|
length: { maximum: 255 }
|
18
20
|
validate :ensure_destination_has_no_unallowed_scheme
|
19
21
|
|
22
|
+
after_initialize :set_random_source, if: -> { new_record? && source.nil? }
|
23
|
+
|
20
24
|
def regular_destination
|
21
25
|
if URI.extract(destination).present?
|
22
26
|
destination
|
@@ -53,5 +57,9 @@ module Katgut
|
|
53
57
|
errors.add(:destination, "has unallowed scheme.")
|
54
58
|
end
|
55
59
|
end
|
60
|
+
|
61
|
+
def set_random_source
|
62
|
+
self.source = SecureRandom.urlsafe_base64(6)
|
63
|
+
end
|
56
64
|
end
|
57
65
|
end
|
data/lib/katgut/version.rb
CHANGED
Binary file
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -751,3 +751,29 @@ ActionController::RoutingError (No route matches [GET] "/toritsugi_success.html"
|
|
751
751
|
Rendered /Users/kazuki-hamada/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/routes/_table.html.erb (27.1ms)
|
752
752
|
Rendered /Users/kazuki-hamada/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (11.3ms)
|
753
753
|
Rendered /Users/kazuki-hamada/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout (164.8ms)
|
754
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.5ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
755
|
+
Migrating to AddRedirectionCountToRules (20160721095501)
|
756
|
+
[1m[35m (0.1ms)[0m begin transaction
|
757
|
+
[1m[36m (0.2ms)[0m [1mALTER TABLE "rules" ADD "redirection_count" integer DEFAULT 0 NOT NULL[0m
|
758
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
759
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
760
|
+
Migrating to AddRedirectionCountToKatgutRules (20160721095501)
|
761
|
+
[1m[35m (0.1ms)[0m begin transaction
|
762
|
+
[1m[36m (0.5ms)[0m [1mALTER TABLE "katgut_rules" ADD "redirection_count" integer DEFAULT 0 NOT NULL[0m
|
763
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20160721095501"]]
|
764
|
+
[1m[36m (0.6ms)[0m [1mcommit transaction[0m
|
765
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
766
|
+
[1m[36m (0.1ms)[0m [1m SELECT sql
|
767
|
+
FROM sqlite_master
|
768
|
+
WHERE name='idx_katgut_source' AND type='index'
|
769
|
+
UNION ALL
|
770
|
+
SELECT sql
|
771
|
+
FROM sqlite_temp_master
|
772
|
+
WHERE name='idx_katgut_source' AND type='index'
|
773
|
+
[0m
|
774
|
+
[1m[36mKatgut::Rule Load (0.4ms)[0m [1mSELECT "katgut_rules".* FROM "katgut_rules" ORDER BY "katgut_rules"."id" ASC LIMIT 1[0m
|
775
|
+
[1m[35mKatgut::Rule Exists (0.4ms)[0m SELECT 1 AS one FROM "katgut_rules" WHERE "katgut_rules"."source" IS NULL LIMIT 1
|
776
|
+
[1m[36mKatgut::Rule Exists (0.5ms)[0m [1mSELECT 1 AS one FROM "katgut_rules" WHERE "katgut_rules"."source" IS NULL LIMIT 1[0m
|
777
|
+
[1m[35mKatgut::Rule Exists (0.4ms)[0m SELECT 1 AS one FROM "katgut_rules" WHERE "katgut_rules"."source" IS NULL LIMIT 1
|
778
|
+
[1m[36mKatgut::Rule Exists (0.2ms)[0m [1mSELECT 1 AS one FROM "katgut_rules" WHERE "katgut_rules"."source" IS NULL LIMIT 1[0m
|
779
|
+
[1m[35mKatgut::Rule Exists (0.1ms)[0m SELECT 1 AS one FROM "katgut_rules" WHERE "katgut_rules"."source" IS NULL LIMIT 1
|