bemer 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +12 -0
- data/.overcommit.yml +59 -0
- data/.rspec +4 -0
- data/.rubocop.yml +12 -1
- data/.rubocop_todo.yml +3 -6
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/LICENSE-RU +23 -0
- data/README.md +2 -10
- data/Rakefile +8 -1
- data/bemer.gemspec +19 -6
- data/lib/bemer.rb +93 -2
- data/lib/bemer/asset_matcher.rb +21 -0
- data/lib/bemer/builders.rb +23 -0
- data/lib/bemer/builders/tag/element.rb +22 -0
- data/lib/bemer/builders/template.rb +57 -0
- data/lib/bemer/builders/template_list.rb +56 -0
- data/lib/bemer/builders/tree.rb +35 -0
- data/lib/bemer/builders/tree/element.rb +22 -0
- data/lib/bemer/common_template.rb +29 -0
- data/lib/bemer/component.rb +19 -0
- data/lib/bemer/component_pack.rb +39 -0
- data/lib/bemer/configuration.rb +36 -0
- data/lib/bemer/context.rb +44 -0
- data/lib/bemer/context_extentions.rb +12 -0
- data/lib/bemer/context_extentions/structure.rb +32 -0
- data/lib/bemer/context_extentions/template.rb +15 -0
- data/lib/bemer/default_template_list.rb +35 -0
- data/lib/bemer/entity.rb +94 -0
- data/lib/bemer/entity_builder.rb +126 -0
- data/lib/bemer/helpers.rb +41 -0
- data/lib/bemer/mixin_list.rb +74 -0
- data/lib/bemer/modifier_list.rb +68 -0
- data/lib/bemer/pipeline.rb +85 -0
- data/lib/bemer/pipeline/handler.rb +132 -0
- data/lib/bemer/predicate.rb +63 -0
- data/lib/bemer/railtie.rb +36 -0
- data/lib/bemer/renderer.rb +15 -0
- data/lib/bemer/tag.rb +35 -0
- data/lib/bemer/tag_builder.rb +11 -0
- data/lib/bemer/template.rb +90 -0
- data/lib/bemer/template_catalog.rb +42 -0
- data/lib/bemer/template_catalog/drawer.rb +31 -0
- data/lib/bemer/template_list.rb +62 -0
- data/lib/bemer/tree.rb +143 -0
- data/lib/bemer/tree/base_node.rb +49 -0
- data/lib/bemer/tree/node.rb +129 -0
- data/lib/bemer/tree/text_node.rb +11 -0
- data/lib/bemer/version.rb +1 -1
- data/spec/bemer/entity_spec.rb +37 -0
- data/spec/bemer/mixin_list_spec.rb +99 -0
- data/spec/bemer/modifier_list_spec.rb +83 -0
- data/spec/bemer_spec.rb +36 -0
- data/spec/dummy/Rakefile +8 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +4 -0
- data/spec/dummy/app/jobs/application_job.rb +4 -0
- data/spec/dummy/app/mailers/application_mailer.rb +6 -0
- data/spec/dummy/app/models/application_record.rb +5 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +5 -0
- data/spec/dummy/bin/rails +6 -0
- data/spec/dummy/bin/rake +6 -0
- data/spec/dummy/bin/setup +39 -0
- data/spec/dummy/bin/update +31 -0
- data/spec/dummy/bin/yarn +13 -0
- data/spec/dummy/config.ru +7 -0
- data/spec/dummy/config/application.rb +27 -0
- data/spec/dummy/config/boot.rb +7 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +7 -0
- data/spec/dummy/config/environments/development.rb +51 -0
- data/spec/dummy/config/environments/production.rb +84 -0
- data/spec/dummy/config/environments/test.rb +44 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +7 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/dummy/config/initializers/bemer.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/spec/dummy/config/initializers/inflections.rb +17 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +16 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +58 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/config/secrets.yml +32 -0
- data/spec/dummy/config/spring.rb +8 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/package.json +5 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/rails_helper.rb +37 -0
- data/spec/spec_helper.rb +41 -0
- metadata +301 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16debb87f2467a03c58ce016590f7a8782f8058b
|
4
|
+
data.tar.gz: 106a22bbfb569721d22b9cde7d9f4518ede99ec2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e01fb9646706fa961e6183bd8ab7bf13a558b9712c6cf2a1bc71fe02869b8f2aaffefff031573c17dcdb4f614afd78b2071d1705cc9039ce63f208f7efa8704f
|
7
|
+
data.tar.gz: 0e0e17a046595b5b0531e8f1f106bdf4f8895dcef75f3c68e49f6773ef100db3a10bcad819424b3f1665e92882447b15d65074496e1df4bc2bf1643741873095
|
data/.gitignore
CHANGED
data/.overcommit.yml
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Use this file to configure the Overcommit hooks you wish to use. This will
|
2
|
+
# extend the default configuration defined in:
|
3
|
+
# https://github.com/brigade/overcommit/blob/master/config/default.yml
|
4
|
+
#
|
5
|
+
# At the topmost level of this YAML file is a key representing type of hook
|
6
|
+
# being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
|
7
|
+
# customize each hook, such as whether to only run it on certain files (via
|
8
|
+
# `include`), whether to only display output if it fails (via `quiet`), etc.
|
9
|
+
#
|
10
|
+
# For a complete list of hooks, see:
|
11
|
+
# https://github.com/brigade/overcommit/tree/master/lib/overcommit/hook
|
12
|
+
#
|
13
|
+
# For a complete list of options that you can use to customize hooks, see:
|
14
|
+
# https://github.com/brigade/overcommit#configuration
|
15
|
+
|
16
|
+
gemfile: Gemfile
|
17
|
+
|
18
|
+
CommitMsg:
|
19
|
+
HardTabs:
|
20
|
+
enabled: true
|
21
|
+
|
22
|
+
RussianNovel:
|
23
|
+
enabled: true
|
24
|
+
|
25
|
+
PreCommit:
|
26
|
+
BundleAudit:
|
27
|
+
enabled: true
|
28
|
+
flags:
|
29
|
+
# Update the ruby-advisory-db and check Gemfile.lock
|
30
|
+
- '--update'
|
31
|
+
|
32
|
+
BundleCheck:
|
33
|
+
enabled: true
|
34
|
+
|
35
|
+
ExecutePermissions:
|
36
|
+
enabled: true
|
37
|
+
exclude:
|
38
|
+
- 'spec/dummy/bin/*'
|
39
|
+
|
40
|
+
Fasterer:
|
41
|
+
enabled: true
|
42
|
+
|
43
|
+
ForbiddenBranches:
|
44
|
+
enabled: true
|
45
|
+
branch_patterns:
|
46
|
+
- 'master'
|
47
|
+
|
48
|
+
HardTabs:
|
49
|
+
enabled: true
|
50
|
+
|
51
|
+
RuboCop:
|
52
|
+
enabled: true
|
53
|
+
|
54
|
+
TrailingWhitespace:
|
55
|
+
enabled: true
|
56
|
+
|
57
|
+
PrePush:
|
58
|
+
RSpec:
|
59
|
+
enabled: true
|
data/.rspec
ADDED
data/.rubocop.yml
CHANGED
@@ -1,10 +1,21 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
2
|
|
3
|
+
require: rubocop-rspec
|
4
|
+
|
3
5
|
AllCops:
|
4
|
-
TargetRubyVersion: 2.
|
6
|
+
TargetRubyVersion: 2.2
|
5
7
|
DisplayCopNames: true
|
6
8
|
|
7
9
|
Metrics/LineLength:
|
8
10
|
Max: 100
|
9
11
|
IgnoredPatterns:
|
10
12
|
- '^\s*#'
|
13
|
+
Exclude:
|
14
|
+
- 'spec/**/*'
|
15
|
+
|
16
|
+
Metrics/BlockLength:
|
17
|
+
Exclude:
|
18
|
+
- 'spec/**/*'
|
19
|
+
|
20
|
+
Style/FrozenStringLiteralComment:
|
21
|
+
EnforcedStyle: always
|
data/.rubocop_todo.yml
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2018-03-01 16:43:54 +0700 using RuboCop version 0.52.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 31
|
10
10
|
Style/Documentation:
|
11
|
-
|
12
|
-
- 'spec/**/*'
|
13
|
-
- 'test/**/*'
|
14
|
-
- 'lib/bemer.rb'
|
11
|
+
Enabled: false
|
data/Gemfile
CHANGED
@@ -4,3 +4,9 @@ source 'https://rubygems.org'
|
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in bemer.gemspec
|
6
6
|
gemspec
|
7
|
+
|
8
|
+
group :development do
|
9
|
+
# Auto-reload require files or local gems without restarting server during Rails development.
|
10
|
+
gem 'require_reloader', '~> 0.2.1', git: 'https://github.com/vill/require_reloader.git',
|
11
|
+
branch: 'bugfix/delete-watchable-gems'
|
12
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017-2018 Alexander Grigorev
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/LICENSE-RU
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Лицензия MIT
|
2
|
+
|
3
|
+
Copyright (c) 2017-2018 Александр Григорьев
|
4
|
+
|
5
|
+
Данная лицензия разрешает лицам, получившим копию данного программного
|
6
|
+
обеспечения и сопутствующей документации (в дальнейшем именуемыми
|
7
|
+
«Программное Обеспечение»), безвозмездно использовать Программное
|
8
|
+
Обеспечение без ограничений, включая неограниченное право на использование,
|
9
|
+
копирование, изменение, слияние, публикацию, распространение, сублицензирование
|
10
|
+
и/или продажу копий Программного Обеспечения, а также лицам, которым
|
11
|
+
предоставляется данное Программное Обеспечение, при соблюдении следующих условий:
|
12
|
+
|
13
|
+
Указанное выше уведомление об авторском праве и данные условия должны быть включены
|
14
|
+
во все копии или значимые части данного Программного Обеспечения.
|
15
|
+
|
16
|
+
ДАННОЕ ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ ПРЕДОСТАВЛЯЕТСЯ «КАК ЕСТЬ», БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ,
|
17
|
+
ЯВНО ВЫРАЖЕННЫХ ИЛИ ПОДРАЗУМЕВАЕМЫХ, ВКЛЮЧАЯ ГАРАНТИИ ТОВАРНОЙ ПРИГОДНОСТИ,
|
18
|
+
СООТВЕТСТВИЯ ПО ЕГО КОНКРЕТНОМУ НАЗНАЧЕНИЮ И ОТСУТСТВИЯ НАРУШЕНИЙ,
|
19
|
+
НО НЕ ОГРАНИЧИВАЯСЬ ИМИ. НИ В КАКОМ СЛУЧАЕ АВТОРЫ ИЛИ ПРАВООБЛАДАТЕЛИ
|
20
|
+
НЕ НЕСУТ ОТВЕТСТВЕННОСТИ ПО КАКИМ-ЛИБО ИСКАМ, ЗА УЩЕРБ ИЛИ ПО ИНЫМ ТРЕБОВАНИЯМ,
|
21
|
+
В ТОМ ЧИСЛЕ, ПРИ ДЕЙСТВИИ КОНТРАКТА, ДЕЛИКТЕ ИЛИ ИНОЙ СИТУАЦИИ,
|
22
|
+
ВОЗНИКШИМ ИЗ-ЗА ИСПОЛЬЗОВАНИЯ ПРОГРАММНОГО ОБЕСПЕЧЕНИЯ ИЛИ ИНЫХ ДЕЙСТВИЙ
|
23
|
+
С ПРОГРАММНЫМ ОБЕСПЕЧЕНИЕМ.
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Bemer
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Build reusable UI components for Rails applications using the [BEM methodology](https://en.bem.info/methodology/).
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -24,12 +22,6 @@ Or install it yourself as:
|
|
24
22
|
|
25
23
|
TODO: Write usage instructions here
|
26
24
|
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
25
|
## Contributing
|
34
26
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
27
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/vill/bemer.
|
data/Rakefile
CHANGED
data/bemer.gemspec
CHANGED
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
6
|
|
7
7
|
require 'bemer/version'
|
8
8
|
|
9
|
-
Gem::Specification.new do |spec|
|
9
|
+
Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
10
10
|
spec.name = 'bemer'
|
11
11
|
spec.version = Bemer::VERSION
|
12
12
|
spec.author = 'Alexander Grigorev'
|
@@ -15,16 +15,29 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.summary = 'Build reusable UI components for Rails applications using the BEM methodology.'
|
16
16
|
spec.description = 'Build reusable UI components for Rails applications using the BEM methodology.'
|
17
17
|
# rubocop:enable Metrics/LineLength
|
18
|
+
spec.homepage = 'https://github.com/vill/bemer'
|
18
19
|
spec.license = 'MIT'
|
19
20
|
spec.require_paths = ['lib']
|
21
|
+
spec.test_files = `git ls-files -z -- spec/*`.split("\x0")
|
20
22
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
21
|
-
f.match(%r{^
|
23
|
+
f.match(%r{^spec/|^Gemfile.lock$})
|
22
24
|
end
|
23
25
|
|
24
|
-
spec.required_ruby_version = '>= 2.
|
26
|
+
spec.required_ruby_version = '>= 2.2.0'
|
25
27
|
spec.required_rubygems_version = '>= 2.2.0'
|
26
28
|
|
27
|
-
spec.add_development_dependency 'bundler',
|
28
|
-
spec.add_development_dependency '
|
29
|
-
spec.add_development_dependency '
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
30
|
+
spec.add_development_dependency 'bundler-audit', '~> 0.6.0'
|
31
|
+
spec.add_development_dependency 'fasterer', '~> 0.3.2'
|
32
|
+
spec.add_development_dependency 'overcommit', '~> 0.41.0'
|
33
|
+
spec.add_development_dependency 'rails', '~> 5.1.4'
|
34
|
+
spec.add_development_dependency 'rake', '~> 12.3.0'
|
35
|
+
spec.add_development_dependency 'require_reloader', '~> 0.2.1'
|
36
|
+
spec.add_development_dependency 'rspec', '~> 3.7.0'
|
37
|
+
spec.add_development_dependency 'rspec-rails', '~> 3.7.2'
|
38
|
+
spec.add_development_dependency 'rubocop', '~> 0.52.1'
|
39
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.21'
|
40
|
+
spec.add_development_dependency 'sqlite3', '~> 1.3.13'
|
41
|
+
|
42
|
+
spec.add_runtime_dependency 'railties', '>= 3.2.22', '<= 5.2'
|
30
43
|
end
|
data/lib/bemer.rb
CHANGED
@@ -1,7 +1,98 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'forwardable'
|
4
|
+
require 'active_support'
|
5
|
+
require 'active_support/dependencies/autoload'
|
6
|
+
require 'active_support/core_ext/object/blank'
|
7
|
+
require 'active_support/core_ext/string/inflections'
|
4
8
|
|
5
9
|
module Bemer
|
6
|
-
|
10
|
+
extend ActiveSupport::Autoload
|
11
|
+
|
12
|
+
autoload :AssetMatcher
|
13
|
+
autoload :Builders
|
14
|
+
autoload :CommonTemplate
|
15
|
+
autoload :Component
|
16
|
+
autoload :ComponentPack
|
17
|
+
autoload :Configuration
|
18
|
+
autoload :Context
|
19
|
+
autoload :ContextExtentions
|
20
|
+
autoload :DefaultTemplateList
|
21
|
+
autoload :Entity
|
22
|
+
autoload :EntityBuilder
|
23
|
+
autoload :MixinList
|
24
|
+
autoload :ModifierList
|
25
|
+
autoload :Pipeline
|
26
|
+
autoload :Predicate
|
27
|
+
autoload :Renderer
|
28
|
+
autoload :Tag
|
29
|
+
autoload :TagBuilder
|
30
|
+
autoload :Template
|
31
|
+
autoload :TemplateList
|
32
|
+
autoload :Tree
|
33
|
+
|
34
|
+
eager_autoload do
|
35
|
+
autoload :Helpers
|
36
|
+
autoload :TemplateCatalog
|
37
|
+
end
|
38
|
+
|
39
|
+
class << self
|
40
|
+
extend Forwardable
|
41
|
+
|
42
|
+
# rubocop:disable Layout/AlignParameters
|
43
|
+
def_delegators :config, :asset_paths,
|
44
|
+
:bem,
|
45
|
+
:can_use_new_matcher?,
|
46
|
+
:default_block_tag,
|
47
|
+
:default_element_tag,
|
48
|
+
:default_path_prefix,
|
49
|
+
:element_name_separator,
|
50
|
+
:modifier_name_separator,
|
51
|
+
:modifier_value_separator,
|
52
|
+
:path,
|
53
|
+
:paths,
|
54
|
+
:prepend_asset_paths
|
55
|
+
# rubocop:enable Layout/AlignParameters
|
56
|
+
|
57
|
+
alias prepend_asset_paths? prepend_asset_paths
|
58
|
+
|
59
|
+
def config
|
60
|
+
Configuration.instance
|
61
|
+
end
|
62
|
+
|
63
|
+
def setup
|
64
|
+
yield config
|
65
|
+
end
|
66
|
+
|
67
|
+
def eager_load!
|
68
|
+
super
|
69
|
+
|
70
|
+
Bemer::Builders.eager_load!
|
71
|
+
end
|
72
|
+
|
73
|
+
def bem_class(block, element = nil)
|
74
|
+
return '' if block.blank? || (!element.nil? && element.blank?)
|
75
|
+
|
76
|
+
entity_name(block, element)
|
77
|
+
end
|
78
|
+
|
79
|
+
def entity_name(block, element = nil)
|
80
|
+
names = [block]
|
81
|
+
|
82
|
+
names << element unless element.nil?
|
83
|
+
|
84
|
+
names.map { |name| css_class(name) }.join(element_name_separator)
|
85
|
+
end
|
86
|
+
|
87
|
+
def css_class(name)
|
88
|
+
name_without_whitespace = name.to_s.delete(' ')
|
89
|
+
|
90
|
+
return name_without_whitespace if name.instance_of?(String)
|
91
|
+
|
92
|
+
name_without_whitespace.dasherize
|
93
|
+
end
|
94
|
+
end
|
7
95
|
end
|
96
|
+
|
97
|
+
require 'bemer/version'
|
98
|
+
require 'bemer/railtie' if defined?(::Rails::Railtie)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bemer
|
4
|
+
class AssetMatcher
|
5
|
+
def initialize(loose_app_assets)
|
6
|
+
@loose_app_assets = loose_app_assets
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(logical_path, filename = nil)
|
10
|
+
filename = Rails.application.assets.resolve(logical_path).to_s if filename.nil?
|
11
|
+
|
12
|
+
return if [Bemer.path, *Bemer.asset_paths].detect { |path| filename.start_with?(path.to_s) }
|
13
|
+
|
14
|
+
loose_app_assets.call(logical_path, filename) if loose_app_assets.respond_to?(:call)
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
attr_reader :loose_app_assets
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/dependencies/autoload'
|
4
|
+
|
5
|
+
module Bemer
|
6
|
+
module Builders
|
7
|
+
extend ActiveSupport::Autoload
|
8
|
+
|
9
|
+
eager_autoload do
|
10
|
+
autoload :Template
|
11
|
+
autoload :TemplateList
|
12
|
+
autoload :Tree
|
13
|
+
end
|
14
|
+
|
15
|
+
module Tag
|
16
|
+
extend ActiveSupport::Autoload
|
17
|
+
|
18
|
+
eager_autoload do
|
19
|
+
autoload :Element
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bemer
|
4
|
+
module Builders
|
5
|
+
module Tag
|
6
|
+
class Element
|
7
|
+
def initialize(block, bem_cascade)
|
8
|
+
@bem_cascade = bem_cascade
|
9
|
+
@block = block
|
10
|
+
end
|
11
|
+
|
12
|
+
def elem(name = '', **options, &content)
|
13
|
+
Bemer::Tag.new(block, name, bem_cascade: bem_cascade, **options, &content).render
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
attr_reader :block, :bem_cascade
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|