module Staticpress::Route
Constants
- REGEX_STUBS
- RegexStub
Public Class Methods
extract_params(pattern, url_path)
click to toggle source
# File lib/staticpress/route.rb, line 20 def self.extract_params(pattern, url_path) if match = regex_for_pattern(pattern).match(url_path) hash_from_match_data match end end
regex_for_pattern(pattern)
click to toggle source
# File lib/staticpress/route.rb, line 26 def self.regex_for_pattern(pattern) regex = REGEX_STUBS.inject("^#{pattern}$") do |snip, (key, value)| snip.gsub /:#{key}/, value.regex.source end Regexp.new regex end
route_options(title)
click to toggle source
# File lib/staticpress/route.rb, line 34 def self.route_options(title) t = Time.now.utc { :date => "#{t.year}-#{'%02d' % t.month}-#{'%02d' % t.day}", :year => t.year, :month => '%02d' % t.month, :day => '%02d' % t.day, :title => title } end