Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7e843b026a35
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 106cfa129ef4
Choose a head ref
  • 7 commits
  • 10 files changed
  • 1 contributor

Commits on Jun 23, 2014

  1. Fix indentation

    elia committed Jun 23, 2014

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    330834a View commit details
  2. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    3066941 View commit details
  3. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    dd85db0 View commit details

Commits on Jun 24, 2014

  1. Use an actual guard plugin

    elia committed Jun 24, 2014

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    ccc8743 View commit details

Commits on Jun 26, 2014

  1. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    8e8ab2b View commit details
  2. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    9ab9c90 View commit details
  3. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    106cfa1 View commit details
Showing with 81 additions and 159 deletions.
  1. +1 −1 Gemfile
  2. +59 −47 Guardfile
  3. +9 −9 lib/opal/sprockets/server.rb
  4. +7 −4 opal/corelib/io.rb
  5. +0 −1 opal/corelib/kernel.rb
  6. +2 −0 spec/filters/bugs/opal.rb
  7. +2 −0 spec/filters/unsupported/private_methods.rb
  8. +0 −83 spec/opal/core/kernel/warn_spec.rb
  9. +1 −0 spec/rubyspecs
  10. +0 −14 stdlib/nodejs/io.rb
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -14,8 +14,8 @@ group :repl do
end

unless ENV['CI']
gem 'rb-fsevent'
gem 'guard', require: false
gem 'rb-fsevent', require: false
gem 'terminal-notifier-guard'
end

106 changes: 59 additions & 47 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,58 +1,70 @@
watch(%r{.*}) do |m|
path = m[0]
puts color("Searching specs for #{m[0]}...", :yellow)
case path
when %r{^spec/cli} then rspec path
when %r{^spec/corelib} then mspec path
when %r{^opal/corelib}
name = File.basename(path, '.rb')
mspec "spec/corelib/core/#{name}/**/*_spec.rb"
when %r{^lib/opal/(.*)\.rb$}
name = $1
specs = Dir["spec/cli/#{name}_spec.rb"]
rspec *specs
require 'guard/plugin'

class ::Guard::Opal < Plugin
def mspec *paths
command = ['bundle', 'exec', './bin/opal-mspec', *paths.flatten]
result = time(:mspec, *paths) { system *command }
notify 'MSpec', result
end
end

def rspec *paths
command = ['bundle', 'exec', 'rspec', *paths.flatten]
result = time(:rspec, *paths) { system *command }
notify 'RSpec', result
end

def mspec *paths
command = ['bundle', 'exec', './bin/opal-mspec', *paths.flatten]
result = time(:mspec, *paths) { system *command }
notify 'MSpec', result
end
def notify lib, result
if result
::Guard::Notifier.notify(
'Success ♥︎', title: "#{lib} results", image: :success, priority: 1
)
else
::Guard::Notifier.notify(
'Failed ♠︎', title: "#{lib} results", image: :failed, priority: 1
)
end
end

def rspec *paths
command = ['bundle', 'exec', 'rspec', *paths.flatten]
result = time(:rspec, *paths) { system *command }
notify 'RSpec', result
end
def color *args
Guard::UI.send :color, *args
end

def notify lib, result
if result
::Guard::Notifier.notify(
'Success ♥︎', title: "#{lib} results", image: :success, priority: 1
)
else
::Guard::Notifier.notify(
'Failed ♠︎', title: "#{lib} results", image: :failed, priority: 1
)
def terminal_columns
cols = `tput cols 2> /dev/tty`.strip.to_i
($?.success? && cols.nonzero?) ? cols : 80
end
end

def color *args
Guard::UI.send :color, *args
end
def time *titles
columns = terminal_columns
puts color("=== running: #{titles.join(' ')} ".ljust(columns,'='), :cyan)
s = Time.now
yield
t = (Time.now - s).to_f
puts color("=== time: #{t} seconds ".ljust(columns, '='), :cyan)
end

def terminal_columns
cols = `tput cols 2> /dev/tty`.strip.to_i
($?.success? && cols.nonzero?) ? cols : 80
def run_on_changes(changes)
m = changes
path = m[0]
puts color("Searching specs for #{m[0]}...", :yellow)
case path
when %r{^spec/cli} then rspec path
when %r{^spec/corelib} then mspec path
when %r{^opal/corelib}
name = File.basename(path, '.rb')
mspec "spec/corelib/core/#{name}/**/*_spec.rb"
when %r{^lib/opal/(.*)\.rb$}
name = $1
specs = Dir["spec/cli/#{name}_spec.rb"]
rspec *specs
end
end

def run_all
time(:all) { system 'bundle', 'exec', 'rake' }
end
end

def time *titles
columns = terminal_columns
puts color("=== running: #{titles.join(' ')} ".ljust(columns,'='), :cyan)
s = Time.now
yield
t = (Time.now - s).to_f
puts color("=== time: #{t} seconds ".ljust(columns, '='), :cyan)
guard :opal do
watch /.*/
end
18 changes: 9 additions & 9 deletions lib/opal/sprockets/server.rb
Original file line number Diff line number Diff line change
@@ -158,15 +158,15 @@ def javascript_include_tag source
end

SOURCE = <<-HTML
<!DOCTYPE html>
<html>
<head>
<title>Opal Server</title>
</head>
<body>
<%= javascript_include_tag @server.main %>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Opal Server</title>
</head>
<body>
<%= javascript_include_tag @server.main %>
</body>
</html>
HTML
end
end
11 changes: 7 additions & 4 deletions opal/corelib/io.rb
Original file line number Diff line number Diff line change
@@ -13,16 +13,18 @@ def write(string)
module Writable
def <<(string)
write(string)

self
end

def print(*args)
write args.map { |arg| String(arg) }.join($,)
nil
end

def puts(*args)
write args.map { |arg| String(arg) }.join($/)
newline = $/
write args.map { |arg| String(arg).chomp }.concat([nil]).join(newline)
nil
end
end

@@ -49,8 +51,9 @@ def readpartial(integer, outbuf = nil)
STDIN = $stdin = IO.new
STDOUT = $stdout = IO.new

$stdout.write_proc = -> (string) {`console.log(#{string.to_s});`}
$stderr.write_proc = -> (string) {`console.warn(#{string.to_s});`}

$stdout.write_proc = `typeof(process) === 'object' ? function(s){process.stdout.write(s)} : function(s){console.log(s)}`
$stderr.write_proc = `typeof(process) === 'object' ? function(s){process.stderr.write(s)} : function(s){console.warn(s)}`

$stdout.extend(IO::Writable)
$stderr.extend(IO::Writable)
1 change: 0 additions & 1 deletion opal/corelib/kernel.rb
Original file line number Diff line number Diff line change
@@ -453,7 +453,6 @@ def print(*strs)

def warn(*strs)
$stderr.puts(*strs) unless $VERBOSE.nil? || strs.empty?
nil
end

def raise(exception = undefined, string = undefined)
2 changes: 2 additions & 0 deletions spec/filters/bugs/opal.rb
Original file line number Diff line number Diff line change
@@ -9,4 +9,6 @@
fails "String#index with Regexp supports \\G which matches at the given start offset"
fails "String#index with Regexp starts the search at the given offset"
fails "String#index with Regexp returns the index of the first match of regexp"

fails "Kernel#warn requires multiple arguments"
end
2 changes: 2 additions & 0 deletions spec/filters/unsupported/private_methods.rb
Original file line number Diff line number Diff line change
@@ -39,4 +39,6 @@
fails "Class#initialize is private"

fails "Math#atanh is a private instance method"

fails "Kernel#warn is a private method"
end
83 changes: 0 additions & 83 deletions spec/opal/core/kernel/warn_spec.rb

This file was deleted.

1 change: 1 addition & 0 deletions spec/rubyspecs
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@ corelib/core/kernel/equal_spec
corelib/core/kernel/equal_value_spec
corelib/core/kernel/tap_spec
corelib/core/kernel/to_s_spec
corelib/core/kernel/warn_spec

corelib/core/matchdata/captures_spec
corelib/core/matchdata/inspect_spec
14 changes: 0 additions & 14 deletions stdlib/nodejs/io.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,2 @@
module IO::Writable
def puts(*args)
write args.map { |arg| String(arg) }.join($/)+$/
end
end

STDERR = $stderr = IO.new
STDIN = $stdin = IO.new
STDOUT = $stdout = IO.new

$stdout.write_proc = -> (string) {`process.stdout.write(#{string})`}
$stderr.write_proc = -> (string) {`process.stderr.write(string)`}

$stdout.extend(IO::Writable)
$stderr.extend(IO::Writable)