opal 0.3.35 → 0.3.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -1,19 +1,12 @@
1
1
  source :rubygems
2
2
  gemspec
3
3
 
4
- gem "rake"
4
+ gem 'rake'
5
5
 
6
- # for building opal.js
7
- group :building do
8
- gem "sprockets"
9
- end
6
+ gem 'sprockets'
7
+ gem 'opal-spec', '~> 0.2.8'
10
8
 
11
9
  # for rebuilding grammar.rb from grammar.y
12
10
  group :grammar do
13
- gem "racc"
14
- end
15
-
16
- # running tests on command line
17
- group :testing do
18
- gem 'opal-spec'
19
- end
11
+ gem 'racc'
12
+ end
data/README.md CHANGED
@@ -14,16 +14,14 @@ See the website, [http://opalrb.org](http://opalrb.org).
14
14
 
15
15
  ## Running tests
16
16
 
17
- Build the runtime, tests and dependencies, and run the tests with:
17
+ Tests can be run with phantomjs using:
18
18
 
19
19
  ```
20
- rake
20
+ $ rake
21
21
  ```
22
22
 
23
- You can just build opal using `rake opal`.
24
-
25
- Alternatively, after building, you can open `spec/index.html` in any
26
- web browser.
23
+ Alternatively, you can just load up a rack instance using `rackup`, and
24
+ visit `http://localhost:9292/` in any web browser.
27
25
 
28
26
  ## Code Overview
29
27
 
data/Rakefile CHANGED
@@ -1,54 +1,15 @@
1
- require 'bundler/setup'
2
- require 'opal-spec'
1
+ require 'bundler'
2
+ Bundler.require
3
3
 
4
- desc "Build opal.js into ./build"
5
- task :opal => [:dir] do
6
- File.open('build/opal.js', 'w+') { |o| o.puts Opal.process('opal') }
7
- end
8
-
9
- desc "Build opal-parser.js into ./build"
10
- task :parser => [:dir] do
11
- File.open('build/opal-parser.js', 'w+') { |o| o.puts Opal.process('opal-parser') }
12
- end
13
-
14
- desc "Build specs ready to run"
15
- task :build_specs => [:dir] do
16
- Opal.append_path File.join(File.dirname(__FILE__), 'spec')
17
-
18
- File.open('build/core_spec.js', 'w+') { |o| o.puts Opal.process('core_spec') }
19
- File.open('build/grammar_spec.js', 'w+') { |o| o.puts Opal.process('grammar_spec') }
20
- File.open('build/specs.js', 'w+') { |o| o.puts Opal.process('spec_helper') }
21
- end
22
-
23
- task :default => [:build_specs, :parser, :test]
24
-
25
- desc "Run opal specs through phantomjs"
26
- task :test do
27
- OpalSpec.runner
28
- end
29
-
30
- task :dir do
31
- require 'fileutils'
32
- FileUtils.mkdir_p 'build'
33
- end
34
-
35
- desc "opal.min.js and opal-parser.min.js"
36
- task :min do
37
- %w[opal opal-parser].each do |file|
38
- puts " * #{file}.min.js"
39
- File.open("build/#{file}.min.js", "w+") do |o|
40
- o.puts uglify(File.read "build/#{file}.js")
41
- end
42
- end
43
- end
4
+ require 'opal/spec/rake_task'
5
+ Opal::Spec::RakeTask.new(:default)
44
6
 
45
7
  desc "Check file sizes for opal.js runtime"
46
8
  task :sizes do
47
- o = File.read 'build/opal.js'
9
+ o = Opal::Environment.new['opal'].to_s
48
10
  m = uglify o
49
11
  g = gzip m
50
12
 
51
- puts "opal.js:"
52
13
  puts "development: #{o.size}, minified: #{m.size}, gzipped: #{g.size}"
53
14
  end
54
15
 
data/config.ru ADDED
@@ -0,0 +1,26 @@
1
+ require 'bundler'
2
+ Bundler.require
3
+
4
+ html = <<HTML
5
+ <!DOCTYPE html>
6
+ <html>
7
+ <head>
8
+ <title>Opal corelib and runtime specs</title>
9
+ </head>
10
+ <body>
11
+ <script type="text/javascript" src="/assets/autorun.js"></script>
12
+ </body>
13
+ </html>
14
+ HTML
15
+
16
+ map '/assets' do
17
+ env = Opal::Environment.new
18
+ env.append_path 'spec'
19
+ run env
20
+ end
21
+
22
+ map '/' do
23
+ run lambda { |env|
24
+ [200, {'Content-Type' => 'text/html'}, [html]]
25
+ }
26
+ end
@@ -1,22 +1,21 @@
1
- #= require_self
2
- #= require opal/class
3
- #= require opal/basic_object
4
- #= require opal/kernel
5
- #= require opal/nil_class
6
- #= require opal/boolean
7
- #= require opal/error
8
- #= require opal/regexp
9
- #= require opal/comparable
10
- #= require opal/enumerable
11
- #= require opal/array
12
- #= require opal/hash
13
- #= require opal/string
14
- #= require opal/numeric
15
- #= require opal/proc
16
- #= require opal/range
17
- #= require opal/time
18
- #= require opal/date
19
- #= require opal/json
1
+ require 'opal/class'
2
+ require 'opal/basic_object'
3
+ require 'opal/kernel'
4
+ require 'opal/nil_class'
5
+ require 'opal/boolean'
6
+ require 'opal/error'
7
+ require 'opal/regexp'
8
+ require 'opal/comparable'
9
+ require 'opal/enumerable'
10
+ require 'opal/array'
11
+ require 'opal/hash'
12
+ require 'opal/string'
13
+ require 'opal/numeric'
14
+ require 'opal/proc'
15
+ require 'opal/range'
16
+ require 'opal/time'
17
+ require 'opal/date'
18
+ require 'opal/json'
20
19
 
21
20
  # regexp matches
22
21
  $~ = nil
data/lib/opal.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'opal/parser'
2
2
  require 'opal/processor'
3
+ require 'opal/environment'
3
4
  require 'opal/version'
4
5
 
5
6
  # Opal is a ruby to javascript compiler, with a runtime for running
@@ -30,12 +31,4 @@ module Opal
30
31
  def self.paths
31
32
  @paths ||= [Opal.core_dir]
32
33
  end
33
-
34
- # Build ruby/opal file at fname
35
- def self.process(fname)
36
- env = Sprockets::Environment.new
37
- paths.each { |p| env.append_path p }
38
-
39
- env[fname].to_s
40
- end
41
34
  end
@@ -0,0 +1,12 @@
1
+ require 'opal'
2
+ require 'sprockets'
3
+
4
+ module Opal
5
+ class Environment < Sprockets::Environment
6
+ def initialize(*)
7
+ super
8
+
9
+ Opal.paths.each { |path| append_path path }
10
+ end
11
+ end
12
+ end
@@ -17,8 +17,12 @@ module Opal
17
17
  # ...
18
18
  end
19
19
 
20
- def evaluate(scope, locals, &block)
21
- Opal.parse data
20
+ def evaluate(context, locals, &block)
21
+ parser = Opal::Parser.new
22
+ result = parser.parse data
23
+
24
+ parser.requires.each { |r| context.require_asset r }
25
+ result
22
26
  end
23
27
  end
24
28
  end
data/lib/opal/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Opal
2
- VERSION = '0.3.35'
2
+ VERSION = '0.3.36'
3
3
  end
data/spec/autorun.rb ADDED
@@ -0,0 +1,3 @@
1
+ #= require opal
2
+ #= require opal-spec
3
+ #= require_tree .
@@ -1,11 +1,11 @@
1
1
  describe "Array#shuffle" do
2
2
  it "returns an array mixed up" do
3
3
  ary = [1, 2, 3, 4, 5]
4
- [1, 2, 3, 4, 5].shuffle.should_not == ary
4
+ [1, 2, 3, 4, 5].shuffle.size.should eq(ary.size)
5
5
  end
6
6
 
7
7
  it "returns an array mixed up with UTF-8 characters" do
8
8
  ary = ["á", "é", "à", "ñÑ", "¥ØŁØ"]
9
- ["á", "é", "à", "ñÑ", "¥ØŁØ"].shuffle.should_not == ary
9
+ ["á", "é", "à", "ñÑ", "¥ØŁØ"].shuffle.size.should eq(ary.size)
10
10
  end
11
- end
11
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  #= require opal
2
+ #= require opal-parser
2
3
  #= require opal-spec
3
4
 
4
5
  module Kernel
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.35
4
+ version: 0.3.36
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-05 00:00:00.000000000Z
12
+ date: 2013-02-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets
16
- requirement: &70122599320160 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70122599320160
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  description: Ruby runtime and core library for javascript.
26
31
  email: adam.beynon@gmail.com
27
32
  executables:
@@ -37,6 +42,7 @@ files:
37
42
  - README.md
38
43
  - Rakefile
39
44
  - bin/opal
45
+ - config.ru
40
46
  - lib/assets/javascripts/opal-parser.js.erb
41
47
  - lib/assets/javascripts/opal.js.erb
42
48
  - lib/assets/javascripts/opal/array.rb
@@ -61,6 +67,7 @@ files:
61
67
  - lib/assets/javascripts/opal/strscan.rb
62
68
  - lib/assets/javascripts/opal/time.rb
63
69
  - lib/opal.rb
70
+ - lib/opal/environment.rb
64
71
  - lib/opal/grammar.rb
65
72
  - lib/opal/grammar.y
66
73
  - lib/opal/lexer.rb
@@ -69,7 +76,7 @@ files:
69
76
  - lib/opal/scope.rb
70
77
  - lib/opal/version.rb
71
78
  - opal.gemspec
72
- - spec/core.html
79
+ - spec/autorun.rb
73
80
  - spec/core/array/allocate_spec.rb
74
81
  - spec/core/array/append_spec.rb
75
82
  - spec/core/array/assoc_spec.rb
@@ -357,8 +364,6 @@ files:
357
364
  - spec/core/time/month_spec.rb
358
365
  - spec/core/time/now_spec.rb
359
366
  - spec/core/time/saturday_spec.rb
360
- - spec/core_spec.rb
361
- - spec/grammar.html
362
367
  - spec/grammar/alias_spec.rb
363
368
  - spec/grammar/and_spec.rb
364
369
  - spec/grammar/array_spec.rb
@@ -404,8 +409,6 @@ files:
404
409
  - spec/grammar/while_spec.rb
405
410
  - spec/grammar/xstr_spec.rb
406
411
  - spec/grammar/yield_spec.rb
407
- - spec/grammar_spec.rb
408
- - spec/index.html
409
412
  - spec/language/alias_spec.rb
410
413
  - spec/language/and_spec.rb
411
414
  - spec/language/array_spec.rb
@@ -458,12 +461,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
458
461
  version: '0'
459
462
  requirements: []
460
463
  rubyforge_project:
461
- rubygems_version: 1.8.11
464
+ rubygems_version: 1.8.23
462
465
  signing_key:
463
466
  specification_version: 3
464
467
  summary: Ruby runtime and core library for javascript
465
468
  test_files:
466
- - spec/core.html
469
+ - spec/autorun.rb
467
470
  - spec/core/array/allocate_spec.rb
468
471
  - spec/core/array/append_spec.rb
469
472
  - spec/core/array/assoc_spec.rb
@@ -751,8 +754,6 @@ test_files:
751
754
  - spec/core/time/month_spec.rb
752
755
  - spec/core/time/now_spec.rb
753
756
  - spec/core/time/saturday_spec.rb
754
- - spec/core_spec.rb
755
- - spec/grammar.html
756
757
  - spec/grammar/alias_spec.rb
757
758
  - spec/grammar/and_spec.rb
758
759
  - spec/grammar/array_spec.rb
@@ -798,8 +799,6 @@ test_files:
798
799
  - spec/grammar/while_spec.rb
799
800
  - spec/grammar/xstr_spec.rb
800
801
  - spec/grammar/yield_spec.rb
801
- - spec/grammar_spec.rb
802
- - spec/index.html
803
802
  - spec/language/alias_spec.rb
804
803
  - spec/language/and_spec.rb
805
804
  - spec/language/array_spec.rb
data/spec/core.html DELETED
@@ -1,10 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Opal corelib and runtime specs (core)</title>
5
- </head>
6
- <body>
7
- <script type="text/javascript" src="../build/specs.js"></script>
8
- <script type="text/javascript" src="../build/core_spec.js"></script>
9
- </body>
10
- </html>
data/spec/core_spec.rb DELETED
@@ -1,2 +0,0 @@
1
- #= require_tree ./core
2
- #= require_tree ./language
data/spec/grammar.html DELETED
@@ -1,11 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Opal corelib and runtime specs (grammar)</title>
5
- </head>
6
- <body>
7
- <script type="text/javascript" src="../build/specs.js"></script>
8
- <script type="text/javascript" src="../build/opal-parser.js"></script>
9
- <script type="text/javascript" src="../build/grammar_spec.js"></script>
10
- </body>
11
- </html>
data/spec/grammar_spec.rb DELETED
@@ -1 +0,0 @@
1
- #= require_tree ./grammar
data/spec/index.html DELETED
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Opal corelib and runtime specs</title>
5
- </head>
6
- <body>
7
- <script type="text/javascript" src="../build/specs.js"></script>
8
- <script type="text/javascript" src="../build/opal-parser.js"></script>
9
- <script type="text/javascript" src="../build/core_spec.js"></script>
10
- <script type="text/javascript" src="../build/grammar_spec.js"></script>
11
- </body>
12
- </html>