ai_summary 0.1.1 → 0.1.3

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: e4c8f47c79f9814f4ce433a4294ee95ef2a87c15cf62a01001ee50d3c094cf4f
4
- data.tar.gz: b0244c27bac8ce73d4483f5fe41cd88d5e1ff538d6c5adfe18fbd49bf07d21e4
3
+ metadata.gz: b82ed0cd0cebb1054c4cd9c405c18b33ffcbf32d2fe11ff4baeb5d28d926e182
4
+ data.tar.gz: 8726c9e1b003b06eb9792965b90b17b920e899729bf98f7f7aead275f1723c6c
5
5
  SHA512:
6
- metadata.gz: 62eb2ddb523aa3bccc741f0505cf3c15a06abc99e704802ec782b73127c80cfdb6f7852f1bd8561204e9d1ec99d9a4fe7d343c9f112bf3b6cbdf23f937a6e43c
7
- data.tar.gz: 21539fb0afb6fd7de34a88893c0ec477c302046a9ddab420b0cb0592f065f987578d5c48104ad5341a044ac09c8d0700d2c9d57036230cdb3776a05fac9ed1e6
6
+ metadata.gz: cca919cb3fde7168c78d8a7c17b2849bbbc55c912a3f9057ef8eb96b6a48c6359f59c4b00763a7db15825f1ce072dec14874a7f4cc12abb398d0d5ca98d39806
7
+ data.tar.gz: bd1f900519a861904f77a98bd0a53cc8c91fe79c137113ca1902ef1a4eb8b71f65798f5c2b8d7c9ec56acab40853c4eaa9cb831516eb3f138247c68c309f5861
data/.idea/workspace.xml CHANGED
@@ -4,8 +4,11 @@
4
4
  <option name="autoReloadType" value="SELECTIVE" />
5
5
  </component>
6
6
  <component name="ChangeListManager">
7
- <list default="true" id="34d5e5cf-2804-4d8f-a534-bf8fd82f58ab" name="Changes" comment="Test Github Action v2">
8
- <change beforePath="$PROJECT_DIR$/.github/workflows/rubygems.yml" beforeDir="false" afterPath="$PROJECT_DIR$/.github/workflows/rubygems.yml" afterDir="false" />
7
+ <list default="true" id="34d5e5cf-2804-4d8f-a534-bf8fd82f58ab" name="Changes" comment="Add Dummy app and rspec v2">
8
+ <change beforePath="$PROJECT_DIR$/Gemfile.lock" beforeDir="false" afterPath="$PROJECT_DIR$/Gemfile.lock" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
10
+ <change beforePath="$PROJECT_DIR$/ai_summary.gemspec" beforeDir="false" afterPath="$PROJECT_DIR$/ai_summary.gemspec" afterDir="false" />
11
+ <change beforePath="$PROJECT_DIR$/lib/ai_summary/version.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/ai_summary/version.rb" afterDir="false" />
9
12
  </list>
10
13
  <option name="SHOW_DIALOG" value="false" />
11
14
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -34,6 +37,9 @@
34
37
  &quot;associatedIndex&quot;: 3
35
38
  }</component>
36
39
  <component name="ProjectId" id="30HOYw0CzPfd6UVL8dI2mGUJ0fS" />
40
+ <component name="ProjectLevelVcsManager">
41
+ <ConfirmationsSetting value="2" id="Add" />
42
+ </component>
37
43
  <component name="ProjectViewState">
38
44
  <option name="hideEmptyMiddlePackages" value="true" />
39
45
  <option name="showLibraryContents" value="true" />
@@ -45,7 +51,7 @@
45
51
  "RunOnceActivity.git.unshallow": "true",
46
52
  "com.intellij.lang.ruby.rbs.tools.collection.workspace.sync.RbsCollectionUpdateProjectActivity#LAST_UPDATE_TIMESTAMP": "1753281912802",
47
53
  "git-widget-placeholder": "main",
48
- "last_opened_file_path": "/Users/aj/RubymineProjects/ai_summary",
54
+ "last_opened_file_path": "/Users/aj/RubymineProjects/ai_summary/spec",
49
55
  "node.js.detected.package.eslint": "true",
50
56
  "node.js.detected.package.tslint": "true",
51
57
  "node.js.selected.package.eslint": "(autodetect)",
@@ -57,6 +63,7 @@
57
63
  }]]></component>
58
64
  <component name="RecentsManager">
59
65
  <key name="CopyFile.RECENT_KEYS">
66
+ <recent name="$PROJECT_DIR$/spec" />
60
67
  <recent name="$PROJECT_DIR$" />
61
68
  </key>
62
69
  </component>
@@ -76,7 +83,7 @@
76
83
  <option name="presentableId" value="Default" />
77
84
  <updated>1753281082472</updated>
78
85
  <workItem from="1753281097573" duration="753000" />
79
- <workItem from="1753281853845" duration="1287000" />
86
+ <workItem from="1753281853845" duration="3719000" />
80
87
  </task>
81
88
  <task id="LOCAL-00001" summary="Add README and Gemspec">
82
89
  <option name="closed" value="true" />
@@ -118,17 +125,63 @@
118
125
  <option name="project" value="LOCAL" />
119
126
  <updated>1753282869396</updated>
120
127
  </task>
121
- <option name="localTasksCounter" value="6" />
128
+ <task id="LOCAL-00006" summary="Test Github Action v3">
129
+ <option name="closed" value="true" />
130
+ <created>1753283147557</created>
131
+ <option name="number" value="00006" />
132
+ <option name="presentableId" value="LOCAL-00006" />
133
+ <option name="project" value="LOCAL" />
134
+ <updated>1753283147557</updated>
135
+ </task>
136
+ <task id="LOCAL-00007" summary="Add Dummy app and rspec">
137
+ <option name="closed" value="true" />
138
+ <created>1753285049613</created>
139
+ <option name="number" value="00007" />
140
+ <option name="presentableId" value="LOCAL-00007" />
141
+ <option name="project" value="LOCAL" />
142
+ <updated>1753285049613</updated>
143
+ </task>
144
+ <task id="LOCAL-00008" summary="Add Dummy app and rspec">
145
+ <option name="closed" value="true" />
146
+ <created>1753285065962</created>
147
+ <option name="number" value="00008" />
148
+ <option name="presentableId" value="LOCAL-00008" />
149
+ <option name="project" value="LOCAL" />
150
+ <updated>1753285065962</updated>
151
+ </task>
152
+ <task id="LOCAL-00009" summary="Add Dummy app and rspec v2">
153
+ <option name="closed" value="true" />
154
+ <created>1753285169489</created>
155
+ <option name="number" value="00009" />
156
+ <option name="presentableId" value="LOCAL-00009" />
157
+ <option name="project" value="LOCAL" />
158
+ <updated>1753285169489</updated>
159
+ </task>
160
+ <option name="localTasksCounter" value="10" />
122
161
  <servers />
123
162
  </component>
124
163
  <component name="TypeScriptGeneratedFilesManager">
125
164
  <option name="version" value="3" />
126
165
  </component>
166
+ <component name="Vcs.Log.Tabs.Properties">
167
+ <option name="TAB_STATES">
168
+ <map>
169
+ <entry key="MAIN">
170
+ <value>
171
+ <State />
172
+ </value>
173
+ </entry>
174
+ </map>
175
+ </option>
176
+ </component>
127
177
  <component name="VcsManagerConfiguration">
128
178
  <MESSAGE value="Add README and Gemspec" />
129
179
  <MESSAGE value="Update Readme" />
130
180
  <MESSAGE value="Test Github Action" />
131
181
  <MESSAGE value="Test Github Action v2" />
132
- <option name="LAST_COMMIT_MESSAGE" value="Test Github Action v2" />
182
+ <MESSAGE value="Test Github Action v3" />
183
+ <MESSAGE value="Add Dummy app and rspec" />
184
+ <MESSAGE value="Add Dummy app and rspec v2" />
185
+ <option name="LAST_COMMIT_MESSAGE" value="Add Dummy app and rspec v2" />
133
186
  </component>
134
187
  </project>
data/README.md CHANGED
@@ -28,10 +28,17 @@ Then run:
28
28
  bundle install
29
29
 
30
30
  ## 🚀 Usage
31
- Run via Rails runner:
31
+ # Rails Runner
32
32
  bundle exec rails runner 'AiSummary::SummaryGenerator.generate'
33
- Or inside a Rails console:
33
+
34
+ # Rails Console
34
35
  AiSummary::SummaryGenerator.generate
36
+
37
+ # Rake Task
38
+ bundle exec rake ai_summary:generate # Default output: rails_summary.txt
39
+ bundle exec rake ai_summary:generate[json] # Output: rails_summary.json
40
+ bundle exec rake ai_summary:generate[yaml] # Output: rails_summary.yaml
41
+
35
42
  By default, this will generate a rails_summary.txt file in your project root.
36
43
 
37
44
  ## 📂 Output Example
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "yaml"
5
+
6
+ module AiSummary
7
+ class SummaryGenerator
8
+ def self.generate(format: "txt")
9
+ # Ensure models are loaded
10
+ Dir[Rails.root.join("app/models/**/*.rb")].sort.each { |file| require_dependency file }
11
+
12
+ data = {
13
+ models: extract_models,
14
+ routes: extract_routes,
15
+ controllers: extract_controllers
16
+ }
17
+
18
+ case format.downcase
19
+ when "json"
20
+ File.write("rails_summary.json", JSON.pretty_generate(data))
21
+ puts "✅ AI Summary generated in rails_summary.json"
22
+ when "yaml", "yml"
23
+ File.write("rails_summary.yaml", data.to_yaml)
24
+ puts "✅ AI Summary generated in rails_summary.yaml"
25
+ else
26
+ File.write("rails_summary.txt", format_txt(data))
27
+ puts "✅ AI Summary generated in rails_summary.txt"
28
+ end
29
+ end
30
+
31
+ def self.extract_models
32
+ ActiveRecord::Base.descendants.reject { |m| m.abstract_class? || !m.table_exists? }.map do |model|
33
+ {
34
+ name: model.name,
35
+ table: model.table_name,
36
+ 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 } }
38
+ }
39
+ end
40
+ end
41
+
42
+ def self.extract_routes
43
+ Rails.application.routes.routes.map do |r|
44
+ verb = r.verb&.gsub(/\W/, "")
45
+ next unless r.defaults[:controller] && r.defaults[:action]
46
+
47
+ {
48
+ verb: verb,
49
+ path: r.path.spec.to_s,
50
+ controller: r.defaults[:controller],
51
+ action: r.defaults[:action]
52
+ }
53
+ end.compact
54
+ end
55
+
56
+ def self.extract_controllers
57
+ Dir.glob(Rails.root.join("app/controllers/**/*_controller.rb")).map do |file|
58
+ class_name = File.basename(file, ".rb").camelize
59
+ klass = class_name.safe_constantize
60
+ next unless klass.is_a?(Class)
61
+ {
62
+ name: klass.name,
63
+ actions: klass.public_instance_methods(false).map(&:to_s)
64
+ }
65
+ end.compact
66
+ end
67
+
68
+ def self.format_txt(data)
69
+ lines = []
70
+
71
+ lines << "# MODELS"
72
+ data[:models].each do |model|
73
+ 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]}" }
76
+ lines << ""
77
+ end
78
+
79
+ lines << "# ROUTES"
80
+ data[:routes].each do |route|
81
+ lines << "#{route[:verb].to_s.ljust(6)} #{route[:path]} => #{route[:controller]}##{route[:action]}"
82
+ end
83
+
84
+ lines << "# CONTROLLERS"
85
+ data[:controllers].each do |ctrl|
86
+ lines << ctrl[:name]
87
+ ctrl[:actions].each { |action| lines << " - #{action}" }
88
+ lines << ""
89
+ end
90
+
91
+ lines.join("\n")
92
+ end
93
+ end
94
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AiSummary
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/ai_summary.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "ai_summary/version"
4
+ require_relative "ai_summary/summary_generator"
5
+
6
+ # Auto-load Rake tasks
7
+ task_file = File.expand_path("../tasks/ai_summary.rake", __FILE__)
8
+ load task_file if defined?(Rake)
4
9
 
5
10
  module AiSummary
6
11
  class Error < StandardError; end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :ai_summary do
4
+ desc "Generate AI Summary of your Rails app. Optionally specify FORMAT=json or FORMAT=yaml"
5
+ task :generate, [:format] => :environment do |t, args|
6
+ format = args[:format]&.downcase || "txt"
7
+ AiSummary::SummaryGenerator.generate(format: format)
8
+ end
9
+ end
data/rails_summary.txt ADDED
@@ -0,0 +1,13 @@
1
+ # MODELS
2
+ User (table: users)
3
+ - id: integer
4
+ - email: string
5
+ - created_at: datetime
6
+ - updated_at: datetime
7
+
8
+ # ROUTES
9
+ GET /up(.:format) => rails/health#show
10
+ GET /service-worker(.:format) => rails/pwa#service_worker
11
+ GET /manifest(.:format) => rails/pwa#manifest
12
+ # CONTROLLERS
13
+ ApplicationController
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.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anders Jonassen
@@ -14,44 +14,62 @@ dependencies:
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '7.1'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '6.1'
22
+ version: '9.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '6.1'
29
+ version: '7.1'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '9.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: activerecord
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '7.1'
40
+ - - "<"
32
41
  - !ruby/object:Gem::Version
33
- version: '6.1'
42
+ version: '9.0'
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
- - - "~>"
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '7.1'
50
+ - - "<"
39
51
  - !ruby/object:Gem::Version
40
- version: '6.1'
52
+ version: '9.0'
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: activesupport
43
55
  requirement: !ruby/object:Gem::Requirement
44
56
  requirements:
45
- - - "~>"
57
+ - - ">="
46
58
  - !ruby/object:Gem::Version
47
- version: '6.1'
59
+ version: '7.1'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '9.0'
48
63
  type: :runtime
49
64
  prerelease: false
50
65
  version_requirements: !ruby/object:Gem::Requirement
51
66
  requirements:
52
- - - "~>"
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '7.1'
70
+ - - "<"
53
71
  - !ruby/object:Gem::Version
54
- version: '6.1'
72
+ version: '9.0'
55
73
  - !ruby/object:Gem::Dependency
56
74
  name: rspec
57
75
  requirement: !ruby/object:Gem::Requirement
@@ -112,7 +130,10 @@ files:
112
130
  - README.md
113
131
  - Rakefile
114
132
  - lib/ai_summary.rb
133
+ - lib/ai_summary/summary_generator.rb
115
134
  - lib/ai_summary/version.rb
135
+ - lib/tasks/ai_summary.rake
136
+ - rails_summary.txt
116
137
  - sig/ai_summary.rbs
117
138
  homepage: https://github.com/andersmarkc/ai_summary
118
139
  licenses: