actionview 5.0.7.2 → 5.1.0.beta1
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 +5 -5
- data/CHANGELOG.md +92 -384
- data/MIT-LICENSE +1 -1
- data/README.rdoc +1 -1
- data/lib/action_view.rb +5 -5
- data/lib/action_view/base.rb +19 -19
- data/lib/action_view/buffers.rb +1 -1
- data/lib/action_view/context.rb +1 -1
- data/lib/action_view/dependency_tracker.rb +4 -5
- data/lib/action_view/digestor.rb +6 -7
- data/lib/action_view/flows.rb +5 -6
- data/lib/action_view/gem_version.rb +3 -3
- data/lib/action_view/helpers.rb +1 -1
- data/lib/action_view/helpers/active_model_helper.rb +8 -8
- data/lib/action_view/helpers/asset_tag_helper.rb +62 -36
- data/lib/action_view/helpers/asset_url_helper.rb +111 -49
- data/lib/action_view/helpers/atom_feed_helper.rb +12 -13
- data/lib/action_view/helpers/cache_helper.rb +34 -20
- data/lib/action_view/helpers/capture_helper.rb +2 -2
- data/lib/action_view/helpers/controller_helper.rb +3 -11
- data/lib/action_view/helpers/csrf_helper.rb +3 -3
- data/lib/action_view/helpers/date_helper.rb +109 -107
- data/lib/action_view/helpers/debug_helper.rb +2 -3
- data/lib/action_view/helpers/form_helper.rb +406 -31
- data/lib/action_view/helpers/form_options_helper.rb +12 -12
- data/lib/action_view/helpers/form_tag_helper.rb +19 -18
- data/lib/action_view/helpers/javascript_helper.rb +6 -6
- data/lib/action_view/helpers/number_helper.rb +48 -46
- data/lib/action_view/helpers/output_safety_helper.rb +8 -8
- data/lib/action_view/helpers/rendering_helper.rb +2 -2
- data/lib/action_view/helpers/sanitize_helper.rb +6 -8
- data/lib/action_view/helpers/tag_helper.rb +194 -77
- data/lib/action_view/helpers/tags/base.rb +121 -102
- data/lib/action_view/helpers/tags/check_box.rb +17 -17
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +8 -8
- data/lib/action_view/helpers/tags/collection_helpers.rb +60 -60
- data/lib/action_view/helpers/tags/collection_radio_buttons.rb +2 -2
- data/lib/action_view/helpers/tags/collection_select.rb +2 -2
- data/lib/action_view/helpers/tags/date_select.rb +36 -36
- data/lib/action_view/helpers/tags/grouped_collection_select.rb +2 -2
- data/lib/action_view/helpers/tags/label.rb +4 -0
- data/lib/action_view/helpers/tags/password_field.rb +1 -1
- data/lib/action_view/helpers/tags/radio_button.rb +4 -4
- data/lib/action_view/helpers/tags/select.rb +9 -9
- data/lib/action_view/helpers/tags/text_area.rb +1 -1
- data/lib/action_view/helpers/tags/text_field.rb +5 -5
- data/lib/action_view/helpers/tags/translator.rb +14 -12
- data/lib/action_view/helpers/text_helper.rb +20 -19
- data/lib/action_view/helpers/translation_helper.rb +6 -6
- data/lib/action_view/helpers/url_helper.rb +42 -38
- data/lib/action_view/layouts.rb +51 -47
- data/lib/action_view/log_subscriber.rb +24 -9
- data/lib/action_view/lookup_context.rb +19 -25
- data/lib/action_view/path_set.rb +19 -19
- data/lib/action_view/railtie.rb +3 -3
- data/lib/action_view/record_identifier.rb +6 -6
- data/lib/action_view/renderer/abstract_renderer.rb +17 -17
- data/lib/action_view/renderer/partial_renderer.rb +188 -187
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +7 -1
- data/lib/action_view/renderer/streaming_template_renderer.rb +45 -47
- data/lib/action_view/renderer/template_renderer.rb +64 -66
- data/lib/action_view/rendering.rb +4 -5
- data/lib/action_view/routing_url_for.rb +9 -13
- data/lib/action_view/tasks/cache_digests.rake +7 -7
- data/lib/action_view/template.rb +26 -27
- data/lib/action_view/template/error.rb +5 -15
- data/lib/action_view/template/handlers.rb +4 -4
- data/lib/action_view/template/handlers/builder.rb +7 -7
- data/lib/action_view/template/handlers/erb.rb +9 -76
- data/lib/action_view/template/handlers/erb/deprecated_erubis.rb +9 -0
- data/lib/action_view/template/handlers/erb/erubi.rb +81 -0
- data/lib/action_view/template/handlers/erb/erubis.rb +81 -0
- data/lib/action_view/template/html.rb +2 -4
- data/lib/action_view/template/resolver.rb +107 -90
- data/lib/action_view/template/text.rb +5 -8
- data/lib/action_view/template/types.rb +1 -1
- data/lib/action_view/test_case.rb +20 -21
- data/lib/action_view/testing/resolvers.rb +29 -30
- data/lib/action_view/version.rb +1 -1
- data/lib/action_view/view_paths.rb +20 -8
- data/lib/assets/compiled/rails-ujs.js +648 -0
- metadata +19 -14
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "active_support/core_ext/module"
|
2
|
+
require "action_view/model_naming"
|
3
3
|
|
4
4
|
module ActionView
|
5
5
|
# RecordIdentifier encapsulates methods used by various ActionView helpers
|
@@ -57,8 +57,8 @@ module ActionView
|
|
57
57
|
|
58
58
|
include ModelNaming
|
59
59
|
|
60
|
-
JOIN =
|
61
|
-
NEW =
|
60
|
+
JOIN = "_".freeze
|
61
|
+
NEW = "new".freeze
|
62
62
|
|
63
63
|
# The DOM class convention is to use the singular form of an object or class.
|
64
64
|
#
|
@@ -92,7 +92,7 @@ module ActionView
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
|
95
|
+
private
|
96
96
|
|
97
97
|
# Returns a string representation of the key attribute(s) that is suitable for use in an HTML DOM id.
|
98
98
|
# This can be overwritten to customize the default generated string representation if desired.
|
@@ -102,7 +102,7 @@ module ActionView
|
|
102
102
|
# overwritten version of the method. By default, this implementation passes the key string through a
|
103
103
|
# method that replaces all characters that are invalid inside DOM ids, with valid ones. You need to
|
104
104
|
# make sure yourself that your dom ids are valid, in case you overwrite this method.
|
105
|
-
def record_key_for_dom_id(record)
|
105
|
+
def record_key_for_dom_id(record) # :doc:
|
106
106
|
key = convert_to_model(record).to_key
|
107
107
|
key ? key.join(JOIN) : key
|
108
108
|
end
|
@@ -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, :find_file, :template_exists?, :any_templates?, :with_fallbacks, :with_layout_format, :formats, :
|
18
|
+
delegate :find_template, :find_file, :template_exists?, :any_templates?, :with_fallbacks, :with_layout_format, :formats, to: :@lookup_context
|
19
19
|
|
20
20
|
def initialize(lookup_context)
|
21
21
|
@lookup_context = lookup_context
|
@@ -25,29 +25,29 @@ module ActionView
|
|
25
25
|
raise NotImplementedError
|
26
26
|
end
|
27
27
|
|
28
|
-
|
28
|
+
private
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
def extract_details(options) # :doc:
|
31
|
+
@lookup_context.registered_details.each_with_object({}) do |key, details|
|
32
|
+
value = options[key]
|
33
33
|
|
34
|
-
|
34
|
+
details[key] = Array(value) if value
|
35
|
+
end
|
35
36
|
end
|
36
|
-
end
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
def instrument(name, **options) # :doc:
|
39
|
+
options[:identifier] ||= (@template && @template.identifier) || @path
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
ActiveSupport::Notifications.instrument("render_#{name}.action_view", options) do |payload|
|
42
|
+
yield payload
|
43
|
+
end
|
43
44
|
end
|
44
|
-
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
def prepend_formats(formats) # :doc:
|
47
|
+
formats = Array(formats)
|
48
|
+
return if formats.empty? || @lookup_context.html_fallback_for_js
|
49
49
|
|
50
|
-
|
51
|
-
|
50
|
+
@lookup_context.formats = formats | @lookup_context.formats
|
51
|
+
end
|
52
52
|
end
|
53
53
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "concurrent/map"
|
2
|
+
require "action_view/renderer/partial_renderer/collection_caching"
|
3
3
|
|
4
4
|
module ActionView
|
5
5
|
class PartialIteration
|
@@ -98,8 +98,8 @@ module ActionView
|
|
98
98
|
#
|
99
99
|
# <%= render partial: "ad", collection: @advertisements, spacer_template: "ad_divider" %>
|
100
100
|
#
|
101
|
-
# If the given <tt>:collection</tt> is nil or empty, <tt>render</tt> will return nil. This will allow you
|
102
|
-
# to specify a text which will displayed instead by using this form:
|
101
|
+
# If the given <tt>:collection</tt> is +nil+ or empty, <tt>render</tt> will return nil. This will allow you
|
102
|
+
# to specify a text which will be displayed instead by using this form:
|
103
103
|
#
|
104
104
|
# <%= render(partial: "ad", collection: @advertisements) || "There's no ad to be displayed" %>
|
105
105
|
#
|
@@ -307,243 +307,244 @@ module ActionView
|
|
307
307
|
if @collection
|
308
308
|
render_collection
|
309
309
|
else
|
310
|
-
|
311
|
-
render_partial
|
312
|
-
end
|
310
|
+
render_partial
|
313
311
|
end
|
314
312
|
end
|
315
313
|
|
316
314
|
private
|
317
315
|
|
318
|
-
|
319
|
-
|
320
|
-
|
316
|
+
def render_collection
|
317
|
+
instrument(:collection, count: @collection.size) do |payload|
|
318
|
+
return nil if @collection.blank?
|
321
319
|
|
322
|
-
|
323
|
-
|
324
|
-
|
320
|
+
if @options.key?(:spacer_template)
|
321
|
+
spacer = find_template(@options[:spacer_template], @locals.keys).render(@view, @locals)
|
322
|
+
end
|
325
323
|
|
326
|
-
|
327
|
-
|
328
|
-
|
324
|
+
cache_collection_render(payload) do
|
325
|
+
@template ? collection_with_template : collection_without_template
|
326
|
+
end.join(spacer).html_safe
|
327
|
+
end
|
329
328
|
end
|
330
|
-
end
|
331
329
|
|
332
|
-
|
333
|
-
|
334
|
-
|
330
|
+
def render_partial
|
331
|
+
instrument(:partial) do |payload|
|
332
|
+
view, locals, block = @view, @locals, @block
|
333
|
+
object, as = @object, @variable
|
335
334
|
|
336
|
-
|
337
|
-
|
338
|
-
|
335
|
+
if !block && (layout = @options[:layout])
|
336
|
+
layout = find_template(layout.to_s, @template_keys)
|
337
|
+
end
|
338
|
+
|
339
|
+
object = locals[as] if object.nil? # Respect object when object is false
|
340
|
+
locals[as] = object if @has_object
|
339
341
|
|
340
|
-
|
341
|
-
|
342
|
+
content = @template.render(view, locals) do |*name|
|
343
|
+
view._layout_for(*name, &block)
|
344
|
+
end
|
342
345
|
|
343
|
-
|
344
|
-
|
346
|
+
content = layout.render(view, locals) { content } if layout
|
347
|
+
payload[:cache_hit] = view.cache_hit
|
348
|
+
content
|
349
|
+
end
|
345
350
|
end
|
346
351
|
|
347
|
-
|
348
|
-
|
349
|
-
|
352
|
+
# Sets up instance variables needed for rendering a partial. This method
|
353
|
+
# finds the options and details and extracts them. The method also contains
|
354
|
+
# logic that handles the type of object passed in as the partial.
|
355
|
+
#
|
356
|
+
# If +options[:partial]+ is a string, then the +@path+ instance variable is
|
357
|
+
# set to that string. Otherwise, the +options[:partial]+ object must
|
358
|
+
# respond to +to_partial_path+ in order to setup the path.
|
359
|
+
def setup(context, options, block)
|
360
|
+
@view = context
|
361
|
+
@options = options
|
362
|
+
@block = block
|
363
|
+
|
364
|
+
@locals = options[:locals] || {}
|
365
|
+
@details = extract_details(options)
|
366
|
+
|
367
|
+
prepend_formats(options[:formats])
|
368
|
+
|
369
|
+
partial = options[:partial]
|
370
|
+
|
371
|
+
if String === partial
|
372
|
+
@has_object = options.key?(:object)
|
373
|
+
@object = options[:object]
|
374
|
+
@collection = collection_from_options
|
375
|
+
@path = partial
|
376
|
+
else
|
377
|
+
@has_object = true
|
378
|
+
@object = partial
|
379
|
+
@collection = collection_from_object || collection_from_options
|
380
|
+
|
381
|
+
if @collection
|
382
|
+
paths = @collection_data = @collection.map { |o| partial_path(o) }
|
383
|
+
@path = paths.uniq.one? ? paths.first : nil
|
384
|
+
else
|
385
|
+
@path = partial_path
|
386
|
+
end
|
387
|
+
end
|
350
388
|
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
# If +options[:partial]+ is a string, then the +@path+ instance variable is
|
356
|
-
# set to that string. Otherwise, the +options[:partial]+ object must
|
357
|
-
# respond to +to_partial_path+ in order to setup the path.
|
358
|
-
def setup(context, options, block)
|
359
|
-
@view = context
|
360
|
-
@options = options
|
361
|
-
@block = block
|
362
|
-
|
363
|
-
@locals = options[:locals] || {}
|
364
|
-
@details = extract_details(options)
|
365
|
-
|
366
|
-
prepend_formats(options[:formats])
|
367
|
-
|
368
|
-
partial = options[:partial]
|
369
|
-
|
370
|
-
if String === partial
|
371
|
-
@has_object = options.key?(:object)
|
372
|
-
@object = options[:object]
|
373
|
-
@collection = collection_from_options
|
374
|
-
@path = partial
|
375
|
-
else
|
376
|
-
@has_object = true
|
377
|
-
@object = partial
|
378
|
-
@collection = collection_from_object || collection_from_options
|
389
|
+
if as = options[:as]
|
390
|
+
raise_invalid_option_as(as) unless /\A[a-z_]\w*\z/.match?(as.to_s)
|
391
|
+
as = as.to_sym
|
392
|
+
end
|
379
393
|
|
380
|
-
if @
|
381
|
-
|
382
|
-
@
|
394
|
+
if @path
|
395
|
+
@variable, @variable_counter, @variable_iteration = retrieve_variable(@path, as)
|
396
|
+
@template_keys = retrieve_template_keys
|
383
397
|
else
|
384
|
-
|
398
|
+
paths.map! { |path| retrieve_variable(path, as).unshift(path) }
|
385
399
|
end
|
386
|
-
end
|
387
400
|
|
388
|
-
|
389
|
-
raise_invalid_option_as(as) unless as.to_s =~ /\A[a-z_]\w*\z/
|
390
|
-
as = as.to_sym
|
401
|
+
self
|
391
402
|
end
|
392
403
|
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
404
|
+
def collection_from_options
|
405
|
+
if @options.key?(:collection)
|
406
|
+
collection = @options[:collection]
|
407
|
+
collection ? collection.to_a : []
|
408
|
+
end
|
398
409
|
end
|
399
410
|
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
def collection_from_options
|
404
|
-
if @options.key?(:collection)
|
405
|
-
collection = @options[:collection]
|
406
|
-
collection ? collection.to_a : []
|
411
|
+
def collection_from_object
|
412
|
+
@object.to_ary if @object.respond_to?(:to_ary)
|
407
413
|
end
|
408
|
-
end
|
409
414
|
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
def find_partial
|
415
|
-
find_template(@path, @template_keys) if @path
|
416
|
-
end
|
415
|
+
def find_partial
|
416
|
+
find_template(@path, @template_keys) if @path
|
417
|
+
end
|
417
418
|
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
419
|
+
def find_template(path, locals)
|
420
|
+
prefixes = path.include?(?/) ? [] : @lookup_context.prefixes
|
421
|
+
@lookup_context.find_template(path, prefixes, true, locals, @details)
|
422
|
+
end
|
422
423
|
|
423
|
-
|
424
|
-
|
425
|
-
|
424
|
+
def collection_with_template
|
425
|
+
view, locals, template = @view, @locals, @template
|
426
|
+
as, counter, iteration = @variable, @variable_counter, @variable_iteration
|
426
427
|
|
427
|
-
|
428
|
-
|
429
|
-
|
428
|
+
if layout = @options[:layout]
|
429
|
+
layout = find_template(layout, @template_keys)
|
430
|
+
end
|
430
431
|
|
431
|
-
|
432
|
-
|
432
|
+
partial_iteration = PartialIteration.new(@collection.size)
|
433
|
+
locals[iteration] = partial_iteration
|
433
434
|
|
434
|
-
|
435
|
-
|
436
|
-
|
435
|
+
@collection.map do |object|
|
436
|
+
locals[as] = object
|
437
|
+
locals[counter] = partial_iteration.index
|
437
438
|
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
439
|
+
content = template.render(view, locals)
|
440
|
+
content = layout.render(view, locals) { content } if layout
|
441
|
+
partial_iteration.iterate!
|
442
|
+
content
|
443
|
+
end
|
442
444
|
end
|
443
|
-
end
|
444
445
|
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
446
|
+
def collection_without_template
|
447
|
+
view, locals, collection_data = @view, @locals, @collection_data
|
448
|
+
cache = {}
|
449
|
+
keys = @locals.keys
|
449
450
|
|
450
|
-
|
451
|
+
partial_iteration = PartialIteration.new(@collection.size)
|
451
452
|
|
452
|
-
|
453
|
-
|
454
|
-
|
453
|
+
@collection.map do |object|
|
454
|
+
index = partial_iteration.index
|
455
|
+
path, as, counter, iteration = collection_data[index]
|
455
456
|
|
456
|
-
|
457
|
-
|
458
|
-
|
457
|
+
locals[as] = object
|
458
|
+
locals[counter] = index
|
459
|
+
locals[iteration] = partial_iteration
|
459
460
|
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
461
|
+
template = (cache[path] ||= find_template(path, keys + [as, counter, iteration]))
|
462
|
+
content = template.render(view, locals)
|
463
|
+
partial_iteration.iterate!
|
464
|
+
content
|
465
|
+
end
|
464
466
|
end
|
465
|
-
end
|
466
467
|
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
468
|
+
# Obtains the path to where the object's partial is located. If the object
|
469
|
+
# responds to +to_partial_path+, then +to_partial_path+ will be called and
|
470
|
+
# will provide the path. If the object does not respond to +to_partial_path+,
|
471
|
+
# then an +ArgumentError+ is raised.
|
472
|
+
#
|
473
|
+
# If +prefix_partial_path_with_controller_namespace+ is true, then this
|
474
|
+
# method will prefix the partial paths with a namespace.
|
475
|
+
def partial_path(object = @object)
|
476
|
+
object = object.to_model if object.respond_to?(:to_model)
|
477
|
+
|
478
|
+
path = if object.respond_to?(:to_partial_path)
|
479
|
+
object.to_partial_path
|
480
|
+
else
|
481
|
+
raise ArgumentError.new("'#{object.inspect}' is not an ActiveModel-compatible object. It must implement :to_partial_path.")
|
482
|
+
end
|
483
|
+
|
484
|
+
if @view.prefix_partial_path_with_controller_namespace
|
485
|
+
prefixed_partial_names[path] ||= merge_prefix_into_object_path(@context_prefix, path.dup)
|
486
|
+
else
|
487
|
+
path
|
488
|
+
end
|
481
489
|
end
|
482
490
|
|
483
|
-
|
484
|
-
prefixed_partial_names
|
485
|
-
else
|
486
|
-
path
|
491
|
+
def prefixed_partial_names
|
492
|
+
@prefixed_partial_names ||= PREFIXED_PARTIAL_NAMES[@context_prefix]
|
487
493
|
end
|
488
|
-
end
|
489
494
|
|
490
|
-
|
491
|
-
|
492
|
-
|
495
|
+
def merge_prefix_into_object_path(prefix, object_path)
|
496
|
+
if prefix.include?(?/) && object_path.include?(?/)
|
497
|
+
prefixes = []
|
498
|
+
prefix_array = File.dirname(prefix).split("/")
|
499
|
+
object_path_array = object_path.split("/")[0..-3] # skip model dir & partial
|
493
500
|
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
object_path_array = object_path.split('/')[0..-3] # skip model dir & partial
|
501
|
+
prefix_array.each_with_index do |dir, index|
|
502
|
+
break if dir == object_path_array[index]
|
503
|
+
prefixes << dir
|
504
|
+
end
|
499
505
|
|
500
|
-
|
501
|
-
|
502
|
-
|
506
|
+
(prefixes << object_path).join("/")
|
507
|
+
else
|
508
|
+
object_path
|
503
509
|
end
|
504
|
-
|
505
|
-
(prefixes << object_path).join("/")
|
506
|
-
else
|
507
|
-
object_path
|
508
510
|
end
|
509
|
-
end
|
510
511
|
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
512
|
+
def retrieve_template_keys
|
513
|
+
keys = @locals.keys
|
514
|
+
keys << @variable if @has_object || @collection
|
515
|
+
if @collection
|
516
|
+
keys << @variable_counter
|
517
|
+
keys << @variable_iteration
|
518
|
+
end
|
519
|
+
keys
|
517
520
|
end
|
518
|
-
keys
|
519
|
-
end
|
520
521
|
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
522
|
+
def retrieve_variable(path, as)
|
523
|
+
variable = as || begin
|
524
|
+
base = path[-1] == "/".freeze ? "".freeze : File.basename(path)
|
525
|
+
raise_invalid_identifier(path) unless base =~ /\A_?(.*?)(?:\.\w+)*\z/
|
526
|
+
$1.to_sym
|
527
|
+
end
|
528
|
+
if @collection
|
529
|
+
variable_counter = :"#{variable}_counter"
|
530
|
+
variable_iteration = :"#{variable}_iteration"
|
531
|
+
end
|
532
|
+
[variable, variable_counter, variable_iteration]
|
530
533
|
end
|
531
|
-
[variable, variable_counter, variable_iteration]
|
532
|
-
end
|
533
534
|
|
534
|
-
|
535
|
-
|
535
|
+
IDENTIFIER_ERROR_MESSAGE = "The partial name (%s) is not a valid Ruby identifier; " \
|
536
|
+
"make sure your partial name starts with underscore."
|
536
537
|
|
537
|
-
|
538
|
-
|
539
|
-
|
538
|
+
OPTION_AS_ERROR_MESSAGE = "The value (%s) of the option `as` is not a valid Ruby identifier; " \
|
539
|
+
"make sure it starts with lowercase letter, " \
|
540
|
+
"and is followed by any combination of letters, numbers and underscores."
|
540
541
|
|
541
|
-
|
542
|
-
|
543
|
-
|
542
|
+
def raise_invalid_identifier(path)
|
543
|
+
raise ArgumentError.new(IDENTIFIER_ERROR_MESSAGE % (path))
|
544
|
+
end
|
544
545
|
|
545
|
-
|
546
|
-
|
547
|
-
|
546
|
+
def raise_invalid_option_as(as)
|
547
|
+
raise ArgumentError.new(OPTION_AS_ERROR_MESSAGE % (as))
|
548
|
+
end
|
548
549
|
end
|
549
550
|
end
|