utopia 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/utopia/content.rb +9 -1
- data/lib/utopia/controller/base.rb +9 -0
- data/lib/utopia/controller/rewrite.rb +21 -2
- data/lib/utopia/controller.rb +10 -0
- data/lib/utopia/exception_handler.rb +9 -1
- data/lib/utopia/localization.rb +13 -1
- data/lib/utopia/redirector.rb +13 -3
- data/lib/utopia/static.rb +12 -2
- data/lib/utopia/version.rb +1 -1
- 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: e53e0a1f210f0c4e8e14ff4f7e1cf21bbc705f18
|
4
|
+
data.tar.gz: 3756ebee30e3b76f4712d7f129aecdf943d60931
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f751489f085bf36b52d6a0b842e127f56d1061d0050f1452ae9798d2deadd2fdef426c254a1ec15a7f06715ef01e56a5c78c2e5abea095f7cbd89c925d136776
|
7
|
+
data.tar.gz: 679a51d33577028c5fdc27a66498617e9b5e4f764a483a387f9b005df33c6ded2439cebb8ba6f30be0a6c9d670694407289d22681553b916816328517dfa47e3
|
data/lib/utopia/content.rb
CHANGED
@@ -42,10 +42,18 @@ module Utopia
|
|
42
42
|
end
|
43
43
|
|
44
44
|
@tags = options.fetch(:tags, {})
|
45
|
+
|
46
|
+
self.freeze
|
47
|
+
end
|
48
|
+
|
49
|
+
def freeze
|
50
|
+
@root.freeze
|
51
|
+
@tags.freeze
|
52
|
+
|
53
|
+
super
|
45
54
|
end
|
46
55
|
|
47
56
|
attr :root
|
48
|
-
attr :passthrough
|
49
57
|
|
50
58
|
def fetch_xml(path)
|
51
59
|
if @templates
|
@@ -36,6 +36,15 @@ module Utopia
|
|
36
36
|
end
|
37
37
|
|
38
38
|
class << self
|
39
|
+
def freeze
|
40
|
+
# This ensures that all class variables are frozen.
|
41
|
+
self.instance_variables.each do |name|
|
42
|
+
self.instance_variable_get(name).freeze
|
43
|
+
end
|
44
|
+
|
45
|
+
super
|
46
|
+
end
|
47
|
+
|
39
48
|
def direct?(path)
|
40
49
|
path.dirname == uri_path
|
41
50
|
end
|
@@ -35,6 +35,15 @@ module Utopia
|
|
35
35
|
def initialize(arguments, block)
|
36
36
|
@arguments = arguments
|
37
37
|
@block = block
|
38
|
+
|
39
|
+
self.freeze
|
40
|
+
end
|
41
|
+
|
42
|
+
def freeze
|
43
|
+
@arguments.freeze
|
44
|
+
@block.freeze
|
45
|
+
|
46
|
+
super
|
38
47
|
end
|
39
48
|
|
40
49
|
attr :arguments
|
@@ -48,9 +57,19 @@ module Utopia
|
|
48
57
|
end
|
49
58
|
|
50
59
|
class ExtractPrefixRule < Rule
|
51
|
-
def
|
52
|
-
@matcher
|
60
|
+
def initialize(arguments, block)
|
61
|
+
@matcher = Path::Matcher.new(arguments)
|
53
62
|
|
63
|
+
super
|
64
|
+
end
|
65
|
+
|
66
|
+
def freeze
|
67
|
+
@matcher.freeze
|
68
|
+
|
69
|
+
super
|
70
|
+
end
|
71
|
+
|
72
|
+
def apply(context, request, path)
|
54
73
|
if match_data = @matcher.match(path)
|
55
74
|
apply_match_to_context(match_data, context)
|
56
75
|
|
data/lib/utopia/controller.rb
CHANGED
@@ -57,6 +57,12 @@ module Utopia
|
|
57
57
|
|
58
58
|
attr :app
|
59
59
|
|
60
|
+
def freeze
|
61
|
+
@root.freeze
|
62
|
+
|
63
|
+
super
|
64
|
+
end
|
65
|
+
|
60
66
|
def lookup_controller(path)
|
61
67
|
if @controllers
|
62
68
|
@controllers.fetch_or_store(path.to_s) do
|
@@ -90,6 +96,10 @@ module Utopia
|
|
90
96
|
# Give the controller a useful name:
|
91
97
|
# Controllers.define(klass)
|
92
98
|
|
99
|
+
# We lock down the controller class to prevent unsafe modifications:
|
100
|
+
klass.freeze
|
101
|
+
|
102
|
+
# Create an instance of the controller:
|
93
103
|
return klass.new
|
94
104
|
else
|
95
105
|
return nil
|
data/lib/utopia/localization.rb
CHANGED
@@ -86,8 +86,20 @@ module Utopia
|
|
86
86
|
@nonlocalized = options.fetch(:nonlocalized, [])
|
87
87
|
|
88
88
|
# puts "All:#{@all_locales.inspect} defaults:#{@default_locales.inspect} default:#{default_locale}"
|
89
|
+
|
90
|
+
self.freeze
|
89
91
|
end
|
90
|
-
|
92
|
+
|
93
|
+
def freeze
|
94
|
+
@all_locale.freeze
|
95
|
+
@default_locales.freeze
|
96
|
+
@default_locale.freeze
|
97
|
+
@hosts.freeze
|
98
|
+
@nonlocalized.freeze
|
99
|
+
|
100
|
+
super
|
101
|
+
end
|
102
|
+
|
91
103
|
attr :all_locales
|
92
104
|
attr :default_locale
|
93
105
|
|
data/lib/utopia/redirector.rb
CHANGED
@@ -37,7 +37,7 @@ module Utopia
|
|
37
37
|
|
38
38
|
class Redirector
|
39
39
|
# This redirects directories to the directory + 'index'
|
40
|
-
DIRECTORY_INDEX = [/^(.*)\/$/, lambda{|prefix| [307, {HTTP::LOCATION => "#{prefix}index"}, []]}]
|
40
|
+
DIRECTORY_INDEX = [/^(.*)\/$/, lambda{|prefix| [307, {HTTP::LOCATION => "#{prefix}index"}, []]}].freeze
|
41
41
|
|
42
42
|
# Redirects a whole source tree to a destination tree, given by the roots.
|
43
43
|
def self.moved(source_root, destination_root)
|
@@ -76,9 +76,9 @@ module Utopia
|
|
76
76
|
normalized = []
|
77
77
|
|
78
78
|
patterns.each do |pattern|
|
79
|
-
uri = pattern
|
79
|
+
*keys, uri = *pattern
|
80
80
|
|
81
|
-
|
81
|
+
keys.each do |key|
|
82
82
|
normalized.push([key, uri])
|
83
83
|
end
|
84
84
|
end
|
@@ -106,6 +106,16 @@ module Utopia
|
|
106
106
|
@patterns = normalize_patterns(@patterns)
|
107
107
|
|
108
108
|
@errors = options[:errors]
|
109
|
+
|
110
|
+
self.freeze
|
111
|
+
end
|
112
|
+
|
113
|
+
def freeze
|
114
|
+
@strings.freeze
|
115
|
+
@patterns.freeze
|
116
|
+
@errors.freeze
|
117
|
+
|
118
|
+
super
|
109
119
|
end
|
110
120
|
|
111
121
|
def redirect(uri, match_data)
|
data/lib/utopia/static.rb
CHANGED
@@ -196,7 +196,7 @@ module Utopia
|
|
196
196
|
|
197
197
|
def initialize(app, **options)
|
198
198
|
@app = app
|
199
|
-
@root = options[:root] || Utopia::default_root
|
199
|
+
@root = (options[:root] || Utopia::default_root).freeze
|
200
200
|
|
201
201
|
if options[:types]
|
202
202
|
@extensions = load_mime_types(options[:types])
|
@@ -204,7 +204,17 @@ module Utopia
|
|
204
204
|
@extensions = load_mime_types(MIME_TYPES[:default])
|
205
205
|
end
|
206
206
|
|
207
|
-
@cache_control = options[:cache_control] || "public, max-age=3600"
|
207
|
+
@cache_control = (options[:cache_control] || "public, max-age=3600")
|
208
|
+
|
209
|
+
self.freeze
|
210
|
+
end
|
211
|
+
|
212
|
+
def freeze
|
213
|
+
@root.freeze
|
214
|
+
@extensions.freeze
|
215
|
+
@cache_control.freeze
|
216
|
+
|
217
|
+
super
|
208
218
|
end
|
209
219
|
|
210
220
|
def fetch_file(path)
|
data/lib/utopia/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utopia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trenni
|