evil-blocks-rails 0.1.0 → 0.2.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.
Files changed (4) hide show
  1. data/ChangeLog +3 -0
  2. data/README.md +19 -1
  3. data/lib/evil-blocks-rails.rb +20 -10
  4. metadata +2 -2
data/ChangeLog CHANGED
@@ -1,2 +1,5 @@
1
+ == 0.2 (Little Boy, 6th August 1945)
2
+ * Support non-Rails applications in gem.
3
+
1
4
  == 0.1 (The Gadget, 16th July 1945)
2
5
  * Initial release.
data/README.md CHANGED
@@ -100,7 +100,7 @@ evil.block '.user-page', ($, b, block) ->
100
100
  It will execute `callback` only if block `selector` exists in current page.
101
101
  So you can be free to join all JS files in one.
102
102
  * `evil.block` will send to `callback` three arguments: `$` is jQuery,
103
- `b` is “b-function”, `block` is a finded blocks by `selector`.
103
+ `b` is “b-function”, `block` is blocks found by `selector`.
104
104
  * B-function is like jQuery function, but find only inside finded block
105
105
  (alias `b('a') = $('a', selector)`).
106
106
  * Bind JavaScript to `data-role` attribute to be free to change styles
@@ -125,6 +125,24 @@ Load `evil-blocks.js` in your script:
125
125
  //= require evil-blocks
126
126
  ```
127
127
 
128
+ ### Ruby
129
+
130
+ If you use Sinatra or other non-Rails framework you can add Evil Blocks path
131
+ to Sprockets environment:
132
+ ```ruby
133
+ EvilBlocks.install(sprockets)
134
+ ```
135
+
136
+ And change Slim options to support `@data-rule` shortcut:
137
+ ```ruby
138
+ EvilBlocks.install_to_slim!
139
+ ```
140
+
141
+ Then just load `evil-blocks.js` in your script:
142
+ ```js
143
+ //= require evil-blocks
144
+ ```
145
+
128
146
  ### Others
129
147
 
130
148
  Add file `lib/evil-blocks.js` to your project.
@@ -17,16 +17,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  =end
18
18
 
19
19
  module EvilBlocks
20
- # Tell Ruby on Rails to add `evil-block.js` to Rails Admin load paths.
21
- class Engine < ::Rails::Engine
22
- initializer 'evil-front.slim' do
23
- if defined?(Slim::Parser)
24
- # Add @data-role alias to Slim.
25
- #
26
- # Copy from role-rails by Sasha Koss.
27
- # https://github.com/kossnocorp/role-rails
28
- Slim::Parser.default_options[:shortcut]['@'] = { :attr => 'data-role' }
29
- Slim::Engine.default_options[:merge_attrs]['data-role'] = ' '
20
+ # Change Slim options to support @data-role shortcut.
21
+ def self.install_to_slim!
22
+ # Add @data-role alias to Slim.
23
+ #
24
+ # Copy from role-rails by Sasha Koss.
25
+ # https://github.com/kossnocorp/role-rails
26
+ Slim::Parser.default_options[:shortcut]['@'] = { :attr => 'data-role' }
27
+ Slim::Engine.default_options[:merge_attrs]['data-role'] = ' '
28
+ end
29
+
30
+ # Add assets paths to standalone Sprockets environment.
31
+ def self.install(sprockets)
32
+ sprockets.append_path(Pathname(__FILE__).dirname.join('assets/javascripts'))
33
+ end
34
+
35
+ if defined? ::Rails
36
+ # Tell Ruby on Rails to add `evil-block.js` to Rails Admin load paths.
37
+ class Engine < ::Rails::Engine
38
+ initializer 'evil-front.slim' do
39
+ EvilBlocks.install_to_slim! if defined?(Slim::Parser)
30
40
  end
31
41
  end
32
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evil-blocks-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-29 00:00:00.000000000 Z
12
+ date: 2013-05-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets