opal-rails 0.5.2 → 0.6.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: 9b22d76807c1341981c89a5562ac3c878c09d391
4
- data.tar.gz: 2b6cce5182f8b9db817e323ef200cdf612ce7e8d
3
+ metadata.gz: ac0ced6ff2b710322ffff46ae1da74a727f29305
4
+ data.tar.gz: b1ac2f475561f7188b78f8e4db208df8062dc43b
5
5
  SHA512:
6
- metadata.gz: 403229e9749a59d2ea8820f1d37a919fbad0fcfc432cd9154021d5140f1597457cd19fc4b50cf531375ed6c9ac9cd406c451996ef533dde6c9cc6ae9a0eda2f3
7
- data.tar.gz: 211278574a80eb006da1bb5148e31caa9b6043db3b63f5eb62afcaef9506c522fce4f7a31a8c1990348ed3c52bc632eeeddf9f81f8b8571258c7a1ae53d28827
6
+ metadata.gz: 354fe4c691ed9c6d49b83b439e91fd00b749cf5d6ae234757bfc19cf953a080fe8775405160e8a73755840829256a6cda4419cc7cadad1f6cba489fd9b1b0de6
7
+ data.tar.gz: 73ca176afd17d8e9f6b9a80dd1c13d3e68a24437774c90f3f431da887feaaef6bea313d8417bb9cf35d0466cb06e7f0e5a69d7c68a27ad0ee8e13e30e5129e35
data/Gemfile CHANGED
@@ -4,9 +4,10 @@ gemspec
4
4
  gem 'capybara-webkit' unless ENV['CI']
5
5
  # gem 'opal', :github => 'opal/opal'
6
6
  # gem 'opal-jquery', :github => 'opal/opal-jquery'
7
- # gem 'opal-spec', :github => 'opal/opal-spec'
7
+ # gem 'opal-rspec', :github => 'opal/opal-rspec'
8
8
 
9
- if RUBY_VERSION.to_f == 1.8
9
+ platform :ruby_18 do
10
10
  gem 'nokogiri', '< 1.6'
11
11
  gem 'rails', '< 4.0'
12
+ gem 'rubyzip', '< 1'
12
13
  end
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <title>Opal Spec Runner</title>
6
- <%= javascript_include_tag 'opal-spec-runner' %>
6
+ <%= javascript_include_tag 'opal-rspec-runner' %>
7
7
  <%= javascript_include_tag *spec_files.map { |f| "spec/#{f}"} %>
8
8
  <style>
9
9
  body { font-family: sans-serif; }
@@ -1,9 +1,9 @@
1
1
  require 'jquery'
2
2
 
3
3
  require 'opal'
4
- require 'opal-spec'
4
+ require 'opal-rspec'
5
5
  require 'opal-jquery'
6
6
 
7
7
  Document.ready? do
8
- Opal::Spec::Runner.new.run
8
+ Opal::RSpec::Runner.new.run
9
9
  end
@@ -27,16 +27,18 @@ module Opal
27
27
  config.after_initialize do |app|
28
28
  require 'opal/rails/haml_filter' if defined?(Haml)
29
29
 
30
+ config = app.config
30
31
  config.opal.each_pair do |key, value|
31
32
  key = "#{key}="
32
33
  Opal::Processor.send(key, value) if Opal::Processor.respond_to? key
33
34
  end
34
35
 
35
- config = app.config
36
- maps_app = Opal::SourceMapServer.new(app.assets)
37
-
38
36
  app.routes.prepend do
39
- mount maps_app => maps_app.prefix
37
+ if config.opal.source_map_enabled
38
+ maps_app = Opal::SourceMapServer.new(app.assets)
39
+ mount maps_app => maps_app.prefix
40
+ end
41
+
40
42
  get '/opal_spec' => 'opal_spec#run'
41
43
  end
42
44
  end
@@ -2,17 +2,17 @@ module Haml::Filters::Opal
2
2
  include Haml::Filters::Base
3
3
 
4
4
  def render_with_options ruby, options
5
- text = ::Opal.parse(ruby)
6
-
5
+ text = ::Opal.compile(ruby)
6
+
7
7
  if options[:format] == :html5
8
8
  type = ''
9
9
  else
10
10
  type = " type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}"
11
11
  end
12
-
12
+
13
13
  text.rstrip!
14
14
  text.gsub!("\n", "\n ")
15
-
15
+
16
16
  <<HTML
17
17
  <script#{type}>
18
18
  //<![CDATA[
@@ -10,7 +10,7 @@ module Opal
10
10
  def call(template)
11
11
  escaped = template.source.gsub(':', '\:')
12
12
  string = '%q:' + escaped + ':'
13
- "Opal.parse('Object.new.instance_eval {' << #{assigns} << #{local_assigns} << #{string} << '}')"
13
+ "Opal.compile('Object.new.instance_eval {' << #{assigns} << #{local_assigns} << #{string} << '}')"
14
14
  end
15
15
 
16
16
  private
@@ -1,5 +1,5 @@
1
1
  module Opal
2
2
  module Rails
3
- VERSION = '0.5.2'
3
+ VERSION = '0.6.0'
4
4
  end
5
5
  end
data/lib/opal/rails.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'opal'
2
2
  require 'opal-jquery'
3
3
  require 'opal-activesupport'
4
- require 'opal-spec'
4
+ require 'opal-rspec'
5
5
 
6
6
  require 'opal/rails/engine'
7
7
  require 'opal/rails/template_handler'
@@ -4,7 +4,7 @@ Opal::Spec::RakeTask.new('opal:spec' => :environment) do |server|
4
4
  require 'tempfile'
5
5
 
6
6
  asset_paths = Opal.paths + Rails.configuration.assets.paths.to_a
7
- tempfile = Tempfile.new(['opal-spec', '.js.rb'])
7
+ tempfile = Tempfile.new(['opal-rspec', '.js.rb'])
8
8
 
9
9
  server.sprockets.clear_paths
10
10
  asset_paths << File.dirname(tempfile.path)
@@ -13,7 +13,7 @@ Opal::Spec::RakeTask.new('opal:spec' => :environment) do |server|
13
13
  asset_paths.each { |path| server.append_path path }
14
14
 
15
15
  required_assets = ['opal']
16
- required_assets << 'opal-spec-runner'
16
+ required_assets << 'opal-rspec-runner'
17
17
 
18
18
  asset_paths.each do |path|
19
19
  Dir["#{path}/spec/**_spec.js.{opal,rb}"].each do |spec|
data/opal-rails.gemspec CHANGED
@@ -19,13 +19,13 @@ 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.4.4'
23
- s.add_runtime_dependency 'opal-sprockets', '~> 0.2.0'
22
+ s.add_runtime_dependency 'opal', '~> 0.5.0'
23
+ s.add_runtime_dependency 'opal-sprockets', '~> 0.3.0'
24
24
 
25
25
  s.add_runtime_dependency 'rails', '>= 3.2.13', '< 5.0'
26
- s.add_runtime_dependency 'opal-jquery', '>= 0.0.8'
27
- s.add_runtime_dependency 'opal-spec', '~> 0.3.1'
28
- s.add_runtime_dependency 'opal-activesupport'
26
+ s.add_runtime_dependency 'opal-jquery', '>= 0.1.0'
27
+ s.add_runtime_dependency 'opal-rspec'
28
+ s.add_runtime_dependency 'opal-activesupport', '>= 0.0.5'
29
29
  s.add_runtime_dependency 'jquery-rails'
30
30
 
31
31
  s.add_development_dependency 'rspec', '~> 2.13'
@@ -2,17 +2,23 @@ require 'spec_helper'
2
2
  require 'opal/source_map'
3
3
 
4
4
  describe Opal::SourceMap do
5
- before { get '/assets/source_map_example.js' }
5
+ before do
6
+ expect(Rails.application.config.opal.source_map_enabled).to be_true
7
+ get '/assets/source_map_example.js'
8
+ end
9
+
10
+ let(:map_url) { extract_map_url(response) }
6
11
 
7
12
  let(:map_body) do
8
- get response.headers['X-SourceMap']
13
+ get map_url
14
+ raise "#{response.status}\n\n#{response.body}" unless response.success?
9
15
  response.body
10
16
  end
11
17
 
12
18
  let(:map) { JSON.parse(map_body) }
13
19
 
14
- it 'has the source map header' do
15
- expect(response.headers['X-SourceMap']).to be_present
20
+ it 'has the source map header or magic comment' do
21
+ expect(extract_map_url(response)).to be_present
16
22
  end
17
23
 
18
24
  it "the map is a valid json" do
@@ -21,10 +27,9 @@ describe Opal::SourceMap do
21
27
  end
22
28
  end
23
29
 
24
- it "points to a file on the disk" do
25
- path = map['sources'].first
26
- pathname = Pathname(path.gsub(%r{^file\://}, ''))
27
- expect(pathname.exist?).to be_true
30
+ def extract_map_url response
31
+ response.headers['X-SourceMap'] or
32
+ response.body.scan(%r{^//@ sourceMappingURL=([^\n]+)}).flatten.first.strip
28
33
  end
29
34
 
30
35
  end
@@ -68,5 +68,8 @@ module TestApp
68
68
 
69
69
  # Version of your assets, change this if you want to expire all your assets
70
70
  config.assets.version = '1.0'
71
+
72
+ # Disabled by default, we need it for tests
73
+ config.opal.source_map_enabled = true
71
74
  end
72
75
  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.5.2
4
+ version: 0.6.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-09-05 00:00:00.000000000 Z
11
+ date: 2013-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 0.4.4
19
+ version: 0.5.0
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.4.4
26
+ version: 0.5.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: opal-sprockets
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.0
33
+ version: 0.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: 0.2.0
40
+ version: 0.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rails
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -64,42 +64,42 @@ dependencies:
64
64
  requirements:
65
65
  - - '>='
66
66
  - !ruby/object:Gem::Version
67
- version: 0.0.8
67
+ version: 0.1.0
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - '>='
73
73
  - !ruby/object:Gem::Version
74
- version: 0.0.8
74
+ version: 0.1.0
75
75
  - !ruby/object:Gem::Dependency
76
- name: opal-spec
76
+ name: opal-rspec
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ~>
79
+ - - '>='
80
80
  - !ruby/object:Gem::Version
81
- version: 0.3.1
81
+ version: '0'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - ~>
86
+ - - '>='
87
87
  - !ruby/object:Gem::Version
88
- version: 0.3.1
88
+ version: '0'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: opal-activesupport
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - '>='
94
94
  - !ruby/object:Gem::Version
95
- version: '0'
95
+ version: 0.0.5
96
96
  type: :runtime
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: '0'
102
+ version: 0.0.5
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: jquery-rails
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -201,7 +201,7 @@ files:
201
201
  - app/controllers/opal_spec_controller.rb
202
202
  - app/views/layouts/opal_spec.html.erb
203
203
  - app/views/opal_spec/run.html.erb
204
- - lib/assets/javascripts/opal-spec-runner.js.rb
204
+ - lib/assets/javascripts/opal-rspec-runner.js.rb
205
205
  - lib/assets/javascripts/opal_ujs.js.rb
206
206
  - lib/opal-rails.rb
207
207
  - lib/opal/rails.rb
@@ -275,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
275
275
  version: '0'
276
276
  requirements: []
277
277
  rubyforge_project: opal-rails
278
- rubygems_version: 2.0.3
278
+ rubygems_version: 2.1.2
279
279
  signing_key:
280
280
  specification_version: 4
281
281
  summary: Rails bindings for opal JS engine