module Roda::RodaPlugins::Controller
Constants
- DEFAULTS
- VERSION
Public Class Methods
configure(app, opts={}, &block)
click to toggle source
# File lib/roda/plugins/controller.rb, line 14 def self.configure(app, opts={}, &block) plugin_opts = (app.opts[:controller] ||= DEFAULTS) app.opts[:controller] = plugin_opts.merge(opts) app.register_controller(opts[:controllers]) if opts[:controllers] end
underscore(name, acronym_regex: /(?=a)b/)
click to toggle source
# File lib/roda/plugins/controller.rb, line 22 def self.underscore(name, acronym_regex: /(?=a)b/) return name unless name =~ /[A-Z-]|::/ name.gsub!(/Controller$/, "") word = name.to_s.gsub("::", "/") word.gsub!(/(?:(?<=([A-Za-z\d]))|\b)(#{acronym_regex})(?=\b|[^a-z])/) { "#{$1 && '_' }#{$2.downcase}" } word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2') word.gsub!(/([a-z\d])([A-Z])/, '\1_\2') word.tr!("-", "_") word.downcase! word end