opal-rails 0.3.8 → 0.4.0

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: 61a03343b0c30a6365c2ba2ab691541729606aca
4
- data.tar.gz: 8d776f2d27aaf21d15bebb9a599f8af88c95838a
3
+ metadata.gz: 32adae8b04d04337405ba3018e5b863435d5d67d
4
+ data.tar.gz: 882a63b23907f3ee8a7076838a40af8803aaa055
5
5
  SHA512:
6
- metadata.gz: e5e4b2cde945df61756177b6fc2b1433691896bd7904167787c154b67c959cf8faf353c7f5adbf5f9bcac39b72bcf929bc6a106cf9a9718a5641c36b4f12ede7
7
- data.tar.gz: b18feb589c8435dd0061775a26d4847dbf4e084e72956ef06e438828700339235e158d38f7157be04d6e4748501014c2c26cc27a9005eb5c35c3b090fe32a2c2
6
+ metadata.gz: b4a4748f5d127153eecd3eba0ade49273c1b253929e3cf57b74b8789d68461192c866b1ef85c97e2dffdda5250b0d97e50719388369c0d365783bdf235767d3d
7
+ data.tar.gz: a7aadcf9bbe904443c0a4ec9621d96209d40c2ac52ffd35a9588dccc8a90db1e50a09d17bbc66c78a5dde4bc9061b1cc8ca0d14af69f4b66c36f4aeba53bff89
data/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # edge
2
+
3
+ * Add `Rails.application.config.opal` which accepts:
4
+ - method_missing: `<Boolean>` (default: `true`)
5
+ - optimized_operators: `<Boolean>` (default: `true`)
6
+ - arity_check: `<Boolean>` (default: `false`)
7
+ - const_missing: `<Boolean>` (default: `true`)
8
+
9
+ * Add the Changelog
10
+
11
+ # 0.3.8 2013-05-07
12
+
13
+ * Add `opal/rails` alongside to `opal-rails` for older bundlers autorequire
14
+
15
+
16
+ # 0.3.7 2013-05-04
17
+
18
+ * Rails 4.0.0 support
19
+ * Add `opal_ujs`, now it's possible to use Opal for new Rails apps: `rails new <app-name> -j opal`
20
+ * Updated README examples
21
+
data/README.md CHANGED
@@ -2,8 +2,9 @@
2
2
 
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
+ [![Gem Version](https://badge.fury.io/rb/opal-rails.png)](http://badge.fury.io/rb/opal-rails)
5
6
 
6
- _Rails (3.2+, 4.0) bindings for [Opal Ruby](http://opalrb.org) engine._
7
+ _Rails (3.2+, 4.0) bindings for [Opal Ruby](http://opalrb.org) engine. ([Changelog](https://github.com/opal/opal-rails/blob/master/CHANGELOG.md))_
7
8
 
8
9
 
9
10
 
@@ -22,6 +23,29 @@ rails new <app-name> --javascript=opal
22
23
  ```
23
24
 
24
25
 
26
+ ### Configuration
27
+
28
+ Add your configuration in `config/application.rb` with the following contents:
29
+
30
+ ```ruby
31
+ module MyApp
32
+ class Application < Rails::Application
33
+ # These are the available options with their default value:
34
+ config.opal.method_missing = true
35
+ config.opal.optimized_operators = true
36
+ config.opal.arity_check = false
37
+ config.opal.const_missing = true
38
+ end
39
+ end
40
+ ```
41
+
42
+
43
+ ### Gotchas
44
+
45
+ After changing the version of the `opal` gem (e.g. via `bundle update opal`) or any configuration flag **you should trash the `#{Rails.root}/tmp/cache/assets` folder**, otherwise you could see a cached source compiled before the change.
46
+
47
+
48
+
25
49
  ## Usage
26
50
 
27
51
 
@@ -0,0 +1,18 @@
1
+ require 'opal'
2
+
3
+ class << Opal
4
+ attr_writer :default_options
5
+ def default_options
6
+ @default_options ||= {}
7
+ end
8
+
9
+ def parse_with_default_options source, options = {}
10
+ parse_without_default_options(source, default_options.merge(options))
11
+ end
12
+
13
+ alias parse_without_default_options parse
14
+ alias parse parse_with_default_options
15
+ end
16
+
17
+
18
+
@@ -1,10 +1,14 @@
1
1
  require 'rails'
2
+ require 'opal/default_options'
2
3
 
3
4
  module Opal
4
5
  module Rails
5
6
  class Engine < ::Rails::Engine
6
7
  config.app_generators.javascript_engine :opal
7
8
 
9
+ config.opal = ActiveSupport::OrderedOptions.new
10
+
11
+
8
12
  # Cache eager_load_paths now, otherwise the assets dir is added
9
13
  # and its .rb files are eagerly loaded.
10
14
  config.eager_load_paths
@@ -17,6 +21,8 @@ module Opal
17
21
  Opal.paths.each do |path|
18
22
  app.assets.append_path path
19
23
  end
24
+
25
+ Opal.default_options = config.opal
20
26
  end
21
27
 
22
28
  end
@@ -1,5 +1,5 @@
1
1
  module Opal
2
2
  module Rails
3
- VERSION = '0.3.8'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
data/opal-rails.gemspec CHANGED
@@ -26,8 +26,8 @@ Gem::Specification.new do |s|
26
26
  s.add_runtime_dependency 'opal-spec', '>= 0.2.15'
27
27
  s.add_runtime_dependency 'jquery-rails'
28
28
 
29
- s.add_development_dependency 'rspec', '~> 2.4'
30
- s.add_development_dependency 'rspec-rails', '~> 2.4'
29
+ s.add_development_dependency 'rspec', '~> 2.13'
30
+ s.add_development_dependency 'rspec-rails', '~> 2.13'
31
31
 
32
32
  s.add_development_dependency 'capybara', '< 2'
33
33
  s.add_development_dependency 'launchy'
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'opal/default_options'
3
+
4
+ describe Opal::Parser do
5
+ let(:default_options) { {:method_missing => false} }
6
+ let(:source) { 'puts "ciao"' }
7
+ before { Opal.default_options = default_options }
8
+
9
+ it 'fetches default options defined in the Opal module' do
10
+ described_class.any_instance.should_receive(:parse).with(source, default_options)
11
+ Opal.parse(source)
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ require 'fileutils'
2
+
3
+ RSpec.configure do |config|
4
+ config.before(:suite) { FileUtils.rmtree(Rails.root.join('tmp/cache/assets')) }
5
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.before { Opal.default_options = nil }
3
+ end
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.8
4
+ version: 0.4.0
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-05-07 00:00:00.000000000 Z
11
+ date: 2013-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal
@@ -92,28 +92,28 @@ dependencies:
92
92
  requirements:
93
93
  - - ~>
94
94
  - !ruby/object:Gem::Version
95
- version: '2.4'
95
+ version: '2.13'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - ~>
101
101
  - !ruby/object:Gem::Version
102
- version: '2.4'
102
+ version: '2.13'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: rspec-rails
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: '2.4'
109
+ version: '2.13'
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - ~>
115
115
  - !ruby/object:Gem::Version
116
- version: '2.4'
116
+ version: '2.13'
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: capybara
119
119
  requirement: !ruby/object:Gem::Requirement
@@ -166,6 +166,7 @@ files:
166
166
  - .gitignore
167
167
  - .rspec
168
168
  - .travis.yml
169
+ - CHANGELOG.md
169
170
  - Gemfile
170
171
  - README.md
171
172
  - Rakefile
@@ -176,6 +177,7 @@ files:
176
177
  - lib/assets/javascripts/opal-spec-runner.js.rb
177
178
  - lib/assets/javascripts/opal_ujs.js.rb
178
179
  - lib/opal-rails.rb
180
+ - lib/opal/default_options.rb
179
181
  - lib/opal/rails.rb
180
182
  - lib/opal/rails/engine.rb
181
183
  - lib/opal/rails/haml_filter.rb
@@ -186,9 +188,12 @@ files:
186
188
  - script/rails
187
189
  - spec/integration/assigns_spec.rb
188
190
  - spec/integration/in_browser_specs_spec.rb
191
+ - spec/opal/default_options_spec.rb
189
192
  - spec/opal/processor_spec.rb
190
193
  - spec/spec_helper.rb
191
194
  - spec/support/capybara.rb
195
+ - spec/support/reset_assets_cache.rb
196
+ - spec/support/reset_default_options.rb
192
197
  - test_app/.gitignore
193
198
  - test_app/Rakefile
194
199
  - test_app/app/assets/images/rails.png
@@ -250,6 +255,9 @@ summary: Rails bindings for opal JS engine
250
255
  test_files:
251
256
  - spec/integration/assigns_spec.rb
252
257
  - spec/integration/in_browser_specs_spec.rb
258
+ - spec/opal/default_options_spec.rb
253
259
  - spec/opal/processor_spec.rb
254
260
  - spec/spec_helper.rb
255
261
  - spec/support/capybara.rb
262
+ - spec/support/reset_assets_cache.rb
263
+ - spec/support/reset_default_options.rb