Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' into ffi-io
Fixed a conflict in io.rb with #write_nonblock and a
conflict in spec/ruby/core/io/read_nonblock_spec.rb.
  • Loading branch information
chuckremes committed Jan 22, 2016
2 parents 685a4a5 + 9da9d6a commit 910d9f8
Show file tree
Hide file tree
Showing 59 changed files with 848 additions and 209 deletions.
2 changes: 1 addition & 1 deletion Gemfile.installed
Expand Up @@ -8,7 +8,7 @@ gem "daedalus-core", "~> 0.1"
gem "rubinius-build_tools", "~> 2.0"
gem "rubinius-developer_tools", "~> 2.0"

gem "rubysl", "~> 2.0"
gem "rubysl", "~> 2.2"
gem "rubysl-test-unit", "~> 2.0"
gem "minitest", "~> 4.7"
gem "racc", "~> 1.4"
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Expand Up @@ -2,7 +2,7 @@ GEM
remote: https://rubygems.org/
specs:
daedalus-core (0.5.0)
rake (10.4.2)
rake (10.5.0)
redcard (1.1.0)
rubinius-ast (2.3.2)
rubinius-bridge (1.1.0)
Expand Down
6 changes: 6 additions & 0 deletions configure
Expand Up @@ -78,6 +78,7 @@ class Configure
@dtrace_const = false
@have_lchmod = false
@have_lchown = false
@have_mkfifo = false
@debug_build = false
@include_dirs = []
@lib_dirs = []
Expand Down Expand Up @@ -1290,6 +1291,10 @@ int main() { return tgetnum(""); }
if has_function("lchown", ["sys/stat.h", "unistd.h"])
@have_lchown = true
end

if has_function("mkfifo", ["sys/stat.h", "sys/types.h"])
@have_mkfifo = true
end
end

def detect_structures
Expand Down Expand Up @@ -1656,6 +1661,7 @@ int main() { return tgetnum(""); }
#define RBX_LIBC "#{@libc}"
#define RBX_HAVE_LCHMOD #{@have_lchmod}
#define RBX_HAVE_LCHOWN #{@have_lchown}
#define RBX_HAVE_MKFIFO #{@have_mkfifo}
#define RBX_DEBUG_BUILD #{@debug_build.inspect}
EOC

Expand Down
8 changes: 0 additions & 8 deletions dockerfiles/ubuntu/14.04/Dockerfile

This file was deleted.

8 changes: 0 additions & 8 deletions dockerfiles/ubuntu/15.10/Dockerfile

This file was deleted.

7 changes: 4 additions & 3 deletions gems_list.txt
Expand Up @@ -5,7 +5,7 @@ json-1.8.3.gem
minitest-4.7.5.gem
psych-2.0.17.gem
racc-1.4.14.gem
rake-10.4.2.gem
rake-10.5.0.gem
rb-readline-0.5.3.gem
rdoc-4.2.1.gem
redcard-1.1.0.gem
Expand All @@ -20,7 +20,7 @@ rubinius-melbourne-2.3.1.0.gem
rubinius-processor-2.3.0.gem
rubinius-profiler-2.0.2.gem
rubinius-toolset-2.3.1.gem
rubysl-2.1.0.gem
rubysl-2.2.0.gem
rubysl-abbrev-2.0.4.gem
rubysl-base64-2.0.0.gem
rubysl-benchmark-2.0.1.gem
Expand Down Expand Up @@ -70,9 +70,9 @@ rubysl-net-smtp-2.0.1.gem
rubysl-net-telnet-2.0.0.gem
rubysl-nkf-2.0.1.gem
rubysl-observer-2.0.0.gem
rubysl-open-uri-2.0.0.gem
rubysl-open3-2.0.0.gem
rubysl-openssl-2.8.0.gem
rubysl-open-uri-2.0.0.gem
rubysl-optparse-2.0.1.gem
rubysl-ostruct-2.1.0.gem
rubysl-pathname-2.1.0.gem
Expand Down Expand Up @@ -107,6 +107,7 @@ rubysl-timeout-2.0.0.gem
rubysl-tmpdir-2.0.1.gem
rubysl-tsort-2.0.1.gem
rubysl-un-2.0.0.gem
rubysl-unicode_normalize-2.0.gem
rubysl-uri-2.0.0.gem
rubysl-weakref-2.0.0.gem
rubysl-webrick-2.0.0.gem
Expand Down
22 changes: 22 additions & 0 deletions kernel/common/argf.rb
Expand Up @@ -330,6 +330,7 @@ def readbyte
def read(bytes=nil, output=nil)
# The user might try to pass in nil, so we have to check here
output ||= default_value
output.clear

if bytes
bytes_left = bytes
Expand Down Expand Up @@ -401,6 +402,27 @@ def readlines(sep=$/)

alias_method :to_a, :readlines

def readpartial(maxlen, output=nil)
output ||= default_value

unless advance!
output.clear
raise EOFError, "ARGF at end"
end

begin
@stream.readpartial(maxlen, output)
rescue EOFError => e
raise e if @use_stdin_only

@stream.close
@advance = true
advance! or raise e
end

return output
end

#
# Rewind the stream to its beginning.
#
Expand Down
8 changes: 4 additions & 4 deletions kernel/common/array.rb
Expand Up @@ -597,13 +597,13 @@ def delete_if
self
end

def dig(*sequence)
item = self[sequence.shift]
return item if sequence.empty? || item.nil?
def dig(index, *remaining_indeces)
item = self[index]
return item if remaining_indeces.empty? || item.nil?

raise TypeError, "#{item.class} does not have #dig method" unless item.respond_to?(:dig)

item.dig(*sequence)
item.dig(*remaining_indeces)
end

def each_index
Expand Down
67 changes: 39 additions & 28 deletions kernel/common/enumerable.rb
Expand Up @@ -4,19 +4,13 @@
# these methods can be written *in those classes* to override these.

module Enumerable
def chunk(initial_state = nil, &original_block)
def chunk
raise ArgumentError, "no block given" unless block_given?
::Enumerator.new do |yielder|
previous = nil
accumulate = []
block = if initial_state.nil?
original_block
else
duplicated_initial_state = initial_state.dup
Proc.new{ |val| original_block.yield(val, duplicated_initial_state)}
end
each do |element|
key = block.yield(element)
key = yield(element)
if key.nil? || (key.is_a?(Symbol) && key.to_s[0, 1] == "_")
yielder.yield [previous, accumulate] unless accumulate.empty?
accumulate = []
Expand Down Expand Up @@ -136,18 +130,18 @@ def group_by
h
end

def slice_before(arg = undefined, &block)
if block_given?
has_init = !(undefined.equal? arg)
else
raise ArgumentError, "wrong number of arguments (0 for 1)" if undefined.equal? arg
block = Proc.new{ |elem| arg === elem }
end
def slice_before(pattern = undefined, &block)
pattern_given = !(undefined.equal? pattern)

raise ArgumentError, "cannot pass both pattern and block" if pattern_given && block_given?
raise ArgumentError, "a pattern or a block must be provided" if !pattern_given && !block_given?

block = Proc.new{ |elem| pattern === elem } if pattern_given

Enumerator.new do |yielder|
init = arg.dup if has_init
accumulator = nil
each do |element|
start_new = has_init ? block.yield(element, init) : block.yield(element)
start_new = block.yield(element)
if start_new
yielder.yield accumulator if accumulator
accumulator = [element]
Expand All @@ -164,7 +158,7 @@ def slice_after(pattern = undefined, &block)
pattern_given = !undefined.equal?(pattern)

raise ArgumentError, "cannot pass both pattern and block" if pattern_given && block_given?
raise ArgumentError, "wrong number of arguments (0 for 1)" if !pattern_given && !block_given?
raise ArgumentError, "a pattern or a block must be provided" if !pattern_given && !block_given?

block = Proc.new { |elem| pattern === elem } if pattern_given

Expand Down Expand Up @@ -212,6 +206,12 @@ def slice_when(&block)
end
end

def chunk_while(&block)
raise ArgumentError, "no block given" unless block_given?

slice_when { |before, after| !(yield before, after) }
end

def to_a(*arg)
ary = []
each(*arg) do
Expand Down Expand Up @@ -293,19 +293,30 @@ def each_with_index(*args)
def grep(pattern)
ary = []

if block_given?
each do
element = Rubinius.single_block_arg
if pattern === element
Regexp.set_block_last_match
each do
element = Rubinius.single_block_arg
if pattern === element
Regexp.set_block_last_match
if block_given?
ary << yield(element)
else
ary << element
end
end
else
each do
element = Rubinius.single_block_arg
if pattern === element
Regexp.set_block_last_match
end

ary
end

def grep_v(pattern)
ary = []

each do
element = Rubinius.single_block_arg
unless pattern === element
if block_given?
ary << yield(element)
else
ary << element
end
end
Expand Down
30 changes: 20 additions & 10 deletions kernel/common/enumerator.rb
Expand Up @@ -347,19 +347,29 @@ def reject
end

def grep(pattern)
if block_given?
Lazy.new(self, nil) do |yielder, *args|
val = args.length >= 2 ? args : args.first
if pattern === val
Regexp.set_block_last_match
Lazy.new(self, nil) do |yielder, *args|
val = args.length >= 2 ? args : args.first

if pattern === val
Regexp.set_block_last_match

if block_given?
yielder.yield yield(val)
else
yielder.yield val
end
end
else
Lazy.new(self, nil) do |yielder, *args|
val = args.length >= 2 ? args : args.first
if pattern === val
Regexp.set_block_last_match
end
end

def grep_v(pattern)
Lazy.new(self, nil) do |yielder, *args|
val = args.length >= 2 ? args : args.first

unless pattern === val
if block_given?
yielder.yield yield(val)
else
yielder.yield val
end
end
Expand Down
15 changes: 15 additions & 0 deletions kernel/common/file.rb
Expand Up @@ -1195,6 +1195,21 @@ def self.sticky?(file_name)
return false
end

def self.mkfifo(file_name, mode = 0666)
raise NotImplementedError, "mkfifo is not implemented on this platform" unless Rubinius::HAVE_MKFIFO

file_name = file_name.to_path if file_name.respond_to?(:to_path)
file_name = StringValue(file_name)

ret = POSIX.mkfifo(file_name, mode)

if ret == 0
ret
else
Errno.handle(file_name)
end
end

class << self
alias_method :delete, :unlink
alias_method :exists?, :exist?
Expand Down
43 changes: 39 additions & 4 deletions kernel/common/hash.rb
Expand Up @@ -252,6 +252,37 @@ def ==(other)
true
end

def <(other)
other = Rubinius::Type.coerce_to(other, Hash, :to_hash)
other > self
end

def <=(other)
other = Rubinius::Type.coerce_to(other, Hash, :to_hash)
other >= self
end

def >(other)
other = Rubinius::Type.coerce_to(other, Hash, :to_hash)

return false if size <= other.size

self >= other
end

def >=(other)
other = Rubinius::Type.coerce_to(other, Hash, :to_hash)

return false if size < other.size

other.each do |other_key, other_val|
val = fetch(other_key, undefined)
return false if undefined.equal?(val) || val != other_val
end

true
end

def assoc(key)
each_item { |e| return e.key, e.value if key == e.key }
end
Expand Down Expand Up @@ -322,13 +353,13 @@ def delete(key)
return yield(key) if block_given?
end

def dig(*sequence)
item = self[sequence.shift]
return item if sequence.empty? || item.nil?
def dig(key, *remaining_keys)
item = self[key]
return item if remaining_keys.empty? || item.nil?

raise TypeError, "#{item.class} does not have #dig method" unless item.respond_to?(:dig)

item.dig(*sequence)
item.dig(*remaining_keys)
end

def each_item
Expand Down Expand Up @@ -367,6 +398,10 @@ def fetch(key, default=undefined)
raise KeyError, "key #{key} not found"
end

def fetch_values(*keys, &block)
keys.map { |key| fetch(key, &block) }
end

# Searches for an item matching +key+. Returns the item
# if found. Otherwise returns +nil+.
def find_item(key)
Expand Down

0 comments on commit 910d9f8

Please sign in to comment.