checkoff 0.223.0 → 0.225.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/checkoff.gemspec +10 -5
  3. data/lib/checkoff/cli.rb +1 -1
  4. data/lib/checkoff/clients.rb +1 -1
  5. data/lib/checkoff/custom_fields.rb +1 -1
  6. data/lib/checkoff/events.rb +1 -1
  7. data/lib/checkoff/internal/config_loader.rb +2 -3
  8. data/lib/checkoff/internal/selector_classes/section/function_evaluator.rb +3 -2
  9. data/lib/checkoff/my_tasks.rb +1 -1
  10. data/lib/checkoff/portfolios.rb +11 -9
  11. data/lib/checkoff/projects.rb +1 -1
  12. data/lib/checkoff/sections.rb +3 -4
  13. data/lib/checkoff/tags.rb +66 -17
  14. data/lib/checkoff/tasks.rb +1 -1
  15. data/lib/checkoff/version.rb +1 -1
  16. data/lib/checkoff/workspaces.rb +1 -1
  17. data/rbi/checkoff.rbi +4529 -0
  18. data/sig/checkoff.rbs +3749 -0
  19. metadata +4 -210
  20. data/.circleci/config.yml +0 -291
  21. data/.envrc +0 -9
  22. data/.git-hooks/pre_commit/circle_ci.rb +0 -26
  23. data/.git-hooks/pre_commit/punchlist.rb +0 -52
  24. data/.git-hooks/pre_commit/solargraph_typecheck.rb +0 -77
  25. data/.gitattributes +0 -6
  26. data/.gitignore +0 -65
  27. data/.markdownlint_style.rb +0 -4
  28. data/.mdlrc +0 -1
  29. data/.overcommit.yml +0 -115
  30. data/.rubocop.yml +0 -143
  31. data/.rubocop_todo.yml +0 -90
  32. data/.solargraph.yml +0 -35
  33. data/.yamllint.yml +0 -8
  34. data/.yardopts +0 -2
  35. data/CODE_OF_CONDUCT.md +0 -133
  36. data/CONTRIBUTING.rst +0 -75
  37. data/DEVELOPMENT.md +0 -69
  38. data/GLOSSARY.md +0 -16
  39. data/Gemfile +0 -67
  40. data/Gemfile.lock +0 -351
  41. data/LICENSE +0 -21
  42. data/Makefile +0 -139
  43. data/bin/brakeman +0 -27
  44. data/bin/bump +0 -29
  45. data/bin/checkoff +0 -29
  46. data/bin/console +0 -15
  47. data/bin/overcommit +0 -29
  48. data/bin/overcommit_branch +0 -114
  49. data/bin/rake +0 -29
  50. data/bin/rubocop +0 -27
  51. data/bin/setup +0 -8
  52. data/bin/solargraph +0 -27
  53. data/bin/sord +0 -27
  54. data/bin/spoom +0 -27
  55. data/bin/srb +0 -27
  56. data/bin/srb-rbi +0 -27
  57. data/bin/tapioca +0 -27
  58. data/bin/yard +0 -27
  59. data/config/annotations_asana.rb +0 -253
  60. data/config/annotations_misc.rb +0 -68
  61. data/config/env.1p +0 -2
  62. data/docs/.gitignore +0 -3
  63. data/docs/cookiecutter_input.json +0 -17
  64. data/docs/example_project.png +0 -0
  65. data/fix.sh +0 -534
  66. data/metrics/bigfiles_high_water_mark +0 -1
  67. data/metrics/brakeman_high_water_mark +0 -1
  68. data/metrics/bundle-audit_high_water_mark +0 -1
  69. data/metrics/cane_high_water_mark +0 -1
  70. data/metrics/eslint_high_water_mark +0 -1
  71. data/metrics/flake8_high_water_mark +0 -1
  72. data/metrics/flay_high_water_mark +0 -1
  73. data/metrics/flog_high_water_mark +0 -1
  74. data/metrics/jscs_high_water_mark +0 -1
  75. data/metrics/mdl_high_water_mark +0 -1
  76. data/metrics/pep8_high_water_mark +0 -1
  77. data/metrics/punchlist_high_water_mark +0 -1
  78. data/metrics/pycodestyle_high_water_mark +0 -1
  79. data/metrics/rails_best_practices_high_water_mark +0 -1
  80. data/metrics/rubocop_high_water_mark +0 -1
  81. data/metrics/scalastyle_high_water_mark +0 -1
  82. data/metrics/shellcheck_high_water_mark +0 -1
  83. data/package.json +0 -9
  84. data/rakelib/citest.rake +0 -4
  85. data/rakelib/clear_metrics.rake +0 -9
  86. data/rakelib/console.rake +0 -15
  87. data/rakelib/default.rake +0 -4
  88. data/rakelib/doc.rake +0 -6
  89. data/rakelib/gem_tasks.rake +0 -3
  90. data/rakelib/localtest.rake +0 -4
  91. data/rakelib/overcommit.rake +0 -6
  92. data/rakelib/quality.rake +0 -4
  93. data/rakelib/repl.rake +0 -4
  94. data/rakelib/test.rake +0 -10
  95. data/rakelib/trigger_next_builds.rake +0 -7
  96. data/rakelib/undercover.rake +0 -8
  97. data/requirements_dev.txt +0 -2
  98. data/sorbet/config +0 -4
  99. data/sorbet/rbi/annotations/.gitattributes +0 -1
  100. data/sorbet/rbi/annotations/activesupport.rbi +0 -453
  101. data/sorbet/rbi/annotations/faraday.rbi +0 -17
  102. data/sorbet/rbi/annotations/minitest.rbi +0 -119
  103. data/sorbet/rbi/annotations/mocha.rbi +0 -34
  104. data/sorbet/rbi/annotations/rainbow.rbi +0 -269
  105. data/sorbet/rbi/annotations/webmock.rbi +0 -9
  106. data/sorbet/rbi/dsl/.gitattributes +0 -1
  107. data/sorbet/rbi/dsl/active_support/callbacks.rbi +0 -23
  108. data/sorbet/rbi/gems/.gitattributes +0 -1
  109. data/sorbet/rbi/gems/activesupport@7.1.5.rbi +0 -18746
  110. data/sorbet/rbi/gems/addressable@2.8.6.rbi +0 -1994
  111. data/sorbet/rbi/gems/ansi@1.5.0.rbi +0 -688
  112. data/sorbet/rbi/gems/asana@0.10.6-ab9393136d9ca59b75e42a661fdddc1c65c8f7c3.rbi +0 -6142
  113. data/sorbet/rbi/gems/ast@2.4.2.rbi +0 -585
  114. data/sorbet/rbi/gems/backport@1.2.0.rbi +0 -523
  115. data/sorbet/rbi/gems/base64@0.2.0.rbi +0 -509
  116. data/sorbet/rbi/gems/benchmark@0.4.0.rbi +0 -618
  117. data/sorbet/rbi/gems/bigdecimal@3.1.5.rbi +0 -78
  118. data/sorbet/rbi/gems/brakeman@6.2.2.rbi +0 -222
  119. data/sorbet/rbi/gems/builder@3.2.4.rbi +0 -505
  120. data/sorbet/rbi/gems/bump@0.10.0.rbi +0 -169
  121. data/sorbet/rbi/gems/cache@0.4.1.rbi +0 -211
  122. data/sorbet/rbi/gems/cache_method@0.2.7.rbi +0 -293
  123. data/sorbet/rbi/gems/chef-utils@18.3.0.rbi +0 -9
  124. data/sorbet/rbi/gems/childprocess@5.1.0.rbi +0 -383
  125. data/sorbet/rbi/gems/coderay@1.1.3.rbi +0 -3427
  126. data/sorbet/rbi/gems/commander@4.6.0.rbi +0 -9
  127. data/sorbet/rbi/gems/concurrent-ruby@1.2.3.rbi +0 -11591
  128. data/sorbet/rbi/gems/connection_pool@2.4.1.rbi +0 -9
  129. data/sorbet/rbi/gems/crack@0.4.5.rbi +0 -145
  130. data/sorbet/rbi/gems/diff-lcs@1.5.1.rbi +0 -969
  131. data/sorbet/rbi/gems/docile@1.4.0.rbi +0 -377
  132. data/sorbet/rbi/gems/drb@2.2.1.rbi +0 -1347
  133. data/sorbet/rbi/gems/e2mmap@0.1.0.rbi +0 -9
  134. data/sorbet/rbi/gems/erubi@1.13.0.rbi +0 -152
  135. data/sorbet/rbi/gems/faraday-em_http@1.0.0.rbi +0 -222
  136. data/sorbet/rbi/gems/faraday-em_synchrony@1.0.0.rbi +0 -126
  137. data/sorbet/rbi/gems/faraday-excon@1.1.0.rbi +0 -136
  138. data/sorbet/rbi/gems/faraday-httpclient@1.0.1.rbi +0 -145
  139. data/sorbet/rbi/gems/faraday-multipart@1.0.4.rbi +0 -259
  140. data/sorbet/rbi/gems/faraday-net_http@1.0.1.rbi +0 -142
  141. data/sorbet/rbi/gems/faraday-net_http_persistent@1.2.0.rbi +0 -118
  142. data/sorbet/rbi/gems/faraday-patron@1.0.0.rbi +0 -125
  143. data/sorbet/rbi/gems/faraday-rack@1.0.0.rbi +0 -133
  144. data/sorbet/rbi/gems/faraday-retry@1.0.3.rbi +0 -198
  145. data/sorbet/rbi/gems/faraday@1.10.3.rbi +0 -2729
  146. data/sorbet/rbi/gems/faraday_middleware-multi_json@0.0.6.rbi +0 -29
  147. data/sorbet/rbi/gems/faraday_middleware@1.2.0.rbi +0 -1004
  148. data/sorbet/rbi/gems/gli@2.22.0.rbi +0 -9
  149. data/sorbet/rbi/gems/hashdiff@1.0.1.rbi +0 -351
  150. data/sorbet/rbi/gems/highline@2.0.3.rbi +0 -9
  151. data/sorbet/rbi/gems/i18n@1.14.6.rbi +0 -2359
  152. data/sorbet/rbi/gems/imagen@0.1.8.rbi +0 -340
  153. data/sorbet/rbi/gems/iniparse@1.5.0.rbi +0 -899
  154. data/sorbet/rbi/gems/jaro_winkler@1.6.0.rbi +0 -22
  155. data/sorbet/rbi/gems/json@2.7.1.rbi +0 -1562
  156. data/sorbet/rbi/gems/jwt@2.7.1.rbi +0 -1405
  157. data/sorbet/rbi/gems/kramdown-parser-gfm@1.1.0.rbi +0 -128
  158. data/sorbet/rbi/gems/kramdown@2.4.0.rbi +0 -3272
  159. data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +0 -14238
  160. data/sorbet/rbi/gems/logger@1.6.2.rbi +0 -923
  161. data/sorbet/rbi/gems/mdl@0.13.0.rbi +0 -445
  162. data/sorbet/rbi/gems/method_source@1.0.0.rbi +0 -273
  163. data/sorbet/rbi/gems/mime-types-data@3.2023.1205.rbi +0 -127
  164. data/sorbet/rbi/gems/mime-types@3.5.1.rbi +0 -1252
  165. data/sorbet/rbi/gems/minitest-profile@0.0.2.rbi +0 -136
  166. data/sorbet/rbi/gems/minitest-reporters@1.6.1.rbi +0 -1014
  167. data/sorbet/rbi/gems/minitest@5.21.1.rbi +0 -1539
  168. data/sorbet/rbi/gems/mixlib-cli@2.1.8.rbi +0 -314
  169. data/sorbet/rbi/gems/mixlib-config@3.0.27.rbi +0 -581
  170. data/sorbet/rbi/gems/mixlib-shellout@3.2.7.rbi +0 -629
  171. data/sorbet/rbi/gems/mocha@2.1.0.rbi +0 -12
  172. data/sorbet/rbi/gems/multi_json@1.15.0.rbi +0 -268
  173. data/sorbet/rbi/gems/multi_xml@0.6.0.rbi +0 -102
  174. data/sorbet/rbi/gems/multipart-post@2.3.0.rbi +0 -234
  175. data/sorbet/rbi/gems/mutex_m@0.3.0.rbi +0 -97
  176. data/sorbet/rbi/gems/netrc@0.11.0.rbi +0 -159
  177. data/sorbet/rbi/gems/nokogiri@1.17.0.rbi +0 -8201
  178. data/sorbet/rbi/gems/oauth2@1.4.11.rbi +0 -833
  179. data/sorbet/rbi/gems/overcommit@0.64.1.rbi +0 -2400
  180. data/sorbet/rbi/gems/parallel@1.23.0.rbi +0 -274
  181. data/sorbet/rbi/gems/parlour@5.0.0.rbi +0 -3007
  182. data/sorbet/rbi/gems/parser@3.2.2.4.rbi +0 -7253
  183. data/sorbet/rbi/gems/prism@1.2.0.rbi +0 -39085
  184. data/sorbet/rbi/gems/pry@0.14.2.rbi +0 -10070
  185. data/sorbet/rbi/gems/public_suffix@5.0.4.rbi +0 -936
  186. data/sorbet/rbi/gems/punchlist@1.3.2.rbi +0 -173
  187. data/sorbet/rbi/gems/racc@1.8.1.rbi +0 -162
  188. data/sorbet/rbi/gems/rack@3.1.8.rbi +0 -4896
  189. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +0 -403
  190. data/sorbet/rbi/gems/rake@13.1.0.rbi +0 -3022
  191. data/sorbet/rbi/gems/rbi@0.2.1.rbi +0 -4535
  192. data/sorbet/rbi/gems/rbs@2.8.4.rbi +0 -5613
  193. data/sorbet/rbi/gems/regexp_parser@2.8.3.rbi +0 -3750
  194. data/sorbet/rbi/gems/reverse_markdown@2.1.1.rbi +0 -390
  195. data/sorbet/rbi/gems/rexml@3.3.9.rbi +0 -4964
  196. data/sorbet/rbi/gems/rubocop-ast@1.30.0.rbi +0 -7127
  197. data/sorbet/rbi/gems/rubocop-minitest@0.34.5.rbi +0 -2577
  198. data/sorbet/rbi/gems/rubocop-performance@1.20.2.rbi +0 -3262
  199. data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +0 -329
  200. data/sorbet/rbi/gems/rubocop-rspec@3.0.0.rbi +0 -7546
  201. data/sorbet/rbi/gems/rubocop@1.59.0.rbi +0 -57238
  202. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +0 -1318
  203. data/sorbet/rbi/gems/ruby2_keywords@0.0.5.rbi +0 -9
  204. data/sorbet/rbi/gems/rugged@1.6.3.rbi +0 -1577
  205. data/sorbet/rbi/gems/securerandom@0.4.0.rbi +0 -75
  206. data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +0 -217
  207. data/sorbet/rbi/gems/simplecov-lcov@0.8.0.rbi +0 -256
  208. data/sorbet/rbi/gems/simplecov@0.22.0.rbi +0 -2149
  209. data/sorbet/rbi/gems/simplecov_json_formatter@0.1.4.rbi +0 -9
  210. data/sorbet/rbi/gems/solargraph-rails@1.1.0-9dc37915bd4f3b169046e34db6fb32193ab347d8.rbi +0 -320
  211. data/sorbet/rbi/gems/solargraph@0.50.1-904b9304770a59fac393c5cc3cad481e5bdf0fd8.rbi +0 -9396
  212. data/sorbet/rbi/gems/sord@5.1.0.rbi +0 -820
  213. data/sorbet/rbi/gems/source_finder@3.2.1.rbi +0 -317
  214. data/sorbet/rbi/gems/spoom@1.5.0.rbi +0 -4932
  215. data/sorbet/rbi/gems/tapioca@0.16.5.rbi +0 -3617
  216. data/sorbet/rbi/gems/thor@1.3.2.rbi +0 -4378
  217. data/sorbet/rbi/gems/tilt@2.4.0.rbi +0 -933
  218. data/sorbet/rbi/gems/tomlrb@2.0.3.rbi +0 -9
  219. data/sorbet/rbi/gems/tzinfo@2.0.6.rbi +0 -5918
  220. data/sorbet/rbi/gems/undercover@0.5.0.rbi +0 -433
  221. data/sorbet/rbi/gems/unicode-display_width@2.5.0.rbi +0 -66
  222. data/sorbet/rbi/gems/webmock@3.19.1.rbi +0 -1769
  223. data/sorbet/rbi/gems/yard-sorbet@0.9.0.rbi +0 -435
  224. data/sorbet/rbi/gems/yard@0.9.37.rbi +0 -18406
  225. data/sorbet/rbi/todo.rbi +0 -11
  226. data/sorbet/tapioca/config.yml +0 -13
  227. data/sorbet/tapioca/require.rb +0 -4
@@ -1,585 +0,0 @@
1
- # typed: strict
2
-
3
- # DO NOT EDIT MANUALLY
4
- # This is an autogenerated file for types exported from the `ast` gem.
5
- # Please instead update this file by running `bin/tapioca gem ast`.
6
-
7
-
8
- # {AST} is a library for manipulating abstract syntax trees.
9
- #
10
- # It embraces immutability; each AST node is inherently frozen at
11
- # creation, and updating a child node requires recreating that node
12
- # and its every parent, recursively.
13
- # This is a design choice. It does create some pressure on
14
- # garbage collector, but completely eliminates all concurrency
15
- # and aliasing problems.
16
- #
17
- # See also {AST::Node}, {AST::Processor::Mixin} and {AST::Sexp} for
18
- # additional recommendations and design patterns.
19
- #
20
- # source://ast//lib/ast.rb#13
21
- module AST; end
22
-
23
- # Node is an immutable class, instances of which represent abstract
24
- # syntax tree nodes. It combines semantic information (i.e. anything
25
- # that affects the algorithmic properties of a program) with
26
- # meta-information (line numbers or compiler intermediates).
27
- #
28
- # Notes on inheritance
29
- # ====================
30
- #
31
- # The distinction between semantics and metadata is important. Complete
32
- # semantic information should be contained within just the {#type} and
33
- # {#children} of a Node instance; in other words, if an AST was to be
34
- # stripped of all meta-information, it should remain a valid AST which
35
- # could be successfully processed to yield a result with the same
36
- # algorithmic properties.
37
- #
38
- # Thus, Node should never be inherited in order to define methods which
39
- # affect or return semantic information, such as getters for `class_name`,
40
- # `superclass` and `body` in the case of a hypothetical `ClassNode`. The
41
- # correct solution is to use a generic Node with a {#type} of `:class`
42
- # and three children. See also {Processor} for tips on working with such
43
- # ASTs.
44
- #
45
- # On the other hand, Node can and should be inherited to define
46
- # application-specific metadata (see also {#initialize}) or customize the
47
- # printing format. It is expected that an application would have one or two
48
- # such classes and use them across the entire codebase.
49
- #
50
- # The rationale for this pattern is extensibility and maintainability.
51
- # Unlike static ones, dynamic languages do not require the presence of a
52
- # predefined, rigid structure, nor does it improve dispatch efficiency,
53
- # and while such a structure can certainly be defined, it does not add
54
- # any value but incurs a maintaining cost.
55
- # For example, extending the AST even with a transformation-local
56
- # temporary node type requires making globally visible changes to
57
- # the codebase.
58
- #
59
- # source://ast//lib/ast/node.rb#40
60
- class AST::Node
61
- # Constructs a new instance of Node.
62
- #
63
- # The arguments `type` and `children` are converted with `to_sym` and
64
- # `to_a` respectively. Additionally, the result of converting `children`
65
- # is frozen. While mutating the arguments is generally considered harmful,
66
- # the most common case is to pass an array literal to the constructor. If
67
- # your code does not expect the argument to be frozen, use `#dup`.
68
- #
69
- # The `properties` hash is passed to {#assign_properties}.
70
- #
71
- # @return [Node] a new instance of Node
72
- #
73
- # source://ast//lib/ast/node.rb#72
74
- def initialize(type, children = T.unsafe(nil), properties = T.unsafe(nil)); end
75
-
76
- # Concatenates `array` with `children` and returns the resulting node.
77
- #
78
- # @return [AST::Node]
79
- #
80
- # source://ast//lib/ast/node.rb#168
81
- def +(array); end
82
-
83
- # Appends `element` to `children` and returns the resulting node.
84
- #
85
- # @return [AST::Node]
86
- #
87
- # source://ast//lib/ast/node.rb#177
88
- def <<(element); end
89
-
90
- # Compares `self` to `other`, possibly converting with `to_ast`. Only
91
- # `type` and `children` are compared; metadata is deliberately ignored.
92
- #
93
- # @return [Boolean]
94
- #
95
- # source://ast//lib/ast/node.rb#153
96
- def ==(other); end
97
-
98
- # Appends `element` to `children` and returns the resulting node.
99
- #
100
- # @return [AST::Node]
101
- #
102
- # source://ast//lib/ast/node.rb#177
103
- def append(element); end
104
-
105
- # Returns the children of this node.
106
- # The returned value is frozen.
107
- # The to_a alias is useful for decomposing nodes concisely.
108
- # For example:
109
- #
110
- # node = s(:gasgn, :$foo, s(:integer, 1))
111
- # var_name, value = *node
112
- # p var_name # => :$foo
113
- # p value # => (integer 1)
114
- #
115
- # @return [Array]
116
- #
117
- # source://ast//lib/ast/node.rb#56
118
- def children; end
119
-
120
- # Nodes are already frozen, so there is no harm in returning the
121
- # current node as opposed to initializing from scratch and freezing
122
- # another one.
123
- #
124
- # @return self
125
- #
126
- # source://ast//lib/ast/node.rb#115
127
- def clone; end
128
-
129
- # Concatenates `array` with `children` and returns the resulting node.
130
- #
131
- # @return [AST::Node]
132
- #
133
- # source://ast//lib/ast/node.rb#168
134
- def concat(array); end
135
-
136
- # Enables matching for Node, where type is the first element
137
- # and the children are remaining items.
138
- #
139
- # @return [Array]
140
- #
141
- # source://ast//lib/ast/node.rb#253
142
- def deconstruct; end
143
-
144
- # Nodes are already frozen, so there is no harm in returning the
145
- # current node as opposed to initializing from scratch and freezing
146
- # another one.
147
- #
148
- # @return self
149
- #
150
- # source://ast//lib/ast/node.rb#115
151
- def dup; end
152
-
153
- # Test if other object is equal to
154
- #
155
- # @param other [Object]
156
- # @return [Boolean]
157
- #
158
- # source://ast//lib/ast/node.rb#85
159
- def eql?(other); end
160
-
161
- # Returns the precomputed hash value for this node
162
- #
163
- # @return [Fixnum]
164
- #
165
- # source://ast//lib/ast/node.rb#61
166
- def hash; end
167
-
168
- # Converts `self` to a s-expression ruby string.
169
- # The code return will recreate the node, using the sexp module s()
170
- #
171
- # @param indent [Integer] Base indentation level.
172
- # @return [String]
173
- #
174
- # source://ast//lib/ast/node.rb#211
175
- def inspect(indent = T.unsafe(nil)); end
176
-
177
- # Returns the children of this node.
178
- # The returned value is frozen.
179
- # The to_a alias is useful for decomposing nodes concisely.
180
- # For example:
181
- #
182
- # node = s(:gasgn, :$foo, s(:integer, 1))
183
- # var_name, value = *node
184
- # p var_name # => :$foo
185
- # p value # => (integer 1)
186
- #
187
- # @return [Array]
188
- #
189
- # source://ast//lib/ast/node.rb#56
190
- def to_a; end
191
-
192
- # @return [AST::Node] self
193
- #
194
- # source://ast//lib/ast/node.rb#229
195
- def to_ast; end
196
-
197
- # Converts `self` to a pretty-printed s-expression.
198
- #
199
- # @param indent [Integer] Base indentation level.
200
- # @return [String]
201
- #
202
- # source://ast//lib/ast/node.rb#187
203
- def to_s(indent = T.unsafe(nil)); end
204
-
205
- # Converts `self` to a pretty-printed s-expression.
206
- #
207
- # @param indent [Integer] Base indentation level.
208
- # @return [String]
209
- #
210
- # source://ast//lib/ast/node.rb#187
211
- def to_sexp(indent = T.unsafe(nil)); end
212
-
213
- # Converts `self` to an Array where the first element is the type as a Symbol,
214
- # and subsequent elements are the same representation of its children.
215
- #
216
- # @return [Array<Symbol, [...Array]>]
217
- #
218
- # source://ast//lib/ast/node.rb#237
219
- def to_sexp_array; end
220
-
221
- # Returns the type of this node.
222
- #
223
- # @return [Symbol]
224
- #
225
- # source://ast//lib/ast/node.rb#43
226
- def type; end
227
-
228
- # Returns a new instance of Node where non-nil arguments replace the
229
- # corresponding fields of `self`.
230
- #
231
- # For example, `Node.new(:foo, [ 1, 2 ]).updated(:bar)` would yield
232
- # `(bar 1 2)`, and `Node.new(:foo, [ 1, 2 ]).updated(nil, [])` would
233
- # yield `(foo)`.
234
- #
235
- # If the resulting node would be identical to `self`, does nothing.
236
- #
237
- # @param type [Symbol, nil]
238
- # @param children [Array, nil]
239
- # @param properties [Hash, nil]
240
- # @return [AST::Node]
241
- #
242
- # source://ast//lib/ast/node.rb#133
243
- def updated(type = T.unsafe(nil), children = T.unsafe(nil), properties = T.unsafe(nil)); end
244
-
245
- protected
246
-
247
- # By default, each entry in the `properties` hash is assigned to
248
- # an instance variable in this instance of Node. A subclass should define
249
- # attribute readers for such variables. The values passed in the hash
250
- # are not frozen or whitelisted; such behavior can also be implemented
251
- # by subclassing Node and overriding this method.
252
- #
253
- # @return [nil]
254
- #
255
- # source://ast//lib/ast/node.rb#98
256
- def assign_properties(properties); end
257
-
258
- # Returns `@type` with all underscores replaced by dashes. This allows
259
- # to write symbol literals without quotes in Ruby sources and yet have
260
- # nicely looking s-expressions.
261
- #
262
- # @return [String]
263
- #
264
- # source://ast//lib/ast/node.rb#264
265
- def fancy_type; end
266
-
267
- private
268
-
269
- def original_dup; end
270
- end
271
-
272
- # This class includes {AST::Processor::Mixin}; however, it is
273
- # deprecated, since the module defines all of the behaviors that
274
- # the processor includes. Any new libraries should use
275
- # {AST::Processor::Mixin} instead of subclassing this.
276
- #
277
- # @deprecated Use {AST::Processor::Mixin} instead.
278
- #
279
- # source://ast//lib/ast/processor.rb#8
280
- class AST::Processor
281
- include ::AST::Processor::Mixin
282
- end
283
-
284
- # The processor module is a module which helps transforming one
285
- # AST into another. In a nutshell, the {#process} method accepts
286
- # a {Node} and dispatches it to a handler corresponding to its
287
- # type, and returns a (possibly) updated variant of the node.
288
- #
289
- # The processor module has a set of associated design patterns.
290
- # They are best explained with a concrete example. Let's define a
291
- # simple arithmetic language and an AST format for it:
292
- #
293
- # Terminals (AST nodes which do not have other AST nodes inside):
294
- #
295
- # * `(integer <int-literal>)`,
296
- #
297
- # Nonterminals (AST nodes with other nodes as children):
298
- #
299
- # * `(add <node> <node>)`,
300
- # * `(multiply <node> <node>)`,
301
- # * `(divide <node> <node>)`,
302
- # * `(negate <node>)`,
303
- # * `(store <node> <string-literal>)`: stores value of `<node>`
304
- # into a variable named `<string-literal>`,
305
- # * `(load <string-literal>)`: loads value of a variable named
306
- # `<string-literal>`,
307
- # * `(each <node> ...)`: computes each of the `<node>`s and
308
- # prints the result.
309
- #
310
- # All AST nodes have the same Ruby class, and therefore they don't
311
- # know how to traverse themselves. (A solution which dynamically
312
- # checks the type of children is possible, but is slow and
313
- # error-prone.) So, a class including the module which knows how
314
- # to traverse the entire tree should be defined. Such classes
315
- # have a handler for each nonterminal node which recursively
316
- # processes children nodes:
317
- #
318
- # require 'ast'
319
- #
320
- # class ArithmeticsProcessor
321
- # include AST::Processor::Mixin
322
- # # This method traverses any binary operators such as (add)
323
- # # or (multiply).
324
- # def process_binary_op(node)
325
- # # Children aren't decomposed automatically; it is
326
- # # suggested to use Ruby multiple assignment expansion,
327
- # # as it is very convenient here.
328
- # left_expr, right_expr = *node
329
- #
330
- # # AST::Node#updated won't change node type if nil is
331
- # # passed as a first argument, which allows to reuse the
332
- # # same handler for multiple node types using `alias'
333
- # # (below).
334
- # node.updated(nil, [
335
- # process(left_expr),
336
- # process(right_expr)
337
- # ])
338
- # end
339
- # alias_method :on_add, :process_binary_op
340
- # alias_method :on_multiply, :process_binary_op
341
- # alias_method :on_divide, :process_binary_op
342
- #
343
- # def on_negate(node)
344
- # # It is also possible to use #process_all for more
345
- # # compact code if every child is a Node.
346
- # node.updated(nil, process_all(node))
347
- # end
348
- #
349
- # def on_store(node)
350
- # expr, variable_name = *node
351
- #
352
- # # Note that variable_name is not a Node and thus isn't
353
- # # passed to #process.
354
- # node.updated(nil, [
355
- # process(expr),
356
- # variable_name
357
- # ])
358
- # end
359
- #
360
- # # (load) is effectively a terminal node, and so it does
361
- # # not need an explicit handler, as the following is the
362
- # # default behavior. Essentially, for any nodes that don't
363
- # # have a defined handler, the node remains unchanged.
364
- # def on_load(node)
365
- # nil
366
- # end
367
- #
368
- # def on_each(node)
369
- # node.updated(nil, process_all(node))
370
- # end
371
- # end
372
- #
373
- # Let's test our ArithmeticsProcessor:
374
- #
375
- # include AST::Sexp
376
- # expr = s(:add, s(:integer, 2), s(:integer, 2))
377
- #
378
- # p ArithmeticsProcessor.new.process(expr) == expr # => true
379
- #
380
- # As expected, it does not change anything at all. This isn't
381
- # actually very useful, so let's now define a Calculator, which
382
- # will compute the expression values:
383
- #
384
- # # This Processor folds nonterminal nodes and returns an
385
- # # (integer) terminal node.
386
- # class ArithmeticsCalculator < ArithmeticsProcessor
387
- # def compute_op(node)
388
- # # First, node children are processed and then unpacked
389
- # # to local variables.
390
- # nodes = process_all(node)
391
- #
392
- # if nodes.all? { |node| node.type == :integer }
393
- # # If each of those nodes represents a literal, we can
394
- # # fold this node!
395
- # values = nodes.map { |node| node.children.first }
396
- # AST::Node.new(:integer, [
397
- # yield(values)
398
- # ])
399
- # else
400
- # # Otherwise, we can just leave the current node in the
401
- # # tree and only update it with processed children
402
- # # nodes, which can be partially folded.
403
- # node.updated(nil, nodes)
404
- # end
405
- # end
406
- #
407
- # def on_add(node)
408
- # compute_op(node) { |left, right| left + right }
409
- # end
410
- #
411
- # def on_multiply(node)
412
- # compute_op(node) { |left, right| left * right }
413
- # end
414
- # end
415
- #
416
- # Let's check:
417
- #
418
- # p ArithmeticsCalculator.new.process(expr) # => (integer 4)
419
- #
420
- # Excellent, the calculator works! Now, a careful reader could
421
- # notice that the ArithmeticsCalculator does not know how to
422
- # divide numbers. What if we pass an expression with division to
423
- # it?
424
- #
425
- # expr_with_division = \
426
- # s(:add,
427
- # s(:integer, 1),
428
- # s(:divide,
429
- # s(:add, s(:integer, 8), s(:integer, 4)),
430
- # s(:integer, 3))) # 1 + (8 + 4) / 3
431
- #
432
- # folded_expr_with_division = ArithmeticsCalculator.new.process(expr_with_division)
433
- # p folded_expr_with_division
434
- # # => (add
435
- # # (integer 1)
436
- # # (divide
437
- # # (integer 12)
438
- # # (integer 3)))
439
- #
440
- # As you can see, the expression was folded _partially_: the inner
441
- # `(add)` node which could be computed was folded to
442
- # `(integer 12)`, the `(divide)` node is left as-is because there
443
- # is no computing handler for it, and the root `(add)` node was
444
- # also left as it is because some of its children were not
445
- # literals.
446
- #
447
- # Note that this partial folding is only possible because the
448
- # _data_ format, i.e. the format in which the computed values of
449
- # the nodes are represented, is the same as the AST itself.
450
- #
451
- # Let's extend our ArithmeticsCalculator class further.
452
- #
453
- # class ArithmeticsCalculator
454
- # def on_divide(node)
455
- # compute_op(node) { |left, right| left / right }
456
- # end
457
- #
458
- # def on_negate(node)
459
- # # Note how #compute_op works regardless of the operator
460
- # # arity.
461
- # compute_op(node) { |value| -value }
462
- # end
463
- # end
464
- #
465
- # Now, let's apply our renewed ArithmeticsCalculator to a partial
466
- # result of previous evaluation:
467
- #
468
- # p ArithmeticsCalculator.new.process(expr_with_division) # => (integer 5)
469
- #
470
- # Five! Excellent. This is also pretty much how CRuby 1.8 executed
471
- # its programs.
472
- #
473
- # Now, let's do some automated bug searching. Division by zero is
474
- # an error, right? So if we could detect that someone has divided
475
- # by zero before the program is even run, that could save some
476
- # debugging time.
477
- #
478
- # class DivisionByZeroVerifier < ArithmeticsProcessor
479
- # class VerificationFailure < Exception; end
480
- #
481
- # def on_divide(node)
482
- # # You need to process the children to handle nested divisions
483
- # # such as:
484
- # # (divide
485
- # # (integer 1)
486
- # # (divide (integer 1) (integer 0))
487
- # left, right = process_all(node)
488
- #
489
- # if right.type == :integer &&
490
- # right.children.first == 0
491
- # raise VerificationFailure, "Ouch! This code divides by zero."
492
- # end
493
- # end
494
- #
495
- # def divides_by_zero?(ast)
496
- # process(ast)
497
- # false
498
- # rescue VerificationFailure
499
- # true
500
- # end
501
- # end
502
- #
503
- # nice_expr = \
504
- # s(:divide,
505
- # s(:add, s(:integer, 10), s(:integer, 2)),
506
- # s(:integer, 4))
507
- #
508
- # p DivisionByZeroVerifier.new.divides_by_zero?(nice_expr)
509
- # # => false. Good.
510
- #
511
- # bad_expr = \
512
- # s(:add, s(:integer, 10),
513
- # s(:divide, s(:integer, 1), s(:integer, 0)))
514
- #
515
- # p DivisionByZeroVerifier.new.divides_by_zero?(bad_expr)
516
- # # => true. WHOOPS. DO NOT RUN THIS.
517
- #
518
- # Of course, this won't detect more complex cases... unless you
519
- # use some partial evaluation before! The possibilites are
520
- # endless. Have fun.
521
- #
522
- # source://ast//lib/ast/processor/mixin.rb#240
523
- module AST::Processor::Mixin
524
- # Default handler. Does nothing.
525
- #
526
- # @param node [AST::Node]
527
- # @return [AST::Node, nil]
528
- #
529
- # source://ast//lib/ast/processor/mixin.rb#284
530
- def handler_missing(node); end
531
-
532
- # Dispatches `node`. If a node has type `:foo`, then a handler
533
- # named `on_foo` is invoked with one argument, the `node`; if
534
- # there isn't such a handler, {#handler_missing} is invoked
535
- # with the same argument.
536
- #
537
- # If the handler returns `nil`, `node` is returned; otherwise,
538
- # the return value of the handler is passed along.
539
- #
540
- # @param node [AST::Node, nil]
541
- # @return [AST::Node, nil]
542
- #
543
- # source://ast//lib/ast/processor/mixin.rb#251
544
- def process(node); end
545
-
546
- # {#process}es each node from `nodes` and returns an array of
547
- # results.
548
- #
549
- # @param nodes [Array<AST::Node>]
550
- # @return [Array<AST::Node>]
551
- #
552
- # source://ast//lib/ast/processor/mixin.rb#274
553
- def process_all(nodes); end
554
- end
555
-
556
- # This simple module is very useful in the cases where one needs
557
- # to define deeply nested ASTs from Ruby code, for example, in
558
- # tests. It should be used like this:
559
- #
560
- # describe YourLanguage::AST do
561
- # include Sexp
562
- #
563
- # it "should correctly parse expressions" do
564
- # YourLanguage.parse("1 + 2 * 3").should ==
565
- # s(:add,
566
- # s(:integer, 1),
567
- # s(:multiply,
568
- # s(:integer, 2),
569
- # s(:integer, 3)))
570
- # end
571
- # end
572
- #
573
- # This way the amount of boilerplate code is greatly reduced.
574
- #
575
- # source://ast//lib/ast/sexp.rb#20
576
- module AST::Sexp
577
- # Creates a {Node} with type `type` and children `children`.
578
- # Note that the resulting node is of the type AST::Node and not a
579
- # subclass.
580
- # This would not pose a problem with comparisons, as {Node#==}
581
- # ignores metadata.
582
- #
583
- # source://ast//lib/ast/sexp.rb#26
584
- def s(type, *children); end
585
- end