opal-rails 0.4.0 → 0.5.0.pre

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: 32adae8b04d04337405ba3018e5b863435d5d67d
4
- data.tar.gz: 882a63b23907f3ee8a7076838a40af8803aaa055
3
+ metadata.gz: 06be2a87140ad5dd193bf6e7cf4c604bd73b967b
4
+ data.tar.gz: a1a79d8e9ec0bdc5d9d4affa4f264307be2eeb3c
5
5
  SHA512:
6
- metadata.gz: b4a4748f5d127153eecd3eba0ade49273c1b253929e3cf57b74b8789d68461192c866b1ef85c97e2dffdda5250b0d97e50719388369c0d365783bdf235767d3d
7
- data.tar.gz: a7aadcf9bbe904443c0a4ec9621d96209d40c2ac52ffd35a9588dccc8a90db1e50a09d17bbc66c78a5dde4bc9061b1cc8ca0d14af69f4b66c36f4aeba53bff89
6
+ metadata.gz: 0db0ad35ce410a22e4a334c88fc6b108a380a7ebbbb4fe30df4fa418cae41b8457d5ea4dc1e10900f4c2ad5d1098fd7c37f6f7292f991138f29bc7ad607284ea
7
+ data.tar.gz: 541662e0f82e1852246544e7347a5f566c61c2983fca85060fb401410912d7e2bc04a842fd6c1cf029a364768c56fc802637ac0d8407c240cab16ec8557fc136
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  /.bundle/
2
2
  /log/*.log
3
3
  /pkg/
4
+ /tmp
4
5
  /test_app/db/*.sqlite3
5
6
  /test_app/log/*.log
6
7
  /test_app/tmp/
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
4
  gem 'capybara-webkit' unless ENV['CI']
5
+ gem 'opal', :github => 'opal/opal'
6
+ gem 'opal-jquery', :github => 'opal/opal-jquery'
data/lib/opal/rails.rb CHANGED
@@ -8,3 +8,4 @@ require 'opal/rails/version'
8
8
  require 'opal/rails/haml_filter' if defined?(Haml)
9
9
 
10
10
  require 'jquery-rails'
11
+ require 'opal/sprockets_source_map_header'
@@ -1,5 +1,6 @@
1
1
  require 'rails'
2
- require 'opal/default_options'
2
+ require 'opal/server'
3
+ require 'opal/processor'
3
4
 
4
5
  module Opal
5
6
  module Rails
@@ -13,16 +14,29 @@ module Opal
13
14
  # and its .rb files are eagerly loaded.
14
15
  config.eager_load_paths
15
16
 
16
- initializer 'opal.asset_paths', :after => 'sprockets.environment', :group => :all do |app|
17
- app.config.before_initialize do
18
- app.config.eager_load_paths = app.config.eager_load_paths.dup - Dir["#{app.root}/app/{assets,views}"]
19
- end
17
+ config.before_initialize do |app|
18
+ app.config.eager_load_paths = app.config.eager_load_paths.dup - Dir["#{app.root}/app/{assets,views}"]
19
+ end
20
20
 
21
+ initializer 'opal.asset_paths', :after => 'sprockets.environment', :group => :all do |app|
21
22
  Opal.paths.each do |path|
22
23
  app.assets.append_path path
23
24
  end
25
+ end
24
26
 
25
- Opal.default_options = config.opal
27
+ config.after_initialize do |app|
28
+ config.opal.each_pair do |key, value|
29
+ key = "#{key}="
30
+ Opal::Processor.send(key, value) if Opal::Processor.respond_to? key
31
+ end
32
+
33
+ config = app.config
34
+ maps_app = Opal::SourceMapServer.new(app.assets)
35
+
36
+ app.routes.prepend do
37
+ mount maps_app => maps_app.prefix
38
+ get '/opal_spec' => 'opal_spec#run'
39
+ end
26
40
  end
27
41
 
28
42
  end
@@ -1,5 +1,5 @@
1
1
  module Opal
2
2
  module Rails
3
- VERSION = '0.4.0'
3
+ VERSION = '0.5.0.pre'
4
4
  end
5
5
  end
@@ -0,0 +1,21 @@
1
+ require 'sprockets/server'
2
+
3
+ module Sprockets
4
+ module Server
5
+
6
+ # Adds the source map header to all sprocket responses for assets
7
+ # with a .rb or .opal extension in the extension chain.
8
+ def headers_with_opal_source_maps(env, asset, length)
9
+ headers_without_opal_source_maps(env, asset, length).tap do |headers|
10
+ if asset.pathname.to_s =~ /\.(rb|opal)\b/
11
+ headers['X-SourceMap'] = '/__opal_source_maps__/'+asset.logical_path + '.map'
12
+ end
13
+ end
14
+ end
15
+
16
+ # Poor man's alias_method_chain :)
17
+ alias headers_without_opal_source_maps headers
18
+ alias headers headers_with_opal_source_maps
19
+
20
+ end
21
+ end
data/opal-rails.gemspec CHANGED
@@ -19,7 +19,7 @@ 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.43'
22
+ s.add_runtime_dependency 'opal', '~> 0.4.1'
23
23
 
24
24
  s.add_runtime_dependency 'rails', '>= 3.2.13', '< 5.0'
25
25
  s.add_runtime_dependency 'opal-jquery', '>= 0.0.8'
@@ -1,9 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Opal::Processor do
4
- # Preparing a context that responds to #logical_path and #require_asset
5
- # should't be necessary:
6
- let(:_context) { double('_context', :logical_path => 'asdf.js.rb' ) }
4
+ let(:pathname) { Pathname('/Code/app/mylib/opal/asdf.rb') }
5
+ let(:_context) do
6
+ double('_context', :logical_path => 'asdf.js.rb', :pathname => pathname)
7
+ end
7
8
 
8
9
  it "is registered for '.opal' files" do
9
10
  Tilt['test.opal'].should eq(Opal::Processor)
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'opal/source_map'
3
+
4
+ describe Opal::SourceMap do
5
+ let(:assets) { Opal::Environment.new }
6
+ let(:asset) { assets['opal'] }
7
+ let(:source) { asset.to_s }
8
+ let(:map) { described_class.new(source, asset.pathname.to_s) }
9
+
10
+ it 'source has the magic comments' do
11
+ described_class::FILE_REGEXP.should match(source)
12
+ described_class::LINE_REGEXP.should match(source)
13
+ end
14
+
15
+ it 'does not blow while generating the map' do
16
+ expect { map.as_json }.not_to raise_exception
17
+ end
18
+ end
@@ -1,5 +1,5 @@
1
1
  require 'fileutils'
2
2
 
3
3
  RSpec.configure do |config|
4
- config.before(:suite) { FileUtils.rmtree(Rails.root.join('tmp/cache/assets')) }
4
+ config.before(:suite) { FileUtils.rmtree(Rails.root.join('tmp/cache/assets').to_s) }
5
5
  end
@@ -10,6 +10,6 @@
10
10
  // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
11
  // GO AFTER THE REQUIRES BELOW.
12
12
  //
13
- //= require jquery
14
- //= require jquery_ujs
15
- //= require_tree .
13
+ //= require opal
14
+ //= require opal_ujs
15
+ //= require opal-parser
@@ -0,0 +1,3 @@
1
+ <script type="text/ruby">
2
+ raise 'pippo'
3
+ </script>
@@ -5,4 +5,4 @@ return {
5
5
  hash_var: @hash_var,
6
6
  object_var: @object_var,
7
7
  local_var: local_var
8
- }.to_native
8
+ }.to_n
@@ -1,3 +1,7 @@
1
+ require 'fileutils'
2
+ # Clear assets cache to avoid false errors
3
+ FileUtils.rmtree(File.expand_path('../../tmp/cache/assets'))
4
+
1
5
  require File.expand_path('../boot', __FILE__)
2
6
 
3
7
  # Pick the frameworks you want:
@@ -1,60 +1,4 @@
1
1
  TestApp::Application.routes.draw do
2
2
  get 'application/with_assignments' => 'application#with_assignments'
3
-
4
- # The priority is based upon order of creation:
5
- # first created -> highest priority.
6
-
7
- # Sample of regular route:
8
- # match 'products/:id' => 'catalog#view'
9
- # Keep in mind you can assign values other than :controller and :action
10
-
11
- # Sample of named route:
12
- # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
13
- # This route can be invoked with purchase_url(:id => product.id)
14
-
15
- # Sample resource route (maps HTTP verbs to controller actions automatically):
16
- # resources :products
17
-
18
- # Sample resource route with options:
19
- # resources :products do
20
- # member do
21
- # get 'short'
22
- # post 'toggle'
23
- # end
24
- #
25
- # collection do
26
- # get 'sold'
27
- # end
28
- # end
29
-
30
- # Sample resource route with sub-resources:
31
- # resources :products do
32
- # resources :comments, :sales
33
- # resource :seller
34
- # end
35
-
36
- # Sample resource route with more complex sub-resources
37
- # resources :products do
38
- # resources :comments
39
- # resources :sales do
40
- # get 'recent', :on => :collection
41
- # end
42
- # end
43
-
44
- # Sample resource route within a namespace:
45
- # namespace :admin do
46
- # # Directs /admin/products/* to Admin::ProductsController
47
- # # (app/controllers/admin/products_controller.rb)
48
- # resources :products
49
- # end
50
-
51
- # You can have the root of your site routed with "root"
52
- # just remember to delete public/index.html.
53
- # root :to => 'welcome#index'
54
-
55
- # See how all your routes lay out with "rake routes"
56
-
57
- # This is a legacy wild controller route that's not recommended for RESTful applications.
58
- # Note: This route will make all actions in every controller accessible via GET requests.
59
- # match ':controller(/:action(/:id))(.:format)'
3
+ root :to => 'application#index'
60
4
  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.4.0
4
+ version: 0.5.0.pre
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-06-03 00:00:00.000000000 Z
11
+ date: 2013-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.43
19
+ version: 0.4.1
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.43
26
+ version: 0.4.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -173,27 +173,25 @@ files:
173
173
  - app/controllers/opal_spec_controller.rb
174
174
  - app/views/layouts/opal_spec.html.erb
175
175
  - app/views/opal_spec/run.html.erb
176
- - config/routes.rb
177
176
  - lib/assets/javascripts/opal-spec-runner.js.rb
178
177
  - lib/assets/javascripts/opal_ujs.js.rb
179
178
  - lib/opal-rails.rb
180
- - lib/opal/default_options.rb
181
179
  - lib/opal/rails.rb
182
180
  - lib/opal/rails/engine.rb
183
181
  - lib/opal/rails/haml_filter.rb
184
182
  - lib/opal/rails/template_handler.rb
185
183
  - lib/opal/rails/version.rb
184
+ - lib/opal/sprockets_source_map_header.rb
186
185
  - lib/tasks/opal-rails_tasks.rake
187
186
  - opal-rails.gemspec
188
187
  - script/rails
189
188
  - spec/integration/assigns_spec.rb
190
189
  - spec/integration/in_browser_specs_spec.rb
191
- - spec/opal/default_options_spec.rb
192
190
  - spec/opal/processor_spec.rb
191
+ - spec/opal/source_map_spec.rb
193
192
  - spec/spec_helper.rb
194
193
  - spec/support/capybara.rb
195
194
  - spec/support/reset_assets_cache.rb
196
- - spec/support/reset_default_options.rb
197
195
  - test_app/.gitignore
198
196
  - test_app/Rakefile
199
197
  - test_app/app/assets/images/rails.png
@@ -202,6 +200,7 @@ files:
202
200
  - test_app/app/assets/javascripts/spec/example_spec.js.rb
203
201
  - test_app/app/assets/stylesheets/application.css
204
202
  - test_app/app/controllers/application_controller.rb
203
+ - test_app/app/views/application/index.html.erb
205
204
  - test_app/app/views/application/with_assignments.js.opal
206
205
  - test_app/app/views/layouts/application.html.erb
207
206
  - test_app/config.ru
@@ -243,9 +242,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
243
242
  version: '0'
244
243
  required_rubygems_version: !ruby/object:Gem::Requirement
245
244
  requirements:
246
- - - '>='
245
+ - - '>'
247
246
  - !ruby/object:Gem::Version
248
- version: '0'
247
+ version: 1.3.1
249
248
  requirements: []
250
249
  rubyforge_project: opal-rails
251
250
  rubygems_version: 2.0.3
@@ -255,9 +254,8 @@ summary: Rails bindings for opal JS engine
255
254
  test_files:
256
255
  - spec/integration/assigns_spec.rb
257
256
  - spec/integration/in_browser_specs_spec.rb
258
- - spec/opal/default_options_spec.rb
259
257
  - spec/opal/processor_spec.rb
258
+ - spec/opal/source_map_spec.rb
260
259
  - spec/spec_helper.rb
261
260
  - spec/support/capybara.rb
262
261
  - spec/support/reset_assets_cache.rb
263
- - spec/support/reset_default_options.rb
data/config/routes.rb DELETED
@@ -1,3 +0,0 @@
1
- Rails.application.routes.draw do
2
- get '/opal_spec' => 'opal_spec#run' if %w[test development].include? Rails.env
3
- end
@@ -1,18 +0,0 @@
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,13 +0,0 @@
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
@@ -1,3 +0,0 @@
1
- RSpec.configure do |config|
2
- config.before { Opal.default_options = nil }
3
- end