Class: Girb::Tools::RailsProjectInfo
- Inherits:
-
Base
- Object
- Base
- Girb::Tools::RailsProjectInfo
show all
- Defined in:
- lib/girb/tools/rails_tools.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
to_gemini_tool, tool_name
Class Method Details
.available? ⇒ Boolean
9
10
11
|
# File 'lib/girb/tools/rails_tools.rb', line 9
def available?
defined?(Rails)
end
|
.description ⇒ Object
13
14
15
|
# File 'lib/girb/tools/rails_tools.rb', line 13
def description
"Get Rails project information: current directory (Rails.root), environment, Ruby/Rails versions, database config, and list of all defined models. Use this to find project path or list models."
end
|
.parameters ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/girb/tools/rails_tools.rb', line 17
def parameters
{
type: "object",
properties: {},
required: []
}
end
|
Instance Method Details
#execute(binding) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/girb/tools/rails_tools.rb', line 26
def execute(binding)
info = {
root: Rails.root.to_s,
environment: Rails.env,
ruby_version: RUBY_VERSION
}
info[:rails_version] = Rails.version if Rails.respond_to?(:version)
if defined?(ActiveRecord::Base)
begin
config = ActiveRecord::Base.connection_db_config
info[:database] = {
adapter: config.adapter,
database: config.database
}
rescue StandardError
end
end
if defined?(ActiveRecord::Base)
begin
Rails.application.eager_load! unless Rails.application.config.eager_load
info[:models] = ActiveRecord::Base.descendants.map(&:name).sort
rescue StandardError
end
end
info
rescue StandardError => e
{ error: "#{e.class}: #{e.message}" }
end
|