Class: PrelandsRails::CreateSimpleSource::ValidateZipContent::ValidateCss::Css

Inherits:
Object
  • Object
show all
Defined in:
lib/prelands_rails/create_simple_source/validate_zip_content/validate_css/css.rb

Overview

Принимает строку с css и валидирует её. Правила, обязательные для всех css файлов.

Constant Summary collapse

CUSTOM_FONTS =
/\.(eot|woff|woff2|ttf)/.freeze
/\.svg/.freeze
IMAGES_BAD_PATH =
/\/images/.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ Css

Returns a new instance of Css.

Parameters:

  • string (String)

    Содержимое css файла.



19
20
21
22
# File 'lib/prelands_rails/create_simple_source/validate_zip_content/validate_css/css.rb', line 19

def initialize(string)
  @errors = []
  @string = string
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



12
13
14
# File 'lib/prelands_rails/create_simple_source/validate_zip_content/validate_css/css.rb', line 12

def errors
  @errors
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
32
# File 'lib/prelands_rails/create_simple_source/validate_zip_content/validate_css/css.rb', line 24

def valid?
  @errors = [
    check_svg_links,
    check_images_relative_paths,
    check_custom_fonts_absence
  ].compact

  @errors.none?
end