opal-rails 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -40
- data/config/routes.rb +1 -1
- data/lib/assets/javascripts/opal_ujs.js.rb +4 -0
- data/lib/opal-rails.rb +2 -4
- data/lib/opal/rails/version.rb +1 -1
- data/opal-rails.gemspec +4 -5
- metadata +17 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5966e3475126d88e40a01b51cebcac69b6768f0b
|
4
|
+
data.tar.gz: 9bf8f8d42ebcd1d990512487156c195376357224
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da713910909d0fb6cbb1032253718be7cd77af65890e7629bbaa4ea1634001f90c5df60f753145662ef102913611fa415722bd32ecc2f3d53cf479cef3cac57e
|
7
|
+
data.tar.gz: 2c0c9784b17ab49e3554e9c956599f17b0dbd57d4165c43dd20a29d0150d73c8286039f2f4b34de4861c8ad2e0ff06e85b7f919c180ed2de680ae49820144d27
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[![Build Status](https://secure.travis-ci.org/elia/opal-rails.png)](http://travis-ci.org/elia/opal-rails)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/elia/opal-rails.png)](https://codeclimate.com/github/elia/opal-rails)
|
5
5
|
|
6
|
-
_Rails (3.2
|
6
|
+
_Rails (3.2+, 4.0) bindings for [Opal Ruby](http://opalrb.org) engine._
|
7
7
|
|
8
8
|
|
9
9
|
|
@@ -15,6 +15,11 @@ In your `Gemfile`
|
|
15
15
|
gem 'opal-rails'
|
16
16
|
```
|
17
17
|
|
18
|
+
or when you build your new Rails app:
|
19
|
+
|
20
|
+
```bash
|
21
|
+
rails new <app-name> --javascript=opal
|
22
|
+
```
|
18
23
|
|
19
24
|
|
20
25
|
## Usage
|
@@ -22,23 +27,26 @@ gem 'opal-rails'
|
|
22
27
|
|
23
28
|
### Asset Pipeline
|
24
29
|
|
25
|
-
```
|
26
|
-
// app/assets/application.js
|
30
|
+
```js
|
31
|
+
// app/assets/application.js.rb
|
27
32
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
// = require jquery
|
33
|
-
// = require opal-jquery
|
33
|
+
//= require opal
|
34
|
+
//= require opal_ujs
|
35
|
+
//= require turbolinks
|
36
|
+
//= require_tree .
|
34
37
|
```
|
35
38
|
|
36
|
-
|
39
|
+
Opal requires are forwarded to the Asset Pipeline at compile time (similarly to what happens for RubyMotion). You can use either the `.rb` or `.opal` extension:
|
37
40
|
|
38
41
|
```ruby
|
39
|
-
# app/assets/javascripts/
|
42
|
+
# app/assets/javascripts/greeter.js.rb
|
43
|
+
|
44
|
+
puts "G'day world!" # check the console!
|
45
|
+
|
46
|
+
# Dom manipulation
|
47
|
+
require 'opal-jquery'
|
40
48
|
|
41
|
-
|
49
|
+
Element.find('body > header').html = '<h1>Hi there!</h1>'
|
42
50
|
```
|
43
51
|
|
44
52
|
|
@@ -62,9 +70,10 @@ Each assign is filtered through JSON so it's reduced to basic types:
|
|
62
70
|
```ruby
|
63
71
|
# app/views/posts/cerate.js.opal
|
64
72
|
|
65
|
-
|
66
|
-
|
67
|
-
|
73
|
+
post = Element.find('.post')
|
74
|
+
post.find('.title').html = @post[:title]
|
75
|
+
post.find('.body').html = @post[:body]
|
76
|
+
post.find('.comments').html = comments_html
|
68
77
|
```
|
69
78
|
|
70
79
|
|
@@ -87,9 +96,10 @@ Of course you need to require `haml-rails` separately since its presence is not
|
|
87
96
|
|
88
97
|
:opal
|
89
98
|
Document.ready? do
|
90
|
-
|
91
|
-
|
92
|
-
|
99
|
+
Element.find('#show-comments').on :click do |click|
|
100
|
+
click.prevent_default
|
101
|
+
click.current_target.hide
|
102
|
+
Element.find('.comments').effect(:fade_in)
|
93
103
|
end
|
94
104
|
end
|
95
105
|
```
|
@@ -97,16 +107,12 @@ Of course you need to require `haml-rails` separately since its presence is not
|
|
97
107
|
|
98
108
|
### Spec!
|
99
109
|
|
100
|
-
Add
|
101
|
-
|
102
|
-
```js
|
103
|
-
// = require_tree ./spec
|
104
|
-
```
|
110
|
+
Add specs into `app/assets/javascripts/specs`:
|
105
111
|
|
106
112
|
and then a spec folder with you specs!
|
107
113
|
|
108
114
|
```ruby
|
109
|
-
# assets/javascripts/spec/example_spec.js.rb
|
115
|
+
# app/assets/javascripts/spec/example_spec.js.rb
|
110
116
|
|
111
117
|
describe 'a spec' do
|
112
118
|
it 'has successful examples' do
|
@@ -120,24 +126,9 @@ Then visit `/opal_spec` from your app and **reload at will**.
|
|
120
126
|
![1 examples, 0 failures](http://f.cl.ly/items/001n0V0g0u0v14160W2G/Schermata%2007-2456110%20alle%201.06.29%20am.png)
|
121
127
|
|
122
128
|
|
123
|
-
## (Rails) Caveats
|
124
|
-
|
125
|
-
During eager loading (e.g. in production or test env) Rails loads all `.rb` files inside `app/` thus catching Opal files inside `app/assets` or `app/views`, the workaround for this is to add the following code to `application.rb`
|
126
|
-
|
127
|
-
```ruby
|
128
|
-
# Don't eager load stuff from app/assets and app/views
|
129
|
-
config.before_initialize do
|
130
|
-
config.eager_load_paths = config.eager_load_paths.dup - Dir["#{Rails.root}/app/{assets,views}"]
|
131
|
-
end
|
132
|
-
```
|
133
|
-
|
134
|
-
**NOTE:** Rails does not do this on purpose, but the paths system (which states no eager loading for assets/views) is caught in a corner case here. I opened [an issue](rails/rails#7587) on Rails already.
|
135
|
-
|
136
|
-
|
137
|
-
|
138
129
|
## License
|
139
130
|
|
140
|
-
© 2012 Elia Schito
|
131
|
+
© 2012-2013 Elia Schito
|
141
132
|
|
142
133
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
143
134
|
of this software and associated documentation files (the "Software"), to deal
|
data/config/routes.rb
CHANGED
data/lib/opal-rails.rb
CHANGED
data/lib/opal/rails/version.rb
CHANGED
data/opal-rails.gemspec
CHANGED
@@ -19,12 +19,11 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ['lib']
|
21
21
|
|
22
|
-
s.add_runtime_dependency 'opal', '~> 0.3.
|
23
|
-
s.add_runtime_dependency 'opal-sprockets'
|
22
|
+
s.add_runtime_dependency 'opal', '~> 0.3.43'
|
24
23
|
|
25
|
-
s.add_runtime_dependency 'rails', '
|
26
|
-
s.add_runtime_dependency 'opal-jquery', '>= 0.0.
|
27
|
-
s.add_runtime_dependency 'opal-spec', '>= 0.2.
|
24
|
+
s.add_runtime_dependency 'rails', '>= 3.2.13', '< 5.0'
|
25
|
+
s.add_runtime_dependency 'opal-jquery', '>= 0.0.8'
|
26
|
+
s.add_runtime_dependency 'opal-spec', '>= 0.2.15'
|
28
27
|
s.add_runtime_dependency 'jquery-rails'
|
29
28
|
|
30
29
|
s.add_development_dependency 'rspec', '~> 2.4'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elia Schito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04
|
11
|
+
date: 2013-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -16,70 +16,62 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.3.
|
19
|
+
version: 0.3.43
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.3.
|
26
|
+
version: 0.3.43
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 3.2.13
|
34
|
+
- - <
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '5.0'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
41
|
- - '>='
|
39
42
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
-
-
|
42
|
-
name: rails
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ~>
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 3.2.0
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ~>
|
43
|
+
version: 3.2.13
|
44
|
+
- - <
|
53
45
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
46
|
+
version: '5.0'
|
55
47
|
- !ruby/object:Gem::Dependency
|
56
48
|
name: opal-jquery
|
57
49
|
requirement: !ruby/object:Gem::Requirement
|
58
50
|
requirements:
|
59
51
|
- - '>='
|
60
52
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.0.
|
53
|
+
version: 0.0.8
|
62
54
|
type: :runtime
|
63
55
|
prerelease: false
|
64
56
|
version_requirements: !ruby/object:Gem::Requirement
|
65
57
|
requirements:
|
66
58
|
- - '>='
|
67
59
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.0.
|
60
|
+
version: 0.0.8
|
69
61
|
- !ruby/object:Gem::Dependency
|
70
62
|
name: opal-spec
|
71
63
|
requirement: !ruby/object:Gem::Requirement
|
72
64
|
requirements:
|
73
65
|
- - '>='
|
74
66
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.2.
|
67
|
+
version: 0.2.15
|
76
68
|
type: :runtime
|
77
69
|
prerelease: false
|
78
70
|
version_requirements: !ruby/object:Gem::Requirement
|
79
71
|
requirements:
|
80
72
|
- - '>='
|
81
73
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.2.
|
74
|
+
version: 0.2.15
|
83
75
|
- !ruby/object:Gem::Dependency
|
84
76
|
name: jquery-rails
|
85
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,6 +174,7 @@ files:
|
|
182
174
|
- app/views/opal_spec/run.html.erb
|
183
175
|
- config/routes.rb
|
184
176
|
- lib/assets/javascripts/opal-spec-runner.js.rb
|
177
|
+
- lib/assets/javascripts/opal_ujs.js.rb
|
185
178
|
- lib/opal-rails.rb
|
186
179
|
- lib/opal/rails/engine.rb
|
187
180
|
- lib/opal/rails/haml_filter.rb
|