actionview 5.0.0.beta1 → 5.0.0.beta1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionview might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a5d4fbdf7e7d54e2c400d21f35654616b57d37e
4
- data.tar.gz: aad959776d43d98e48262abf657a4af7bc94c342
3
+ metadata.gz: 76116781d2e7e87d011ef7bc50aa9e16c821c21d
4
+ data.tar.gz: 8a5378c1c8a1163f2937642492144c5777030332
5
5
  SHA512:
6
- metadata.gz: 8d99f3c252cc0440ffe527237ef527adaf85c2c48d56614b686ae4954eed201eb1ff736f35cf1486ed5dc0b13737c6567b1fa353adf785ef186e3a8ed090e5a0
7
- data.tar.gz: 56a74dc0bd588a9ff6a5fd2899f509396d4e22fdf4d2b673fcd253b76cf177e1148834f1440d26a7df5d7799ee564f335fe76c50a2f46191dbceb1fb0c633e07
6
+ metadata.gz: 1cf10241b15afb78e1d3326d10f632dd8e9a3adc1ccd1ad34d54cc1128cd2604c00537fb1d039e54aa966cbe9ce6e34c66d90a3a5a2bb82b709f5ea8debb6914
7
+ data.tar.gz: dc548becb90858c6a682b0d66c2f1acabe7fa2dd0db55fd08fbc6f30617c9f0898211c449b4845093632fcfc2cdff7ffde22df1a853128b2c5182d06befb2404
@@ -8,7 +8,7 @@ module ActionView
8
8
  MAJOR = 5
9
9
  MINOR = 0
10
10
  TINY = 0
11
- PRE = "beta1"
11
+ PRE = "beta1.1"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -123,6 +123,10 @@ module ActionView
123
123
  end
124
124
  alias :find_template :find
125
125
 
126
+ def find_file(name, prefixes = [], partial = false, keys = [], options = {})
127
+ @view_paths.find_file(*args_for_lookup(name, prefixes, partial, keys, options))
128
+ end
129
+
126
130
  def find_all(name, prefixes = [], partial = false, keys = [], options = {})
127
131
  @view_paths.find_all(*args_for_lookup(name, prefixes, partial, keys, options))
128
132
  end
@@ -46,15 +46,12 @@ module ActionView #:nodoc:
46
46
  find_all(*args).first || raise(MissingTemplate.new(self, *args))
47
47
  end
48
48
 
49
+ def find_file(path, prefixes = [], *args)
50
+ _find_all(path, prefixes, args, true).first || raise(MissingTemplate.new(self, path, prefixes, *args))
51
+ end
52
+
49
53
  def find_all(path, prefixes = [], *args)
50
- prefixes = [prefixes] if String === prefixes
51
- prefixes.each do |prefix|
52
- paths.each do |resolver|
53
- templates = resolver.find_all(path, prefix, *args)
54
- return templates unless templates.empty?
55
- end
56
- end
57
- []
54
+ _find_all path, prefixes, args, false
58
55
  end
59
56
 
60
57
  def exists?(path, prefixes, *args)
@@ -72,6 +69,21 @@ module ActionView #:nodoc:
72
69
 
73
70
  private
74
71
 
72
+ def _find_all(path, prefixes, args, outside_app)
73
+ prefixes = [prefixes] if String === prefixes
74
+ prefixes.each do |prefix|
75
+ paths.each do |resolver|
76
+ if outside_app
77
+ templates = resolver.find_all_anywhere(path, prefix, *args)
78
+ else
79
+ templates = resolver.find_all(path, prefix, *args)
80
+ end
81
+ return templates unless templates.empty?
82
+ end
83
+ end
84
+ []
85
+ end
86
+
75
87
  def typecast(paths)
76
88
  paths.map do |path|
77
89
  case path
@@ -15,7 +15,7 @@ module ActionView
15
15
  # that new object is called in turn. This abstracts the setup and rendering
16
16
  # into a separate classes for partials and templates.
17
17
  class AbstractRenderer #:nodoc:
18
- delegate :find_template, :template_exists?, :with_fallbacks, :with_layout_format, :formats, :to => :@lookup_context
18
+ delegate :find_template, :find_file, :template_exists?, :with_fallbacks, :with_layout_format, :formats, :to => :@lookup_context
19
19
 
20
20
  def initialize(lookup_context)
21
21
  @lookup_context = lookup_context
@@ -29,7 +29,7 @@ module ActionView
29
29
  elsif options.key?(:html)
30
30
  Template::HTML.new(options[:html], formats.first)
31
31
  elsif options.key?(:file)
32
- with_fallbacks { find_template(options[:file], nil, false, keys, @details) }
32
+ with_fallbacks { find_file(options[:file], nil, false, keys, @details) }
33
33
  elsif options.key?(:inline)
34
34
  handler = Template.handler_for_extension(options[:type] || "erb")
35
35
  Template.new(options[:inline], "inline template", handler, :locals => keys)
@@ -126,6 +126,12 @@ module ActionView
126
126
  end
127
127
  end
128
128
 
129
+ def find_all_anywhere(name, prefix, partial=false, details={}, key=nil, locals=[])
130
+ cached(key, [name, prefix, partial], details, locals) do
131
+ find_templates(name, prefix, partial, details, true)
132
+ end
133
+ end
134
+
129
135
  def find_all_with_query(query) # :nodoc:
130
136
  @cache.cache_query(query) { find_template_paths(File.join(@path, query)) }
131
137
  end
@@ -187,15 +193,16 @@ module ActionView
187
193
 
188
194
  private
189
195
 
190
- def find_templates(name, prefix, partial, details)
196
+ def find_templates(name, prefix, partial, details, outside_app_allowed = false)
191
197
  path = Path.build(name, prefix, partial)
192
- query(path, details, details[:formats])
198
+ query(path, details, details[:formats], outside_app_allowed)
193
199
  end
194
200
 
195
- def query(path, details, formats)
201
+ def query(path, details, formats, outside_app_allowed)
196
202
  query = build_query(path, details)
197
203
 
198
204
  template_paths = find_template_paths(query)
205
+ template_paths = reject_files_external_to_app(template_paths) unless outside_app_allowed
199
206
 
200
207
  template_paths.map do |template|
201
208
  handler, format, variant = extract_handler_and_format_and_variant(template, formats)
@@ -210,6 +217,10 @@ module ActionView
210
217
  end
211
218
  end
212
219
 
220
+ def reject_files_external_to_app(files)
221
+ files.reject { |filename| !inside_path?(@path, filename) }
222
+ end
223
+
213
224
  def find_template_paths(query)
214
225
  Dir[query].reject do |filename|
215
226
  File.directory?(filename) ||
@@ -218,6 +229,12 @@ module ActionView
218
229
  end
219
230
  end
220
231
 
232
+ def inside_path?(path, filename)
233
+ filename = File.expand_path(filename)
234
+ path = File.join(path, '')
235
+ filename.start_with?(path)
236
+ end
237
+
221
238
  # Helper for building query glob string based on resolver's pattern.
222
239
  def build_query(path, details)
223
240
  query = @pattern.dup
@@ -19,7 +19,7 @@ module ActionView #:nodoc:
19
19
 
20
20
  private
21
21
 
22
- def query(path, exts, formats)
22
+ def query(path, exts, formats, _)
23
23
  query = ""
24
24
  EXTENSIONS.each_key do |ext|
25
25
  query << '(' << exts[ext].map {|e| e && Regexp.escape(".#{e}") }.join('|') << '|)'
@@ -44,7 +44,7 @@ module ActionView #:nodoc:
44
44
  end
45
45
 
46
46
  class NullResolver < PathResolver
47
- def query(path, exts, formats)
47
+ def query(path, exts, formats, _)
48
48
  handler, format, variant = extract_handler_and_format_and_variant(path, formats)
49
49
  [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, :virtual_path => path.virtual, :format => format, :variant => variant)]
50
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionview
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.beta1
4
+ version: 5.0.0.beta1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-18 00:00:00.000000000 Z
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.0.beta1
19
+ version: 5.0.0.beta1.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.0.0.beta1
26
+ version: 5.0.0.beta1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -98,28 +98,28 @@ dependencies:
98
98
  requirements:
99
99
  - - '='
100
100
  - !ruby/object:Gem::Version
101
- version: 5.0.0.beta1
101
+ version: 5.0.0.beta1.1
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - '='
107
107
  - !ruby/object:Gem::Version
108
- version: 5.0.0.beta1
108
+ version: 5.0.0.beta1.1
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: activemodel
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - '='
114
114
  - !ruby/object:Gem::Version
115
- version: 5.0.0.beta1
115
+ version: 5.0.0.beta1.1
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - '='
121
121
  - !ruby/object:Gem::Version
122
- version: 5.0.0.beta1
122
+ version: 5.0.0.beta1.1
123
123
  description: Simple, battle-tested conventions and helpers for building web pages.
124
124
  email: david@loudthinking.com
125
125
  executables: []
@@ -254,4 +254,3 @@ signing_key:
254
254
  specification_version: 4
255
255
  summary: Rendering framework putting the V in MVC (part of Rails).
256
256
  test_files: []
257
- has_rdoc: