infraruby-shim 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +19 -0
- data/README.md +25 -0
- data/infraruby-shim.gemspec +16 -0
- data/lib/infraruby-shim.rb +3 -0
- data/ruby/Array.rb +25 -0
- data/ruby/Bignum.rb +10 -0
- data/ruby/Date.rb +11 -0
- data/ruby/Enumerable.rb +8 -0
- data/ruby/Fixnum.rb +10 -0
- data/ruby/Float.rb +5 -0
- data/ruby/Hash.rb +15 -0
- data/ruby/InfraRuby.rb +2 -0
- data/ruby/InfraRuby/Condition.rb +29 -0
- data/ruby/InfraRuby/IO.rb +8 -0
- data/ruby/InfraRuby/StringBuilder.rb +99 -0
- data/ruby/Integer.rb +20 -0
- data/ruby/MatchData.rb +7 -0
- data/ruby/Object.rb +5 -0
- data/ruby/SecureRandom.rb +36 -0
- data/ruby/Set.rb +10 -0
- data/ruby/String.rb +23 -0
- data/ruby/Time.rb +11 -0
- metadata +121 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e8cff7e460cc859c8b703028fe7617ae9d578dcc
|
4
|
+
data.tar.gz: c3cdace46988d6043515237df6094f922a7b2b95
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b664d75c77887bb485e3a337f677fb6a645059f79b240b12e2aec77070f2caa0e401c55d77df600962865f02c13ed3d4387de4d9aeb01771a06875eb0116805f
|
7
|
+
data.tar.gz: 0383e6869687be27aa1caa17736c76b5ef0ea5694065ed68282ec81d49513d273bd34dee558876a9b8b31571c14b8fd64fbf28325c80ad8347b14420698cf923
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2011-2015 InfraRuby Vision
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
4
|
+
copy of this software and associated documentation files (the "Software"),
|
5
|
+
to deal in the Software without restriction, including without limitation
|
6
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
7
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
8
|
+
Software is furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
18
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
19
|
+
DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
InfraRuby shim for Ruby interpreters
|
2
|
+
====================================
|
3
|
+
|
4
|
+
This gem provides the InfraRuby shim for Ruby interpreters.
|
5
|
+
|
6
|
+
|
7
|
+
Example
|
8
|
+
-------
|
9
|
+
|
10
|
+
require "infraruby-shim"
|
11
|
+
|
12
|
+
sb = InfraRuby::StringBuilder.new
|
13
|
+
sb.append("hello")
|
14
|
+
puts sb.to_s
|
15
|
+
|
16
|
+
|
17
|
+
Support
|
18
|
+
-------
|
19
|
+
|
20
|
+
InfraRuby Vision
|
21
|
+
rubygems@infraruby.com
|
22
|
+
|
23
|
+
http://infraruby.com/
|
24
|
+
https://github.com/InfraRuby
|
25
|
+
https://twitter.com/InfraRuby
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.platform = "ruby"
|
3
|
+
s.name = "infraruby-shim"
|
4
|
+
s.version = "3.7.0"
|
5
|
+
s.licenses = ["MIT"]
|
6
|
+
s.author = "InfraRuby Vision"
|
7
|
+
s.email = "rubygems@infraruby.com"
|
8
|
+
s.homepage = "http://infraruby.com/"
|
9
|
+
s.summary = "InfraRuby shim for Ruby interpreters"
|
10
|
+
s.description = "InfraRuby shim for Ruby interpreters"
|
11
|
+
s.files = Dir["**/*"]
|
12
|
+
s.add_runtime_dependency "infraruby-base", "~> 3.7"
|
13
|
+
s.add_runtime_dependency "infraruby-java", "~> 3.7"
|
14
|
+
s.add_development_dependency "infraruby-task", "~> 3.7"
|
15
|
+
s.add_development_dependency "rspec", "~> 3.0"
|
16
|
+
end
|
data/ruby/Array.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
class Array
|
2
|
+
def size_as_int32
|
3
|
+
return size.to_int32!
|
4
|
+
end
|
5
|
+
|
6
|
+
def first!
|
7
|
+
raise IndexError if empty?
|
8
|
+
return first
|
9
|
+
end
|
10
|
+
|
11
|
+
def last!
|
12
|
+
raise IndexError if empty?
|
13
|
+
return last
|
14
|
+
end
|
15
|
+
|
16
|
+
def pop!
|
17
|
+
raise IndexError if empty?
|
18
|
+
return pop
|
19
|
+
end
|
20
|
+
|
21
|
+
def shift!
|
22
|
+
raise IndexError if empty?
|
23
|
+
return shift
|
24
|
+
end
|
25
|
+
end
|
data/ruby/Bignum.rb
ADDED
data/ruby/Date.rb
ADDED
data/ruby/Enumerable.rb
ADDED
data/ruby/Fixnum.rb
ADDED
data/ruby/Float.rb
ADDED
data/ruby/Hash.rb
ADDED
data/ruby/InfraRuby.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module InfraRuby
|
2
|
+
class Condition
|
3
|
+
def initialize(mutex)
|
4
|
+
super()
|
5
|
+
@cv = ConditionVariable.new
|
6
|
+
@mutex = mutex
|
7
|
+
return
|
8
|
+
end
|
9
|
+
|
10
|
+
def await(timeout = nix)
|
11
|
+
if timeout.nix?
|
12
|
+
@cv.wait(@mutex)
|
13
|
+
else
|
14
|
+
@cv.wait(@mutex, timeout)
|
15
|
+
end
|
16
|
+
return
|
17
|
+
end
|
18
|
+
|
19
|
+
def broadcast
|
20
|
+
@cv.broadcast
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
def signal
|
25
|
+
@cv.signal
|
26
|
+
return
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module InfraRuby
|
2
|
+
class StringBuilder
|
3
|
+
include InfraRuby::IO
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
super()
|
7
|
+
@m = Java::byte[0x20].new
|
8
|
+
@n = 0.i32
|
9
|
+
return
|
10
|
+
end
|
11
|
+
|
12
|
+
def __copy(n)
|
13
|
+
m = Java::byte[n.as_i].new
|
14
|
+
Java::ARRAYCOPY(@m, 0, m, 0, @n.as_i)
|
15
|
+
return m
|
16
|
+
end
|
17
|
+
|
18
|
+
def __write_byte(b)
|
19
|
+
nn = @n + 1
|
20
|
+
raise RuntimeError if nn < 0
|
21
|
+
if nn > @m.length
|
22
|
+
nnn = nn + nn / 2
|
23
|
+
raise RuntimeError if nnn < 0
|
24
|
+
@m = __copy(nnn)
|
25
|
+
end
|
26
|
+
@m[@n.as_i] = b.as_i
|
27
|
+
@n = nn
|
28
|
+
return
|
29
|
+
end
|
30
|
+
|
31
|
+
def __write_array(m)
|
32
|
+
n = m.length.i32
|
33
|
+
if n > 0
|
34
|
+
nn = @n + n
|
35
|
+
raise RuntimeError if nn < 0
|
36
|
+
if nn > @m.length
|
37
|
+
nnn = nn + nn / 2
|
38
|
+
raise RuntimeError if nnn < 0
|
39
|
+
@m = __copy(nnn)
|
40
|
+
end
|
41
|
+
Java::ARRAYCOPY(m, 0, @m, @n.as_i, n.as_i)
|
42
|
+
@n = nn
|
43
|
+
end
|
44
|
+
return
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_java_bytes
|
48
|
+
return __copy(@__n)
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_s(encoding = nix)
|
52
|
+
if encoding.nix?
|
53
|
+
encoding = Encoding::UTF_8
|
54
|
+
end
|
55
|
+
return String.from_java_bytes_unsafe(__copy(@n), encoding)
|
56
|
+
end
|
57
|
+
|
58
|
+
def read(o = nix)
|
59
|
+
raise NotImplementedError
|
60
|
+
end
|
61
|
+
|
62
|
+
def write(o)
|
63
|
+
case o
|
64
|
+
when Java::byte[]
|
65
|
+
__write_array(o)
|
66
|
+
return
|
67
|
+
when String
|
68
|
+
__write_array(o.to_java_bytes_unsafe)
|
69
|
+
return
|
70
|
+
else
|
71
|
+
raise TypeError
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def <<(o)
|
76
|
+
write(o)
|
77
|
+
return self
|
78
|
+
end
|
79
|
+
|
80
|
+
def flush
|
81
|
+
return
|
82
|
+
end
|
83
|
+
|
84
|
+
def close
|
85
|
+
return
|
86
|
+
end
|
87
|
+
|
88
|
+
def append(o)
|
89
|
+
case o
|
90
|
+
when Byte
|
91
|
+
__write_byte(o)
|
92
|
+
return
|
93
|
+
else
|
94
|
+
write(o)
|
95
|
+
return
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/ruby/Integer.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
class Integer
|
2
|
+
def is_a?(c)
|
3
|
+
return c === self
|
4
|
+
end
|
5
|
+
|
6
|
+
def to_fixnum!
|
7
|
+
if is_a?(Fixnum)
|
8
|
+
return self
|
9
|
+
end
|
10
|
+
raise RangeError
|
11
|
+
end
|
12
|
+
|
13
|
+
def signum
|
14
|
+
return self <=> 0
|
15
|
+
end
|
16
|
+
|
17
|
+
def signum_as_int32
|
18
|
+
return signum.to_int32
|
19
|
+
end
|
20
|
+
end
|
data/ruby/MatchData.rb
ADDED
data/ruby/Object.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
module SecureRandom
|
2
|
+
class << self
|
3
|
+
def random_java_bytes(o = nix)
|
4
|
+
if o.nix?
|
5
|
+
s = random_bytes
|
6
|
+
else
|
7
|
+
s = random_bytes(o.as_i)
|
8
|
+
end
|
9
|
+
return s.to_java_bytes_unsafe
|
10
|
+
end
|
11
|
+
|
12
|
+
def random_number_as_int32(o = nix)
|
13
|
+
if o.nix?
|
14
|
+
return Int32[random_number(1 << 32)]
|
15
|
+
else
|
16
|
+
return Int32[random_number(o.as_i)]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def random_number_as_int64(o = nix)
|
21
|
+
if o.nix?
|
22
|
+
return Int64[random_number(1 << 64)]
|
23
|
+
else
|
24
|
+
return Int64[random_number(o.as_i)]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def random_number_as_float32
|
29
|
+
return Float32[random_number]
|
30
|
+
end
|
31
|
+
|
32
|
+
def random_number_as_float64
|
33
|
+
return Float64[random_number]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/ruby/Set.rb
ADDED
data/ruby/String.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
class String
|
2
|
+
def to_fixnum!
|
3
|
+
return to_i.to_fixnum!
|
4
|
+
end
|
5
|
+
|
6
|
+
def with_encoding(encoding)
|
7
|
+
return dup.force_encoding(encoding)
|
8
|
+
end
|
9
|
+
|
10
|
+
def size_as_int32
|
11
|
+
return size.to_int32!
|
12
|
+
end
|
13
|
+
|
14
|
+
def bytesize_as_int32
|
15
|
+
return bytesize.to_int32!
|
16
|
+
end
|
17
|
+
|
18
|
+
def fetch(o)
|
19
|
+
s = self[o]
|
20
|
+
raise KeyError if s.nil?
|
21
|
+
return s
|
22
|
+
end
|
23
|
+
end
|
data/ruby/Time.rb
ADDED
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: infraruby-shim
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.7.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- InfraRuby Vision
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: infraruby-base
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: infraruby-java
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.7'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: infraruby-task
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: InfraRuby shim for Ruby interpreters
|
70
|
+
email: rubygems@infraruby.com
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- MIT-LICENSE
|
76
|
+
- README.md
|
77
|
+
- infraruby-shim.gemspec
|
78
|
+
- lib/infraruby-shim.rb
|
79
|
+
- ruby/Array.rb
|
80
|
+
- ruby/Bignum.rb
|
81
|
+
- ruby/Date.rb
|
82
|
+
- ruby/Enumerable.rb
|
83
|
+
- ruby/Fixnum.rb
|
84
|
+
- ruby/Float.rb
|
85
|
+
- ruby/Hash.rb
|
86
|
+
- ruby/InfraRuby.rb
|
87
|
+
- ruby/InfraRuby/Condition.rb
|
88
|
+
- ruby/InfraRuby/IO.rb
|
89
|
+
- ruby/InfraRuby/StringBuilder.rb
|
90
|
+
- ruby/Integer.rb
|
91
|
+
- ruby/MatchData.rb
|
92
|
+
- ruby/Object.rb
|
93
|
+
- ruby/SecureRandom.rb
|
94
|
+
- ruby/Set.rb
|
95
|
+
- ruby/String.rb
|
96
|
+
- ruby/Time.rb
|
97
|
+
homepage: http://infraruby.com/
|
98
|
+
licenses:
|
99
|
+
- MIT
|
100
|
+
metadata: {}
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.2.2
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: InfraRuby shim for Ruby interpreters
|
121
|
+
test_files: []
|