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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile +2 -0
- data/lib/opal/rails.rb +1 -0
- data/lib/opal/rails/engine.rb +20 -6
- data/lib/opal/rails/version.rb +1 -1
- data/lib/opal/sprockets_source_map_header.rb +21 -0
- data/opal-rails.gemspec +1 -1
- data/spec/opal/processor_spec.rb +4 -3
- data/spec/opal/source_map_spec.rb +18 -0
- data/spec/support/reset_assets_cache.rb +1 -1
- data/test_app/app/assets/javascripts/application.js +3 -3
- data/test_app/app/views/application/index.html.erb +3 -0
- data/test_app/app/views/application/with_assignments.js.opal +1 -1
- data/test_app/config/application.rb +4 -0
- data/test_app/config/routes.rb +1 -57
- metadata +10 -12
- data/config/routes.rb +0 -3
- data/lib/opal/default_options.rb +0 -18
- data/spec/opal/default_options_spec.rb +0 -13
- data/spec/support/reset_default_options.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06be2a87140ad5dd193bf6e7cf4c604bd73b967b
|
4
|
+
data.tar.gz: a1a79d8e9ec0bdc5d9d4affa4f264307be2eeb3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0db0ad35ce410a22e4a334c88fc6b108a380a7ebbbb4fe30df4fa418cae41b8457d5ea4dc1e10900f4c2ad5d1098fd7c37f6f7292f991138f29bc7ad607284ea
|
7
|
+
data.tar.gz: 541662e0f82e1852246544e7347a5f566c61c2983fca85060fb401410912d7e2bc04a842fd6c1cf029a364768c56fc802637ac0d8407c240cab16ec8557fc136
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/lib/opal/rails.rb
CHANGED
data/lib/opal/rails/engine.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rails'
|
2
|
-
require 'opal/
|
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
|
-
|
17
|
-
app.config.
|
18
|
-
|
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
|
-
|
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
|
data/lib/opal/rails/version.rb
CHANGED
@@ -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.
|
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'
|
data/spec/opal/processor_spec.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Opal::Processor do
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
@@ -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
|
14
|
-
//= require
|
15
|
-
//=
|
13
|
+
//= require opal
|
14
|
+
//= require opal_ujs
|
15
|
+
//= require opal-parser
|
data/test_app/config/routes.rb
CHANGED
@@ -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
|
+
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-
|
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.
|
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.
|
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:
|
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
data/lib/opal/default_options.rb
DELETED
@@ -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
|