Class: PrelandsRails::CreateSimpleSource::ValidateZipContent::ValidateJs::Js
- Inherits:
-
Object
- Object
- PrelandsRails::CreateSimpleSource::ValidateZipContent::ValidateJs::Js
- Defined in:
- lib/prelands_rails/create_simple_source/validate_zip_content/validate_js/js.rb
Overview
Принимает строку с JavaScript кодом разметкой и валидирует её.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(string) ⇒ Js
constructor
A new instance of Js.
- #valid? ⇒ Boolean
Constructor Details
#initialize(string) ⇒ Js
Returns a new instance of Js.
14 15 16 17 |
# File 'lib/prelands_rails/create_simple_source/validate_zip_content/validate_js/js.rb', line 14 def initialize(string) @errors = [] @string = string.gsub(/(\r\n?|\n)/, '') # убираем переносы, мешающие регуляркам end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
11 12 13 |
# File 'lib/prelands_rails/create_simple_source/validate_zip_content/validate_js/js.rb', line 11 def errors @errors end |
Instance Method Details
#valid? ⇒ Boolean
19 20 21 22 23 24 25 26 |
# File 'lib/prelands_rails/create_simple_source/validate_zip_content/validate_js/js.rb', line 19 def valid? @errors = [ check_location_changes, check_framework_calls ].compact !@errors.any? end |