bem-on-rails 0.0.5 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,53 +2,58 @@ BEM = {}
2
2
 
3
3
  BEM[:root] = "bem"
4
4
  BEM[:attrs] = [:block, :elem, :mods, :elemMods, :bem, :js, :jsAttr, :cls, :tag, :mix, :content, :attrs]
5
- BEM[:levels] = []
6
5
 
7
6
  BEM[:app] = Rails.application.class.to_s.split("::").first.underscore.split('_').map(&:downcase).join('-')
7
+
8
+ # Default levels
9
+ BEM[:levels] = []
8
10
  BEM[:levels].push({ name: BEM[:app] }) # levels stack
9
11
  BEM[:level] = BEM[:app] # default level
10
12
 
11
13
  # List of known techs.
12
14
  BEM[:techs] = {
13
- haml: ".html.haml",
14
- slim: ".html.slim",
15
- erb: "html.erb",
16
- jade: ".jade",
17
- sass: ".css.sass",
18
- scss: ".css.scss",
19
- less: ".css.less",
20
- styl: ".css.styl",
21
- css: ".css",
22
- coffee: ".coffee",
23
- js: ".js",
24
- md: ".md",
25
- wiki: ".wiki"
15
+ haml: ".html.haml",
16
+ slim: ".html.slim",
17
+ erb: "html.erb",
18
+ jade: ".jade",
19
+ sass: ".css.sass",
20
+ scss: ".css.scss",
21
+ less: ".css.less",
22
+ styl: ".css.styl",
23
+ css: ".css",
24
+ coffee: ".coffee",
25
+ js: ".js",
26
+ md: ".md",
27
+ wiki: ".wiki"
26
28
  }
29
+
27
30
  # List of default techs, generating if -T is empty.
28
31
  BEM[:default] = [:haml, :sass, :coffee, :md]
29
- # Usage files variants.
30
- BEM[:usage] = [:md, :wiki]
32
+
31
33
  # Default directories, try to customize.
32
34
  # Blocks directory in root of rails app.
33
35
  BEM[:blocks] = {
34
- dir: BEM[:root],
35
- prefix: "",
36
- postfix: ""
36
+ dir: BEM[:root],
37
+ prefix: "",
38
+ postfix: ""
37
39
  }
40
+
38
41
  # Elements directory in every block directory.
39
42
  # Write 'dir: ""' for creating elements in root of block.
40
43
  BEM[:elements] = {
41
- dir: "elements",
42
- prefix: "__",
43
- postfix: ""
44
+ dir: '',
45
+ prefix: '__',
46
+ postfix: ''
44
47
  }
48
+
45
49
  # Mods directory in every block directory.
46
50
  # Write 'dir: ""' for creating mods in root of block.
47
51
  BEM[:mods] = {
48
- dir: "mods",
49
- prefix: "_",
50
- postfix: ""
52
+ dir: '',
53
+ prefix: '_',
54
+ postfix: '_'
51
55
  }
56
+
52
57
  # [!] If you work with sass and you want to create blocks, elements and mods in sass,
53
58
  # you should convert 'application.css' to 'application.css.sass'. Because, when
54
59
  # blocks, elements or mods is created, technology files will be included to application
@@ -65,18 +70,19 @@ BEM[:mods] = {
65
70
  # }
66
71
  # }
67
72
  BEM[:assets] = {
68
- stylesheets:
69
- {
70
- ext: BEM[:techs][:sass],
71
- import: '//= require'
72
- },
73
- javascripts:
74
- {
75
- ext: BEM[:techs][:js],
76
- import: '//= require'
77
- }
73
+ stylesheets:
74
+ {
75
+ ext: BEM[:techs][:sass],
76
+ import: '//= require'
77
+ },
78
+ javascripts:
79
+ {
80
+ ext: BEM[:techs][:js],
81
+ import: '//= require'
82
+ }
78
83
  }
84
+
79
85
  # You must use application files in
80
86
  # assets as a configs, don't write code in them.
81
87
  # This is need to sprokets includes.
82
- Rails.application.config.assets.paths << BEM[:root]
88
+ Rails.application.config.assets.paths << BEM[:root]
@@ -1,5 +1,8 @@
1
+ require 'bem-on-rails/bem_render_helper'
2
+
1
3
  module Bemonrails
2
4
  class Railtie < Rails::Railtie
5
+
3
6
  initializer "railtie.configure_rails_initialization" do
4
7
  require 'bem-on-rails/initializers/bem'
5
8
  end
@@ -12,6 +15,7 @@ module Bemonrails
12
15
  include Bemonrails::Levels
13
16
  before_filter :parse_bem_levels
14
17
  end
18
+
15
19
  end
16
20
 
17
- end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module Bemonrails
2
- VERSION = "0.0.5"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bem-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Winogradov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-05 00:00:00.000000000 Z
11
+ date: 2014-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.16'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.16'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Gem for work with BEM methodology in Rails applications
@@ -73,18 +73,17 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .rvmrc
76
+ - ".gitignore"
77
+ - ".rvmrc"
78
78
  - CHANGELOG.md
79
79
  - Gemfile
80
- - LICENSE
81
80
  - README.md
81
+ - README.ru.md
82
82
  - Rakefile
83
- - ToDo.md
84
- - app/helpers/bemonrails/bem_render_helper.rb
85
83
  - app/views/bemonrails/essences/_content.html.haml
86
84
  - bem-on-rails.gemspec
87
85
  - lib/bem-on-rails.rb
86
+ - lib/bem-on-rails/bem_render_helper.rb
88
87
  - lib/bem-on-rails/build/bem_names.rb
89
88
  - lib/bem-on-rails/build/console_messages.rb
90
89
  - lib/bem-on-rails/build/levels.rb
@@ -110,17 +109,17 @@ require_paths:
110
109
  - lib
111
110
  required_ruby_version: !ruby/object:Gem::Requirement
112
111
  requirements:
113
- - - '>='
112
+ - - ">="
114
113
  - !ruby/object:Gem::Version
115
114
  version: '0'
116
115
  required_rubygems_version: !ruby/object:Gem::Requirement
117
116
  requirements:
118
- - - '>='
117
+ - - ">="
119
118
  - !ruby/object:Gem::Version
120
119
  version: '0'
121
120
  requirements: []
122
121
  rubyforge_project:
123
- rubygems_version: 2.0.7
122
+ rubygems_version: 2.2.2
124
123
  signing_key:
125
124
  specification_version: 4
126
125
  summary: BEM Tools for Rails applications
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2013 Anton Winogradov
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/ToDo.md DELETED
@@ -1,7 +0,0 @@
1
- 1. Removing levels.
2
- 2. Update removing assets lines with Thor:Actions (gsub).
3
- 3. Creating essences on levels.
4
- 4. Levels autoordering. Now we write it by hands in initializers/bem.rb.
5
- 5. Manipulate with essence from parent level in template.
6
- 6. Right work for Slim. Now it's trouble.
7
- 7. See here [Stux](https://github.com/inossidabile/styx) for bridge js params from blocks to javascript code.
@@ -1,107 +0,0 @@
1
- module Bemonrails
2
- module BemRenderHelper
3
- include Bemonrails::BemNames
4
-
5
- def b(name, builder={})
6
- unless name.blank?
7
- path = File.join build_path_for(:block, builder, false)
8
- target = File.join path, block(name), block(name)
9
- get_bemattributes_from builder
10
- set_names :block, name
11
- update_bemattributes
12
- template_exists?(target) ? render(file: target) : empty
13
- end
14
- end
15
-
16
- def e(name, builder={})
17
- unless name.blank?
18
- path = File.join build_path_for(:element, builder, false)
19
- target = File.join path, element(name), element(name)
20
- get_bemattributes_from builder
21
- set_names :element, name
22
- update_bemattributes
23
- template_exists?(target) ? render(file: target) : empty
24
- end
25
- end
26
-
27
- def get_bemattributes_from(builder={})
28
- @this = {}
29
- BEM[:attrs].each do |mod|
30
- if builder[mod]
31
- @this[mod] = builder[mod]
32
- builder = builder.except(mod)
33
- end
34
- end
35
- @this[:ctx] = builder
36
- @this[:bem] ||= true
37
- @this[:attrs] ||= {}
38
- @this[:tag] ||= :div
39
- end
40
-
41
- def set_names(essence, name)
42
- case essence
43
- when :block
44
- @this[:block] = @block_buffer = name
45
- when :element
46
- @this[:block] = @block_buffer
47
- @this[:elem] = name
48
- end
49
- end
50
-
51
- def update_bemattributes
52
- classes_array = []
53
- if @this[:bem] == true
54
- generate_class(@this, classes_array)
55
- install_mix(@this[:mix], classes_array)
56
- else
57
- classes_array.push(@this[:elem] ? @this[:elem] : @this[:block])
58
- end
59
- @this[:attrs].merge!({class: [classes_array, @this[:cls]].join(" ").strip!})
60
- end
61
-
62
- def install_mods(mods, classes_array, bl, el=false)
63
- if mods
64
- el = el ? element(el) : ""
65
- mods.each do |mod|
66
- if mod.kind_of? Hash
67
- mod.each do |mod_name, mod_value|
68
- classes_array.push(block(bl) + el + mod(mod_name.to_s) + mod(mod_name.to_s, mod_value))
69
- end
70
- else
71
- classes_array.push(block(bl) + el + mod(mod.to_s))
72
- end
73
- end
74
- end
75
- end
76
-
77
- def install_mix(mixs, classes_array)
78
- if mixs
79
- mixs.each do |mix|
80
- generate_class(mix, classes_array)
81
- end
82
- end
83
- end
84
-
85
- def generate_class(essence, classes_array)
86
- if essence[:block] && !essence[:elem]
87
- classes_array.push(block(essence[:block]))
88
- install_mods(essence[:mods], classes_array, essence[:block])
89
- elsif essence[:elem]
90
- classes_array.push(block(essence[:block]) + element(essence[:elem]))
91
- install_mods(essence[:elemMods], classes_array, essence[:block], essence[:elem])
92
- end
93
- end
94
-
95
- def empty
96
- "<div class=#{ @this[:attrs][:class] }></div>".html_safe
97
- end
98
-
99
- def this
100
- @this
101
- end
102
-
103
- def content
104
- render "bemonrails/essences/content"
105
- end
106
- end
107
- end