ai_summary 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53916606fb68c96f6614948a6193cdab8c3cada4a0e28d1fe03b5692e95cb5a5
4
- data.tar.gz: aefc1d01caa738330338758048b5a4283c9a50cbf89f6d45c46dda586cebf9cd
3
+ metadata.gz: 4054e60f4ebb2c24816ec2c47953f611a47962a3157ce4193f896c994b5a4872
4
+ data.tar.gz: 6987b3a5cd95ffcba7429c1b0e43378d83f0692c26a6f8d9cdd7d58f4376e8c9
5
5
  SHA512:
6
- metadata.gz: 2b1990640271924335ef4e55a3648c390df4d9dbac4c4f4704b864df4ff9bc5fc97ab33ef09c0739e8450b0acd98e1e8b19b028cf2501a38b4b3773728d24fed
7
- data.tar.gz: af3277aa57ce5fe1786fd3fad33282a5868dfb82e04ec202426fe910b163edf3e17df5bfb41fec063cf3e7118ee11e7a1c2f6026e2a6ae7646729bf2b0c385a9
6
+ metadata.gz: 756d7bb33cf722f27d81b125b1744be36da242a96a8800bb1aa811f4c8fa0b606dd7ea5f93b33b2e461d5a340e7ca1f1d53a3f76c5892396c1a7f735dceb9131
7
+ data.tar.gz: 6af9adbd0a173d65db7a19c290aa7e0f65ed4db79a57b499a9848d4253cd59b34107ae95b30c64845b5009405916fb35cd799de7ebd7a15cc28e8dc0d701d990
@@ -2,17 +2,20 @@
2
2
 
3
3
  require "json"
4
4
  require "yaml"
5
+ require "bundler"
5
6
 
6
7
  module AiSummary
7
8
  class SummaryGenerator
8
9
  def self.generate(format: "txt")
9
- # Ensure models are loaded
10
10
  Dir[Rails.root.join("app/models/**/*.rb")].sort.each { |file| require_dependency file }
11
11
 
12
12
  data = {
13
13
  models: extract_models,
14
14
  routes: extract_routes,
15
- controllers: extract_controllers
15
+ controllers: extract_controllers,
16
+ jobs: extract_jobs,
17
+ services: extract_services,
18
+ gems: extract_gems
16
19
  }
17
20
 
18
21
  case format.downcase
@@ -34,7 +37,20 @@ module AiSummary
34
37
  name: model.name,
35
38
  table: model.table_name,
36
39
  columns: model.columns.map { |col| { name: col.name, type: col.type } },
37
- associations: model.reflect_on_all_associations.map { |assoc| { type: assoc.macro, name: assoc.name } }
40
+ associations: model.reflect_on_all_associations.map { |assoc| { type: assoc.macro, name: assoc.name } },
41
+ methods: model.public_instance_methods(false).map(&:to_s).sort,
42
+ validations: extract_validations(model),
43
+ scopes: model.respond_to?(:defined_scopes) ? model.defined_scopes.map(&:to_s) : [],
44
+ indexes: ActiveRecord::Base.connection.indexes(model.table_name).map(&:name)
45
+ }
46
+ end
47
+ end
48
+
49
+ def self.extract_validations(model)
50
+ model.validators.map do |validator|
51
+ {
52
+ type: validator.class.name.demodulize,
53
+ attributes: validator.attributes
38
54
  }
39
55
  end
40
56
  end
@@ -45,10 +61,12 @@ module AiSummary
45
61
  next unless r.defaults[:controller] && r.defaults[:action]
46
62
 
47
63
  {
64
+ name: r.name,
48
65
  verb: verb,
49
66
  path: r.path.spec.to_s,
50
67
  controller: r.defaults[:controller],
51
- action: r.defaults[:action]
68
+ action: r.defaults[:action],
69
+ constraints: r.constraints.map { |k, v| "#{k}: #{v}" }
52
70
  }
53
71
  end.compact
54
72
  end
@@ -58,36 +76,89 @@ module AiSummary
58
76
  class_name = File.basename(file, ".rb").camelize
59
77
  klass = class_name.safe_constantize
60
78
  next unless klass.is_a?(Class)
79
+
61
80
  {
62
81
  name: klass.name,
63
- actions: klass.public_instance_methods(false).map(&:to_s)
82
+ actions: klass.public_instance_methods(false).map(&:to_s),
83
+ filters: klass.respond_to?(:_process_action_callbacks) ? klass._process_action_callbacks.map(&:filter).uniq.map(&:to_s) : []
64
84
  }
65
85
  end.compact
66
86
  end
67
87
 
88
+ def self.extract_jobs
89
+ Dir.glob(Rails.root.join("app/jobs/**/*.rb")).map do |file|
90
+ name = File.basename(file, ".rb").camelize
91
+ klass = name.safe_constantize
92
+ next unless klass&.ancestors&.include?(ActiveJob::Base)
93
+
94
+ { name: klass.name }
95
+ end.compact
96
+ end
97
+
98
+ def self.extract_services
99
+ Dir.glob(Rails.root.join("app/services/**/*.rb")).map do |file|
100
+ File.basename(file, ".rb").camelize
101
+ end
102
+ end
103
+
104
+ def self.extract_gems
105
+ Bundler.load.specs.map(&:name).sort.uniq.take(25) # limit for size
106
+ end
107
+
68
108
  def self.format_txt(data)
69
109
  lines = []
70
110
 
71
111
  lines << "# MODELS"
72
112
  data[:models].each do |model|
73
113
  lines << "#{model[:name]} (table: #{model[:table]})"
74
- model[:columns].each { |col| lines << " - #{col[:name]}: #{col[:type]}" }
75
- model[:associations].each { |assoc| lines << " - #{assoc[:type]} :#{assoc[:name]}" }
114
+ lines << " Attributes:"
115
+ model[:columns].each { |col| lines << " - #{col[:name]}: #{col[:type]}" }
116
+ lines << " Associations:"
117
+ model[:associations].each { |assoc| lines << " - #{assoc[:type]} :#{assoc[:name]}" }
118
+ lines << " Validations:"
119
+ model[:validations].each { |v| lines << " - #{v[:type]} on #{v[:attributes].join(', ')}" }
120
+ lines << " Scopes:"
121
+ model[:scopes].each { |s| lines << " - #{s}" }
122
+ lines << " Indexes:"
123
+ model[:indexes].each { |i| lines << " - #{i}" }
124
+ lines << " Methods:"
125
+ model[:methods].each { |method| lines << " - #{method}" }
76
126
  lines << ""
77
127
  end
78
128
 
79
129
  lines << "# ROUTES"
80
130
  data[:routes].each do |route|
81
- lines << "#{route[:verb].to_s.ljust(6)} #{route[:path]} => #{route[:controller]}##{route[:action]}"
131
+ lines << "#{route[:verb].to_s.ljust(6)} #{route[:path]} => #{route[:controller]}##{route[:action]} (#{route[:name]})"
82
132
  end
83
133
 
134
+ lines << ""
84
135
  lines << "# CONTROLLERS"
85
136
  data[:controllers].each do |ctrl|
86
137
  lines << ctrl[:name]
87
- ctrl[:actions].each { |action| lines << " - #{action}" }
138
+ lines << " Filters:"
139
+ ctrl[:filters].each { |f| lines << " - #{f}" }
140
+ lines << " Actions:"
141
+ ctrl[:actions].each { |a| lines << " - #{a}" }
88
142
  lines << ""
89
143
  end
90
144
 
145
+ lines << "# JOBS"
146
+ data[:jobs].each do |job|
147
+ lines << "- #{job[:name]}"
148
+ end
149
+
150
+ lines << ""
151
+ lines << "# SERVICES"
152
+ data[:services].each do |service|
153
+ lines << "- #{service}"
154
+ end
155
+
156
+ lines << ""
157
+ lines << "# GEMS"
158
+ data[:gems].each do |gem|
159
+ lines << "- #{gem}"
160
+ end
161
+
91
162
  lines.join("\n")
92
163
  end
93
164
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AiSummary
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.7"
5
5
  end
data/rails_summary.txt CHANGED
@@ -1,13 +1,57 @@
1
1
  # MODELS
2
2
  User (table: users)
3
- - id: integer
4
- - email: string
5
- - created_at: datetime
6
- - updated_at: datetime
3
+ Attributes:
4
+ - id: integer
5
+ - email: string
6
+ - created_at: datetime
7
+ - updated_at: datetime
8
+ Associations:
9
+ Validations:
10
+ Scopes:
11
+ Indexes:
12
+ Methods:
7
13
 
8
14
  # ROUTES
9
- GET /up(.:format) => rails/health#show
10
- GET /service-worker(.:format) => rails/pwa#service_worker
11
- GET /manifest(.:format) => rails/pwa#manifest
15
+ GET /up(.:format) => rails/health#show (rails_health_check)
16
+ GET /service-worker(.:format) => rails/pwa#service_worker (pwa_service_worker)
17
+ GET /manifest(.:format) => rails/pwa#manifest (pwa_manifest)
18
+
12
19
  # CONTROLLERS
13
20
  ApplicationController
21
+ Filters:
22
+ - verify_authenticity_token
23
+ - verify_same_origin_request
24
+ - #<Proc:0x00000001207d5bb0 /Users/aj/.rbenv/versions/3.4.3/lib/ruby/gems/3.4.0/gems/actionpack-7.2.2.1/lib/action_controller/metal/allow_browser.rb:48 (lambda)>
25
+ Actions:
26
+
27
+ # JOBS
28
+ - ApplicationJob
29
+
30
+ # SERVICES
31
+
32
+ # GEMS
33
+ - actioncable
34
+ - actionmailbox
35
+ - actionmailer
36
+ - actionpack
37
+ - actiontext
38
+ - actionview
39
+ - activejob
40
+ - activemodel
41
+ - activerecord
42
+ - activestorage
43
+ - activesupport
44
+ - ai_summary
45
+ - base64
46
+ - benchmark
47
+ - bigdecimal
48
+ - builder
49
+ - bundler
50
+ - concurrent-ruby
51
+ - connection_pool
52
+ - crass
53
+ - date
54
+ - diff-lcs
55
+ - drb
56
+ - erb
57
+ - erubi
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ai_summary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anders Jonassen
@@ -123,7 +123,6 @@ extensions: []
123
123
  extra_rdoc_files: []
124
124
  files:
125
125
  - ".github/workflows/rubygems.yml"
126
- - ".idea/workspace.xml"
127
126
  - CHANGELOG.md
128
127
  - CODE_OF_CONDUCT.md
129
128
  - LICENSE.txt
data/.idea/workspace.xml DELETED
@@ -1,256 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="AutoImportSettings">
4
- <option name="autoReloadType" value="SELECTIVE" />
5
- </component>
6
- <component name="ChangeListManager">
7
- <list default="true" id="34d5e5cf-2804-4d8f-a534-bf8fd82f58ab" name="Changes" comment="Push new version v0.1.6">
8
- <change beforePath="$PROJECT_DIR$/Gemfile.lock" beforeDir="false" afterPath="$PROJECT_DIR$/Gemfile.lock" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/spec/dummy/Gemfile.lock" beforeDir="false" afterPath="$PROJECT_DIR$/spec/dummy/Gemfile.lock" afterDir="false" />
10
- <change beforePath="$PROJECT_DIR$/spec/dummy/log/test.log" beforeDir="false" afterPath="$PROJECT_DIR$/spec/dummy/log/test.log" afterDir="false" />
11
- </list>
12
- <option name="SHOW_DIALOG" value="false" />
13
- <option name="HIGHLIGHT_CONFLICTS" value="true" />
14
- <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
15
- <option name="LAST_RESOLUTION" value="IGNORE" />
16
- </component>
17
- <component name="Git.Settings">
18
- <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
19
- </component>
20
- <component name="GitHubPullRequestSearchHistory"><![CDATA[{
21
- "lastFilter": {
22
- "state": "OPEN",
23
- "assignee": "andersmarkc"
24
- }
25
- }]]></component>
26
- <component name="GithubPullRequestsUISettings"><![CDATA[{
27
- "selectedUrlAndAccountId": {
28
- "url": "git@github.com:andersmarkc/ai_summary.git",
29
- "accountId": "0bbf21cb-80eb-4c6d-aa6e-7f5156d440f3"
30
- }
31
- }]]></component>
32
- <component name="ProblemsViewState">
33
- <option name="selectedTabId" value="CurrentFile" />
34
- </component>
35
- <component name="ProjectColorInfo">{
36
- &quot;associatedIndex&quot;: 3
37
- }</component>
38
- <component name="ProjectId" id="30HOYw0CzPfd6UVL8dI2mGUJ0fS" />
39
- <component name="ProjectLevelVcsManager">
40
- <ConfirmationsSetting value="2" id="Add" />
41
- </component>
42
- <component name="ProjectViewState">
43
- <option name="hideEmptyMiddlePackages" value="true" />
44
- <option name="showLibraryContents" value="true" />
45
- </component>
46
- <component name="PropertiesComponent"><![CDATA[{
47
- "keyToString": {
48
- "ModuleVcsDetector.initialDetectionPerformed": "true",
49
- "RunOnceActivity.ShowReadmeOnStart": "true",
50
- "RunOnceActivity.git.unshallow": "true",
51
- "com.intellij.lang.ruby.rbs.tools.collection.workspace.sync.RbsCollectionUpdateProjectActivity#LAST_UPDATE_TIMESTAMP": "1753281912802",
52
- "git-widget-placeholder": "main",
53
- "last_opened_file_path": "/Users/aj/RubymineProjects/ai_summary/spec",
54
- "node.js.detected.package.eslint": "true",
55
- "node.js.detected.package.tslint": "true",
56
- "node.js.selected.package.eslint": "(autodetect)",
57
- "node.js.selected.package.tslint": "(autodetect)",
58
- "nodejs_package_manager_path": "npm",
59
- "ruby.structure.view.model.defaults.configured": "true",
60
- "vue.rearranger.settings.migration": "true"
61
- }
62
- }]]></component>
63
- <component name="RecentsManager">
64
- <key name="CopyFile.RECENT_KEYS">
65
- <recent name="$PROJECT_DIR$/spec" />
66
- <recent name="$PROJECT_DIR$" />
67
- </key>
68
- </component>
69
- <component name="SharedIndexes">
70
- <attachedChunks>
71
- <set>
72
- <option value="bundled-js-predefined-d6986cc7102b-b26f3e71634d-JavaScript-RM-251.26094.122" />
73
- </set>
74
- </attachedChunks>
75
- </component>
76
- <component name="SpringUtil" SPRING_PRE_LOADER_OPTION="true" RAKE_SPRING_PRE_LOADER_OPTION="true" RAILS_SPRING_PRE_LOADER_OPTION="true" />
77
- <component name="TaskManager">
78
- <task active="true" id="Default" summary="Default task">
79
- <changelist id="34d5e5cf-2804-4d8f-a534-bf8fd82f58ab" name="Changes" comment="" />
80
- <created>1753281082472</created>
81
- <option name="number" value="Default" />
82
- <option name="presentableId" value="Default" />
83
- <updated>1753281082472</updated>
84
- <workItem from="1753281097573" duration="753000" />
85
- <workItem from="1753281853845" duration="5984000" />
86
- </task>
87
- <task id="LOCAL-00001" summary="Add README and Gemspec">
88
- <option name="closed" value="true" />
89
- <created>1753281896707</created>
90
- <option name="number" value="00001" />
91
- <option name="presentableId" value="LOCAL-00001" />
92
- <option name="project" value="LOCAL" />
93
- <updated>1753281896707</updated>
94
- </task>
95
- <task id="LOCAL-00002" summary="Update Readme">
96
- <option name="closed" value="true" />
97
- <created>1753281955589</created>
98
- <option name="number" value="00002" />
99
- <option name="presentableId" value="LOCAL-00002" />
100
- <option name="project" value="LOCAL" />
101
- <updated>1753281955589</updated>
102
- </task>
103
- <task id="LOCAL-00003" summary="Test Github Action">
104
- <option name="closed" value="true" />
105
- <created>1753282623109</created>
106
- <option name="number" value="00003" />
107
- <option name="presentableId" value="LOCAL-00003" />
108
- <option name="project" value="LOCAL" />
109
- <updated>1753282623109</updated>
110
- </task>
111
- <task id="LOCAL-00004" summary="Test Github Action">
112
- <option name="closed" value="true" />
113
- <created>1753282692552</created>
114
- <option name="number" value="00004" />
115
- <option name="presentableId" value="LOCAL-00004" />
116
- <option name="project" value="LOCAL" />
117
- <updated>1753282692552</updated>
118
- </task>
119
- <task id="LOCAL-00005" summary="Test Github Action v2">
120
- <option name="closed" value="true" />
121
- <created>1753282869396</created>
122
- <option name="number" value="00005" />
123
- <option name="presentableId" value="LOCAL-00005" />
124
- <option name="project" value="LOCAL" />
125
- <updated>1753282869396</updated>
126
- </task>
127
- <task id="LOCAL-00006" summary="Test Github Action v3">
128
- <option name="closed" value="true" />
129
- <created>1753283147557</created>
130
- <option name="number" value="00006" />
131
- <option name="presentableId" value="LOCAL-00006" />
132
- <option name="project" value="LOCAL" />
133
- <updated>1753283147557</updated>
134
- </task>
135
- <task id="LOCAL-00007" summary="Add Dummy app and rspec">
136
- <option name="closed" value="true" />
137
- <created>1753285049613</created>
138
- <option name="number" value="00007" />
139
- <option name="presentableId" value="LOCAL-00007" />
140
- <option name="project" value="LOCAL" />
141
- <updated>1753285049613</updated>
142
- </task>
143
- <task id="LOCAL-00008" summary="Add Dummy app and rspec">
144
- <option name="closed" value="true" />
145
- <created>1753285065962</created>
146
- <option name="number" value="00008" />
147
- <option name="presentableId" value="LOCAL-00008" />
148
- <option name="project" value="LOCAL" />
149
- <updated>1753285065962</updated>
150
- </task>
151
- <task id="LOCAL-00009" summary="Add Dummy app and rspec v2">
152
- <option name="closed" value="true" />
153
- <created>1753285169489</created>
154
- <option name="number" value="00009" />
155
- <option name="presentableId" value="LOCAL-00009" />
156
- <option name="project" value="LOCAL" />
157
- <updated>1753285169489</updated>
158
- </task>
159
- <task id="LOCAL-00010" summary="Update README and Dependencies to allow rails 7 &lt;">
160
- <option name="closed" value="true" />
161
- <created>1753285608911</created>
162
- <option name="number" value="00010" />
163
- <option name="presentableId" value="LOCAL-00010" />
164
- <option name="project" value="LOCAL" />
165
- <updated>1753285608911</updated>
166
- </task>
167
- <task id="LOCAL-00011" summary="Hotfix Rails s Error">
168
- <option name="closed" value="true" />
169
- <created>1753285929263</created>
170
- <option name="number" value="00011" />
171
- <option name="presentableId" value="LOCAL-00011" />
172
- <option name="project" value="LOCAL" />
173
- <updated>1753285929263</updated>
174
- </task>
175
- <task id="LOCAL-00012" summary="Push new version">
176
- <option name="closed" value="true" />
177
- <created>1753285966210</created>
178
- <option name="number" value="00012" />
179
- <option name="presentableId" value="LOCAL-00012" />
180
- <option name="project" value="LOCAL" />
181
- <updated>1753285966210</updated>
182
- </task>
183
- <task id="LOCAL-00013" summary="Push new version v0.1.4">
184
- <option name="closed" value="true" />
185
- <created>1753286003268</created>
186
- <option name="number" value="00013" />
187
- <option name="presentableId" value="LOCAL-00013" />
188
- <option name="project" value="LOCAL" />
189
- <updated>1753286003268</updated>
190
- </task>
191
- <task id="LOCAL-00014" summary="Push new version v0.1.4">
192
- <option name="closed" value="true" />
193
- <created>1753286011189</created>
194
- <option name="number" value="00014" />
195
- <option name="presentableId" value="LOCAL-00014" />
196
- <option name="project" value="LOCAL" />
197
- <updated>1753286011189</updated>
198
- </task>
199
- <task id="LOCAL-00015" summary="Push new version v0.1.5">
200
- <option name="closed" value="true" />
201
- <created>1753286168440</created>
202
- <option name="number" value="00015" />
203
- <option name="presentableId" value="LOCAL-00015" />
204
- <option name="project" value="LOCAL" />
205
- <updated>1753286168440</updated>
206
- </task>
207
- <task id="LOCAL-00016" summary="Push new version v0.1.5">
208
- <option name="closed" value="true" />
209
- <created>1753286205597</created>
210
- <option name="number" value="00016" />
211
- <option name="presentableId" value="LOCAL-00016" />
212
- <option name="project" value="LOCAL" />
213
- <updated>1753286205597</updated>
214
- </task>
215
- <task id="LOCAL-00017" summary="Push new version v0.1.6">
216
- <option name="closed" value="true" />
217
- <created>1753294491369</created>
218
- <option name="number" value="00017" />
219
- <option name="presentableId" value="LOCAL-00017" />
220
- <option name="project" value="LOCAL" />
221
- <updated>1753294491369</updated>
222
- </task>
223
- <option name="localTasksCounter" value="18" />
224
- <servers />
225
- </component>
226
- <component name="TypeScriptGeneratedFilesManager">
227
- <option name="version" value="3" />
228
- </component>
229
- <component name="Vcs.Log.Tabs.Properties">
230
- <option name="TAB_STATES">
231
- <map>
232
- <entry key="MAIN">
233
- <value>
234
- <State />
235
- </value>
236
- </entry>
237
- </map>
238
- </option>
239
- </component>
240
- <component name="VcsManagerConfiguration">
241
- <MESSAGE value="Add README and Gemspec" />
242
- <MESSAGE value="Update Readme" />
243
- <MESSAGE value="Test Github Action" />
244
- <MESSAGE value="Test Github Action v2" />
245
- <MESSAGE value="Test Github Action v3" />
246
- <MESSAGE value="Add Dummy app and rspec" />
247
- <MESSAGE value="Add Dummy app and rspec v2" />
248
- <MESSAGE value="Update README and Dependencies to allow rails 7 &lt;" />
249
- <MESSAGE value="Hotfix Rails s Error" />
250
- <MESSAGE value="Push new version" />
251
- <MESSAGE value="Push new version v0.1.4" />
252
- <MESSAGE value="Push new version v0.1.5" />
253
- <MESSAGE value="Push new version v0.1.6" />
254
- <option name="LAST_COMMIT_MESSAGE" value="Push new version v0.1.6" />
255
- </component>
256
- </project>