shorui 0.1.0 → 0.1.2

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: 16e910590d0e53daf7f5d7e3343606c304a43dc783972457cfb74cb4f2d102c2
4
- data.tar.gz: 23762704dd247083fd0c305432dbe1cd1b29a2f076c57cfeb0f4048c77902cab
3
+ metadata.gz: a3c941e85895f0a8379bb62aad976170ad43e5f2e95c05563c511b9fed356112
4
+ data.tar.gz: a49192b11854a42310fcdd2b8c4e159d092a2692c5864b0400e0a2fabd513c48
5
5
  SHA512:
6
- metadata.gz: 2c3be5a124997cfb0a1658cf0805bb3a2f97ee4dc4c1c31a974199b508949307888c9042722fa0616269d7a9169c24d10eba48915e885737ef5818791d32b645
7
- data.tar.gz: c403f6804f457c9a939e9298ed118d4a35d9908fe94c66a582d692ad10e92ed1dc059303039ab01803720c866f434e5b5a9773a705572f1f60695271600252a9
6
+ metadata.gz: da0a23b1b5ad8ddaa4db768598cb5fb97c9b71853b4f39a6df36f74aeba9b846762482ca9aac5966ae34bd86c895cb995abd8dfe8e0364a219217390a1859053
7
+ data.tar.gz: 1c0a0f66a997cf2dd18f3457ef4c4ee14d1b85523042130f47cd1bb18ca116a98ad14d83bbc29154b7a57d31496d58ce1c3d43cc300f14eb74f90ed5d1dc25c4
@@ -0,0 +1,29 @@
1
+ module Shorui
2
+ class Generator
3
+ def self.fetch_routes
4
+ Rails.application.routes.routes.map do |route|
5
+ {
6
+ path: route.path.spec.to_s,
7
+ verb: route.verb,
8
+ controller_action: route.defaults.slice(:controller, :action),
9
+ }
10
+ end.reject { |r| r[:path].include?('(.:format)') }
11
+ end
12
+
13
+ def self.generate_readme
14
+ routes = fetch_routes
15
+ content = "# API Documentation\n\n"
16
+
17
+ routes.each do |route|
18
+ controller = route[:controller_action][:controller]
19
+ action = route[:controller_action][:action]
20
+ content << "## #{controller.camelize}##{action}\n"
21
+ content << "- **Path:** `#{route[:path]}`\n"
22
+ content << "- **HTTP Verb:** `#{route[:verb]}`\n\n"
23
+ end
24
+
25
+ File.write('README.md', content)
26
+ puts "README.md successfully generated in #{Dir.pwd}!"
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shorui
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -0,0 +1,6 @@
1
+ namespace :shorui do
2
+ desc "Generate README.md from routes"
3
+ task generate: :environment do
4
+ Shorui::Generator.generate_readme
5
+ end
6
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shorui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - DevCurumin
@@ -24,7 +24,9 @@ files:
24
24
  - README.md
25
25
  - Rakefile
26
26
  - lib/shorui.rb
27
+ - lib/shorui/generator.rb
27
28
  - lib/shorui/version.rb
29
+ - lib/tasks/shorui.rake
28
30
  - sig/shorui.rbs
29
31
  homepage: https://github.com/thiagochirana/shorui
30
32
  licenses:
@@ -48,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
50
  - !ruby/object:Gem::Version
49
51
  version: '0'
50
52
  requirements: []
51
- rubygems_version: 3.5.16
53
+ rubygems_version: 3.2.33
52
54
  signing_key:
53
55
  specification_version: 4
54
56
  summary: A gem that helps you generate README.md from routes.rb