code-ruby 3.1.2 → 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.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/bin/code +100 -20
  4. data/lib/code/concerns/shared.rb +335 -15
  5. data/lib/code/format.rb +33 -15
  6. data/lib/code/network.rb +82 -0
  7. data/lib/code/node/call.rb +80 -2
  8. data/lib/code/node/call_argument.rb +14 -0
  9. data/lib/code/node/code.rb +4 -3
  10. data/lib/code/node/function_parameter.rb +7 -4
  11. data/lib/code/node/list.rb +32 -2
  12. data/lib/code/node/square_bracket.rb +4 -2
  13. data/lib/code/object/base_64.rb +132 -6
  14. data/lib/code/object/boolean.rb +56 -0
  15. data/lib/code/object/class.rb +143 -2
  16. data/lib/code/object/code.rb +108 -7
  17. data/lib/code/object/context.rb +59 -1
  18. data/lib/code/object/cryptography.rb +69 -0
  19. data/lib/code/object/date.rb +13800 -462
  20. data/lib/code/object/decimal.rb +1098 -0
  21. data/lib/code/object/dictionary.rb +1861 -11
  22. data/lib/code/object/duration.rb +24 -0
  23. data/lib/code/object/function.rb +289 -27
  24. data/lib/code/object/global.rb +447 -1
  25. data/lib/code/object/html.rb +181 -7
  26. data/lib/code/object/http.rb +253 -17
  27. data/lib/code/object/ics.rb +76 -13
  28. data/lib/code/object/identifier_list.rb +30 -10
  29. data/lib/code/object/integer.rb +1265 -2
  30. data/lib/code/object/json.rb +80 -1
  31. data/lib/code/object/list.rb +3371 -10
  32. data/lib/code/object/nothing.rb +53 -0
  33. data/lib/code/object/number.rb +120 -0
  34. data/lib/code/object/parameter.rb +149 -0
  35. data/lib/code/object/range.rb +530 -14
  36. data/lib/code/object/smtp.rb +103 -12
  37. data/lib/code/object/string.rb +968 -3
  38. data/lib/code/object/super.rb +11 -1
  39. data/lib/code/object/time.rb +13932 -498
  40. data/lib/code/object/url.rb +67 -0
  41. data/lib/code/object.rb +582 -0
  42. data/lib/code/parser.rb +194 -55
  43. data/lib/code-ruby.rb +3 -0
  44. data/lib/code.rb +30 -3
  45. metadata +135 -84
  46. data/.github/dependabot.yml +0 -15
  47. data/.github/workflows/ci.yml +0 -38
  48. data/.gitignore +0 -30
  49. data/.node-version +0 -1
  50. data/.npm-version +0 -1
  51. data/.prettierignore +0 -2
  52. data/.rspec +0 -1
  53. data/.rubocop.yml +0 -140
  54. data/.ruby-version +0 -1
  55. data/.tool-versions +0 -3
  56. data/AGENTS.md +0 -43
  57. data/Gemfile +0 -22
  58. data/Gemfile.lock +0 -292
  59. data/Rakefile +0 -5
  60. data/bin/bundle +0 -123
  61. data/bin/bundle-audit +0 -31
  62. data/bin/bundler-audit +0 -31
  63. data/bin/dorian +0 -31
  64. data/bin/rspec +0 -31
  65. data/bin/rubocop +0 -31
  66. data/bin/test +0 -5
  67. data/code-ruby.gemspec +0 -34
  68. data/docs/precedence.txt +0 -36
  69. data/package-lock.json +0 -14
  70. data/package.json +0 -7
  71. data/spec/bin/code_spec.rb +0 -48
  72. data/spec/code/format_spec.rb +0 -153
  73. data/spec/code/node/call_spec.rb +0 -11
  74. data/spec/code/object/boolean_spec.rb +0 -18
  75. data/spec/code/object/cryptography_spec.rb +0 -25
  76. data/spec/code/object/decimal_spec.rb +0 -50
  77. data/spec/code/object/dictionary_spec.rb +0 -98
  78. data/spec/code/object/function_spec.rb +0 -268
  79. data/spec/code/object/http_spec.rb +0 -33
  80. data/spec/code/object/ics_spec.rb +0 -50
  81. data/spec/code/object/integer_spec.rb +0 -42
  82. data/spec/code/object/list_spec.rb +0 -22
  83. data/spec/code/object/nothing_spec.rb +0 -14
  84. data/spec/code/object/range_spec.rb +0 -23
  85. data/spec/code/object/string_spec.rb +0 -26
  86. data/spec/code/parser/boolean_spec.rb +0 -11
  87. data/spec/code/parser/chained_call_spec.rb +0 -16
  88. data/spec/code/parser/dictionary_spec.rb +0 -18
  89. data/spec/code/parser/function_spec.rb +0 -16
  90. data/spec/code/parser/group_spec.rb +0 -11
  91. data/spec/code/parser/if_modifier_spec.rb +0 -18
  92. data/spec/code/parser/list_spec.rb +0 -17
  93. data/spec/code/parser/number_spec.rb +0 -11
  94. data/spec/code/parser/string_spec.rb +0 -20
  95. data/spec/code/parser_spec.rb +0 -52
  96. data/spec/code/type_spec.rb +0 -21
  97. data/spec/code_spec.rb +0 -717
  98. data/spec/spec_helper.rb +0 -21
  99. data/spec/zeitwerk/loader_spec.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2495002bb8e1d284386f2a90ff600370cfe0490a356688426682ec106727fbb3
4
- data.tar.gz: e8dffdf7d8d0c0e62a091d2a7d305eae48dc74d024aa26c5a8dc393763147f13
3
+ metadata.gz: 04a1a64dae9f86bb218f016da7f56a7d4358d4dc63c620132ce58dd0a8d96b7d
4
+ data.tar.gz: 3735d10e82af9370ed1c4cff86e5c3965678a7b22e3a5ea709f11eda601d49b7
5
5
  SHA512:
6
- metadata.gz: 55ceb13028c588110d3adec5539995ddd1f2dc4fd7173fd067a8e009a8093610adb150de78be46dfc57e605dbad0f03dd89e5693820be31c6d61c3440fb129ea
7
- data.tar.gz: 6ae82061c1a129f1607eb348e18917e75c7d23accf7dca589da00ed3ae34eccf76af79826e430f5267b4a2011ce7c9df8a1709069f95f660c8dff22d16c0c37a
6
+ metadata.gz: d3c2288da223c047a41c6f6f30eba9c22c4e3ec7e4b058390530c0036a20d42580ce4755620345c4ff2c8403c0ffd9381d3a4865f690aedc2e4483617c695852
7
+ data.tar.gz: f21b89e07ec4f156d8ed3eec697902da23cd6dc269a74eeee375a7cc06b83bd78f22d8dee9613a10e9546908379f1128d75f104549d5c16650d81849e08f94b0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.2
1
+ 4.0.1
data/bin/code CHANGED
@@ -37,51 +37,131 @@ parsed =
37
37
  abort Code::Version.to_s if parsed.options.version
38
38
  abort parsed.help if parsed.options.help
39
39
 
40
+ MAX_ARGUMENT_FILES = 1000
41
+
40
42
  def glob_pattern?(value)
41
43
  value.match?(/[*?\[\]{]/)
42
44
  end
43
45
 
44
- expanded_argument_files = []
45
- remaining_arguments = []
46
+ def timeout
47
+ @timeout ||= @parsed_timeout
48
+ end
49
+
50
+ def with_timeout(&)
51
+ Timeout.timeout(timeout, &)
52
+ rescue Timeout::Error
53
+ raise Code::Error, "timeout"
54
+ end
55
+
56
+ def append_limited(buffer, value, label: "input")
57
+ value = value.to_s
58
+ if buffer.bytesize + value.bytesize > Code::MAX_INPUT_BYTES
59
+ raise Code::Error, "#{label} is too large"
60
+ end
61
+
62
+ buffer << value
63
+ end
64
+
65
+ def read_file(path)
66
+ raise Code::Error, "#{path} is not a regular file" unless File.file?(path)
67
+
68
+ File.open(path, "rb") do |file|
69
+ data = file.read(Code::MAX_INPUT_BYTES + 1).to_s
70
+ Code.ensure_input_size!(data, label: path)
71
+ data
72
+ end
73
+ end
74
+
75
+ def read_stdin
76
+ data = $stdin.read(Code::MAX_INPUT_BYTES + 1).to_s
77
+ Code.ensure_input_size!(data, label: "stdin")
78
+ data
79
+ end
80
+
81
+ def expand_arguments(arguments)
82
+ expanded_files = []
83
+ remaining_arguments = []
46
84
 
47
- parsed.arguments.each do |argument|
48
- if glob_pattern?(argument)
49
- matches = Dir.glob(argument).select { |path| File.file?(path) }
85
+ arguments.each do |argument|
86
+ if glob_pattern?(argument)
87
+ matches = Dir.glob(argument).select { |path| File.file?(path) }
50
88
 
51
- if matches.any?
52
- expanded_argument_files.concat(matches)
89
+ if matches.any?
90
+ expanded_files.concat(matches)
91
+ else
92
+ remaining_arguments << argument
93
+ end
53
94
  else
54
95
  remaining_arguments << argument
55
96
  end
56
- else
57
- remaining_arguments << argument
97
+
98
+ if expanded_files.size > MAX_ARGUMENT_FILES
99
+ raise Code::Error, "too many input files"
100
+ end
58
101
  end
102
+
103
+ [expanded_files, remaining_arguments]
59
104
  end
60
105
 
61
- input = parsed.options.input.to_s
62
- input += File.read(input) if File.exist?(input)
63
- input += remaining_arguments.join(" ")
64
- input +=
65
- (parsed.files + expanded_argument_files)
66
- .map { |file| File.read(file) }
67
- .join("\n\n")
106
+ begin
107
+ @parsed_timeout =
108
+ Code.normalize_timeout!(parsed.options.timeout || Code::DEFAULT_TIMEOUT)
109
+ rescue Code::Error => e
110
+ abort "#{e.class}: #{e.message}"
111
+ end
112
+
113
+ begin
114
+ input =
115
+ with_timeout do
116
+ buffer = +""
117
+ option_input = parsed.options.input.to_s
118
+ expanded_argument_files, remaining_arguments =
119
+ expand_arguments(parsed.arguments)
120
+
121
+ if option_input.present? && File.exist?(option_input)
122
+ append_limited(buffer, read_file(option_input))
123
+ else
124
+ append_limited(buffer, option_input)
125
+ end
126
+
127
+ append_limited(buffer, remaining_arguments.join(" "))
128
+
129
+ input_files = parsed.files + expanded_argument_files
130
+ if input_files.size > MAX_ARGUMENT_FILES
131
+ raise Code::Error, "too many input files"
132
+ end
133
+
134
+ input_files.each.with_index do |file, index|
135
+ append_limited(buffer, "\n\n") if index.positive?
136
+ append_limited(buffer, read_file(file), label: file)
137
+ end
138
+
139
+ buffer
140
+ end
141
+ rescue Code::Error => e
142
+ abort "#{e.class}: #{e.message}"
143
+ end
68
144
 
69
145
  profile = parsed.options.profile || parsed.options.profiler
70
146
  require "ruby-prof" if profile
71
147
 
72
148
  RubyProf.start if profile
73
149
 
74
- input = $stdin.each_line.to_a.join if input.empty?
150
+ begin
151
+ input = with_timeout { read_stdin } if input.empty?
152
+ rescue Code::Error => e
153
+ abort "#{e.class}: #{e.message}"
154
+ end
75
155
 
76
156
  if parsed.options.parse
77
157
  begin
78
- pp Code::Parser.parse(input).to_raw
158
+ pp Code.parse(input, timeout: timeout)
79
159
  rescue StandardError => e
80
160
  warn e.message
81
161
  end
82
162
  elsif parsed.options.format
83
163
  begin
84
- print(Code.format(input, timeout: parsed.options.timeout))
164
+ print(Code.format(input, timeout: timeout))
85
165
  rescue Code::Error => e
86
166
  warn "#{e.class}: #{e.message}"
87
167
  end
@@ -93,7 +173,7 @@ else
93
173
  output: $stdout,
94
174
  error: $stderr,
95
175
  input: $stdin,
96
- timeout: parsed.options.timeout
176
+ timeout: timeout
97
177
  )
98
178
  )
99
179
  rescue Code::Error => e
@@ -3,14 +3,122 @@
3
3
  class Code
4
4
  module Concerns
5
5
  module Shared
6
- attr_accessor :raw, :methods
6
+ attr_accessor :raw, :functions
7
+
8
+ COMPOUND_ASSIGNMENT_OPERATORS = %w[
9
+ +=
10
+ -=
11
+ *=
12
+ /=
13
+ %=
14
+ <<=
15
+ >>=
16
+ &=
17
+ |=
18
+ ^=
19
+ ||=
20
+ &&=
21
+ ].freeze
22
+ SHARED_OPERATORS = %w[
23
+ documentation
24
+ present?
25
+ blank?
26
+ presence
27
+ presence_in
28
+ is_a?
29
+ is_an?
30
+ kind_of?
31
+ instance_of?
32
+ new
33
+ !
34
+ not
35
+ !=
36
+ different
37
+ &&
38
+ and
39
+ +
40
+ self
41
+ ..
42
+ inclusive_range
43
+ ...
44
+ exclusive_range
45
+ ==
46
+ equal
47
+ equal?
48
+ same_object?
49
+ >
50
+ greater
51
+ >=
52
+ greater_or_equal
53
+ <=>
54
+ compare
55
+ <
56
+ less
57
+ <=
58
+ less_or_equal
59
+ ===
60
+ strict_equal
61
+ !==
62
+ strict_different
63
+ falsy?
64
+ truthy?
65
+ true?
66
+ false?
67
+ ||
68
+ or
69
+ to_boolean
70
+ to_class
71
+ to_date
72
+ to_decimal
73
+ to_dictionary
74
+ to_duration
75
+ to_integer
76
+ to_list
77
+ to_nothing
78
+ to_range
79
+ to_string
80
+ inspect
81
+ to_time
82
+ as_json
83
+ duplicate
84
+ deep_duplicate
85
+ to_parameter
86
+ to_json
87
+ functions
88
+ instance_functions
89
+ class_functions
90
+ respond_to?
91
+ send
92
+ itself
93
+ tap
94
+ then
95
+ name
96
+ nothing?
97
+ something?
98
+ ].freeze
99
+ OPERATOR_METHOD_ALIASES = {
100
+ "[]" => "get",
101
+ "at" => "get",
102
+ "length" => "size",
103
+ "member?" => "include?",
104
+ "key?" => "has_key?",
105
+ "value?" => "has_value?",
106
+ "filter" => "select",
107
+ "filter!" => "select!"
108
+ }.freeze
7
109
 
8
110
  def call(**args)
9
111
  code_operator = args.fetch(:operator, nil).to_code
10
112
  code_arguments = args.fetch(:arguments, []).to_code
11
113
  code_value = code_arguments.code_first
12
114
 
115
+ dynamic_result = code_dynamic_call(code_operator, **args)
116
+ return dynamic_result if dynamic_result
117
+
13
118
  case code_operator.to_s
119
+ when "documentation"
120
+ sig(args)
121
+ code_documentation
14
122
  when "present?"
15
123
  sig(args)
16
124
  code_present?
@@ -23,6 +131,12 @@ class Code
23
131
  when "presence_in"
24
132
  sig(args) { Object::List }
25
133
  code_presence_in(code_value)
134
+ when "is_a?", "is_an?", "kind_of?"
135
+ sig(args) { Object::Class }
136
+ code_is_a?(code_value)
137
+ when "instance_of?"
138
+ sig(args) { Object::Class }
139
+ code_instance_of?(code_value)
26
140
  when "new"
27
141
  sig(args) { Object.repeat }
28
142
  code_new(*code_arguments.raw)
@@ -44,13 +158,16 @@ class Code
44
158
  when "...", "exclusive_range"
45
159
  sig(args) { Object }
46
160
  code_exclusive_range(code_value)
47
- when "==", "equal"
161
+ when "==", "equal", "equal?"
48
162
  sig(args) { Object }
49
163
  code_equal(code_value)
50
- when ">", "greater_or_equal"
164
+ when "same_object?"
165
+ sig(args) { Object }
166
+ code_same_object?(code_value)
167
+ when ">", "greater"
51
168
  sig(args) { Object }
52
169
  code_greater(code_value)
53
- when ">=", "greater"
170
+ when ">=", "greater_or_equal"
54
171
  sig(args) { Object }
55
172
  code_greater_or_equal(code_value)
56
173
  when "<=>", "compare"
@@ -74,6 +191,12 @@ class Code
74
191
  when "truthy?"
75
192
  sig(args)
76
193
  code_truthy?
194
+ when "true?"
195
+ sig(args)
196
+ code_true?
197
+ when "false?"
198
+ sig(args)
199
+ code_false?
77
200
  when "||", "or"
78
201
  sig(args) { Object }
79
202
  code_or(code_value)
@@ -136,9 +259,30 @@ class Code
136
259
  else
137
260
  code_to_json
138
261
  end
139
- when "methods"
262
+ when "functions"
140
263
  sig(args)
141
- code_methods
264
+ code_functions
265
+ when "instance_functions"
266
+ sig(args)
267
+ code_instance_functions
268
+ when "class_functions"
269
+ sig(args)
270
+ code_class_functions
271
+ when "respond_to?"
272
+ sig(args) { Object }
273
+ code_respond_to?(code_value)
274
+ when "send"
275
+ sig(args) { [Object, Object.repeat] }
276
+ code_send(*code_arguments.raw, **args)
277
+ when "itself"
278
+ sig(args)
279
+ code_itself
280
+ when "tap"
281
+ sig(args) { Object::Function }
282
+ code_tap(code_value, **args)
283
+ when "then"
284
+ sig(args) { Object::Function }
285
+ code_then(code_value, **args)
142
286
  when "name"
143
287
  sig(args)
144
288
  code_name
@@ -154,6 +298,9 @@ class Code
154
298
  if code_operator.to_s == "="
155
299
  code_context = args.fetch(:context)
156
300
  code_context.code_set(self, code_value)
301
+ elsif setter_operator?(code_operator)
302
+ code_dynamic_functions.code_set(code_operator.to_s.chop, code_value)
303
+ return code_value
157
304
  else
158
305
  code_context = args.fetch(:context).code_lookup!(self)
159
306
  code_context.code_set(
@@ -336,7 +483,7 @@ class Code
336
483
  self.class.new(self)
337
484
  end
338
485
 
339
- def code_deep_duplicate
486
+ def code_deep_duplicate(_seen = {})
340
487
  self.class.new(self)
341
488
  end
342
489
 
@@ -352,16 +499,32 @@ class Code
352
499
  Object::Nothing.new
353
500
  end
354
501
 
355
- def code_fetch(...)
356
- Object::Nothing.new
502
+ def code_fetch(key)
503
+ code_dynamic_functions.code_fetch(key)
357
504
  end
358
505
 
359
- def code_set(...)
360
- Object::Nothing.new
506
+ def code_set(key, value)
507
+ code_dynamic_functions.code_set(key, value)
361
508
  end
362
509
 
363
- def code_get(...)
364
- Object::Nothing.new
510
+ def code_get(key)
511
+ code_dynamic_functions.code_get(key)
512
+ end
513
+
514
+ def code_has_key?(key)
515
+ code_dynamic_functions.code_has_key?(key)
516
+ end
517
+
518
+ def code_dynamic_call(operator, **args)
519
+ return nil unless code_dynamic_functions.code_has_key?(operator).truthy?
520
+
521
+ stored_value = code_dynamic_functions.code_fetch(operator)
522
+ if stored_value.is_a?(Object::Function)
523
+ return stored_value.call(**args, operator: nil, bound_self: self)
524
+ end
525
+
526
+ sig(args)
527
+ stored_value
365
528
  end
366
529
 
367
530
  def code_to_parameter
@@ -404,6 +567,14 @@ class Code
404
567
  Object::Boolean.new(truthy?)
405
568
  end
406
569
 
570
+ def code_true?
571
+ Object::Boolean.new(self == Object::Boolean.new(true))
572
+ end
573
+
574
+ def code_false?
575
+ Object::Boolean.new(self == Object::Boolean.new(false) || nothing?)
576
+ end
577
+
407
578
  def code_to_boolean
408
579
  Object::Boolean.new(self)
409
580
  end
@@ -460,8 +631,84 @@ class Code
460
631
  Object::String.new(name.to_s.split("::")[2..].join("::"))
461
632
  end
462
633
 
463
- def code_methods
464
- Object::List.new(methods)
634
+ def code_documentation
635
+ Object.documentation_for(self.class)
636
+ end
637
+
638
+ def code_functions
639
+ Object.sorted_dictionary(
640
+ code_instance_functions.code_merge(code_class_functions).raw
641
+ )
642
+ end
643
+
644
+ def code_instance_functions
645
+ Object.sorted_dictionary(
646
+ Object
647
+ .documented_functions_for(self.class, :instance)
648
+ .code_merge(dynamic_functions_documentation)
649
+ .raw
650
+ )
651
+ end
652
+
653
+ def code_class_functions
654
+ dynamic_functions_documentation
655
+ end
656
+
657
+ def code_respond_to?(operator)
658
+ code_operator = operator.to_code
659
+
660
+ Object::Boolean.new(code_respond_to_operator?(code_operator))
661
+ end
662
+
663
+ def code_is_a?(klass)
664
+ code_klass = klass.to_code
665
+
666
+ Object::Boolean.new(is_a?(code_klass.raw))
667
+ end
668
+
669
+ def code_instance_of?(klass)
670
+ code_klass = klass.to_code
671
+
672
+ Object::Boolean.new(instance_of?(code_klass.raw))
673
+ end
674
+
675
+ def code_same_object?(other)
676
+ code_other = other.to_code
677
+
678
+ Object::Boolean.new(equal?(code_other))
679
+ end
680
+
681
+ def code_itself
682
+ self
683
+ end
684
+
685
+ def code_send(operator, *arguments, **globals)
686
+ code_operator = operator.to_code
687
+
688
+ call(
689
+ **globals,
690
+ arguments: Object::List.new(arguments),
691
+ operator: code_operator
692
+ )
693
+ end
694
+
695
+ def code_tap(function, **globals)
696
+ code_function = function.to_code
697
+ code_function.call(
698
+ **globals,
699
+ arguments: Object::List.new([self]),
700
+ operator: nil
701
+ )
702
+ self
703
+ end
704
+
705
+ def code_then(function, **globals)
706
+ code_function = function.to_code
707
+ code_function.call(
708
+ **globals,
709
+ arguments: Object::List.new([self]),
710
+ operator: nil
711
+ )
465
712
  end
466
713
 
467
714
  def present?
@@ -489,6 +736,79 @@ class Code
489
736
 
490
737
  code_list.code_include?(self).truthy? ? self : Object::Nothing.new
491
738
  end
739
+
740
+ def code_documentable_functions
741
+ Object::Dictionary.new(
742
+ code_dynamic_functions.raw.merge(dictionary_attributes)
743
+ )
744
+ end
745
+
746
+ private
747
+
748
+ def setter_operator?(operator)
749
+ !COMPOUND_ASSIGNMENT_OPERATORS.include?(operator.to_s)
750
+ end
751
+
752
+ def code_respond_to_operator?(operator)
753
+ operator_name = operator.to_s
754
+
755
+ SHARED_OPERATORS.include?(operator_name) ||
756
+ code_operator_method_defined?(operator_name) ||
757
+ code_functions.code_has_key?(operator).truthy?
758
+ end
759
+
760
+ def code_operator_method_defined?(operator_name)
761
+ method_name =
762
+ :"code_#{OPERATOR_METHOD_ALIASES.fetch(operator_name, operator_name)}"
763
+ return false unless respond_to?(method_name)
764
+
765
+ method(method_name).owner != Shared
766
+ end
767
+
768
+ def code_dynamic_functions
769
+ @functions = Object::Dictionary.new if @functions.blank?
770
+
771
+ @functions
772
+ end
773
+
774
+ def dynamic_functions_documentation
775
+ Object.sorted_dictionary(
776
+ code_documentable_functions.raw.to_h do |key, value|
777
+ name = key.to_s
778
+ [
779
+ name,
780
+ Object::Dictionary.new(
781
+ "name" => Object::String.new(name),
782
+ "description" =>
783
+ Object::String.new(dynamic_function_description(value)),
784
+ "examples" =>
785
+ Object::List.new(dynamic_function_examples(value)),
786
+ "function" => value
787
+ )
788
+ ]
789
+ end
790
+ )
791
+ end
792
+
793
+ def dictionary_attributes
794
+ return {} unless is_a?(Object::Dictionary)
795
+
796
+ raw
797
+ end
798
+
799
+ def dynamic_function_description(value)
800
+ code_value = value.to_code
801
+ return "" unless code_value.is_a?(Object::Function)
802
+
803
+ code_value.documentation.code_get("description").to_s
804
+ end
805
+
806
+ def dynamic_function_examples(value)
807
+ code_value = value.to_code
808
+ return [] unless code_value.is_a?(Object::Function)
809
+
810
+ code_value.documentation.code_get("examples").to_code.code_to_list.raw
811
+ end
492
812
  end
493
813
  end
494
814
  end