code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
assert_normal_exit %q{
a1,a2,b1,b2=Array.new(4){""}
ObjectSpace.define_finalizer(b2,proc{})
ObjectSpace.define_finalizer(b1,proc{b1.inspect})
ObjectSpace.define_finalizer(a2,proc{a1.inspect})
ObjectSpace.define_finalizer(a1,proc{})
}, '[ruby-dev:35778]'
| Ruby |
assert_equal 'A', %q{
class A
@@a = 'A'
def a=(x)
@@a = x
end
def a
@@a
end
end
B = A.dup
B.new.a = 'B'
A.new.a
}, '[ruby-core:17019]'
assert_equal 'ok', %q{
def m
lambda{
proc{
return :ng1
}
}.call.call
:ng2
end
begin
m()
rescue L... | Ruby |
assert_normal_exit %q{
a = []
ms = "a".."k"
("A".."Z").each do |mod|
mod = eval("module #{mod}; self; end")
ms.each do |meth|
iseq = RubyVM::InstructionSequence.compile("module #{mod}; def #{meth}; end; end")
GC.stress = true
iseq.eval
GC.stress = false
end
o = Object.new.extend(mod)
ms.each d... | Ruby |
assert_equal %q{1}, %q{
1.times{
begin
a = 1
ensure
foo = nil
end
}
}
assert_equal %q{2}, %q{
[1,2,3].find{|x| x == 2}
}
assert_equal %q{2}, %q{
class E
include Enumerable
def each(&block)
[1, 2, 3].each(&block)
end
end
E.new.find {|x| x == 2 }
}
assert_equal %q{6},... | Ruby |
assert_equal %q{ok}, %q{
def m
:ng1
mm{
yield
}
:ng2
end
def mm
:ng3
yield
:ng4
end
m{
break :ok
}
}
assert_equal %q{ok}, %q{
3.times{
break :ok
}
}
assert_equal %q{}, %q{
catch(:foo){
throw :foo
}
}
assert_equal %q{false}, %q{
catch(:foo){
throw... | Ruby |
assert_equal 'Struct::Foo', %q{
Struct.instance_eval { const_set(:Foo, nil) }
Struct.new("Foo")
Struct::Foo
}
| Ruby |
assert_normal_exit %q{
eval("", TOPLEVEL_BINDING)
minobj = ObjectSpace.to_enum(:each_object).min_by {|a| a.object_id }
maxobj = ObjectSpace.to_enum(:each_object).max_by {|a| a.object_id }
(((minobj.object_id-100)..(minobj.object_id+100))+
((maxobj.object_id-100)..(maxobj.object_id+100))).each {|id|
begin... | Ruby |
assert_equal %q{E}, %q{$_ = "E"; eval("nil if true..~/^E/",nil,"-e"); $_}
| Ruby |
assert_equal 'ok', %q{
File.unlink('zzz.rb') if File.file?('zzz.rb')
instance_eval do
autoload :ZZZ, './zzz.rb'
begin
ZZZ
rescue LoadError
:ok
end
end
}, '[ruby-dev:43816]'
assert_equal 'ok', %q{
open('zzz.rb', 'w') {|f| f.puts '' }
instance_eval do
autoload :ZZZ, './zzz.rb'
... | Ruby |
# empty program
assert_equal '', ''
assert_equal '', ' '
assert_equal '', "\n"
# special const
assert_equal 'true', 'true'
assert_equal 'TrueClass', 'true.class'
assert_equal 'false', 'false'
assert_equal 'FalseClass', 'false.class'
assert_eq... | Ruby |
assert_equal '0', %q{
begin
GC.stress = true
pid = fork {}
Process.wait pid
$?.to_i
rescue NotImplementedError
0
end
}, '[ruby-dev:32404]'
assert_finish 10, %q{
begin
children = (1..10).map{
Thread.start{fork{}}.value
}
while !children.empty? and pid = Process.wait
c... | Ruby |
assert_equal 'ok', %q{
module M
class A
class << self
attr_accessor :at
def workflow_rule
yield self
end
def eval_str(str)
eval(str)
end
end
end
end
begin
M::A.eval_str(<<-END)
workflow_rule do |r|
r.at 1
end
EN... | Ruby |
# regular argument
assert_equal '1', 'def m() 1 end; m()'
assert_equal '1', 'def m(a) a end; m(1)'
assert_equal '[1, 2]', 'def m(a,b) [a, b] end; m(1,2)'
assert_equal '[1, 2, 3]', 'def m(a,b,c) [a, b, c] end; m(1,2,3)'
assert_equal 'wrong number of arguments (1 for 0)', %q{
def m; end
begin
m(1)
... | Ruby |
assert_equal 'ok', %q{
open("require-lock-test.rb", "w") {|f|
f.puts "sleep 0.1"
f.puts "module M"
f.puts "end"
}
$:.unshift Dir.pwd
vs = (1..2).map {|i|
Thread.start {
require "require-lock-test"
M
}
}.map {|t| t.value }
vs[0] == M && vs[1] == M ? :ok : :ng
}, '[ruby-dev:320... | Ruby |
assert_equal %q{4}, %q{1 && 2 && 3 && 4}
assert_equal %q{}, %q{1 && nil && 3 && 4}
assert_equal %q{}, %q{1 && 2 && 3 && nil}
assert_equal %q{false}, %q{1 && 2 && 3 && false}
assert_equal %q{4}, %q{1 and 2 and 3 and 4}
assert_equal %q{}, %q{1 and nil and 3 and 4}
assert_equal %q{}, %q{1 and 2 and 3 and nil}
assert_equal... | Ruby |
assert_normal_exit %q{
Marshal.load(Marshal.dump({"k"=>"v"}), lambda {|v| v})
}
| Ruby |
assert_equal %q{[1, 2, 3]}, %q{
def getproc &b
b
end
def m
yield
end
m{
i = 1
m{
j = 2
m{
k = 3
getproc{
[i, j, k]
}
}
}
}.call
}
assert_equal %q{7}, %q{
def make_proc(&b)
b
end
def make_closure
a = 0
make_proc{
... | Ruby |
assert_equal %q{2}, %q{
begin
1+1
ensure
2+2
end
}
assert_equal %q{4}, %q{
begin
1+1
begin
2+2
ensure
3+3
end
ensure
4+4
end
}
assert_equal %q{4}, %q{
begin
1+1
begin
2+2
ensure
3+3
end
ensure
4+4
begin
5+5
ensure
... | Ruby |
assert_finish 5, %q{
r, w = IO.pipe
t1 = Thread.new { r.sysread(1) }
t2 = Thread.new { r.sysread(1) }
sleep 0.1
w.write "a"
sleep 0.1
w.write "a"
}, '[ruby-dev:31866]'
assert_finish 10, %q{
begin
require "io/nonblock"
require "timeout"
timeout(3) do
r, w = IO.pipe
w.nonblock?
... | Ruby |
# Thread and Fiber
assert_equal %q{ok}, %q{
Thread.new{
}.join
:ok
}
assert_equal %q{ok}, %q{
Thread.new{
:ok
}.value
}
assert_equal %q{20100}, %q{
v = 0
(1..200).map{|i|
Thread.new{
i
}
}.each{|t|
v += t.value
}
v
}
assert_equal %q{5000}, %q{
5000.times{|e|
(1..2).map{
... | Ruby |
assert_equal '[[1], 2, 3]', '*v1, (a, b) = [1,[2, 3]]; [v1, a, b]'
assert_equal '[[1], 2, 3]', '*v1,(*), (a, b) = [1,:x,[2, 3]]; [v1, a, b]'
assert_equal '[]', '*a = *nil; a'
assert_equal '[nil]', '*a = nil; a'
assert_equal '2', 'a, a = 1, 2; a', "[ruby-dev:31522]"
assert_equal '[1, 2]', ... | Ruby |
class Object
@@golf_hash = {}
def method_missing m, *a, &b
t = @@golf_hash[ [m,self.class] ] ||= matching_methods(m)[0]
if t && b
__send__(t, *a) {|*args|
b.binding.eval("proc{|golf_matchdata| $~ = golf_matchdata }").call($~) if $~
b.call(*args)
}
else
t ? __send__(t, *... | Ruby |
#!./miniruby -sI.
$name = $library = $description = nil
module RbConfig
autoload :CONFIG, "./rbconfig"
end
class Exports
@@subclass = []
def self.inherited(klass)
@@subclass << [/#{klass.name.sub(/.*::/, '').downcase}/i, klass]
end
def self.create(*args, &block)
platform = RUBY_PLATFORM
pat, k... | Ruby |
#!./miniruby -sI.
require './rbconfig'
CONFIG = RbConfig::MAKEFILE_CONFIG
version = RUBY_VERSION.split(/\./)
patch = CONFIG['PATCHLEVEL']
nversion = (version + [patch.to_i < 0 ? '0' : patch]).join(',')
sversion = version.join('.') + (patch.to_i < 0 ? 'dev' : "p#{patch}")
$ruby_name ||= CONFIG["RUBY_INSTALL_NAME"]
$... | Ruby |
load File.dirname(__FILE__) + '/rubyspec/ruby.1.9.mspec'
class MSpecScript
builddir = Dir.pwd
srcdir = ENV['SRCDIR']
if !srcdir and File.exist?("#{builddir}/Makefile") then
File.open("#{builddir}/Makefile", "r:US-ASCII") {|f|
f.read[/^\s*srcdir\s*=\s*(.+)/i] and srcdir = $1
}
end
config = proc{... | Ruby |
# -*-ruby-*-
#
class VM
class InstructionSequence
class Instruction
InsnID2NO = {
<%= insn_id2no %>
}
def self.id2insn_no id
if InsnID2NO.has_key? id
InsnID2NO[id]
end
end
end
end
end
| Ruby |
%w'enc/encdb.so enc/trans/transdb.so'.each do |init|
begin
require(init)
rescue LoadError
end
end
| Ruby |
#! ./miniruby
dir = File.expand_path("../..", __FILE__)
$:.unshift(dir)
$:.unshift(".")
if $".grep(/mkmf/).empty?
$" << "mkmf.rb"
load File.expand_path("lib/mkmf.rb", dir)
end
require 'erb'
CONFIG["MAKEDIRS"] ||= '$(MINIRUBY) -run -e mkdir -- -p'
BUILTIN_ENCS = []
BUILTIN_TRANSES = []
ENC_PATTERNS = []
NOENC_PAT... | Ruby |
WINDOWS_1257_TO_UCS_TBL = [
["A0",0xA0],
["A2",0xA2],
["A3",0xA3],
["A4",0xA4],
["A6",0xA6],
["A7",0xA7],
["8D",0xA8],
["A9",0xA9],
["AB",0xAB],
["AC",0xAC],
["AD",0xAD],
["AE",0xAE],
["9D",0xAF],
["B0",0xB0],
["B1",0xB1],
["B2",0xB2],
["B3",0xB3],
["B4",0xB4],
["B5",0xB5],
["B6"... | Ruby |
ISO_8859_7_TO_UCS_TBL = [
["A0",0xA0],
["A1",0x2018],
["A2",0x2019],
["A3",0xA3],
["A4",0x20AC],
["A5",0x20AF],
["A6",0xA6],
["A7",0xA7],
["A8",0xA8],
["A9",0xA9],
["AA",0x37A],
["AB",0xAB],
["AC",0xAC],
["AD",0xAD],
["AF",0x2015],
["B0",0xB0],
["B1",0xB1],
["B2",0xB2],
["B3",0xB3]... | Ruby |
ISO_8859_10_TO_UCS_TBL = [
["A0",0xA0],
["A1",0x104],
["A2",0x112],
["A3",0x122],
["A4",0x12A],
["A5",0x128],
["A6",0x136],
["A7",0xA7],
["A8",0x13B],
["A9",0x110],
["AA",0x160],
["AB",0x166],
["AC",0x17D],
["AD",0xAD],
["AE",0x16A],
["AF",0x14A],
["B0",0xB0],
["B1",0x105],
["B2",0... | Ruby |
MACTURKISH_TO_UCS_TBL = [
["CA",0xA0],
["C1",0xA1],
["A2",0xA2],
["A3",0xA3],
["B4",0xA5],
["A4",0xA7],
["AC",0xA8],
["A9",0xA9],
["BB",0xAA],
["C7",0xAB],
["C2",0xAC],
["A8",0xAE],
["F8",0xAF],
["A1",0xB0],
["B1",0xB1],
["AB",0xB4],
["B5",0xB5],
["A6",0xB6],
["E1",0xB7],
["FC",0... | Ruby |
IBM866_TO_UCS_TBL = [
["FF",0xA0],
["FD",0xA4],
["F8",0xB0],
["FA",0xB7],
["F0",0x401],
["F2",0x404],
["F4",0x407],
["F6",0x40E],
["80",0x410],
["81",0x411],
["82",0x412],
["83",0x413],
["84",0x414],
["85",0x415],
["86",0x416],
["87",0x417],
["88",0x418],
["89",0x419],
["8A",0x41A]... | Ruby |
IBM775_TO_UCS_TBL = [
["FF",0xA0],
["96",0xA2],
["9C",0xA3],
["9F",0xA4],
["A7",0xA6],
["F5",0xA7],
["A8",0xA9],
["AE",0xAB],
["AA",0xAC],
["F0",0xAD],
["A9",0xAE],
["F8",0xB0],
["F1",0xB1],
["FD",0xB2],
["FC",0xB3],
["E6",0xB5],
["F4",0xB6],
["FA",0xB7],
["FB",0xB9],
["AF",0xBB]... | Ruby |
ISO_8859_13_TO_UCS_TBL = [
["A0",0xA0],
["A1",0x201D],
["A2",0xA2],
["A3",0xA3],
["A4",0xA4],
["A5",0x201E],
["A6",0xA6],
["A7",0xA7],
["A8",0xD8],
["A9",0xA9],
["AA",0x156],
["AB",0xAB],
["AC",0xAC],
["AD",0xAD],
["AE",0xAE],
["AF",0xC6],
["B0",0xB0],
["B1",0xB1],
["B2",0xB2],
[... | Ruby |
WINDOWS_1254_TO_UCS_TBL = [
["A0",0xA0],
["A1",0xA1],
["A2",0xA2],
["A3",0xA3],
["A4",0xA4],
["A5",0xA5],
["A6",0xA6],
["A7",0xA7],
["A8",0xA8],
["A9",0xA9],
["AA",0xAA],
["AB",0xAB],
["AC",0xAC],
["AD",0xAD],
["AE",0xAE],
["AF",0xAF],
["B0",0xB0],
["B1",0xB1],
["B2",0xB2],
["B3"... | Ruby |
MACUKRAINE_TO_UCS_TBL = [
["CA",0xA0],
["A3",0xA3],
["FF",0xA4],
["A4",0xA7],
["A9",0xA9],
["C7",0xAB],
["C2",0xAC],
["A8",0xAE],
["A1",0xB0],
["B1",0xB1],
["B5",0xB5],
["A6",0xB6],
["C8",0xBB],
["D6",0xF7],
["C4",0x192],
["DD",0x401],
["AB",0x402],
["AE",0x403],
["B8",0x404],
["... | Ruby |
BIG5_HKSCS_TO_UCS_TBL= [
["A246",0xA2],
["A247",0xA3],
["A244",0xA5],
["A1B1",0xA7],
["C6D8",0xA8],
["A258",0xB0],
["A1D3",0xB1],
["A150",0xB7],
["8859",0xC0],
["8857",0xC1],
["885D",0xC8],
["885B",0xC9],
["8866",0xCA],
["8861",0xD2],
["885F",0xD3],
["A1D1",0xD7],
["886A",0xE0],
["88... | Ruby |
MACICELAND_TO_UCS_TBL = [
["CA",0xA0],
["C1",0xA1],
["A2",0xA2],
["A3",0xA3],
["DB",0xA4],
["B4",0xA5],
["A4",0xA7],
["AC",0xA8],
["A9",0xA9],
["BB",0xAA],
["C7",0xAB],
["C2",0xAC],
["A8",0xAE],
["F8",0xAF],
["A1",0xB0],
["B1",0xB1],
["AB",0xB4],
["B5",0xB5],
["A6",0xB6],
["E1",0... | Ruby |
EUCKR_TO_UCS_TBL = [
["A1A1",0x3000],
["A1A2",0x3001],
["A1A3",0x3002],
["A1A4",0xB7],
["A1A5",0x2025],
["A1A6",0x2026],
["A1A7",0xA8],
["A1A8",0x3003],
["A1A9",0xAD],
["A1AA",0x2015],
["A1AB",0x2225],
["A1AC",0xFF3C],
["A1AD",0x223C],
["A1AE",0x2018],
["A1AF",0x2019],
["A1B0",0x201C],
... | Ruby |
require 'euckr-tbl'
CP949_TO_UCS_ADDITIONAL_TBL = [
["8141",0xAC02],
["8142",0xAC03],
["8143",0xAC05],
["8144",0xAC06],
["8145",0xAC0B],
["8146",0xAC0C],
["8147",0xAC0D],
["8148",0xAC0E],
["8149",0xAC0F],
["814A",0xAC18],
["814B",0xAC1E],
["814C",0xAC1F],
["814D",0xAC21],
["814E",0xAC22],
... | Ruby |
IBM863_TO_UCS_TBL = [
["FF",0xA0],
["9B",0xA2],
["9C",0xA3],
["98",0xA4],
["A0",0xA6],
["8F",0xA7],
["A4",0xA8],
["AE",0xAB],
["AA",0xAC],
["A7",0xAF],
["F8",0xB0],
["F1",0xB1],
["FD",0xB2],
["A6",0xB3],
["A1",0xB4],
["E6",0xB5],
["86",0xB6],
["FA",0xB7],
["A5",0xB8],
["AF",0xBB]... | Ruby |
ISO_8859_8_TO_UCS_TBL = [
["A0",0xA0],
["A2",0xA2],
["A3",0xA3],
["A4",0xA4],
["A5",0xA5],
["A6",0xA6],
["A7",0xA7],
["A8",0xA8],
["A9",0xA9],
["AA",0xD7],
["AB",0xAB],
["AC",0xAC],
["AD",0xAD],
["AE",0xAE],
["AF",0xAF],
["B0",0xB0],
["B1",0xB1],
["B2",0xB2],
["B3",0xB3],
["B4",0... | Ruby |
KOI8_U_TO_UCS_TBL = [
["9A",0xA0],
["BF",0xA9],
["9C",0xB0],
["9D",0xB2],
["9E",0xB7],
["9F",0xF7],
["B3",0x401],
["B4",0x404],
["B6",0x406],
["B7",0x407],
["E1",0x410],
["E2",0x411],
["F7",0x412],
["E7",0x413],
["E4",0x414],
["E5",0x415],
["F6",0x416],
["FA",0x417],
["E9",0x418],
... | Ruby |
IBM862_TO_UCS_TBL = [
["FF",0xA0],
["AD",0xA1],
["9B",0xA2],
["9C",0xA3],
["9D",0xA5],
["A6",0xAA],
["AE",0xAB],
["AA",0xAC],
["F8",0xB0],
["F1",0xB1],
["FD",0xB2],
["E6",0xB5],
["FA",0xB7],
["A7",0xBA],
["AF",0xBB],
["AC",0xBC],
["AB",0xBD],
["A8",0xBF],
["A5",0xD1],
["E1",0xDF]... | Ruby |
CP855_TO_UCS_TBL = [
["FF",0xA0],
["CF",0xA4],
["FD",0xA7],
["AE",0xAB],
["F0",0xAD],
["AF",0xBB],
["85",0x401],
["81",0x402],
["83",0x403],
["87",0x404],
["89",0x405],
["8B",0x406],
["8D",0x407],
["8F",0x408],
["91",0x409],
["93",0x40A],
["95",0x40B],
["97",0x40C],
["99",0x40E],
... | Ruby |
ISO_8859_11_TO_UCS_TBL = [
["A0",0xA0],
["A1",0xE01],
["A2",0xE02],
["A3",0xE03],
["A4",0xE04],
["A5",0xE05],
["A6",0xE06],
["A7",0xE07],
["A8",0xE08],
["A9",0xE09],
["AA",0xE0A],
["AB",0xE0B],
["AC",0xE0C],
["AD",0xE0D],
["AE",0xE0E],
["AF",0xE0F],
["B0",0xE10],
["B1",0xE11],
["B2... | Ruby |
CP850_TO_UCS_TBL = [
["FF",0xA0],
["AD",0xA1],
["BD",0xA2],
["9C",0xA3],
["CF",0xA4],
["BE",0xA5],
["DD",0xA6],
["F5",0xA7],
["F9",0xA8],
["B8",0xA9],
["A6",0xAA],
["AE",0xAB],
["AA",0xAC],
["F0",0xAD],
["A9",0xAE],
["EE",0xAF],
["F8",0xB0],
["F1",0xB1],
["FD",0xB2],
["FC",0xB3],... | Ruby |
WINDOWS_1251_TO_UCS_TBL = [
["A0",0xA0],
["A4",0xA4],
["A6",0xA6],
["A7",0xA7],
["A9",0xA9],
["AB",0xAB],
["AC",0xAC],
["AD",0xAD],
["AE",0xAE],
["B0",0xB0],
["B1",0xB1],
["B5",0xB5],
["B6",0xB6],
["B7",0xB7],
["BB",0xBB],
["A8",0x401],
["80",0x402],
["81",0x403],
["AA",0x404],
[... | Ruby |
TIS_620_TO_UCS_TBL = [
["A1",0xE01],
["A2",0xE02],
["A3",0xE03],
["A4",0xE04],
["A5",0xE05],
["A6",0xE06],
["A7",0xE07],
["A8",0xE08],
["A9",0xE09],
["AA",0xE0A],
["AB",0xE0B],
["AC",0xE0C],
["AD",0xE0D],
["AE",0xE0E],
["AF",0xE0F],
["B0",0xE10],
["B1",0xE11],
["B2",0xE12],
["B3",0... | Ruby |
ISO_8859_1_TO_UCS_TBL = [
["A0",0xA0],
["A1",0xA1],
["A2",0xA2],
["A3",0xA3],
["A4",0xA4],
["A5",0xA5],
["A6",0xA6],
["A7",0xA7],
["A8",0xA8],
["A9",0xA9],
["AA",0xAA],
["AB",0xAB],
["AC",0xAC],
["AD",0xAD],
["AE",0xAE],
["AF",0xAF],
["B0",0xB0],
["B1",0xB1],
["B2",0xB2],
["B3",0... | Ruby |
ISO_8859_15_TO_UCS_TBL = [
["A0",0xA0],
["A1",0xA1],
["A2",0xA2],
["A3",0xA3],
["A4",0x20AC],
["A5",0xA5],
["A6",0x160],
["A7",0xA7],
["A8",0x161],
["A9",0xA9],
["AA",0xAA],
["AB",0xAB],
["AC",0xAC],
["AD",0xAD],
["AE",0xAE],
["AF",0xAF],
["B0",0xB0],
["B1",0xB1],
["B2",0xB2],
["... | Ruby |
IBM852_TO_UCS_TBL = [
["FF",0xA0],
["CF",0xA4],
["F5",0xA7],
["F9",0xA8],
["AE",0xAB],
["AA",0xAC],
["F0",0xAD],
["F8",0xB0],
["EF",0xB4],
["F7",0xB8],
["AF",0xBB],
["B5",0xC1],
["B6",0xC2],
["8E",0xC4],
["80",0xC7],
["90",0xC9],
["D3",0xCB],
["D6",0xCD],
["D7",0xCE],
["E0",0xD3]... | Ruby |
IBM857_TO_UCS_TBL = [
["FF",0xA0],
["AD",0xA1],
["BD",0xA2],
["9C",0xA3],
["CF",0xA4],
["BE",0xA5],
["DD",0xA6],
["F5",0xA7],
["F9",0xA8],
["B8",0xA9],
["D1",0xAA],
["AE",0xAB],
["AA",0xAC],
["F0",0xAD],
["A9",0xAE],
["EE",0xAF],
["F8",0xB0],
["F1",0xB1],
["FD",0xB2],
["FC",0xB3]... | Ruby |
BIG5_UAO_TO_UCS_TBL = [
["8140",0x4E17],
["8141",0x4E22],
["8142",0x4E2C],
["8143",0x4E55],
["8144",0x4E62],
["8145",0x4E8A],
["8146",0x4EB0],
["8147",0x4EEB],
["8148",0x4EED],
["8149",0x4EFC],
["814A",0x4F1C],
["814B",0x4F8A],
["814C",0x4FFF],
["814D",0x5042],
["814E",0x5050],
["814F",0... | Ruby |
ISO_8859_6_TO_UCS_TBL = [
["A0",0xA0],
["A4",0xA4],
["AC",0x60C],
["AD",0xAD],
["BB",0x61B],
["BF",0x61F],
["C1",0x621],
["C2",0x622],
["C3",0x623],
["C4",0x624],
["C5",0x625],
["C6",0x626],
["C7",0x627],
["C8",0x628],
["C9",0x629],
["CA",0x62A],
["CB",0x62B],
["CC",0x62C],
["CD",0... | Ruby |
MACCYRILLIC_TO_UCS_TBL = [
["CA",0xA0],
["A2",0xA2],
["A3",0xA3],
["FF",0xA4],
["A4",0xA7],
["A9",0xA9],
["C7",0xAB],
["C2",0xAC],
["A8",0xAE],
["A1",0xB0],
["B1",0xB1],
["B5",0xB5],
["A6",0xB6],
["C8",0xBB],
["D6",0xF7],
["C4",0x192],
["DD",0x401],
["AB",0x402],
["AE",0x403],
["... | Ruby |
GB18030_TO_UCS_TBL = [
["81308130",0x80],
["81308131",0x81],
["81308132",0x82],
["81308133",0x83],
["81308134",0x84],
["81308135",0x85],
["81308136",0x86],
["81308137",0x87],
["81308138",0x88],
["81308139",0x89],
["81308230",0x8A],
["81308231",0x8B],
["81308232",0x8C],
["81308233",0x8D],
[... | Ruby |
CP852_TO_UCS_TBL = [
["FF",0xA0],
["CF",0xA4],
["F5",0xA7],
["F9",0xA8],
["AE",0xAB],
["AA",0xAC],
["F0",0xAD],
["F8",0xB0],
["EF",0xB4],
["F7",0xB8],
["AF",0xBB],
["B5",0xC1],
["B6",0xC2],
["8E",0xC4],
["80",0xC7],
["90",0xC9],
["D3",0xCB],
["D6",0xCD],
["D7",0xCE],
["E0",0xD3],... | Ruby |
WINDOWS_1250_TO_UCS_TBL = [
["A0",0xA0],
["A4",0xA4],
["A6",0xA6],
["A7",0xA7],
["A8",0xA8],
["A9",0xA9],
["AB",0xAB],
["AC",0xAC],
["AD",0xAD],
["AE",0xAE],
["B0",0xB0],
["B1",0xB1],
["B4",0xB4],
["B5",0xB5],
["B6",0xB6],
["B7",0xB7],
["B8",0xB8],
["BB",0xBB],
["C1",0xC1],
["C2"... | Ruby |
IBM865_TO_UCS_TBL = [
["FF",0xA0],
["AD",0xA1],
["9C",0xA3],
["AF",0xA4],
["A6",0xAA],
["AE",0xAB],
["AA",0xAC],
["F8",0xB0],
["F1",0xB1],
["FD",0xB2],
["E6",0xB5],
["FA",0xB7],
["A7",0xBA],
["AC",0xBC],
["AB",0xBD],
["A8",0xBF],
["8E",0xC4],
["8F",0xC5],
["92",0xC6],
["80",0xC7]... | Ruby |
IBM437_TO_UCS_TBL = [
["FF",0xA0],
["AD",0xA1],
["9B",0xA2],
["9C",0xA3],
["9D",0xA5],
["A6",0xAA],
["AE",0xAB],
["AA",0xAC],
["F8",0xB0],
["F1",0xB1],
["FD",0xB2],
["E6",0xB5],
["FA",0xB7],
["A7",0xBA],
["AF",0xBB],
["AC",0xBC],
["AB",0xBD],
["A8",0xBF],
["8E",0xC4],
["8F",0xC5]... | Ruby |
MACROMANIA_TO_UCS_TBL = [
["CA",0xA0],
["C1",0xA1],
["A2",0xA2],
["A3",0xA3],
["DB",0xA4],
["B4",0xA5],
["A4",0xA7],
["AC",0xA8],
["A9",0xA9],
["BB",0xAA],
["C7",0xAB],
["C2",0xAC],
["A8",0xAE],
["F8",0xAF],
["A1",0xB0],
["B1",0xB1],
["AB",0xB4],
["B5",0xB5],
["A6",0xB6],
["E1",0... | Ruby |
ISO_8859_5_TO_UCS_TBL = [
["A0",0xA0],
["A1",0x401],
["A2",0x402],
["A3",0x403],
["A4",0x404],
["A5",0x405],
["A6",0x406],
["A7",0x407],
["A8",0x408],
["A9",0x409],
["AA",0x40A],
["AB",0x40B],
["AC",0x40C],
["AD",0xAD],
["AE",0x40E],
["AF",0x40F],
["B0",0x410],
["B1",0x411],
["B2",... | Ruby |
IBM855_TO_UCS_TBL = [
["FF",0xA0],
["CF",0xA4],
["FD",0xA7],
["AE",0xAB],
["F0",0xAD],
["AF",0xBB],
["85",0x401],
["81",0x402],
["83",0x403],
["87",0x404],
["89",0x405],
["8B",0x406],
["8D",0x407],
["8F",0x408],
["91",0x409],
["93",0x40A],
["95",0x40B],
["97",0x40C],
["99",0x40E],
... | Ruby |
ISO_8859_14_TO_UCS_TBL = [
["A0",0xA0],
["A1",0x1E02],
["A2",0x1E03],
["A3",0xA3],
["A4",0x10A],
["A5",0x10B],
["A6",0x1E0A],
["A7",0xA7],
["A8",0x1E80],
["A9",0xA9],
["AA",0x1E82],
["AB",0x1E0B],
["AC",0x1EF2],
["AD",0xAD],
["AE",0xAE],
["AF",0x178],
["B0",0x1E1E],
["B1",0x1E1F],
... | Ruby |
IBM869_TO_UCS_TBL = [
["FF",0xA0],
["9C",0xA3],
["8A",0xA6],
["F5",0xA7],
["F9",0xA8],
["97",0xA9],
["AE",0xAB],
["89",0xAC],
["F0",0xAD],
["F8",0xB0],
["F1",0xB1],
["99",0xB2],
["9A",0xB3],
["88",0xB7],
["AF",0xBB],
["AB",0xBD],
["EF",0x384],
["F7",0x385],
["86",0x386],
["8D",0x... | Ruby |
EMOJI_EXCHANGE_TBL = Hash.new{|h,k| h[k] = {}}
EMOJI_EXCHANGE_TBL['UTF8-DoCoMo']['UTF8-KDDI'] = [
["ee98be", "ee9288"], # [BLACK SUN WITH RAYS] U+E63E -> U+E488
["ee98bf", "ee928d"], # [CLOUD] U+E63F -> U+E48D
["ee9980", "ee928c"], # [UMBRELLA WITH RAIN DROPS] U+E640 -> U+E48C
["ee9981", "ee9285"], # [SNOWMAN W... | Ruby |
MACGREEK_TO_UCS_TBL = [
["CA",0xA0],
["92",0xA3],
["B4",0xA5],
["9B",0xA6],
["AC",0xA7],
["8C",0xA8],
["A9",0xA9],
["C7",0xAB],
["C2",0xAC],
["9C",0xAD],
["A8",0xAE],
["AE",0xB0],
["B1",0xB1],
["82",0xB2],
["84",0xB3],
["81",0xB9],
["C8",0xBB],
["97",0xBD],
["80",0xC4],
["83",0xC... | Ruby |
MACROMAN_TO_UCS_TBL = [
["CA",0xA0],
["C1",0xA1],
["A2",0xA2],
["A3",0xA3],
["DB",0xA4],
["B4",0xA5],
["A4",0xA7],
["AC",0xA8],
["A9",0xA9],
["BB",0xAA],
["C7",0xAB],
["C2",0xAC],
["A8",0xAE],
["F8",0xAF],
["A1",0xB0],
["B1",0xB1],
["AB",0xB4],
["B5",0xB5],
["A6",0xB6],
["E1",0xB... | Ruby |
ISO_8859_3_TO_UCS_TBL = [
["A0",0xA0],
["A1",0x126],
["A2",0x2D8],
["A3",0xA3],
["A4",0xA4],
["A6",0x124],
["A7",0xA7],
["A8",0xA8],
["A9",0x130],
["AA",0x15E],
["AB",0x11E],
["AC",0x134],
["AD",0xAD],
["AF",0x17B],
["B0",0xB0],
["B1",0x127],
["B2",0xB2],
["B3",0xB3],
["B4",0xB4],
... | Ruby |
MACCROATIAN_TO_UCS_TBL = [
["CA",0xA0],
["C1",0xA1],
["A2",0xA2],
["A3",0xA3],
["DB",0xA4],
["A4",0xA7],
["AC",0xA8],
["D9",0xA9],
["BB",0xAA],
["C7",0xAB],
["C2",0xAC],
["A8",0xAE],
["F8",0xAF],
["A1",0xB0],
["B1",0xB1],
["AB",0xB4],
["B5",0xB5],
["A6",0xB6],
["E1",0xB7],
["FC",... | Ruby |
GBK_TO_UCS_TBL= [
["A1E8",0xA4],
["A1EC",0xA7],
["A1A7",0xA8],
["A1E3",0xB0],
["A1C0",0xB1],
["A1A4",0xB7],
["A1C1",0xD7],
["A8A4",0xE0],
["A8A2",0xE1],
["A8A8",0xE8],
["A8A6",0xE9],
["A8BA",0xEA],
["A8AC",0xEC],
["A8AA",0xED],
["A8B0",0xF2],
["A8AE",0xF3],
["A1C2",0xF7],
["A8B4",0xF... | Ruby |
KOI8_R_TO_UCS_TBL = [
["9A",0xA0],
["BF",0xA9],
["9C",0xB0],
["9D",0xB2],
["9E",0xB7],
["9F",0xF7],
["B3",0x401],
["E1",0x410],
["E2",0x411],
["F7",0x412],
["E7",0x413],
["E4",0x414],
["E5",0x415],
["F6",0x416],
["FA",0x417],
["E9",0x418],
["EA",0x419],
["EB",0x41A],
["EC",0x41B],
... | Ruby |
WINDOWS_1253_TO_UCS_TBL = [
["A0",0xA0],
["A3",0xA3],
["A4",0xA4],
["A5",0xA5],
["A6",0xA6],
["A7",0xA7],
["A8",0xA8],
["A9",0xA9],
["AB",0xAB],
["AC",0xAC],
["AD",0xAD],
["AE",0xAE],
["B0",0xB0],
["B1",0xB1],
["B2",0xB2],
["B3",0xB3],
["B5",0xB5],
["B6",0xB6],
["B7",0xB7],
["BB"... | Ruby |
IBM737_TO_UCS_TBL = [
["80",0x391],
["81",0x392],
["82",0x393],
["83",0x394],
["84",0x395],
["85",0x396],
["86",0x397],
["87",0x398],
["88",0x399],
["89",0x39A],
["8A",0x39B],
["8B",0x39C],
["8C",0x39D],
["8D",0x39E],
["8E",0x39F],
["8F",0x3A0],
["90",0x3A1],
["91",0x3A3],
["92",0x... | Ruby |
ISO_8859_2_TO_UCS_TBL = [
["A0",0xA0],
["A1",0x104],
["A2",0x2D8],
["A3",0x141],
["A4",0xA4],
["A5",0x13D],
["A6",0x15A],
["A7",0xA7],
["A8",0xA8],
["A9",0x160],
["AA",0x15E],
["AB",0x164],
["AC",0x179],
["AD",0xAD],
["AE",0x17D],
["AF",0x17B],
["B0",0xB0],
["B1",0x105],
["B2",0x2D... | Ruby |
WINDOWS_1252_TO_UCS_TBL = [
["A0",0xA0],
["A1",0xA1],
["A2",0xA2],
["A3",0xA3],
["A4",0xA4],
["A5",0xA5],
["A6",0xA6],
["A7",0xA7],
["A8",0xA8],
["A9",0xA9],
["AA",0xAA],
["AB",0xAB],
["AC",0xAC],
["AD",0xAD],
["AE",0xAE],
["AF",0xAF],
["B0",0xB0],
["B1",0xB1],
["B2",0xB2],
["B3"... | Ruby |
WINDOWS_1255_TO_UCS_TBL = [
["A0",0xA0],
["A1",0xA1],
["A2",0xA2],
["A3",0xA3],
["A5",0xA5],
["A6",0xA6],
["A7",0xA7],
["A8",0xA8],
["A9",0xA9],
["AB",0xAB],
["AC",0xAC],
["AD",0xAD],
["AE",0xAE],
["AF",0xAF],
["B0",0xB0],
["B1",0xB1],
["B2",0xB2],
["B3",0xB3],
["B4",0xB4],
["B5"... | Ruby |
ISO_8859_4_TO_UCS_TBL = [
["A0",0xA0],
["A1",0x104],
["A2",0x138],
["A3",0x156],
["A4",0xA4],
["A5",0x128],
["A6",0x13B],
["A7",0xA7],
["A8",0xA8],
["A9",0x160],
["AA",0x112],
["AB",0x122],
["AC",0x166],
["AD",0xAD],
["AE",0x17D],
["AF",0xAF],
["B0",0xB0],
["B1",0x105],
["B2",0x2DB... | Ruby |
WINDOWS_874_TO_UCS_TBL = [
["A0",0xA0],
["A1",0xE01],
["A2",0xE02],
["A3",0xE03],
["A4",0xE04],
["A5",0xE05],
["A6",0xE06],
["A7",0xE07],
["A8",0xE08],
["A9",0xE09],
["AA",0xE0A],
["AB",0xE0B],
["AC",0xE0C],
["AD",0xE0D],
["AE",0xE0E],
["AF",0xE0F],
["B0",0xE10],
["B1",0xE11],
["B2... | Ruby |
IBM861_TO_UCS_TBL = [
["FF",0xA0],
["AD",0xA1],
["9C",0xA3],
["AE",0xAB],
["AA",0xAC],
["F8",0xB0],
["F1",0xB1],
["FD",0xB2],
["E6",0xB5],
["FA",0xB7],
["AF",0xBB],
["AC",0xBC],
["AB",0xBD],
["A8",0xBF],
["A4",0xC1],
["8E",0xC4],
["8F",0xC5],
["92",0xC6],
["80",0xC7],
["90",0xC9]... | Ruby |
ISO_8859_9_TO_UCS_TBL = [
["A0",0xA0],
["A1",0xA1],
["A2",0xA2],
["A3",0xA3],
["A4",0xA4],
["A5",0xA5],
["A6",0xA6],
["A7",0xA7],
["A8",0xA8],
["A9",0xA9],
["AA",0xAA],
["AB",0xAB],
["AC",0xAC],
["AD",0xAD],
["AE",0xAE],
["AF",0xAF],
["B0",0xB0],
["B1",0xB1],
["B2",0xB2],
["B3",0... | Ruby |
# http://developer.apple.com/technotes/tn/tn1150table.html
MAC_DECOMPOSE_TBL = [
["c380", "41cc80"],
["c381", "41cc81"],
["c382", "41cc82"],
["c383", "41cc83"],
["c384", "41cc88"],
["c385", "41cc8a"],
["c387", "43cca7"],
["c388", "45cc80"],
["c389", "45cc81"],
["c38a", "45cc82"],
["c38b", "45cc88"... | Ruby |
IBM860_TO_UCS_TBL = [
["FF",0xA0],
["AD",0xA1],
["9B",0xA2],
["9C",0xA3],
["A6",0xAA],
["AE",0xAB],
["AA",0xAC],
["F8",0xB0],
["F1",0xB1],
["FD",0xB2],
["E6",0xB5],
["FA",0xB7],
["A7",0xBA],
["AF",0xBB],
["AC",0xBC],
["AB",0xBD],
["A8",0xBF],
["91",0xC0],
["86",0xC1],
["8F",0xC2]... | Ruby |
WINDOWS_1256_TO_UCS_TBL = [
["A0",0xA0],
["A2",0xA2],
["A3",0xA3],
["A4",0xA4],
["A5",0xA5],
["A6",0xA6],
["A7",0xA7],
["A8",0xA8],
["A9",0xA9],
["AB",0xAB],
["AC",0xAC],
["AD",0xAD],
["AE",0xAE],
["AF",0xAF],
["B0",0xB0],
["B1",0xB1],
["B2",0xB2],
["B3",0xB3],
["B4",0xB4],
["B5"... | Ruby |
# $Id: strip-comment.rb 25189 2009-10-02 12:04:37Z akr $
require 'ripper/filter'
class CommentStripper < Ripper::Filter
def CommentStripper.strip(src)
new(src).parse(nil)
end
def on_default(event, token, data)
print token
end
def on_comment(token, data)
puts
end
end
CommentStripper.strip(AR... | Ruby |
#!/usr/bin/env ruby
# $originalId: ruby2html.rb,v 1.2 2005/09/23 22:53:47 aamine Exp $
TEMPLATE_LINE = __LINE__ + 2
TEMPLATE = <<-EndTemplate
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<%= encoding %>">
<% if css %>
<lin... | Ruby |
# directory access
# list all files but .*/*~/*.o
dirp = Dir.open(".")
for f in dirp
case f
when /^\./, /~$/, /\.o/
# do not print
else
print f, "\n"
end
end
dirp.close
| Ruby |
#!/usr/local/bin/ruby
k, a, b, a1, b1 = 2, 4, 1, 12, 4
loop do
# Next approximation
p, q, k = k*k, 2*k+1, k+1
a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1
# Print common digits
d = a / b
d1 = a1 / b1
while d == d1
print d
$stdout.flush
a, a1 = 10*(a%b), 10*(a1%b1)
d, d1 = a/b, a1/b1
end
e... | Ruby |
=begin
multiple DRbServer client
Copyright (c) 1999-2002 Masatoshi SEKI
=end
require 'drb/drb'
if __FILE__ == $0
s1 = ARGV.shift
s2 = ARGV.shift
unless s1 && s2
$stderr.puts("usage: #{$0} <server_uri1> <server_uri2>")
exit 1
end
DRb.start_service()
r1 = DRbObject.new(nil, s1)
r2 = DRbObject... | Ruby |
require 'drb/drb'
require 'rinda/rinda'
def do_it(v)
puts "do_it(#{v})"
v + v
end
uri = ARGV.shift || raise("usage: #{$0} <server_uri>")
DRb.start_service
ts = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, uri))
while true
r = ts.take(['sum', nil, nil])
v = do_it(r[2])
ts.write(['ans', r[1], r[2], v])
end... | Ruby |
=begin
distributed Ruby --- dRuby Sample Client
Copyright (c) 1999-2000 Masatoshi SEKI
=end
require 'drb/drb'
require 'drb/http'
class DRbEx2
include DRbUndumped
def initialize(n)
@n = n
end
def to_i
@n.to_i
end
end
if __FILE__ == $0
there = ARGV.shift
unless there
$stderr.puts("usage:... | Ruby |
=begin
distributed Ruby --- fetch
Copyright (c) 1999-2000 Masatoshi SEKI
=end
require 'drb/drb'
require 'dqlib'
there = ARGV.shift || raise("usage: #{$0} <server_uri>")
DRb.start_service
queue = DRbObject.new(nil, there)
entry = queue.pop
puts entry.greeting
| Ruby |
=begin
multiple DRbServer
Copyright (c) 1999-2002 Masatoshi SEKI
=end
=begin
How to play.
Terminal 1
| % ruby drbm.rb
| druby://yourhost:7640 druby://yourhost:7641
Terminal 2
| % ruby drbmc.rb druby://yourhost:7640 druby://yourhost:7641
| [#<DRb::DRbObject .... @uri="druby://yourhost:7640">, "FOO"]
| [#<D... | Ruby |
#!/usr/local/bin/ruby
uri = ARGV.shift || raise("usage: #{$0} URI")
N = (ARGV.shift || 100).to_i
case uri
when /^tcpromp:/, /^unixromp:/
require 'romp'
client = ROMP::Client.new(uri, false)
foo = client.resolve("foo")
when /^druby:/
require 'drb/drb'
DRb.start_service
foo = DRbObject.new(nil, uri)
end
... | Ruby |
=begin
distributed Ruby --- dRuby Sample Server
Copyright (c) 1999-2000,2002 Masatoshi SEKI
=end
=begin
How to play.
Terminal 1
| % ruby drbs.rb
| druby://yourhost:7640
Terminal 2
| % ruby drbc.rb druby://yourhost:7640
| "hello"
| ....
=end
require 'drb/drb'
class DRbEx
include DRbUndumped
def ini... | Ruby |
=begin
distributed Ruby --- chat server
Copyright (c) 1999-2000 Masatoshi SEKI
=end
require 'thread'
require 'drb/drb'
class ChatEntry
include DRbUndumped
def initialize(server, there)
@server = server
@there = there
@name = there.name
@key = there.key = Time.now
end
attr :name, true
attr... | Ruby |
#!/usr/local/bin/ruby
# TupleSpace
# Copyright (c) 1999-2000 Masatoshi SEKI
# You can redistribute it and/or modify it under the same terms as Ruby.
require 'thread'
class TupleSpace
class Template
def initialize(list)
@list = list
@check_idx = []
@list.each_with_index do |x, i|
@check_idx.pu... | Ruby |
require 'drb/drb'
class Foo
include DRbUndumped
def foo(n)
n + n
end
def bar(n)
yield(n) + yield(n)
end
end
DRb.start_service(nil)
puts DRb.uri
ro = DRbObject.new(nil, ARGV.shift)
ro[:tcp] = Foo.new
gets
it = ro[:unix]
p [it, it.foo(1)]
gets
p it.bar('2') {|n| n * 3}
gets
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.