code-ruby 4.0.0 → 4.0.1
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 +4 -4
- data/VERSION +1 -1
- data/bin/code +8 -5
- data/lib/code/concerns/shared.rb +102 -98
- data/lib/code/format.rb +23 -19
- data/lib/code/network.rb +23 -28
- data/lib/code/node/call.rb +9 -8
- data/lib/code/node/code.rb +1 -1
- data/lib/code/node/list.rb +10 -8
- data/lib/code/node/square_bracket.rb +4 -2
- data/lib/code/object/boolean.rb +13 -17
- data/lib/code/object/class.rb +32 -27
- data/lib/code/object/code.rb +2 -9
- data/lib/code/object/context.rb +4 -2
- data/lib/code/object/cryptography.rb +12 -6
- data/lib/code/object/date.rb +910 -449
- data/lib/code/object/decimal.rb +229 -856
- data/lib/code/object/dictionary.rb +113 -42
- data/lib/code/object/duration.rb +3 -7
- data/lib/code/object/function.rb +64 -40
- data/lib/code/object/global.rb +121 -208
- data/lib/code/object/html.rb +4 -2
- data/lib/code/object/http.rb +32 -26
- data/lib/code/object/ics.rb +2 -1
- data/lib/code/object/identifier_list.rb +16 -11
- data/lib/code/object/integer.rb +270 -942
- data/lib/code/object/json.rb +8 -3
- data/lib/code/object/list.rb +97 -109
- data/lib/code/object/nothing.rb +11 -11
- data/lib/code/object/number.rb +20 -10
- data/lib/code/object/parameter.rb +18 -9
- data/lib/code/object/range.rb +62 -108
- data/lib/code/object/smtp.rb +20 -12
- data/lib/code/object/string.rb +52 -28
- data/lib/code/object/super.rb +2 -1
- data/lib/code/object/time.rb +1146 -572
- data/lib/code/object/url.rb +4 -2
- data/lib/code/object.rb +119 -80
- data/lib/code/parser.rb +34 -32
- metadata +1 -1
data/lib/code/object/class.rb
CHANGED
|
@@ -5,58 +5,63 @@ class Code
|
|
|
5
5
|
class Class < Object
|
|
6
6
|
CLASS_DOCUMENTATION = {
|
|
7
7
|
name: "Class",
|
|
8
|
-
description:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"Class.new(String)",
|
|
12
|
-
"Class.documentation.name"
|
|
13
|
-
]
|
|
8
|
+
description:
|
|
9
|
+
"wraps a value constructor and documents its class and instance functions.",
|
|
10
|
+
examples: %w[Class Class.new(String) Class.documentation.name]
|
|
14
11
|
}.freeze
|
|
15
12
|
INSTANCE_FUNCTIONS = {
|
|
16
13
|
"documentation" => {
|
|
17
14
|
name: "documentation",
|
|
18
15
|
description: "returns documentation for this class.",
|
|
19
|
-
examples: [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
examples: %w[
|
|
17
|
+
Class.documentation.description
|
|
18
|
+
List.documentation.name
|
|
19
|
+
Dictionary.documentation.name
|
|
23
20
|
]
|
|
24
21
|
},
|
|
25
22
|
"functions" => {
|
|
26
23
|
name: "functions",
|
|
27
|
-
description:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
description:
|
|
25
|
+
"returns documented class functions available on this class.",
|
|
26
|
+
examples: %w[
|
|
27
|
+
Class.functions.keys.include?(:new)
|
|
28
|
+
List.functions.keys.include?(:new)
|
|
29
|
+
Dictionary.functions.keys.include?(:from_entries)
|
|
32
30
|
]
|
|
33
31
|
},
|
|
34
32
|
"instance_functions" => {
|
|
35
33
|
name: "instance_functions",
|
|
36
|
-
description:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
description:
|
|
35
|
+
"returns documented functions available on values built by this class.",
|
|
36
|
+
examples: %w[
|
|
37
|
+
Class.instance_functions.keys.include?(:documentation)
|
|
38
|
+
List.instance_functions.keys.include?(:map)
|
|
39
|
+
String.instance_functions.keys.include?(:upcase)
|
|
41
40
|
]
|
|
42
41
|
},
|
|
43
42
|
"class_functions" => {
|
|
44
43
|
name: "class_functions",
|
|
45
|
-
description:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
description:
|
|
45
|
+
"returns documented class functions available on this class.",
|
|
46
|
+
examples: %w[
|
|
47
|
+
Class.class_functions.keys.include?(:new)
|
|
48
|
+
List.class_functions.keys.include?(:new)
|
|
49
|
+
Dictionary.class_functions.keys.include?(:from_entries)
|
|
50
50
|
]
|
|
51
51
|
},
|
|
52
52
|
"call" => {
|
|
53
53
|
name: "call",
|
|
54
54
|
description: "returns a new value by calling this class constructor.",
|
|
55
|
-
examples: [
|
|
55
|
+
examples: [
|
|
56
|
+
"Class.call(String)",
|
|
57
|
+
"List.call([1, 2])",
|
|
58
|
+
"String.call(:hello)"
|
|
59
|
+
]
|
|
56
60
|
},
|
|
57
61
|
"extend" => {
|
|
58
62
|
name: "extend",
|
|
59
|
-
description:
|
|
63
|
+
description:
|
|
64
|
+
"returns a function that builds a value from this class before running the body.",
|
|
60
65
|
examples: [
|
|
61
66
|
"Widget = Dictionary.extend(() => { self.name = :widget self }) Widget().fetch(:name)",
|
|
62
67
|
"Person = Dictionary.extend((name) => { self.name = name self }) Person(:Ada).fetch(:name)",
|
data/lib/code/object/code.rb
CHANGED
|
@@ -68,11 +68,7 @@ class Code
|
|
|
68
68
|
def initialize(*args, **_kargs, &_block)
|
|
69
69
|
@trusted = args.first.is_a?(Node::Code)
|
|
70
70
|
self.raw =
|
|
71
|
-
|
|
72
|
-
args.first
|
|
73
|
-
else
|
|
74
|
-
Node::Code.new(::Code.parse(args.first.to_s))
|
|
75
|
-
end
|
|
71
|
+
(trusted ? args.first : Node::Code.new(::Code.parse(args.first.to_s)))
|
|
76
72
|
end
|
|
77
73
|
|
|
78
74
|
def self.code_evaluate(*args, **globals)
|
|
@@ -109,10 +105,7 @@ class Code
|
|
|
109
105
|
|
|
110
106
|
def code_evaluate(trusted_evaluation: false, **globals)
|
|
111
107
|
raw.evaluate(
|
|
112
|
-
**evaluation_globals(
|
|
113
|
-
globals,
|
|
114
|
-
trusted_evaluation: trusted_evaluation
|
|
115
|
-
)
|
|
108
|
+
**evaluation_globals(globals, trusted_evaluation: trusted_evaluation)
|
|
116
109
|
)
|
|
117
110
|
end
|
|
118
111
|
|
data/lib/code/object/context.rb
CHANGED
|
@@ -5,7 +5,8 @@ class Code
|
|
|
5
5
|
class Context < Dictionary
|
|
6
6
|
CLASS_DOCUMENTATION = {
|
|
7
7
|
name: "Context",
|
|
8
|
-
description:
|
|
8
|
+
description:
|
|
9
|
+
"stores scoped identifier values used while evaluating code.",
|
|
9
10
|
examples: [
|
|
10
11
|
"context",
|
|
11
12
|
"Context.new(a: 1)",
|
|
@@ -15,7 +16,8 @@ class Code
|
|
|
15
16
|
INSTANCE_FUNCTIONS = {
|
|
16
17
|
"lookup!" => {
|
|
17
18
|
name: "lookup!",
|
|
18
|
-
description:
|
|
19
|
+
description:
|
|
20
|
+
"returns the context that defines an identifier or raises when it is missing.",
|
|
19
21
|
examples: [
|
|
20
22
|
"Context.new(a: 1).lookup!(:a)",
|
|
21
23
|
"Context.new({ a: 1 }, Context.new(b: 2)).lookup!(:b)",
|
|
@@ -5,7 +5,8 @@ class Code
|
|
|
5
5
|
class Cryptography < Object
|
|
6
6
|
CLASS_DOCUMENTATION = {
|
|
7
7
|
name: "Cryptography",
|
|
8
|
-
description:
|
|
8
|
+
description:
|
|
9
|
+
"computes md5, sha1, sha256, sha384, and sha512 message digests in hex, digest, or base64 format.",
|
|
9
10
|
examples: [
|
|
10
11
|
"Cryptography.md5(:hello)",
|
|
11
12
|
"Cryptography.sha256(:hello, format: :hex)",
|
|
@@ -15,7 +16,8 @@ class Code
|
|
|
15
16
|
CLASS_FUNCTIONS = {
|
|
16
17
|
"md5" => {
|
|
17
18
|
name: "md5",
|
|
18
|
-
description:
|
|
19
|
+
description:
|
|
20
|
+
"returns an md5 message digest as hex text by default, with digest and base64 formats available.",
|
|
19
21
|
examples: [
|
|
20
22
|
"Cryptography.md5(:hello)",
|
|
21
23
|
"Cryptography.md5(:hello, format: :hex)",
|
|
@@ -24,7 +26,8 @@ class Code
|
|
|
24
26
|
},
|
|
25
27
|
"sha1" => {
|
|
26
28
|
name: "sha1",
|
|
27
|
-
description:
|
|
29
|
+
description:
|
|
30
|
+
"returns a sha1 message digest as hex text by default, with digest and base64 formats available.",
|
|
28
31
|
examples: [
|
|
29
32
|
"Cryptography.sha1(:hello)",
|
|
30
33
|
"Cryptography.sha1(:hello, format: :hex)",
|
|
@@ -33,7 +36,8 @@ class Code
|
|
|
33
36
|
},
|
|
34
37
|
"sha256" => {
|
|
35
38
|
name: "sha256",
|
|
36
|
-
description:
|
|
39
|
+
description:
|
|
40
|
+
"returns a sha256 message digest as hex text by default, with digest and base64 formats available.",
|
|
37
41
|
examples: [
|
|
38
42
|
"Cryptography.sha256(:hello)",
|
|
39
43
|
"Cryptography.sha256(:hello, format: :hex)",
|
|
@@ -42,7 +46,8 @@ class Code
|
|
|
42
46
|
},
|
|
43
47
|
"sha384" => {
|
|
44
48
|
name: "sha384",
|
|
45
|
-
description:
|
|
49
|
+
description:
|
|
50
|
+
"returns a sha384 message digest as hex text by default, with digest and base64 formats available.",
|
|
46
51
|
examples: [
|
|
47
52
|
"Cryptography.sha384(:hello)",
|
|
48
53
|
"Cryptography.sha384(:hello, format: :hex)",
|
|
@@ -51,7 +56,8 @@ class Code
|
|
|
51
56
|
},
|
|
52
57
|
"sha512" => {
|
|
53
58
|
name: "sha512",
|
|
54
|
-
description:
|
|
59
|
+
description:
|
|
60
|
+
"returns a sha512 message digest as hex text by default, with digest and base64 formats available.",
|
|
55
61
|
examples: [
|
|
56
62
|
"Cryptography.sha512(:hello)",
|
|
57
63
|
"Cryptography.sha512(:hello, format: :hex)",
|