Sha256: ad29c38450ad411010fe4845971baebd6881a1a642519b4b9e79c924b36f886c

Contents?: true

Size: 1.69 KB

Versions: 2

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true

require 'singleton'
require 'rails'

module Bemer
  class Configuration
    include Singleton

    attr_accessor :bem, :default_block_tag, :default_element_tag, :default_path_prefix,
                  :element_name_separator, :modifier_name_separator, :modifier_value_separator,
                  :prepend_asset_paths, :paths, :asset_paths
    attr_reader   :can_use_new_matcher
    attr_writer   :path

    alias can_use_new_matcher? can_use_new_matcher

    def initialize # rubocop:disable Metrics/MethodLength
      @asset_paths              = []
      @bem                      = false
      # https://github.com/brainspec/enumerize/blob/9dd68ca36d1efed6bc4cec8557a359f34f408d47/lib/enumerize/activerecord.rb#L24
      # https://github.com/heartcombo/devise/blob/b52e642c0131f7b0d9f2dd24d8607a186f18223e/lib/devise.rb#L301
      # Gem::Version.new('0.4.1') > Gem::Version.new('0.10.1')
      # Здесь вроде также используют https://github.com/rspec/rspec-rails/blob/9b7ab39c027a8cb25e2ebe9e0e985756025b0549/Gemfile#L45
      # https://github.com/JuanitoFatas/fast-ruby/blob/38f49f95fc7574d929de60b71791d09129c2588c/code/string/%3D%3D%3D-vs-%3D~-vs-match.rb#L20
      @can_use_new_matcher      = RUBY_VERSION >= '2.4.0'
      @default_block_tag        = :div
      @default_element_tag      = :div
      @default_path_prefix      = nil
      @element_name_separator   = '__'
      @modifier_name_separator  = '_'
      @modifier_value_separator = '_'
      @path                     = 'app/bemer_components'
      @paths                    = []
      @prepend_asset_paths      = true
    end

    def path
      Rails.root ? Rails.root.join(@path) : @path
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bemer-0.6.0 lib/bemer/configuration.rb
bemer-0.5.0 lib/bemer/configuration.rb