opal 0.6.1 → 0.6.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c3f8f806c3ccc492181271b934421d199875687
4
- data.tar.gz: 1793e3beab6345556bcb5d9255cbf0bbf6463f68
3
+ metadata.gz: fba7810f4091cf5497c1e42b55e04b1615b673b7
4
+ data.tar.gz: a6ba9289a9179285267f449cbc6fe0a6bbed0d54
5
5
  SHA512:
6
- metadata.gz: 1d3c05b2ef2434e3056b58981e4851964e207d92a5936914e1a54d73f04be7fe9651d43981dd5596c6b6244d3b652395af4cd99944c302d83b385cecfa6e2806
7
- data.tar.gz: a2a98bee95fceb779251cd2cea489fac101aa936e32ff3bccb9395056c4e848c5b5c7907a6648970f0e4fc3658dd3853bf28bdf5ceb7692eda825247511f5182
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.png?branch=master)](http://travis-ci.org/opal/opal)
4
- [![Gem Version](https://badge.fury.io/rb/opal.png)](http://badge.fury.io/rb/opal)
5
- [![Code Climate](https://codeclimate.com/github/opal/opal.png)](https://codeclimate.com/github/opal/opal)
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
- puts options
11
- else
12
- cli = Opal::CLI.new options.options.merge(:filename => ARGV.first)
13
- begin
14
- cli.run
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
@@ -24,7 +24,7 @@ require 'webrick'
24
24
 
25
25
  module MSpec
26
26
  module Opal
27
- DEFAULT_PATTERN = 'spec/opal/{parser,core,compiler,stdlib}/**/*_spec.rb'
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
- def start_phantomjs
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 = %Q{phantomjs #{runner} #{url}}
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 || DEFAULT_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'] = files_to_run(pattern).join(',')
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").map do |line|
180
- line.sub(/#.*/, '').strip
181
- end.reject(&:empty?)
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
- # add custom opal specs from spec/
189
- add_files paths_from_glob(pattern) if pattern
202
+ if pattern
203
+ # add custom opal specs from spec/
204
+ add_files paths_from_glob(pattern) & rubyspec_paths
190
205
 
191
- # add any rubyspecs we want to run (defined in spec/rubyspecs)
192
- add_files rubyspec_paths
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 = DEFAULT_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
@@ -170,8 +170,8 @@ module Opal
170
170
  ##
171
171
  # OUTPUT
172
172
 
173
- def puts *args
174
- output.puts *args
173
+ def puts(*args)
174
+ output.puts(*args)
175
175
  end
176
176
 
177
177
  ##
@@ -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', '--version', 'Display Opal Version') do |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
@@ -37,7 +37,7 @@ module Opal
37
37
  end
38
38
 
39
39
  def compile_to_fragments
40
- return @fragments if @fragments
40
+ return @fragments if defined?(@fragments)
41
41
 
42
42
  @fragments = []
43
43
  self.compile
@@ -43,6 +43,7 @@ module Opal
43
43
  @queue = []
44
44
  @unique = 'a'
45
45
  @while_stack = []
46
+ @identity = nil
46
47
 
47
48
  @methods = []
48
49
 
data/lib/opal/util.rb CHANGED
@@ -14,22 +14,12 @@ module Opal
14
14
  gzip.digest(str)
15
15
  end
16
16
 
17
-
18
- class DigestSourceCommand
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
@@ -1,3 +1,3 @@
1
1
  module Opal
2
- VERSION = '0.6.1'
2
+ VERSION = '0.6.2'
3
3
  end
data/opal.gemspec CHANGED
@@ -26,4 +26,5 @@ Gem::Specification.new do |s|
26
26
  s.add_development_dependency 'racc'
27
27
  s.add_development_dependency 'rspec', '~> 2.14'
28
28
  s.add_development_dependency 'octokit', '~> 2.4.0'
29
+ s.add_development_dependency 'bundler', '~> 1.6'
29
30
  end
data/opal/corelib/hash.rb CHANGED
@@ -25,6 +25,7 @@ class Hash
25
25
  self.none = (defaults === undefined ? nil : defaults);
26
26
  self.proc = block;
27
27
  }
28
+ self
28
29
  end
29
30
 
30
31
  def ==(other)
@@ -25,16 +25,11 @@ class Range
25
25
  }
26
26
  end
27
27
 
28
- # FIXME: currently hardcoded to assume range holds numerics
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 last end
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
- # FIXME: currently hardcoded to assume range holds numerics
71
- def include?(obj)
72
- cover?(obj)
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
@@ -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
@@ -71,7 +71,7 @@ describe "The predefined global constants" do
71
71
 
72
72
  it "includes RUBY_VERSION" do
73
73
  Object.const_defined?(:RUBY_VERSION).should == true
74
- RUBY_VERSION.should == "2.0.0"
74
+ RUBY_VERSION.should == "2.1.1"
75
75
  end
76
76
 
77
77
  it "includes RUBY_RELEASE_DATE" do
data/spec/rubyspecs CHANGED
@@ -47,6 +47,7 @@ corelib/core/matchdata/to_a_spec
47
47
 
48
48
  corelib/core/range/begin_spec
49
49
  corelib/core/range/end_spec
50
+ corelib/core/range/size_spec
50
51
 
51
52
  corelib/core/string/allocate_spec
52
53
  corelib/core/string/append_spec
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.1
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-14 00:00:00.000000000 Z
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: