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.
@@ -5,58 +5,63 @@ class Code
5
5
  class Class < Object
6
6
  CLASS_DOCUMENTATION = {
7
7
  name: "Class",
8
- description: "wraps a value constructor and documents its class and instance functions.",
9
- examples: [
10
- "Class",
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
- "Class.documentation.description",
21
- "List.documentation.name",
22
- "Dictionary.documentation.name"
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: "returns documented class functions available on this class.",
28
- examples: [
29
- "Class.functions.keys.include?(:new)",
30
- "List.functions.keys.include?(:new)",
31
- "Dictionary.functions.keys.include?(:from_entries)"
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: "returns documented functions available on values built by this class.",
37
- examples: [
38
- "Class.instance_functions.keys.include?(:documentation)",
39
- "List.instance_functions.keys.include?(:map)",
40
- "String.instance_functions.keys.include?(:upcase)"
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: "returns documented class functions available on this class.",
46
- examples: [
47
- "Class.class_functions.keys.include?(:new)",
48
- "List.class_functions.keys.include?(:new)",
49
- "Dictionary.class_functions.keys.include?(:from_entries)"
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: ["Class.call(String)", "List.call([1, 2])", "String.call(:hello)"]
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: "returns a function that builds a value from this class before running the body.",
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)",
@@ -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
- if trusted
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
 
@@ -5,7 +5,8 @@ class Code
5
5
  class Context < Dictionary
6
6
  CLASS_DOCUMENTATION = {
7
7
  name: "Context",
8
- description: "stores scoped identifier values used while evaluating code.",
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: "returns the context that defines an identifier or raises when it is missing.",
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: "computes md5, sha1, sha256, sha384, and sha512 message digests in hex, digest, or base64 format.",
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: "returns an md5 message digest as hex text by default, with digest and base64 formats available.",
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: "returns a sha1 message digest as hex text by default, with digest and base64 formats available.",
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: "returns a sha256 message digest as hex text by default, with digest and base64 formats available.",
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: "returns a sha384 message digest as hex text by default, with digest and base64 formats available.",
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: "returns a sha512 message digest as hex text by default, with digest and base64 formats available.",
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)",