opal 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -5
- data/Rakefile +6 -1
- data/bin/opal +15 -9
- data/lib/mspec/opal/rake_task.rb +35 -15
- data/lib/opal/builder.rb +3 -0
- data/lib/opal/cli.rb +2 -2
- data/lib/opal/cli_options.rb +7 -1
- data/lib/opal/nodes/base.rb +1 -1
- data/lib/opal/nodes/scope.rb +1 -0
- data/lib/opal/util.rb +14 -14
- data/lib/opal/version.rb +1 -1
- data/opal.gemspec +1 -0
- data/opal/corelib/hash.rb +1 -0
- data/opal/corelib/range.rb +21 -12
- data/spec/filters/bugs/time.rb +5 -0
- data/spec/opal/core/language/predefined_spec.rb +1 -1
- data/spec/rubyspecs +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fba7810f4091cf5497c1e42b55e04b1615b673b7
|
4
|
+
data.tar.gz: a6ba9289a9179285267f449cbc6fe0a6bbed0d54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aac7dfdf749778ea7385c0d798636c99f1af6ab3b8f614249265756f521f8765e9eca88adaf11791dabb1ef9ddbbb03f3dbabf3278d26c01961444150926ac1d
|
7
|
+
data.tar.gz: 5bbecad1ba6817cae8cf57eab950444f083ce10abe5450751420ba5ebfcdc66eecad651fa955d9678ea95d1896a56deb1ffd4a163b6ef9be54f8e3f29b1c88cc
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Opal
|
2
2
|
|
3
|
-
[![Build Status](https://secure.travis-ci.org/opal/opal.
|
4
|
-
[![Gem Version](https://badge.fury.io/rb/opal.
|
5
|
-
[![Code Climate](
|
3
|
+
[![Build Status](https://secure.travis-ci.org/opal/opal.svg?branch=master)](http://travis-ci.org/opal/opal)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/opal.svg)](http://badge.fury.io/rb/opal)
|
5
|
+
[![Code Climate](http://img.shields.io/codeclimate/github/opal/opal.svg)](https://codeclimate.com/github/opal/opal)
|
6
6
|
|
7
7
|
Opal is a ruby to javascript source-to-source compiler. It also has an
|
8
8
|
implementation of the ruby corelib.
|
@@ -166,8 +166,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
166
166
|
THE SOFTWARE.
|
167
167
|
|
168
168
|
|
169
|
-
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/opal/opal/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
170
|
-
|
171
169
|
[phantomjs]: http://phantomjs.org
|
172
170
|
[spectator]: https://github.com/elia/spectator#readme
|
173
171
|
[MSpec]: https://github.com/rubyspec/mspec#readme
|
data/Rakefile
CHANGED
@@ -10,11 +10,15 @@ RSpec::Core::RakeTask.new(:rspec) do |t|
|
|
10
10
|
end
|
11
11
|
|
12
12
|
require 'mspec/opal/rake_task'
|
13
|
-
MSpec::Opal::RakeTask.new(:mspec)
|
13
|
+
MSpec::Opal::RakeTask.new(:mspec) do |config|
|
14
|
+
config.pattern = ENV['MSPEC_PATTERN'] if ENV['MSPEC_PATTERN']
|
15
|
+
config.basedir = ENV['MSPEC_BASEDIR'] if ENV['MSPEC_BASEDIR']
|
16
|
+
end
|
14
17
|
|
15
18
|
task :default => [:rspec, :mspec]
|
16
19
|
|
17
20
|
|
21
|
+
require 'opal/version'
|
18
22
|
desc <<-DESC
|
19
23
|
Build *corelib* and *stdlib* to "build/"
|
20
24
|
|
@@ -22,6 +26,7 @@ You can restrict the file list with the FILES env var (comma separated)
|
|
22
26
|
and the destination dir with the DIR env var.
|
23
27
|
|
24
28
|
Example: rake dist DIR=/tmp/foo FILES='opal.rb,base64.rb'
|
29
|
+
Example: rake dist DIR=cdn/opal/#{Opal::VERSION}
|
25
30
|
DESC
|
26
31
|
task :dist do
|
27
32
|
require 'opal/util'
|
data/bin/opal
CHANGED
@@ -4,16 +4,22 @@ require 'opal/cli_options'
|
|
4
4
|
options = Opal::CLIOptions.new
|
5
5
|
options.parse!
|
6
6
|
|
7
|
-
require 'opal/cli'
|
8
7
|
|
9
8
|
if ARGV.empty? and !options.options[:evals]
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
rescue Opal::CLI::MissingNodeJS => e
|
16
|
-
$stderr.puts e.message
|
17
|
-
exit 127
|
9
|
+
if options.options[:verbose]
|
10
|
+
exit
|
11
|
+
else
|
12
|
+
options.options[:evals] ||= []
|
13
|
+
options.options[:evals] << gets(nil)
|
18
14
|
end
|
19
15
|
end
|
16
|
+
|
17
|
+
require 'opal/cli'
|
18
|
+
cli = Opal::CLI.new options.options.merge(:filename => ARGV.first)
|
19
|
+
|
20
|
+
begin
|
21
|
+
cli.run
|
22
|
+
rescue Opal::CLI::MissingNodeJS => e
|
23
|
+
$stderr.puts e.message
|
24
|
+
exit 127
|
25
|
+
end
|
data/lib/mspec/opal/rake_task.rb
CHANGED
@@ -24,7 +24,7 @@ require 'webrick'
|
|
24
24
|
|
25
25
|
module MSpec
|
26
26
|
module Opal
|
27
|
-
DEFAULT_PATTERN = 'spec/
|
27
|
+
DEFAULT_PATTERN = 'spec/{corelib,opal,stdlib}/**/*_spec.rb'
|
28
28
|
DEFAULT_BASEDIR = 'spec'
|
29
29
|
|
30
30
|
require 'rake'
|
@@ -84,13 +84,26 @@ module MSpec
|
|
84
84
|
server.kill
|
85
85
|
end
|
86
86
|
|
87
|
-
|
87
|
+
require 'opal/util'
|
88
|
+
class PhantomJS < ::Opal::Util::Command
|
88
89
|
require 'shellwords'
|
90
|
+
|
91
|
+
def initialize(runner, url)
|
92
|
+
runner = runner.shellescape
|
93
|
+
url = url.shellescape
|
94
|
+
super 'phantomjs', "#{runner} #{url}", '. Please install PhantomJS'
|
95
|
+
end
|
96
|
+
|
97
|
+
def run
|
98
|
+
system "#{command} #{options}"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def start_phantomjs
|
89
103
|
runner = File.expand_path('../sprockets.js', __FILE__).shellescape
|
90
104
|
url = "http://localhost:#{port}/".shellescape
|
91
|
-
command =
|
92
|
-
|
93
|
-
@passed = system command
|
105
|
+
command = PhantomJS.new(runner, url)
|
106
|
+
@passed = command.run
|
94
107
|
end
|
95
108
|
|
96
109
|
def start_server
|
@@ -108,7 +121,7 @@ module MSpec
|
|
108
121
|
::Opal::Processor.arity_check_enabled = true
|
109
122
|
::Opal::Processor.dynamic_require_severity = :ignore
|
110
123
|
super()
|
111
|
-
@pattern = pattern
|
124
|
+
@pattern = pattern
|
112
125
|
@basedir = basedir = File.expand_path(basedir || DEFAULT_BASEDIR)
|
113
126
|
append_path basedir
|
114
127
|
use_gem 'mspec'
|
@@ -117,7 +130,7 @@ module MSpec
|
|
117
130
|
::Opal::Processor.stub_file asset
|
118
131
|
end
|
119
132
|
|
120
|
-
ENV['OPAL_SPEC']
|
133
|
+
ENV['OPAL_SPEC'] ||= files_to_run(pattern).join(',')
|
121
134
|
end
|
122
135
|
|
123
136
|
def stubs
|
@@ -147,6 +160,7 @@ module MSpec
|
|
147
160
|
end
|
148
161
|
|
149
162
|
def add_files specs
|
163
|
+
puts "Adding #{specs.size} spec files..."
|
150
164
|
files.concat specs.flatten
|
151
165
|
end
|
152
166
|
|
@@ -176,20 +190,26 @@ module MSpec
|
|
176
190
|
end
|
177
191
|
|
178
192
|
def rubyspec_white_list
|
179
|
-
File.read("#{basedir}/rubyspecs").split("\n").
|
180
|
-
line.sub(/#.*/, '').strip
|
181
|
-
end
|
193
|
+
File.read("#{basedir}/rubyspecs").split("\n").reject do |line|
|
194
|
+
line.sub(/#.*/, '').strip.empty?
|
195
|
+
end
|
182
196
|
end
|
183
197
|
|
184
198
|
def files_to_run(pattern=nil)
|
185
199
|
# add any filters in spec/filters of specs we dont want to run
|
186
200
|
add_files paths_from_glob("#{basedir}/filters/**/*.rb")
|
187
201
|
|
188
|
-
|
189
|
-
|
202
|
+
if pattern
|
203
|
+
# add custom opal specs from spec/
|
204
|
+
add_files paths_from_glob(pattern) & rubyspec_paths
|
190
205
|
|
191
|
-
|
192
|
-
|
206
|
+
else
|
207
|
+
# add opal specific specs
|
208
|
+
add_files paths_from_glob("#{basedir}/{opal}/**/*_spec.rb")
|
209
|
+
|
210
|
+
# add any rubyspecs we want to run (defined in spec/rubyspecs)
|
211
|
+
add_files rubyspec_paths
|
212
|
+
end
|
193
213
|
end
|
194
214
|
|
195
215
|
def build_specs file = "#{basedir}/build/specs.js"
|
@@ -204,7 +224,7 @@ module MSpec
|
|
204
224
|
attr_accessor :pattern, :basedir
|
205
225
|
|
206
226
|
def initialize
|
207
|
-
self.pattern =
|
227
|
+
self.pattern = nil
|
208
228
|
self.basedir = DEFAULT_BASEDIR
|
209
229
|
|
210
230
|
yield(self) if block_given?
|
data/lib/opal/builder.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'opal/compiler'
|
2
2
|
require 'erb'
|
3
|
+
require 'pathname'
|
3
4
|
|
4
5
|
module Opal
|
5
6
|
class Builder
|
@@ -44,6 +45,8 @@ module Opal
|
|
44
45
|
end
|
45
46
|
|
46
47
|
def find_asset(path)
|
48
|
+
return path if Pathname(path).absolute?
|
49
|
+
|
47
50
|
path.untaint if path =~ /\A(\w[-.\w]*\/?)+\Z/
|
48
51
|
file_types = %w[.rb .js .js.erb]
|
49
52
|
|
data/lib/opal/cli.rb
CHANGED
data/lib/opal/cli_options.rb
CHANGED
@@ -8,7 +8,13 @@ module Opal
|
|
8
8
|
super do |opts|
|
9
9
|
opts.banner = 'Usage: opal [options] -- [programfile]'
|
10
10
|
|
11
|
-
opts.on('-v', '--
|
11
|
+
opts.on('-v', '--verbose', 'print version number, then turn on verbose mode') do |v|
|
12
|
+
require 'opal/version'
|
13
|
+
puts "Opal v#{Opal::VERSION}"
|
14
|
+
options[:verbose] = true # TODO: print some warnings when verbose = true
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on('--version', 'Print the version') do |v|
|
12
18
|
require 'opal/version'
|
13
19
|
puts "Opal v#{Opal::VERSION}"
|
14
20
|
exit
|
data/lib/opal/nodes/base.rb
CHANGED
data/lib/opal/nodes/scope.rb
CHANGED
data/lib/opal/util.rb
CHANGED
@@ -14,22 +14,12 @@ module Opal
|
|
14
14
|
gzip.digest(str)
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
def initialize(command, options, message)
|
17
|
+
class Command
|
18
|
+
def initialize(command, options, message = nil)
|
20
19
|
@command, @options, @message = command, options, message
|
21
|
-
end
|
22
|
-
attr_reader :command, :options, :message
|
23
|
-
|
24
|
-
def digest(source)
|
25
20
|
return unless command_installed? command, message
|
26
|
-
IO.popen("#{command} #{options} #{hide_stderr}", 'r+') do |i|
|
27
|
-
i.puts source
|
28
|
-
i.close_write
|
29
|
-
i.read
|
30
|
-
end
|
31
21
|
end
|
32
|
-
|
22
|
+
attr_reader :command, :options, :message
|
33
23
|
|
34
24
|
private
|
35
25
|
|
@@ -54,11 +44,21 @@ module Opal
|
|
54
44
|
|
55
45
|
INSTALLED = {}
|
56
46
|
def command_installed?(cmd, install_comment)
|
57
|
-
command_installed = INSTALLED[cmd.to_s] ||= which(cmd)
|
47
|
+
command_installed = Command::INSTALLED[cmd.to_s] ||= which(cmd)
|
58
48
|
$stderr.puts %Q("#{cmd}" command not found#{install_comment}) unless command_installed
|
59
49
|
command_installed
|
60
50
|
end
|
61
51
|
end
|
62
52
|
|
53
|
+
class DigestSourceCommand < Command
|
54
|
+
def digest(source)
|
55
|
+
IO.popen("#{command} #{options} #{hide_stderr}", 'r+') do |i|
|
56
|
+
i.puts source
|
57
|
+
i.close_write
|
58
|
+
i.read
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
63
|
end
|
64
64
|
end
|
data/lib/opal/version.rb
CHANGED
data/opal.gemspec
CHANGED
data/opal/corelib/hash.rb
CHANGED
data/opal/corelib/range.rb
CHANGED
@@ -25,16 +25,11 @@ class Range
|
|
25
25
|
}
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
def ===(obj)
|
30
|
-
include?(obj)
|
31
|
-
end
|
32
|
-
|
33
|
-
def cover?(value)
|
28
|
+
def ===(value)
|
34
29
|
@begin <= value && (@exclude ? value < @end : value <= @end)
|
35
30
|
end
|
36
31
|
|
37
|
-
alias
|
32
|
+
alias :cover? :===
|
38
33
|
|
39
34
|
def each(&block)
|
40
35
|
return enum_for :each unless block_given?
|
@@ -65,12 +60,11 @@ class Range
|
|
65
60
|
@exclude
|
66
61
|
end
|
67
62
|
|
68
|
-
alias first begin
|
63
|
+
alias :first :begin
|
69
64
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
65
|
+
alias :include? :cover?
|
66
|
+
|
67
|
+
alias :last :end
|
74
68
|
|
75
69
|
# FIXME: currently hardcoded to assume range holds numerics
|
76
70
|
def max
|
@@ -81,6 +75,8 @@ class Range
|
|
81
75
|
end
|
82
76
|
end
|
83
77
|
|
78
|
+
alias :member? :cover?
|
79
|
+
|
84
80
|
def min
|
85
81
|
if block_given?
|
86
82
|
super
|
@@ -91,6 +87,19 @@ class Range
|
|
91
87
|
|
92
88
|
alias member? include?
|
93
89
|
|
90
|
+
def size
|
91
|
+
_begin = @begin
|
92
|
+
_end = @end
|
93
|
+
_end -= 1 if @exclude
|
94
|
+
|
95
|
+
return nil unless Numeric === _begin && Numeric === _end
|
96
|
+
return 0 if _end < _begin
|
97
|
+
infinity = Float::INFINITY
|
98
|
+
return infinity if infinity == _begin.abs || _end.abs == infinity
|
99
|
+
|
100
|
+
(`Math.abs(_end - _begin) + 1`).to_i
|
101
|
+
end
|
102
|
+
|
94
103
|
def step(n = 1)
|
95
104
|
raise NotImplementedError
|
96
105
|
end
|
data/spec/filters/bugs/time.rb
CHANGED
@@ -169,4 +169,9 @@ opal_filter "Time" do
|
|
169
169
|
fails "Time#wday returns an integer representing the day of the week, 0..6, with Sunday being 0"
|
170
170
|
|
171
171
|
fails "Time#year returns the four digit year for a UTC Time as an Integer"
|
172
|
+
|
173
|
+
# The following specs fail under certain TZ / DST conditions
|
174
|
+
fails "Time.utc accepts various year ranges"
|
175
|
+
fails "Time.gm accepts various year ranges"
|
176
|
+
|
172
177
|
end
|
data/spec/rubyspecs
CHANGED
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.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Beynon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: source_map
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 2.4.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: bundler
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.6'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.6'
|
111
125
|
description: Ruby runtime and core library for javascript.
|
112
126
|
email: adam.beynon@gmail.com
|
113
127
|
executables:
|