roast-ai 0.4.6 → 0.4.8
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/.github/workflows/ci.yaml +3 -1
- data/.gitignore +7 -0
- data/.rubocop.yml +14 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +9 -1
- data/Rakefile +16 -4
- data/examples/README.md +9 -0
- data/examples/available_tools_demo/workflow.yml +2 -2
- data/examples/basic_prompt_workflow/workflow.md +1 -0
- data/examples/basic_prompt_workflow/workflow.yml +14 -0
- data/lib/roast/dsl/executor.rb +2 -1
- data/lib/roast/helpers/cmd_runner.rb +199 -0
- data/lib/roast/initializers.rb +1 -1
- data/lib/roast/tools/apply_diff.rb +1 -1
- data/lib/roast/tools/bash.rb +4 -4
- data/lib/roast/tools/cmd.rb +3 -5
- data/lib/roast/tools/coding_agent.rb +1 -1
- data/lib/roast/tools/grep.rb +6 -2
- data/lib/roast/tools/read_file.rb +2 -1
- data/lib/roast/tools/swarm.rb +2 -7
- data/lib/roast/tools.rb +10 -1
- data/lib/roast/version.rb +1 -1
- data/lib/roast/workflow/base_step.rb +2 -3
- data/lib/roast/workflow/command_executor.rb +3 -3
- data/lib/roast/workflow/resource_resolver.rb +1 -1
- data/lib/roast/workflow/shell_script_step.rb +1 -1
- data/lib/roast/workflow/step_loader.rb +2 -7
- data/lib/roast.rb +7 -1
- data/rubocop/cop/roast/use_cmd_runner.rb +93 -0
- data/rubocop/cop/roast.rb +4 -0
- data/sorbet/rbi/gems/docile@1.4.1.rbi +377 -0
- data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +233 -2
- data/sorbet/rbi/gems/racc@1.8.1.rbi +6 -4
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +396 -2
- data/sorbet/rbi/gems/regexp_parser@2.10.0.rbi +3788 -2
- data/sorbet/rbi/gems/rubocop-ast@1.45.1.rbi +7747 -2
- data/sorbet/rbi/gems/rubocop-sorbet@0.10.5.rbi +2386 -0
- data/sorbet/rbi/gems/rubocop@1.77.0.rbi +62813 -2
- data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1311 -2
- data/sorbet/rbi/gems/simplecov-html@0.13.2.rbi +225 -0
- data/sorbet/rbi/gems/simplecov@0.22.0.rbi +2259 -0
- data/sorbet/rbi/gems/simplecov_json_formatter@0.1.4.rbi +9 -0
- data/sorbet/rbi/gems/unicode-display_width@3.1.4.rbi +125 -2
- data/sorbet/rbi/gems/unicode-emoji@4.0.4.rbi +244 -2
- data/sorbet/tapioca/require.rb +2 -1
- metadata +12 -240
- data/CHANGELOG.md +0 -364
- data/examples/agent_continue/add_documentation/prompt.md +0 -5
- data/examples/agent_continue/add_error_handling/prompt.md +0 -5
- data/examples/agent_continue/analyze_codebase/prompt.md +0 -7
- data/examples/agent_continue/combined_workflow.yml +0 -24
- data/examples/agent_continue/continue_adding_features/prompt.md +0 -4
- data/examples/agent_continue/create_integration_tests/prompt.md +0 -3
- data/examples/agent_continue/document_with_context/prompt.md +0 -5
- data/examples/agent_continue/explore_api/prompt.md +0 -6
- data/examples/agent_continue/implement_client/prompt.md +0 -6
- data/examples/agent_continue/inline_workflow.yml +0 -20
- data/examples/agent_continue/refactor_code/prompt.md +0 -2
- data/examples/agent_continue/verify_changes/prompt.md +0 -6
- data/examples/agent_continue/workflow.yml +0 -27
- data/examples/agent_workflow/README.md +0 -75
- data/examples/agent_workflow/apply_refactorings/prompt.md +0 -22
- data/examples/agent_workflow/identify_code_smells/prompt.md +0 -15
- data/examples/agent_workflow/summarize_improvements/prompt.md +0 -18
- data/examples/agent_workflow/workflow.png +0 -0
- data/examples/agent_workflow/workflow.yml +0 -16
- data/examples/api_workflow/README.md +0 -85
- data/examples/api_workflow/fetch_api_data/prompt.md +0 -10
- data/examples/api_workflow/generate_report/prompt.md +0 -10
- data/examples/api_workflow/prompt.md +0 -10
- data/examples/api_workflow/transform_data/prompt.md +0 -10
- data/examples/api_workflow/workflow.png +0 -0
- data/examples/api_workflow/workflow.yml +0 -30
- data/examples/apply_diff_demo/README.md +0 -58
- data/examples/apply_diff_demo/apply_simple_change/prompt.md +0 -13
- data/examples/apply_diff_demo/create_sample_file/prompt.md +0 -11
- data/examples/apply_diff_demo/workflow.yml +0 -24
- data/examples/available_tools_demo/workflow.png +0 -0
- data/examples/bash_prototyping/README.md +0 -53
- data/examples/bash_prototyping/analyze_network/prompt.md +0 -13
- data/examples/bash_prototyping/analyze_system/prompt.md +0 -11
- data/examples/bash_prototyping/api_testing.png +0 -0
- data/examples/bash_prototyping/api_testing.yml +0 -14
- data/examples/bash_prototyping/check_processes/prompt.md +0 -11
- data/examples/bash_prototyping/generate_report/prompt.md +0 -16
- data/examples/bash_prototyping/process_json_response/prompt.md +0 -24
- data/examples/bash_prototyping/system_analysis.png +0 -0
- data/examples/bash_prototyping/system_analysis.yml +0 -14
- data/examples/bash_prototyping/test_public_api/prompt.md +0 -22
- data/examples/case_when/README.md +0 -58
- data/examples/case_when/detect_language/prompt.md +0 -16
- data/examples/case_when/workflow.png +0 -0
- data/examples/case_when/workflow.yml +0 -58
- data/examples/cmd/README.md +0 -99
- data/examples/cmd/analyze_project/prompt.md +0 -57
- data/examples/cmd/basic_demo/prompt.md +0 -48
- data/examples/cmd/basic_workflow.png +0 -0
- data/examples/cmd/basic_workflow.yml +0 -17
- data/examples/cmd/check_repository/prompt.md +0 -57
- data/examples/cmd/create_and_verify/prompt.md +0 -56
- data/examples/cmd/dev_workflow.png +0 -0
- data/examples/cmd/dev_workflow.yml +0 -26
- data/examples/cmd/explore_project/prompt.md +0 -67
- data/examples/cmd/explorer_workflow.png +0 -0
- data/examples/cmd/explorer_workflow.yml +0 -21
- data/examples/cmd/smart_tool_selection/prompt.md +0 -99
- data/examples/coding_agent_with_model.yml +0 -20
- data/examples/coding_agent_with_retries.yml +0 -30
- data/examples/conditional/README.md +0 -161
- data/examples/conditional/check_condition/prompt.md +0 -1
- data/examples/conditional/simple_workflow.png +0 -0
- data/examples/conditional/simple_workflow.yml +0 -15
- data/examples/conditional/workflow.png +0 -0
- data/examples/conditional/workflow.yml +0 -23
- data/examples/context_management_demo/README.md +0 -43
- data/examples/context_management_demo/workflow.yml +0 -42
- data/examples/direct_coerce_syntax/README.md +0 -32
- data/examples/direct_coerce_syntax/workflow.png +0 -0
- data/examples/direct_coerce_syntax/workflow.yml +0 -36
- data/examples/dot_notation/README.md +0 -37
- data/examples/dot_notation/workflow.png +0 -0
- data/examples/dot_notation/workflow.yml +0 -44
- data/examples/exit_on_error/README.md +0 -50
- data/examples/exit_on_error/analyze_lint_output/prompt.md +0 -9
- data/examples/exit_on_error/apply_fixes/prompt.md +0 -2
- data/examples/exit_on_error/workflow.png +0 -0
- data/examples/exit_on_error/workflow.yml +0 -19
- data/examples/grading/README.md +0 -71
- data/examples/grading/analyze_coverage/prompt.md +0 -52
- data/examples/grading/calculate_final_grade.rb +0 -67
- data/examples/grading/format_result.rb +0 -64
- data/examples/grading/generate_grades/prompt.md +0 -105
- data/examples/grading/generate_recommendations/output.txt +0 -17
- data/examples/grading/generate_recommendations/prompt.md +0 -60
- data/examples/grading/js_test_runner +0 -31
- data/examples/grading/rb_test_runner +0 -19
- data/examples/grading/read_dependencies/prompt.md +0 -16
- data/examples/grading/run_coverage.rb +0 -54
- data/examples/grading/verify_mocks_and_stubs/prompt.md +0 -12
- data/examples/grading/verify_test_helpers/prompt.md +0 -53
- data/examples/grading/workflow.md +0 -8
- data/examples/grading/workflow.png +0 -0
- data/examples/grading/workflow.rb.md +0 -6
- data/examples/grading/workflow.ts+tsx.md +0 -6
- data/examples/grading/workflow.yml +0 -41
- data/examples/instrumentation.rb +0 -76
- data/examples/interpolation/README.md +0 -50
- data/examples/interpolation/analyze_file/prompt.md +0 -1
- data/examples/interpolation/analyze_patterns/prompt.md +0 -27
- data/examples/interpolation/generate_report_for_js/prompt.md +0 -3
- data/examples/interpolation/generate_report_for_rb/prompt.md +0 -3
- data/examples/interpolation/sample.js +0 -48
- data/examples/interpolation/sample.rb +0 -42
- data/examples/interpolation/workflow.md +0 -1
- data/examples/interpolation/workflow.png +0 -0
- data/examples/interpolation/workflow.yml +0 -21
- data/examples/iteration/IMPLEMENTATION.md +0 -88
- data/examples/iteration/README.md +0 -68
- data/examples/iteration/analyze_complexity/prompt.md +0 -22
- data/examples/iteration/generate_recommendations/prompt.md +0 -21
- data/examples/iteration/generate_report/prompt.md +0 -129
- data/examples/iteration/implement_fix/prompt.md +0 -25
- data/examples/iteration/prioritize_issues/prompt.md +0 -24
- data/examples/iteration/prompts/analyze_file.md +0 -28
- data/examples/iteration/prompts/generate_summary.md +0 -24
- data/examples/iteration/prompts/update_report.md +0 -29
- data/examples/iteration/prompts/write_report.md +0 -22
- data/examples/iteration/read_file/prompt.md +0 -9
- data/examples/iteration/select_next_issue/prompt.md +0 -25
- data/examples/iteration/simple_workflow.md +0 -39
- data/examples/iteration/simple_workflow.yml +0 -58
- data/examples/iteration/update_fix_count/prompt.md +0 -26
- data/examples/iteration/verify_fix/prompt.md +0 -29
- data/examples/iteration/workflow.png +0 -0
- data/examples/iteration/workflow.yml +0 -42
- data/examples/json_handling/README.md +0 -32
- data/examples/json_handling/workflow.png +0 -0
- data/examples/json_handling/workflow.yml +0 -52
- data/examples/mcp/README.md +0 -223
- data/examples/mcp/analyze_changes/prompt.md +0 -8
- data/examples/mcp/analyze_issues/prompt.md +0 -4
- data/examples/mcp/analyze_schema/prompt.md +0 -4
- data/examples/mcp/check_data_quality/prompt.md +0 -5
- data/examples/mcp/check_documentation/prompt.md +0 -4
- data/examples/mcp/create_recommendations/prompt.md +0 -5
- data/examples/mcp/database_workflow.png +0 -0
- data/examples/mcp/database_workflow.yml +0 -29
- data/examples/mcp/env_demo/workflow.png +0 -0
- data/examples/mcp/env_demo/workflow.yml +0 -34
- data/examples/mcp/fetch_pr_context/prompt.md +0 -4
- data/examples/mcp/filesystem_demo/create_test_file/prompt.md +0 -2
- data/examples/mcp/filesystem_demo/list_files/prompt.md +0 -6
- data/examples/mcp/filesystem_demo/read_with_mcp/prompt.md +0 -7
- data/examples/mcp/filesystem_demo/workflow.png +0 -0
- data/examples/mcp/filesystem_demo/workflow.yml +0 -38
- data/examples/mcp/generate_insights/prompt.md +0 -4
- data/examples/mcp/generate_report/prompt.md +0 -6
- data/examples/mcp/generate_review/prompt.md +0 -16
- data/examples/mcp/github_workflow.png +0 -0
- data/examples/mcp/github_workflow.yml +0 -32
- data/examples/mcp/multi_mcp_workflow.png +0 -0
- data/examples/mcp/multi_mcp_workflow.yml +0 -58
- data/examples/mcp/post_review/prompt.md +0 -3
- data/examples/mcp/save_report/prompt.md +0 -6
- data/examples/mcp/search_issues/prompt.md +0 -2
- data/examples/mcp/summarize/prompt.md +0 -1
- data/examples/mcp/test_filesystem/prompt.md +0 -6
- data/examples/mcp/test_github/prompt.md +0 -8
- data/examples/mcp/test_read/prompt.md +0 -1
- data/examples/mcp/workflow.png +0 -0
- data/examples/mcp/workflow.yml +0 -35
- data/examples/no_model_fallback/README.md +0 -17
- data/examples/no_model_fallback/analyze_file/prompt.md +0 -1
- data/examples/no_model_fallback/analyze_patterns/prompt.md +0 -27
- data/examples/no_model_fallback/generate_report_for_md/prompt.md +0 -10
- data/examples/no_model_fallback/generate_report_for_rb/prompt.md +0 -3
- data/examples/no_model_fallback/sample.rb +0 -42
- data/examples/no_model_fallback/workflow.yml +0 -19
- data/examples/openrouter_example/README.md +0 -48
- data/examples/openrouter_example/analyze_input/prompt.md +0 -16
- data/examples/openrouter_example/generate_response/prompt.md +0 -9
- data/examples/openrouter_example/workflow.png +0 -0
- data/examples/openrouter_example/workflow.yml +0 -12
- data/examples/pre_post_processing/README.md +0 -111
- data/examples/pre_post_processing/analyze_test_file/prompt.md +0 -23
- data/examples/pre_post_processing/improve_test_coverage/prompt.md +0 -17
- data/examples/pre_post_processing/optimize_test_performance/prompt.md +0 -25
- data/examples/pre_post_processing/post_processing/aggregate_metrics/prompt.md +0 -31
- data/examples/pre_post_processing/post_processing/cleanup_environment/prompt.md +0 -28
- data/examples/pre_post_processing/post_processing/generate_summary_report/prompt.md +0 -32
- data/examples/pre_post_processing/post_processing/output.txt +0 -24
- data/examples/pre_post_processing/pre_processing/gather_baseline_metrics/prompt.md +0 -26
- data/examples/pre_post_processing/pre_processing/setup_test_environment/prompt.md +0 -11
- data/examples/pre_post_processing/validate_changes/prompt.md +0 -24
- data/examples/pre_post_processing/workflow.png +0 -0
- data/examples/pre_post_processing/workflow.yml +0 -21
- data/examples/retry/workflow.yml +0 -23
- data/examples/rspec_to_minitest/README.md +0 -68
- data/examples/rspec_to_minitest/analyze_spec/prompt.md +0 -30
- data/examples/rspec_to_minitest/create_minitest/prompt.md +0 -33
- data/examples/rspec_to_minitest/run_and_improve/prompt.md +0 -35
- data/examples/rspec_to_minitest/workflow.md +0 -10
- data/examples/rspec_to_minitest/workflow.png +0 -0
- data/examples/rspec_to_minitest/workflow.yml +0 -40
- data/examples/shared_config/README.md +0 -52
- data/examples/shared_config/example_with_shared_config/workflow.png +0 -0
- data/examples/shared_config/example_with_shared_config/workflow.yml +0 -6
- data/examples/shared_config/shared.png +0 -0
- data/examples/shared_config/shared.yml +0 -7
- data/examples/single_target_prepost/README.md +0 -36
- data/examples/single_target_prepost/post_processing/output.txt +0 -27
- data/examples/single_target_prepost/pre_processing/gather_dependencies/prompt.md +0 -11
- data/examples/single_target_prepost/workflow.png +0 -0
- data/examples/single_target_prepost/workflow.yml +0 -20
- data/examples/smart_coercion_defaults/README.md +0 -65
- data/examples/smart_coercion_defaults/workflow.png +0 -0
- data/examples/smart_coercion_defaults/workflow.yml +0 -44
- data/examples/step_configuration/README.md +0 -84
- data/examples/step_configuration/workflow.png +0 -0
- data/examples/step_configuration/workflow.yml +0 -57
- data/examples/swarm_example.yml +0 -25
- data/examples/tool_config_example/README.md +0 -109
- data/examples/tool_config_example/example_step/prompt.md +0 -42
- data/examples/tool_config_example/workflow.png +0 -0
- data/examples/tool_config_example/workflow.yml +0 -17
- data/examples/user_input/README.md +0 -90
- data/examples/user_input/funny_name/create_backstory/prompt.md +0 -10
- data/examples/user_input/funny_name/workflow.png +0 -0
- data/examples/user_input/funny_name/workflow.yml +0 -26
- data/examples/user_input/generate_summary/prompt.md +0 -11
- data/examples/user_input/simple_input_demo/workflow.png +0 -0
- data/examples/user_input/simple_input_demo/workflow.yml +0 -35
- data/examples/user_input/survey_workflow.png +0 -0
- data/examples/user_input/survey_workflow.yml +0 -71
- data/examples/user_input/welcome_message/prompt.md +0 -3
- data/examples/user_input/workflow.png +0 -0
- data/examples/user_input/workflow.yml +0 -73
- data/examples/workflow_generator/README.md +0 -27
- data/examples/workflow_generator/analyze_user_request/prompt.md +0 -34
- data/examples/workflow_generator/create_workflow_files/prompt.md +0 -32
- data/examples/workflow_generator/get_user_input/prompt.md +0 -14
- data/examples/workflow_generator/info_from_roast.rb +0 -22
- data/examples/workflow_generator/workflow.png +0 -0
- data/examples/workflow_generator/workflow.yml +0 -34
- data/lib/roast/helpers/timeout_handler.rb +0 -89
data/lib/roast.rb
CHANGED
@@ -21,6 +21,7 @@ require "yaml"
|
|
21
21
|
# Third-party gem requires
|
22
22
|
require "active_support"
|
23
23
|
require "active_support/cache"
|
24
|
+
require "active_support/core_ext/array"
|
24
25
|
require "active_support/core_ext/hash/indifferent_access"
|
25
26
|
require "active_support/core_ext/module/delegation"
|
26
27
|
require "active_support/core_ext/string"
|
@@ -36,6 +37,7 @@ require "raix/chat_completion"
|
|
36
37
|
require "raix/function_dispatch"
|
37
38
|
require "ruby-graphviz"
|
38
39
|
require "thor"
|
40
|
+
require "timeout"
|
39
41
|
|
40
42
|
# Autoloading setup
|
41
43
|
require "zeitwerk"
|
@@ -326,7 +328,11 @@ module Roast
|
|
326
328
|
def copy_example(example_name)
|
327
329
|
examples_dir = File.join(Roast::ROOT, "examples")
|
328
330
|
source_path = File.join(examples_dir, example_name)
|
329
|
-
|
331
|
+
|
332
|
+
# Always place new workflows in roast/ so `roast list` can find them
|
333
|
+
roast_dir = File.join(Dir.pwd, "roast")
|
334
|
+
FileUtils.mkdir_p(roast_dir)
|
335
|
+
target_path = File.join(roast_dir, example_name)
|
330
336
|
|
331
337
|
unless File.directory?(source_path)
|
332
338
|
puts "Example '#{example_name}' not found!"
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module RuboCop
|
5
|
+
module Cop
|
6
|
+
module Roast
|
7
|
+
# This cop suggests using CmdRunner instead of other command execution methods
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# # bad
|
11
|
+
# `ls -la`
|
12
|
+
# %x(ls -la)
|
13
|
+
# system("ls -la")
|
14
|
+
# Open3.capture3("ls -la")
|
15
|
+
# spawn("ls -la")
|
16
|
+
# exec("ls -la")
|
17
|
+
#
|
18
|
+
# # good
|
19
|
+
# CmdRunner.capture3("ls -la")
|
20
|
+
# CmdRunner.capture2e("ls -la")
|
21
|
+
class UseCmdRunner < RuboCop::Cop::Base
|
22
|
+
MSG = "Use `CmdRunner` instead of `%<method>s` for command execution to ensure proper process tracking and cleanup"
|
23
|
+
|
24
|
+
# Pattern for backtick commands
|
25
|
+
def_node_matcher :backtick_command?, <<~PATTERN
|
26
|
+
(xstr ...)
|
27
|
+
PATTERN
|
28
|
+
|
29
|
+
# Pattern for %x() commands
|
30
|
+
def_node_matcher :percent_x_command?, <<~PATTERN
|
31
|
+
(xstr ...)
|
32
|
+
PATTERN
|
33
|
+
|
34
|
+
# Pattern for system() calls
|
35
|
+
def_node_matcher :system_call?, <<~PATTERN
|
36
|
+
(send nil? :system ...)
|
37
|
+
PATTERN
|
38
|
+
|
39
|
+
# Pattern for spawn() calls
|
40
|
+
def_node_matcher :spawn_call?, <<~PATTERN
|
41
|
+
(send nil? :spawn ...)
|
42
|
+
PATTERN
|
43
|
+
|
44
|
+
# Pattern for exec() calls
|
45
|
+
def_node_matcher :exec_call?, <<~PATTERN
|
46
|
+
(send nil? :exec ...)
|
47
|
+
PATTERN
|
48
|
+
|
49
|
+
# Pattern for Open3 methods
|
50
|
+
def_node_matcher :open3_call?, <<~PATTERN
|
51
|
+
(send (const nil? :Open3) {:capture2 :capture2e :capture3 :popen2 :popen2e :popen3} ...)
|
52
|
+
PATTERN
|
53
|
+
|
54
|
+
# Pattern for Process.spawn
|
55
|
+
def_node_matcher :process_spawn?, <<~PATTERN
|
56
|
+
(send (const nil? :Process) :spawn ...)
|
57
|
+
PATTERN
|
58
|
+
|
59
|
+
# Pattern for Kernel methods
|
60
|
+
def_node_matcher :kernel_system?, <<~PATTERN
|
61
|
+
(send (const nil? :Kernel) {:system :spawn :exec} ...)
|
62
|
+
PATTERN
|
63
|
+
|
64
|
+
# Pattern for IO.popen
|
65
|
+
def_node_matcher :io_popen?, <<~PATTERN
|
66
|
+
(send (const nil? :IO) :popen ...)
|
67
|
+
PATTERN
|
68
|
+
|
69
|
+
def on_xstr(node)
|
70
|
+
add_offense(node, message: format(MSG, method: "backticks"))
|
71
|
+
end
|
72
|
+
|
73
|
+
def on_send(node)
|
74
|
+
if system_call?(node) || kernel_system?(node)
|
75
|
+
method_name = node.method_name
|
76
|
+
add_offense(node, message: format(MSG, method: method_name))
|
77
|
+
elsif spawn_call?(node)
|
78
|
+
add_offense(node, message: format(MSG, method: "spawn"))
|
79
|
+
elsif exec_call?(node)
|
80
|
+
add_offense(node, message: format(MSG, method: "exec"))
|
81
|
+
elsif open3_call?(node)
|
82
|
+
method_name = "Open3.#{node.method_name}"
|
83
|
+
add_offense(node, message: format(MSG, method: method_name))
|
84
|
+
elsif process_spawn?(node)
|
85
|
+
add_offense(node, message: format(MSG, method: "Process.spawn"))
|
86
|
+
elsif io_popen?(node)
|
87
|
+
add_offense(node, message: format(MSG, method: "IO.popen"))
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,377 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `docile` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem docile`.
|
6
|
+
|
7
|
+
|
8
|
+
# Docile keeps your Ruby DSLs tame and well-behaved.
|
9
|
+
#
|
10
|
+
# source://docile//lib/docile/version.rb#3
|
11
|
+
module Docile
|
12
|
+
extend ::Docile::Execution
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
# Execute a block in the context of an object whose methods represent the
|
17
|
+
# commands in a DSL.
|
18
|
+
#
|
19
|
+
# Use this method to execute an *imperative* DSL, which means that:
|
20
|
+
#
|
21
|
+
# 1. Each command mutates the state of the DSL context object
|
22
|
+
# 2. The return value of each command is ignored
|
23
|
+
# 3. The final return value is the original context object
|
24
|
+
#
|
25
|
+
# @example Use a String as a DSL
|
26
|
+
# Docile.dsl_eval("Hello, world!") do
|
27
|
+
# reverse!
|
28
|
+
# upcase!
|
29
|
+
# end
|
30
|
+
# #=> "!DLROW ,OLLEH"
|
31
|
+
# @example Use an Array as a DSL
|
32
|
+
# Docile.dsl_eval([]) do
|
33
|
+
# push 1
|
34
|
+
# push 2
|
35
|
+
# pop
|
36
|
+
# push 3
|
37
|
+
# end
|
38
|
+
# #=> [1, 3]
|
39
|
+
# @note Use with an *imperative* DSL (commands modify the context object)
|
40
|
+
# @param dsl [Object] context object whose methods make up the DSL
|
41
|
+
# @param args [Array] arguments to be passed to the block
|
42
|
+
# @param block [Proc] the block of DSL commands to be executed against the
|
43
|
+
# `dsl` context object
|
44
|
+
# @return [Object] the `dsl` context object after executing the block
|
45
|
+
#
|
46
|
+
# source://docile//lib/docile.rb#45
|
47
|
+
def dsl_eval(dsl, *args, **_arg2, &block); end
|
48
|
+
|
49
|
+
# Execute a block in the context of an immutable object whose methods,
|
50
|
+
# and the methods of their return values, represent the commands in a DSL.
|
51
|
+
#
|
52
|
+
# Use this method to execute a *functional* DSL, which means that:
|
53
|
+
#
|
54
|
+
# 1. The original DSL context object is never mutated
|
55
|
+
# 2. Each command returns the next DSL context object
|
56
|
+
# 3. The final return value is the value returned by the last command
|
57
|
+
#
|
58
|
+
# @example Use a frozen String as a DSL
|
59
|
+
# Docile.dsl_eval_immutable("I'm immutable!".freeze) do
|
60
|
+
# reverse
|
61
|
+
# upcase
|
62
|
+
# end
|
63
|
+
# #=> "!ELBATUMMI M'I"
|
64
|
+
# @example Use a Float as a DSL
|
65
|
+
# Docile.dsl_eval_immutable(84.5) do
|
66
|
+
# fdiv(2)
|
67
|
+
# floor
|
68
|
+
# end
|
69
|
+
# #=> 42
|
70
|
+
# @note Use with a *functional* DSL (commands return successor
|
71
|
+
# context objects)
|
72
|
+
# @param dsl [Object] immutable context object whose methods make up the
|
73
|
+
# initial DSL
|
74
|
+
# @param args [Array] arguments to be passed to the block
|
75
|
+
# @param block [Proc] the block of DSL commands to be executed against the
|
76
|
+
# `dsl` context object and successor return values
|
77
|
+
# @return [Object] the return value of the final command in the block
|
78
|
+
#
|
79
|
+
# source://docile//lib/docile.rb#128
|
80
|
+
def dsl_eval_immutable(dsl, *args, **_arg2, &block); end
|
81
|
+
|
82
|
+
# Execute a block in the context of an object whose methods represent the
|
83
|
+
# commands in a DSL, and return *the block's return value*.
|
84
|
+
#
|
85
|
+
# Use this method to execute an *imperative* DSL, which means that:
|
86
|
+
#
|
87
|
+
# 1. Each command mutates the state of the DSL context object
|
88
|
+
# 2. The return value of each command is ignored
|
89
|
+
# 3. The final return value is the original context object
|
90
|
+
#
|
91
|
+
# @example Use a String as a DSL
|
92
|
+
# Docile.dsl_eval_with_block_return("Hello, world!") do
|
93
|
+
# reverse!
|
94
|
+
# upcase!
|
95
|
+
# first
|
96
|
+
# end
|
97
|
+
# #=> "!"
|
98
|
+
# @example Use an Array as a DSL
|
99
|
+
# Docile.dsl_eval_with_block_return([]) do
|
100
|
+
# push "a"
|
101
|
+
# push "b"
|
102
|
+
# pop
|
103
|
+
# push "c"
|
104
|
+
# length
|
105
|
+
# end
|
106
|
+
# #=> 2
|
107
|
+
# @note Use with an *imperative* DSL (commands modify the context object)
|
108
|
+
# @param dsl [Object] context object whose methods make up the DSL
|
109
|
+
# @param args [Array] arguments to be passed to the block
|
110
|
+
# @param block [Proc] the block of DSL commands to be executed against the
|
111
|
+
# `dsl` context object
|
112
|
+
# @return [Object] the return value from executing the block
|
113
|
+
#
|
114
|
+
# source://docile//lib/docile.rb#87
|
115
|
+
def dsl_eval_with_block_return(dsl, *args, **_arg2, &block); end
|
116
|
+
|
117
|
+
class << self
|
118
|
+
# Execute a block in the context of an object whose methods represent the
|
119
|
+
# commands in a DSL.
|
120
|
+
#
|
121
|
+
# Use this method to execute an *imperative* DSL, which means that:
|
122
|
+
#
|
123
|
+
# 1. Each command mutates the state of the DSL context object
|
124
|
+
# 2. The return value of each command is ignored
|
125
|
+
# 3. The final return value is the original context object
|
126
|
+
#
|
127
|
+
# @example Use a String as a DSL
|
128
|
+
# Docile.dsl_eval("Hello, world!") do
|
129
|
+
# reverse!
|
130
|
+
# upcase!
|
131
|
+
# end
|
132
|
+
# #=> "!DLROW ,OLLEH"
|
133
|
+
# @example Use an Array as a DSL
|
134
|
+
# Docile.dsl_eval([]) do
|
135
|
+
# push 1
|
136
|
+
# push 2
|
137
|
+
# pop
|
138
|
+
# push 3
|
139
|
+
# end
|
140
|
+
# #=> [1, 3]
|
141
|
+
# @note Use with an *imperative* DSL (commands modify the context object)
|
142
|
+
# @param dsl [Object] context object whose methods make up the DSL
|
143
|
+
# @param args [Array] arguments to be passed to the block
|
144
|
+
# @param block [Proc] the block of DSL commands to be executed against the
|
145
|
+
# `dsl` context object
|
146
|
+
# @return [Object] the `dsl` context object after executing the block
|
147
|
+
#
|
148
|
+
# source://docile//lib/docile.rb#45
|
149
|
+
def dsl_eval(dsl, *args, **_arg2, &block); end
|
150
|
+
|
151
|
+
# Execute a block in the context of an immutable object whose methods,
|
152
|
+
# and the methods of their return values, represent the commands in a DSL.
|
153
|
+
#
|
154
|
+
# Use this method to execute a *functional* DSL, which means that:
|
155
|
+
#
|
156
|
+
# 1. The original DSL context object is never mutated
|
157
|
+
# 2. Each command returns the next DSL context object
|
158
|
+
# 3. The final return value is the value returned by the last command
|
159
|
+
#
|
160
|
+
# @example Use a frozen String as a DSL
|
161
|
+
# Docile.dsl_eval_immutable("I'm immutable!".freeze) do
|
162
|
+
# reverse
|
163
|
+
# upcase
|
164
|
+
# end
|
165
|
+
# #=> "!ELBATUMMI M'I"
|
166
|
+
# @example Use a Float as a DSL
|
167
|
+
# Docile.dsl_eval_immutable(84.5) do
|
168
|
+
# fdiv(2)
|
169
|
+
# floor
|
170
|
+
# end
|
171
|
+
# #=> 42
|
172
|
+
# @note Use with a *functional* DSL (commands return successor
|
173
|
+
# context objects)
|
174
|
+
# @param dsl [Object] immutable context object whose methods make up the
|
175
|
+
# initial DSL
|
176
|
+
# @param args [Array] arguments to be passed to the block
|
177
|
+
# @param block [Proc] the block of DSL commands to be executed against the
|
178
|
+
# `dsl` context object and successor return values
|
179
|
+
# @return [Object] the return value of the final command in the block
|
180
|
+
#
|
181
|
+
# source://docile//lib/docile.rb#128
|
182
|
+
def dsl_eval_immutable(dsl, *args, **_arg2, &block); end
|
183
|
+
|
184
|
+
# Execute a block in the context of an object whose methods represent the
|
185
|
+
# commands in a DSL, and return *the block's return value*.
|
186
|
+
#
|
187
|
+
# Use this method to execute an *imperative* DSL, which means that:
|
188
|
+
#
|
189
|
+
# 1. Each command mutates the state of the DSL context object
|
190
|
+
# 2. The return value of each command is ignored
|
191
|
+
# 3. The final return value is the original context object
|
192
|
+
#
|
193
|
+
# @example Use a String as a DSL
|
194
|
+
# Docile.dsl_eval_with_block_return("Hello, world!") do
|
195
|
+
# reverse!
|
196
|
+
# upcase!
|
197
|
+
# first
|
198
|
+
# end
|
199
|
+
# #=> "!"
|
200
|
+
# @example Use an Array as a DSL
|
201
|
+
# Docile.dsl_eval_with_block_return([]) do
|
202
|
+
# push "a"
|
203
|
+
# push "b"
|
204
|
+
# pop
|
205
|
+
# push "c"
|
206
|
+
# length
|
207
|
+
# end
|
208
|
+
# #=> 2
|
209
|
+
# @note Use with an *imperative* DSL (commands modify the context object)
|
210
|
+
# @param dsl [Object] context object whose methods make up the DSL
|
211
|
+
# @param args [Array] arguments to be passed to the block
|
212
|
+
# @param block [Proc] the block of DSL commands to be executed against the
|
213
|
+
# `dsl` context object
|
214
|
+
# @return [Object] the return value from executing the block
|
215
|
+
#
|
216
|
+
# source://docile//lib/docile.rb#87
|
217
|
+
def dsl_eval_with_block_return(dsl, *args, **_arg2, &block); end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
# This is used to remove entries pointing to Docile's source files
|
222
|
+
# from {Exception#backtrace} and {Exception#backtrace_locations}.
|
223
|
+
#
|
224
|
+
# If {NoMethodError} is caught then the exception object will be extended
|
225
|
+
# by this module to add filter functionalities.
|
226
|
+
#
|
227
|
+
# @api private
|
228
|
+
#
|
229
|
+
# source://docile//lib/docile/backtrace_filter.rb#11
|
230
|
+
module Docile::BacktraceFilter
|
231
|
+
# @api private
|
232
|
+
#
|
233
|
+
# source://docile//lib/docile/backtrace_filter.rb#14
|
234
|
+
def backtrace; end
|
235
|
+
|
236
|
+
# @api private
|
237
|
+
#
|
238
|
+
# source://docile//lib/docile/backtrace_filter.rb#19
|
239
|
+
def backtrace_locations; end
|
240
|
+
end
|
241
|
+
|
242
|
+
# @api private
|
243
|
+
#
|
244
|
+
# source://docile//lib/docile/backtrace_filter.rb#12
|
245
|
+
Docile::BacktraceFilter::FILTER_PATTERN = T.let(T.unsafe(nil), Regexp)
|
246
|
+
|
247
|
+
# Operates in the same manner as {FallbackContextProxy}, but replacing
|
248
|
+
# the primary `receiver` object with the result of each proxied method.
|
249
|
+
#
|
250
|
+
# This is useful for implementing DSL evaluation for immutable context
|
251
|
+
# objects.
|
252
|
+
#
|
253
|
+
#
|
254
|
+
# @api private
|
255
|
+
# @see Docile.dsl_eval_immutable
|
256
|
+
#
|
257
|
+
# source://docile//lib/docile/chaining_fallback_context_proxy.rb#17
|
258
|
+
class Docile::ChainingFallbackContextProxy < ::Docile::FallbackContextProxy
|
259
|
+
# Proxy methods as in {FallbackContextProxy#method_missing}, replacing
|
260
|
+
# `receiver` with the returned value.
|
261
|
+
#
|
262
|
+
# @api private
|
263
|
+
#
|
264
|
+
# source://docile//lib/docile/chaining_fallback_context_proxy.rb#20
|
265
|
+
def method_missing(method, *args, **_arg2, &block); end
|
266
|
+
end
|
267
|
+
|
268
|
+
# A namespace for functions relating to the execution of a block against a
|
269
|
+
# proxy object.
|
270
|
+
#
|
271
|
+
# @api private
|
272
|
+
#
|
273
|
+
# source://docile//lib/docile/execution.rb#8
|
274
|
+
module Docile::Execution
|
275
|
+
private
|
276
|
+
|
277
|
+
# Execute a block in the context of an object whose methods represent the
|
278
|
+
# commands in a DSL, using a specific proxy class.
|
279
|
+
#
|
280
|
+
# @api private
|
281
|
+
# @param dsl [Object] context object whose methods make up the
|
282
|
+
# (initial) DSL
|
283
|
+
# @param proxy_type [FallbackContextProxy, ChainingFallbackContextProxy] which class to instantiate as proxy context
|
284
|
+
# @param args [Array] arguments to be passed to the block
|
285
|
+
# @param block [Proc] the block of DSL commands to be executed
|
286
|
+
# @return [Object] the return value of the block
|
287
|
+
#
|
288
|
+
# source://docile//lib/docile/execution.rb#19
|
289
|
+
def exec_in_proxy_context(dsl, proxy_type, *args, **_arg3, &block); end
|
290
|
+
|
291
|
+
class << self
|
292
|
+
# Execute a block in the context of an object whose methods represent the
|
293
|
+
# commands in a DSL, using a specific proxy class.
|
294
|
+
#
|
295
|
+
# @api private
|
296
|
+
# @param dsl [Object] context object whose methods make up the
|
297
|
+
# (initial) DSL
|
298
|
+
# @param proxy_type [FallbackContextProxy, ChainingFallbackContextProxy] which class to instantiate as proxy context
|
299
|
+
# @param args [Array] arguments to be passed to the block
|
300
|
+
# @param block [Proc] the block of DSL commands to be executed
|
301
|
+
# @return [Object] the return value of the block
|
302
|
+
#
|
303
|
+
# source://docile//lib/docile/execution.rb#19
|
304
|
+
def exec_in_proxy_context(dsl, proxy_type, *args, **_arg3, &block); end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
# A proxy object with a primary receiver as well as a secondary
|
309
|
+
# fallback receiver.
|
310
|
+
#
|
311
|
+
# Will attempt to forward all method calls first to the primary receiver,
|
312
|
+
# and then to the fallback receiver if the primary does not handle that
|
313
|
+
# method.
|
314
|
+
#
|
315
|
+
# This is useful for implementing DSL evaluation in the context of an object.
|
316
|
+
#
|
317
|
+
#
|
318
|
+
# @api private
|
319
|
+
# @see Docile.dsl_eval
|
320
|
+
#
|
321
|
+
# source://docile//lib/docile/fallback_context_proxy.rb#20
|
322
|
+
class Docile::FallbackContextProxy
|
323
|
+
# @api private
|
324
|
+
# @param receiver [Object] the primary proxy target to which all methods
|
325
|
+
# initially will be forwarded
|
326
|
+
# @param fallback [Object] the fallback proxy target to which any methods
|
327
|
+
# not handled by `receiver` will be forwarded
|
328
|
+
# @return [FallbackContextProxy] a new instance of FallbackContextProxy
|
329
|
+
#
|
330
|
+
# source://docile//lib/docile/fallback_context_proxy.rb#46
|
331
|
+
def initialize(receiver, fallback); end
|
332
|
+
|
333
|
+
# @api private
|
334
|
+
# @return [Array<Symbol>] Instance variable names, excluding
|
335
|
+
# {NON_PROXIED_INSTANCE_VARIABLES}
|
336
|
+
#
|
337
|
+
# source://docile//lib/docile/fallback_context_proxy.rb#85
|
338
|
+
def instance_variables; end
|
339
|
+
|
340
|
+
# Proxy all methods, excluding {NON_PROXIED_METHODS}, first to `receiver`
|
341
|
+
# and then to `fallback` if not found.
|
342
|
+
#
|
343
|
+
# @api private
|
344
|
+
#
|
345
|
+
# source://docile//lib/docile/fallback_context_proxy.rb#91
|
346
|
+
def method_missing(method, *args, **_arg2, &block); end
|
347
|
+
end
|
348
|
+
|
349
|
+
# The set of methods which will **not** fallback from the block's context
|
350
|
+
# to the dsl object.
|
351
|
+
#
|
352
|
+
# @api private
|
353
|
+
#
|
354
|
+
# source://docile//lib/docile/fallback_context_proxy.rb#30
|
355
|
+
Docile::FallbackContextProxy::NON_FALLBACK_METHODS = T.let(T.unsafe(nil), Set)
|
356
|
+
|
357
|
+
# The set of instance variables which are local to this object and hidden.
|
358
|
+
# All other instance variables will be copied in and out of this object
|
359
|
+
# from the scope in which this proxy was created.
|
360
|
+
#
|
361
|
+
# @api private
|
362
|
+
#
|
363
|
+
# source://docile//lib/docile/fallback_context_proxy.rb#35
|
364
|
+
Docile::FallbackContextProxy::NON_PROXIED_INSTANCE_VARIABLES = T.let(T.unsafe(nil), Set)
|
365
|
+
|
366
|
+
# The set of methods which will **not** be proxied, but instead answered
|
367
|
+
# by this object directly.
|
368
|
+
#
|
369
|
+
# @api private
|
370
|
+
#
|
371
|
+
# source://docile//lib/docile/fallback_context_proxy.rb#23
|
372
|
+
Docile::FallbackContextProxy::NON_PROXIED_METHODS = T.let(T.unsafe(nil), Set)
|
373
|
+
|
374
|
+
# The current version of this library
|
375
|
+
#
|
376
|
+
# source://docile//lib/docile/version.rb#5
|
377
|
+
Docile::VERSION = T.let(T.unsafe(nil), String)
|