cryolite 0.1.0
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 +7 -0
- data/README.md +2 -0
- data/lib/cryolite/version.rb +3 -0
- data/lib/cryolite.rb +47 -0
- metadata +42 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 590676cd203dcb6394b3345ca8a59ab1bc2bbd1602349890e36599dc1d48c506
|
|
4
|
+
data.tar.gz: 145c5b9ecf7b4368d765e96fb24b962601ac482308a0019ba1f1d84e2914ffbc
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4c92229bf5fc0b462f4f05b8beebe5c19bb4ba3c7856be85efb7225edcb375db21946217b8c54191a30f66fd26c713bd52f2e52197de4bca448fff2cc1f6b4ce
|
|
7
|
+
data.tar.gz: 1406e50ec197970dc7cf029b5a806ee1c0760742c584ea8127f4585490c59c43dd7da7ca8eda208b14c36ee3d01cc288981e1f0b8fbcbefb10f13b8e3355348c
|
data/README.md
ADDED
data/lib/cryolite.rb
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require_relative "cryolite/version"
|
|
2
|
+
|
|
3
|
+
module Cryolite
|
|
4
|
+
# This is how runing under Crystal can be detected.
|
|
5
|
+
COMPILED_BY_CRYSTAL = (((1 / 2) * 2) != 0)
|
|
6
|
+
|
|
7
|
+
# Monkey-patch Ruby to make it recognize the Crystal's .to_i128 method
|
|
8
|
+
class ::Integer def to_i128() to_i end end
|
|
9
|
+
|
|
10
|
+
# An 8-bit zero constant to hint the use of UInt8 instead of Int32 for Crystal
|
|
11
|
+
U8_0 = "\0".bytes.first
|
|
12
|
+
|
|
13
|
+
# A 64-bit zero constant to hint the use of Int64 instead of Int32 for Crystal
|
|
14
|
+
I64_0 = (0x3FFFFFFFFFFFFFFF & 0)
|
|
15
|
+
|
|
16
|
+
# A 128-bit zero constant to hint the use of Int128 instead of Int32 for Crystal
|
|
17
|
+
I128_0 = 0.to_i128
|
|
18
|
+
|
|
19
|
+
# This is a Ruby-compatible trick to create a Crystal's lightweight tuple
|
|
20
|
+
def tuple2(a, b) return a, b end
|
|
21
|
+
def tuple3(a, b, c) return a, b, c end
|
|
22
|
+
|
|
23
|
+
# This icky blob of code aliases the Ruby's "respond_to?" method to "responds_to?",
|
|
24
|
+
# making it easier to maintain the source level compatibility with Crystal. And
|
|
25
|
+
# also provides access to the "eval_if_run_by_ruby" function, which does "eval"
|
|
26
|
+
# when the code is run by Ruby, but does nothing when the code is compiled by
|
|
27
|
+
# Crystal. It can be used to define additional aliases necessary for Ruby/Crystal
|
|
28
|
+
# compatibility.
|
|
29
|
+
module ::Kernel def method_missing(name, *args) true end end
|
|
30
|
+
if (k5324534 = ::Kernel).responds_to? :eval ; k5324534.eval "class ::Object alias
|
|
31
|
+
responds_to? respond_to? end ; module ::Kernel undef method_missing end" end
|
|
32
|
+
def self.eval_if_run_by_ruby(src) if (k = ::Kernel).responds_to? :eval ; k.eval src end end
|
|
33
|
+
# See https://bugs.ruby-lang.org/issues/13551#note-3
|
|
34
|
+
eval_if_run_by_ruby "module ::Kernel def alias_singleton_method(new_name, old_name)
|
|
35
|
+
singleton_class.class_exec { alias_method new_name, old_name } end end"
|
|
36
|
+
# A convenient wrapper
|
|
37
|
+
def self.ruby_class_method_alias(classname, from, to) eval_if_run_by_ruby "class
|
|
38
|
+
#{classname} alias_singleton_method :#{to}, :#{from} end" end
|
|
39
|
+
|
|
40
|
+
# Emulate "File.exists?" for Ruby 3.2.0 and newer, see
|
|
41
|
+
# https://www.reddit.com/r/ruby/comments/1196wti/psa_and_a_little_rant_fileexists_direxists
|
|
42
|
+
ruby_class_method_alias("::File", "exist?", "exists?")
|
|
43
|
+
# Emulate the availability of Crystal's Regex for Ruby (the name is slightly off)
|
|
44
|
+
eval_if_run_by_ruby "Regex = Regexp"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
Object.include(Cryolite)
|
metadata
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: cryolite
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Siarhiej Siamaška
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
email:
|
|
13
|
+
- siarhei.siamashka@gmail.com
|
|
14
|
+
executables: []
|
|
15
|
+
extensions: []
|
|
16
|
+
extra_rdoc_files: []
|
|
17
|
+
files:
|
|
18
|
+
- README.md
|
|
19
|
+
- lib/cryolite.rb
|
|
20
|
+
- lib/cryolite/version.rb
|
|
21
|
+
homepage: https://github.com/ssvb/cryolite
|
|
22
|
+
licenses:
|
|
23
|
+
- MIT
|
|
24
|
+
metadata: {}
|
|
25
|
+
rdoc_options: []
|
|
26
|
+
require_paths:
|
|
27
|
+
- lib
|
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 3.0.0
|
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ">="
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
requirements: []
|
|
39
|
+
rubygems_version: 3.6.7
|
|
40
|
+
specification_version: 4
|
|
41
|
+
summary: Crystal language compatibility
|
|
42
|
+
test_files: []
|