rbem 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5962b2e769ec9943cbfeb4d59326a54928c74982
4
- data.tar.gz: 9330ae69136e46e1f34576ac0d29ab108617d7e3
3
+ metadata.gz: 5a428fe59f010b4ee2f712bbb292425b015fc2ad
4
+ data.tar.gz: 85881b4d649348f05bfbfcf8c49f2ef618675a57
5
5
  SHA512:
6
- metadata.gz: 7f7b604e2c84f253a00e11601169d6e8aa3cf072ccb821ac8e1f8263ce2236d14990b1e8b45351c728808bd854b724508d5f4c8223ac96819a0db19a2861ecd4
7
- data.tar.gz: 9104b77a02ee97ca5982ee7489417fa2339790ffd5f86281c6d1edce1f54d5374d29f614d188dc2ec53b134d1f1d4c4ee7c8005bb3a0e572fb45436dbeaa3694
6
+ metadata.gz: 23ceb2e67d070ea18088fb4cc022978a8c5770cb7914e442c2697e3814fc86a18d18217ca9d7903373dcf1a2f7e6bc3ad3144bc628a0881fc050818e1618128a
7
+ data.tar.gz: 332c2ef9f57f078bf471663437a235caed3b69628fa12ce0eebdb7505337c519028ac6cb289ee4d16cf25c55eb12fb8127817fade7862e80f706709181341d57
data/README.md CHANGED
@@ -6,6 +6,12 @@ Simple methods for [BEM methodology](http://bem.info) coding on Ruby.
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
+ ```ruby
10
+ gem 'rbem'
11
+ ```
12
+
13
+ or install from GitHub source:
14
+
9
15
  ```ruby
10
16
  gem 'rbem', github: 'vadimskrotsky/rbem'
11
17
  ```
@@ -30,6 +36,18 @@ helpers do
30
36
  end
31
37
  ```
32
38
 
39
+ ## Configuration
40
+
41
+ **Rbem** has one configuration option :-)
42
+
43
+ You can change BEM original notation from `name_mod` to `name--mod` ([Nicolas Gallagher notation](http://nicolasgallagher.com/about-html-semantics-front-end-architecture/)):
44
+
45
+ ```ruby
46
+ Rbem.configuration do |config|
47
+ config.notation = '--'
48
+ end
49
+ ```
50
+
33
51
  ## Usage
34
52
 
35
53
  ```slim
@@ -37,8 +55,8 @@ end
37
55
  = e 'element', 'active'
38
56
 
39
57
  / == Returns:
40
- / <div class="block block--full">
41
- / <div class="block__element block__element--active"></div>
58
+ / <div class="block block_full">
59
+ / <div class="block__element block__element_active"></div>
42
60
  / </div>
43
61
  ```
44
62
 
@@ -49,8 +67,8 @@ Set block/element type(`Symbol`):
49
67
  = e 'element', 'active', :a
50
68
 
51
69
  / == Returns:
52
- / <span class="block block--full">
53
- / <a class="block__element block__element--active"></a>
70
+ / <span class="block block_full">
71
+ / <a class="block__element block__element_active"></a>
54
72
  / </span>
55
73
  ```
56
74
 
@@ -61,8 +79,8 @@ Pass block/element options(`Hash`):
61
79
  = e 'element', 'active', data: { tab: 'wonderful_tab' }
62
80
 
63
81
  / == Returns:
64
- / <div class="block block--full js" id="wonderful_id">
65
- / <div class="block__element block__element--active" data-tab="wonderful_tab"></div>
82
+ / <div class="block block_full js" id="wonderful_id">
83
+ / <div class="block__element block__element_active" data-tab="wonderful_tab"></div>
66
84
  / </div>
67
85
  ```
68
86
 
@@ -73,8 +91,8 @@ Inherit block modifier on element `&name`:
73
91
  = e '&element', 'active'
74
92
 
75
93
  / == Returns:
76
- / <div class="block block--full">
77
- / <div class="block__element block__element--active block--full__element"></div>
94
+ / <div class="block block_full">
95
+ / <div class="block__element block__element_active block_full__element"></div>
78
96
  / </div>
79
97
  ```
80
98
 
@@ -85,8 +103,8 @@ Inherit block modifier to element `&modifier`:
85
103
  = e 'element', '&active'
86
104
 
87
105
  / == Returns:
88
- / <div class="block block--full">
89
- / <div class="block__element block__element--active block--full__element--active"></div>
106
+ / <div class="block block_full">
107
+ / <div class="block__element block__element_active block_full__element_active"></div>
90
108
  / </div>
91
109
  ```
92
110
 
@@ -0,0 +1,22 @@
1
+ # Thanks for Eli Fatsi
2
+ # http://viget.com/extend/easy-gem-configuration-variables-with-defaults
3
+ module Configuration
4
+ def configuration
5
+ yield self
6
+ end
7
+ def define_setting(name, default = nil)
8
+ class_variable_set("@@#{name}", default)
9
+ define_class_method "#{name}=" do |value|
10
+ class_variable_set("@@#{name}", value)
11
+ end
12
+ define_class_method name do
13
+ class_variable_get("@@#{name}")
14
+ end
15
+ end
16
+ private
17
+ def define_class_method(name, &block)
18
+ (class << self; self; end).instance_eval do
19
+ define_method name, &block
20
+ end
21
+ end
22
+ end
data/lib/rbem.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  require 'rbem/version'
2
+ require 'helpers/configuration'
2
3
  require 'padrino-helpers'
3
4
 
4
5
  module Rbem
6
+ extend Configuration
7
+
8
+ define_setting :notation, '_'
5
9
 
6
10
  def b(*args, &block)
7
11
  _args = parse_args(args)
@@ -54,25 +58,28 @@ module Rbem
54
58
  end
55
59
 
56
60
  def collect_bem_class(name, mod, options, type: nil, inherit_name: nil, inherit_mod: nil)
61
+ _separ = @@notation
62
+ _separ = '_' unless _separ.is_a?(String)
63
+
57
64
  _class = []
58
65
 
59
66
  if type === :block
60
67
  _class << "#{name}"
61
68
  if mod.present?
62
- _class << "#{name}--#{mod}"
69
+ _class << "#{name}#{_separ}#{mod}"
63
70
  end
64
71
  end
65
72
 
66
73
  if type === :element
67
74
  _class << "#{@block_name}__#{name}"
68
75
  if mod.present?
69
- _class << "#{@block_name}__#{name}--#{mod}"
76
+ _class << "#{@block_name}__#{name}#{_separ}#{mod}"
70
77
  end
71
78
  if inherit_name and @block_mod.present?
72
- _class << "#{@block_name}--#{@block_mod}__#{name}"
79
+ _class << "#{@block_name}#{_separ}#{@block_mod}__#{name}"
73
80
  end
74
81
  if inherit_mod and @block_mod.present? and mod.present?
75
- _class << "#{@block_name}--#{@block_mod}__#{name}--#{mod}"
82
+ _class << "#{@block_name}#{_separ}#{@block_mod}__#{name}#{_separ}#{mod}"
76
83
  end
77
84
  end
78
85
 
data/lib/rbem/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rbem
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vadim Skrotsky
@@ -64,6 +64,7 @@ files:
64
64
  - LICENSE.txt
65
65
  - README.md
66
66
  - Rakefile
67
+ - lib/helpers/configuration.rb
67
68
  - lib/rbem.rb
68
69
  - lib/rbem/version.rb
69
70
  - rbem.gemspec