opal 0.8.0.beta1 → 0.8.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +0 -24
  3. data/.jshintrc +51 -0
  4. data/.travis.yml +6 -1
  5. data/CHANGELOG.md +2 -0
  6. data/Gemfile +3 -7
  7. data/README.md +2 -3
  8. data/Rakefile +1 -0
  9. data/lib/mspec/opal/rake_task.rb +1 -1
  10. data/lib/opal/builder.rb +21 -3
  11. data/lib/opal/builder_processors.rb +2 -2
  12. data/lib/opal/cli.rb +8 -5
  13. data/lib/opal/erb.rb +1 -1
  14. data/lib/opal/nodes/call.rb +1 -1
  15. data/lib/opal/nodes/call_special.rb +1 -1
  16. data/lib/opal/nodes/helpers.rb +6 -4
  17. data/lib/opal/nodes/iter.rb +2 -2
  18. data/lib/opal/nodes/singleton_class.rb +2 -1
  19. data/lib/opal/parser/lexer.rb +3 -2
  20. data/lib/opal/path_reader.rb +8 -1
  21. data/lib/opal/paths.rb +23 -16
  22. data/lib/opal/regexp_anchors.rb +5 -0
  23. data/lib/opal/sprockets/erb.rb +1 -1
  24. data/lib/opal/sprockets/processor.rb +21 -35
  25. data/lib/opal/sprockets/source_map_server.rb +5 -5
  26. data/lib/opal/version.rb +3 -1
  27. data/lib/tilt/opal.rb +11 -5
  28. data/opal.gemspec +2 -2
  29. data/opal/corelib/array.rb +196 -4
  30. data/opal/corelib/enumerable.rb +1 -1
  31. data/opal/corelib/enumerator.rb +2 -2
  32. data/opal/corelib/hash.rb +6 -6
  33. data/opal/corelib/kernel.rb +5 -3
  34. data/opal/corelib/module.rb +18 -12
  35. data/opal/corelib/regexp.rb +110 -4
  36. data/opal/corelib/runtime.js +12 -4
  37. data/opal/corelib/string.rb +51 -95
  38. data/opal/corelib/string/inheritance.rb +22 -0
  39. data/opal/corelib/variables.rb +1 -1
  40. data/spec/filters/bugs/array.rb +3 -39
  41. data/spec/filters/bugs/basic_object.rb +20 -0
  42. data/spec/filters/bugs/date.rb +5 -0
  43. data/spec/filters/bugs/enumerable.rb +9 -0
  44. data/spec/filters/bugs/enumerator.rb +0 -7
  45. data/spec/filters/bugs/hash.rb +2 -0
  46. data/spec/filters/bugs/kernel.rb +5 -0
  47. data/spec/filters/bugs/language.rb +14 -0
  48. data/spec/filters/bugs/method.rb +5 -0
  49. data/spec/filters/bugs/module.rb +23 -0
  50. data/spec/filters/bugs/regular_expressions.rb +41 -0
  51. data/spec/filters/bugs/singleton.rb +3 -0
  52. data/spec/filters/bugs/string.rb +2 -9
  53. data/spec/filters/bugs/stringscanner.rb +3 -0
  54. data/spec/filters/bugs/time.rb +19 -0
  55. data/spec/filters/unsupported/module.rb +6 -0
  56. data/spec/filters/unsupported/mutable_strings.rb +8 -0
  57. data/spec/filters/unsupported/regular_expressions.rb +90 -0
  58. data/spec/lib/builder_spec.rb +12 -6
  59. data/spec/lib/cli_spec.rb +2 -2
  60. data/spec/lib/path_reader_spec.rb +12 -0
  61. data/spec/lib/sprockets/server_spec.rb +7 -8
  62. data/spec/lib/tilt/opal_spec.rb +18 -0
  63. data/spec/opal/core/language/regexp_spec.rb +1 -1
  64. data/spec/opal/core/runtime/bridged_classes_spec.rb +48 -1
  65. data/spec/rubyspecs +88 -78
  66. data/stdlib/encoding.rb +3 -0
  67. data/stdlib/native.rb +1 -1
  68. data/stdlib/pp.rb +27 -6
  69. data/stdlib/set.rb +10 -0
  70. data/tasks/linting.rake +18 -0
  71. data/tasks/testing.rake +11 -4
  72. data/{stdlib → vendored-minitest}/minitest.rb +0 -0
  73. data/{stdlib → vendored-minitest}/minitest/assertions.rb +0 -0
  74. data/{stdlib → vendored-minitest}/minitest/autorun.rb +0 -0
  75. data/{stdlib → vendored-minitest}/minitest/benchmark.rb +0 -0
  76. data/{stdlib → vendored-minitest}/minitest/expectations.rb +0 -0
  77. data/{stdlib → vendored-minitest}/minitest/hell.rb +0 -0
  78. data/{stdlib → vendored-minitest}/minitest/mock.rb +0 -0
  79. data/{stdlib → vendored-minitest}/minitest/parallel.rb +0 -0
  80. data/{stdlib → vendored-minitest}/minitest/pride.rb +0 -0
  81. data/{stdlib → vendored-minitest}/minitest/pride_plugin.rb +0 -0
  82. data/{stdlib → vendored-minitest}/minitest/spec.rb +0 -0
  83. data/{stdlib → vendored-minitest}/minitest/test.rb +0 -0
  84. data/{stdlib → vendored-minitest}/minitest/unit.rb +0 -0
  85. data/vendored-minitest/test/unit.rb +23 -0
  86. metadata +31 -29
  87. data/stdlib/test/unit.rb +0 -10
  88. data/tasks/documentation.rake +0 -38
data/stdlib/set.rb CHANGED
@@ -147,6 +147,16 @@ class Set
147
147
  enum.each { |item| delete item }
148
148
  self
149
149
  end
150
+
151
+ def |(enum)
152
+ unless enum.respond_to? :each
153
+ raise ArgumentError, "value must be enumerable"
154
+ end
155
+ dup.merge(enum)
156
+ end
157
+
158
+ alias + |
159
+ alias union |
150
160
 
151
161
  def to_a
152
162
  @hash.keys
@@ -0,0 +1,18 @@
1
+ directory 'tmp/lint'
2
+
3
+ desc "Build *corelib* and *stdlib* and lint the result"
4
+ task :lint => 'tmp/lint' do
5
+ require 'opal/sprockets/environment'
6
+
7
+ env = Opal::Environment.new
8
+
9
+ files = Dir['{opal,stdlib}/*.rb'].map { |lib| File.basename(lib, '.rb') }
10
+
11
+ files.each do |lib|
12
+ next if lib == 'minitest'
13
+ File.binwrite("tmp/lint/#{lib}.js", env[lib].to_s)
14
+ end
15
+
16
+ sh "jshint --verbose tmp/lint/*.js"
17
+ end
18
+
data/tasks/testing.rake CHANGED
@@ -47,7 +47,10 @@ task :mspec_node do
47
47
  end
48
48
 
49
49
  requires = specs.map{|s| "require '#{s.sub(/^spec\//,'')}'"}
50
+ include_paths = '-Ispec -Ilib'
51
+
50
52
  filename = 'tmp/mspec_node.rb'
53
+ js_filename = 'tmp/mspec_node.js'
51
54
  mkdir_p File.dirname(filename)
52
55
  enter_benchmarking_mode = ENV['BM'] && "OSpecRunner.main.bm!(#{Integer(ENV['BM'])})"
53
56
  File.write filename, <<-RUBY
@@ -59,7 +62,9 @@ task :mspec_node do
59
62
 
60
63
  stubs = '-smspec/helpers/tmp -smspec/helpers/environment -smspec/guards/block_device -smspec/guards/endian'
61
64
 
62
- sh "ruby -rbundler/setup -rmspec/opal/special_calls bin/opal -Ispec -Ilib -gmspec #{stubs} -rnodejs -Dwarning -A #{filename}"
65
+ sh "ruby -rbundler/setup -rmspec/opal/special_calls "\
66
+ "bin/opal -gmspec #{include_paths} #{stubs} -rnodejs -Dwarning -A #{filename} -c > #{js_filename}"
67
+ sh "NODE_PATH=stdlib/nodejs/node_modules node #{js_filename}"
63
68
  end
64
69
 
65
70
  task :cruby_tests do
@@ -81,9 +86,11 @@ task :cruby_tests do
81
86
  end
82
87
  end
83
88
  end
89
+ include_paths << ' -Ivendored-minitest'
84
90
 
85
91
  requires = files.map{|f| "require '#{f}'"}
86
92
  filename = 'tmp/cruby_tests.rb'
93
+ js_filename = 'tmp/cruby_tests.js'
87
94
  mkdir_p File.dirname(filename)
88
95
  File.write filename, requires.join("\n")
89
96
 
@@ -91,9 +98,9 @@ task :cruby_tests do
91
98
 
92
99
  puts "== Running: #{files.join ", "}"
93
100
 
94
- sh 'RUBYOPT="-rbundler/setup" '\
95
- "bin/opal #{include_paths} #{stubs} -rnodejs -Dwarning -A #{filename} -c > tmp/cruby_tests.js"
96
- sh 'NODE_PATH=stdlib/nodejs/node_modules node tmp/cruby_tests.js'
101
+ sh "ruby -rbundler/setup "\
102
+ "bin/opal #{include_paths} #{stubs} -rnodejs -Dwarning -A #{filename} -c > #{js_filename}"
103
+ sh "NODE_PATH=stdlib/nodejs/node_modules node #{js_filename}"
97
104
  end
98
105
 
99
106
  task :mspec => [:mspec_node, :mspec_phantom]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,23 @@
1
+ # test/unit compatibility layer using minitest.
2
+
3
+ require 'minitest/autorun'
4
+ module Test
5
+ module Unit
6
+ class TestCase < Minitest::Test
7
+ alias assert_raise assert_raises
8
+
9
+ def assert_nothing_raised(*)
10
+ yield
11
+ end
12
+
13
+ def assert_raise_with_message(exception, err_message, msg = nil)
14
+ err = assert_raises(exception, msg) { yield }
15
+ if err_message.is_a?(Regexp)
16
+ assert_matches err_message, err.message
17
+ else
18
+ assert_equal err_message, err.message
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0.beta1
4
+ version: 0.8.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Beynon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-08 00:00:00.000000000 Z
11
+ date: 2015-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sourcemap
@@ -28,22 +28,16 @@ dependencies:
28
28
  name: sprockets
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 2.2.3
34
- - - "<"
31
+ - - "~>"
35
32
  - !ruby/object:Gem::Version
36
- version: 4.0.0
33
+ version: '3.1'
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 2.2.3
44
- - - "<"
38
+ - - "~>"
45
39
  - !ruby/object:Gem::Version
46
- version: 4.0.0
40
+ version: '3.1'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: hike
49
43
  requirement: !ruby/object:Gem::Requirement
@@ -62,14 +56,14 @@ dependencies:
62
56
  name: tilt
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
- - - "~>"
59
+ - - ">="
66
60
  - !ruby/object:Gem::Version
67
61
  version: '1.4'
68
62
  type: :runtime
69
63
  prerelease: false
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
- - - "~>"
66
+ - - ">="
73
67
  - !ruby/object:Gem::Version
74
68
  version: '1.4'
75
69
  - !ruby/object:Gem::Dependency
@@ -211,6 +205,7 @@ files:
211
205
  - ".gitignore"
212
206
  - ".gitmodules"
213
207
  - ".inch.yml"
208
+ - ".jshintrc"
214
209
  - ".rspec"
215
210
  - ".spectator"
216
211
  - ".spectator-mspec"
@@ -301,6 +296,7 @@ files:
301
296
  - lib/opal/parser/sexp.rb
302
297
  - lib/opal/path_reader.rb
303
298
  - lib/opal/paths.rb
299
+ - lib/opal/regexp_anchors.rb
304
300
  - lib/opal/source_map.rb
305
301
  - lib/opal/sprockets.rb
306
302
  - lib/opal/sprockets/cache_key_fix.rb
@@ -361,9 +357,11 @@ files:
361
357
  - spec/filters/bugs/kernel.rb
362
358
  - spec/filters/bugs/language.rb
363
359
  - spec/filters/bugs/math.rb
360
+ - spec/filters/bugs/method.rb
364
361
  - spec/filters/bugs/module.rb
365
362
  - spec/filters/bugs/nil.rb
366
363
  - spec/filters/bugs/opal.rb
364
+ - spec/filters/bugs/regular_expressions.rb
367
365
  - spec/filters/bugs/set.rb
368
366
  - spec/filters/bugs/singleton.rb
369
367
  - spec/filters/bugs/string.rb
@@ -378,6 +376,7 @@ files:
378
376
  - spec/filters/unsupported/integer_size.rb
379
377
  - spec/filters/unsupported/marshal.rb
380
378
  - spec/filters/unsupported/method_added.rb
379
+ - spec/filters/unsupported/module.rb
381
380
  - spec/filters/unsupported/mutable_strings.rb
382
381
  - spec/filters/unsupported/private_constants.rb
383
382
  - spec/filters/unsupported/private_methods.rb
@@ -673,19 +672,6 @@ files:
673
672
  - stdlib/iconv.rb
674
673
  - stdlib/json.rb
675
674
  - stdlib/math.rb
676
- - stdlib/minitest.rb
677
- - stdlib/minitest/assertions.rb
678
- - stdlib/minitest/autorun.rb
679
- - stdlib/minitest/benchmark.rb
680
- - stdlib/minitest/expectations.rb
681
- - stdlib/minitest/hell.rb
682
- - stdlib/minitest/mock.rb
683
- - stdlib/minitest/parallel.rb
684
- - stdlib/minitest/pride.rb
685
- - stdlib/minitest/pride_plugin.rb
686
- - stdlib/minitest/spec.rb
687
- - stdlib/minitest/test.rb
688
- - stdlib/minitest/unit.rb
689
675
  - stdlib/native.rb
690
676
  - stdlib/nodejs.rb
691
677
  - stdlib/nodejs/dir.rb
@@ -908,15 +894,28 @@ files:
908
894
  - stdlib/stringio.rb
909
895
  - stdlib/strscan.rb
910
896
  - stdlib/template.rb
911
- - stdlib/test/unit.rb
912
897
  - stdlib/thread.rb
913
898
  - stdlib/time.rb
914
899
  - stdlib/yaml.rb
915
900
  - tasks/building.rake
916
- - tasks/documentation.rake
917
901
  - tasks/documenting.rake
918
902
  - tasks/github.rake
903
+ - tasks/linting.rake
919
904
  - tasks/testing.rake
905
+ - vendored-minitest/minitest.rb
906
+ - vendored-minitest/minitest/assertions.rb
907
+ - vendored-minitest/minitest/autorun.rb
908
+ - vendored-minitest/minitest/benchmark.rb
909
+ - vendored-minitest/minitest/expectations.rb
910
+ - vendored-minitest/minitest/hell.rb
911
+ - vendored-minitest/minitest/mock.rb
912
+ - vendored-minitest/minitest/parallel.rb
913
+ - vendored-minitest/minitest/pride.rb
914
+ - vendored-minitest/minitest/pride_plugin.rb
915
+ - vendored-minitest/minitest/spec.rb
916
+ - vendored-minitest/minitest/test.rb
917
+ - vendored-minitest/minitest/unit.rb
918
+ - vendored-minitest/test/unit.rb
920
919
  homepage: http://opalrb.org
921
920
  licenses:
922
921
  - MIT
@@ -954,9 +953,11 @@ test_files:
954
953
  - spec/filters/bugs/kernel.rb
955
954
  - spec/filters/bugs/language.rb
956
955
  - spec/filters/bugs/math.rb
956
+ - spec/filters/bugs/method.rb
957
957
  - spec/filters/bugs/module.rb
958
958
  - spec/filters/bugs/nil.rb
959
959
  - spec/filters/bugs/opal.rb
960
+ - spec/filters/bugs/regular_expressions.rb
960
961
  - spec/filters/bugs/set.rb
961
962
  - spec/filters/bugs/singleton.rb
962
963
  - spec/filters/bugs/string.rb
@@ -971,6 +972,7 @@ test_files:
971
972
  - spec/filters/unsupported/integer_size.rb
972
973
  - spec/filters/unsupported/marshal.rb
973
974
  - spec/filters/unsupported/method_added.rb
975
+ - spec/filters/unsupported/module.rb
974
976
  - spec/filters/unsupported/mutable_strings.rb
975
977
  - spec/filters/unsupported/private_constants.rb
976
978
  - spec/filters/unsupported/private_methods.rb
data/stdlib/test/unit.rb DELETED
@@ -1,10 +0,0 @@
1
- # test/unit compatibility layer using minitest.
2
-
3
- require 'minitest/autorun'
4
- module Test
5
- module Unit
6
- class TestCase < Minitest::Test
7
- alias assert_raise assert_raises
8
- end
9
- end
10
- end
@@ -1,38 +0,0 @@
1
- namespace :doc do
2
- doc_repo = Pathname(ENV['DOC_REPO'] || 'gh-pages')
3
- doc_base = doc_repo.join('doc')
4
- current_git_release = -> { `git rev-parse --abbrev-ref HEAD`.chomp }
5
- template_option = "--template opal --template-path #{doc_repo.join('yard-templates')}"
6
-
7
- directory doc_repo.to_s do
8
- remote = ENV['DOC_REPO_REMOTE'] || '.'
9
- sh 'git', 'clone', '-b', 'gh-pages', '--', remote, doc_repo.to_s
10
- end
11
-
12
- task :corelib => doc_repo.to_s do
13
- git = current_git_release.call
14
- name = 'corelib'
15
- glob = 'opal/**/*.rb'
16
-
17
- command = "doxx --template #{doc_repo.join('doxx-templates/opal.jade')} "\
18
- "--source opal/corelib --target #{doc_base}/#{git}/#{name} "\
19
- "--title \"Opal runtime.js Documentation\" --readme opal/README.md"
20
- puts command; system command or $stderr.puts "Please install doxx with: npm install"
21
-
22
- command = "yard doc #{glob} #{template_option} "\
23
- "--readme opal/README.md -o #{doc_base}/#{git}/#{name}"
24
- puts command; system command
25
- end
26
-
27
- task :stdlib => doc_repo do
28
- git = current_git_release.call
29
- name = 'stdlib'
30
- glob = '{stdlib/**/*,opal/compiler,opal/erb,opal/version}.rb'
31
- command = "yard doc #{glob} #{template_option} "\
32
- "--readme stdlib/README.md -o gh-pages/doc/#{git}/#{name}"
33
- puts command; system command
34
- end
35
- end
36
-
37
- task :doc => ['doc:corelib', 'doc:stdlib']
38
-