Sha256: 197cf7a8aab7be0d21d47532566ce5f886fadbf414cf911b734c822f624051f8
Contents?: true
Size: 878 Bytes
Versions: 2
Compression:
Stored size: 878 Bytes
Contents
module Shorui class Generator def self.fetch_routes Rails.application.routes.routes.map do |route| { path: route.path.spec.to_s, verb: route.verb, controller_action: route.defaults.slice(:controller, :action), } end.reject { |r| r[:path].include?('(.:format)') } end def self.generate_readme routes = fetch_routes content = "# API Documentation\n\n" routes.each do |route| controller = route[:controller_action][:controller] action = route[:controller_action][:action] content << "## #{controller.camelize}##{action}\n" content << "- **Path:** `#{route[:path]}`\n" content << "- **HTTP Verb:** `#{route[:verb]}`\n\n" end File.write('README.md', content) puts "README.md successfully generated in #{Dir.pwd}!" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shorui-0.1.2 | lib/shorui/generator.rb |
shorui-0.1.1 | lib/shorui/generator.rb |