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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45e530569a9010938a1daa776101bcf4fb144d05
4
- data.tar.gz: 4e2315ddba1aa67ecac6692fa9f3e8d01d04e49d
3
+ metadata.gz: 5966e3475126d88e40a01b51cebcac69b6768f0b
4
+ data.tar.gz: 9bf8f8d42ebcd1d990512487156c195376357224
5
5
  SHA512:
6
- metadata.gz: 107072ae4087162f7b8a823a123c40613b88efe26bae6c91d4faa56659e6467aad34b12f47dd0efd4193704ab54273a82b9457acaded1153f60d5cc0c72f166b
7
- data.tar.gz: cbf44a66dd6fe2f9b28b521036a7b1570d7a5785fd865eeb8169c58f8515959168874b40f12c00c1e0b9095d73371295a0f5384008c4d40700d932e0eccb3b98
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+) bindings for [Opal Ruby](http://opalrb.org) (v0.3.27) engine._
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
- ``` js
26
- // app/assets/application.js
30
+ ```js
31
+ // app/assets/application.js.rb
27
32
 
28
- // The Opal runtime
29
- // = require opal
30
- //
31
- // Dom manipulation
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
- and then just use the `.rb` or `.opal` extensions:
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/hi-world.js.rb
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
- puts "G'day world!" # check the console
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
- Document['.post .title'].html = @post[:title]
66
- Document['.post .body'].html = @post[:body]
67
- Document['.post .comments'].html = comments_html
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
- Document['#show-comments'].on :click do
91
- Document['.comments'].first.show
92
- false
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 a `spec.js` into `assets/javascripts` to require your specs
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
@@ -1,3 +1,3 @@
1
1
  Rails.application.routes.draw do
2
- match '/opal_spec' => 'opal_spec#run' if %w[test development].include? Rails.env
2
+ get '/opal_spec' => 'opal_spec#run' if %w[test development].include? Rails.env
3
3
  end
@@ -0,0 +1,4 @@
1
+ require 'opal'
2
+ require 'jquery'
3
+ require 'jquery_ujs'
4
+ require 'opal-jquery'
data/lib/opal-rails.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  require 'opal'
2
- require 'opal-sprockets'
3
-
4
- require 'opal/jquery'
5
- require 'opal/spec'
2
+ require 'opal-jquery'
3
+ require 'opal-spec'
6
4
 
7
5
  require 'opal/rails/engine'
8
6
  require 'opal/rails/template_handler'
@@ -1,5 +1,5 @@
1
1
  module Opal
2
2
  module Rails
3
- VERSION = '0.3.6'
3
+ VERSION = '0.3.7'
4
4
  end
5
5
  end
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.42'
23
- s.add_runtime_dependency 'opal-sprockets'
22
+ s.add_runtime_dependency 'opal', '~> 0.3.43'
24
23
 
25
- s.add_runtime_dependency 'rails', '~> 3.2.0'
26
- s.add_runtime_dependency 'opal-jquery', '>= 0.0.5'
27
- s.add_runtime_dependency 'opal-spec', '>= 0.2.8'
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.6
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-06 00:00:00.000000000 Z
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.42
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.42
26
+ version: 0.3.43
27
27
  - !ruby/object:Gem::Dependency
28
- name: opal-sprockets
28
+ name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '>='
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
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: '0'
41
- - !ruby/object:Gem::Dependency
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: 3.2.0
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.5
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.5
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.8
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.8
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