pancake 0.2.0 → 0.3.0

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.
Files changed (108) hide show
  1. data/bin/pancake +96 -0
  2. data/lib/pancake.rb +5 -7
  3. data/lib/pancake/configuration.rb +2 -23
  4. data/lib/pancake/core_ext/object.rb +1 -1
  5. data/lib/pancake/defaults/configuration.rb +21 -1
  6. data/lib/pancake/generators.rb +0 -3
  7. data/lib/pancake/hooks/inheritable_inner_classes.rb +15 -2
  8. data/lib/pancake/master.rb +34 -1
  9. data/lib/pancake/mixins/render.rb +1 -2
  10. data/lib/pancake/mixins/stack_helper.rb +1 -1
  11. data/lib/pancake/router.rb +18 -63
  12. data/lib/pancake/stack/configuration.rb +3 -5
  13. data/lib/pancake/stack/router.rb +10 -33
  14. data/lib/pancake/stack/stack.rb +70 -50
  15. data/{spec/helpers → lib/pancake/test}/helpers.rb +3 -3
  16. data/lib/pancake/test/matchers.rb +20 -0
  17. data/lib/pancake/vendor/hashie/.document +5 -0
  18. data/lib/pancake/vendor/hashie/.gitignore +7 -0
  19. data/lib/pancake/vendor/hashie/Gemfile +11 -0
  20. data/lib/pancake/vendor/hashie/Gemfile.lock +25 -0
  21. data/lib/pancake/{generators/templates/short/%stack_name%/LICENSE.tt → vendor/hashie/LICENSE} +1 -1
  22. data/lib/pancake/vendor/hashie/README.rdoc +101 -0
  23. data/lib/pancake/{generators/templates/micro/%stack_name%/Rakefile.tt → vendor/hashie/Rakefile} +3 -13
  24. data/lib/pancake/vendor/hashie/VERSION +1 -0
  25. data/lib/pancake/vendor/hashie/hashie.gemspec +33 -0
  26. data/lib/pancake/vendor/hashie/lib/hashie.rb +5 -0
  27. data/lib/pancake/vendor/hashie/lib/hashie/clash.rb +86 -0
  28. data/lib/pancake/vendor/hashie/lib/hashie/dash.rb +108 -0
  29. data/lib/pancake/vendor/hashie/lib/hashie/hash.rb +22 -0
  30. data/lib/pancake/vendor/hashie/lib/hashie/hash_extensions.rb +49 -0
  31. data/lib/pancake/vendor/hashie/lib/hashie/mash.rb +148 -0
  32. data/lib/pancake/vendor/hashie/spec/hashie/clash_spec.rb +42 -0
  33. data/lib/pancake/vendor/hashie/spec/hashie/dash_spec.rb +103 -0
  34. data/lib/pancake/vendor/hashie/spec/hashie/hash_spec.rb +22 -0
  35. data/lib/pancake/vendor/hashie/spec/hashie/mash_spec.rb +135 -0
  36. data/lib/pancake/vendor/hashie/spec/spec.opts +2 -0
  37. data/lib/pancake/{generators/templates/short/%stack_name%/spec/spec_helper.rb.tt → vendor/hashie/spec/spec_helper.rb} +7 -7
  38. data/spec/pancake/configuration_spec.rb +1 -1
  39. data/spec/pancake/constants_spec.rb +1 -1
  40. data/spec/pancake/defaults/configuration_spec.rb +1 -1
  41. data/spec/pancake/hooks/on_inherit_spec.rb +13 -13
  42. data/spec/pancake/inheritance_spec.rb +22 -22
  43. data/spec/pancake/middleware_spec.rb +6 -5
  44. data/spec/pancake/middlewares/logger_spec.rb +1 -1
  45. data/spec/pancake/middlewares/static_spec.rb +1 -1
  46. data/spec/pancake/mime_types_spec.rb +1 -1
  47. data/spec/pancake/mixins/publish_spec.rb +24 -24
  48. data/spec/pancake/mixins/render/template_spec.rb +1 -1
  49. data/spec/pancake/mixins/render/view_context_spec.rb +1 -1
  50. data/spec/pancake/mixins/render_spec.rb +1 -1
  51. data/spec/pancake/mixins/request_helper_spec.rb +1 -1
  52. data/spec/pancake/mixins/stack_helper_spec.rb +3 -3
  53. data/spec/pancake/pancake_spec.rb +1 -1
  54. data/spec/pancake/paths_spec.rb +30 -30
  55. data/spec/pancake/stack/router_spec.rb +24 -62
  56. data/spec/pancake/stack/stack_configuration_spec.rb +1 -1
  57. data/spec/pancake/stack/stack_spec.rb +47 -4
  58. data/spec/spec_helper.rb +3 -3
  59. metadata +56 -128
  60. data/bin/pancake-gen +0 -30
  61. data/lib/pancake/bootloaders.rb +0 -187
  62. data/lib/pancake/generators/base.rb +0 -12
  63. data/lib/pancake/generators/micro_generator.rb +0 -17
  64. data/lib/pancake/generators/short_generator.rb +0 -18
  65. data/lib/pancake/generators/templates/common/dotgitignore +0 -22
  66. data/lib/pancake/generators/templates/common/dothtaccess +0 -17
  67. data/lib/pancake/generators/templates/micro/%stack_name%/%stack_name%.rb.tt +0 -8
  68. data/lib/pancake/generators/templates/micro/%stack_name%/config.ru.tt +0 -12
  69. data/lib/pancake/generators/templates/micro/%stack_name%/pancake_init.rb.tt +0 -1
  70. data/lib/pancake/generators/templates/micro/%stack_name%/public/.empty_directory +0 -0
  71. data/lib/pancake/generators/templates/micro/%stack_name%/tmp/.empty_directory +0 -0
  72. data/lib/pancake/generators/templates/micro/%stack_name%/views/root.html.haml +0 -1
  73. data/lib/pancake/generators/templates/short/%stack_name%/README.tt +0 -7
  74. data/lib/pancake/generators/templates/short/%stack_name%/Rakefile.tt +0 -56
  75. data/lib/pancake/generators/templates/short/%stack_name%/VERSION.tt +0 -1
  76. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%.rb.tt +0 -12
  77. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/%stack_name%.rb.tt +0 -6
  78. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config.ru.tt +0 -10
  79. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/config.rb.tt +0 -23
  80. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/development.rb.tt +0 -15
  81. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/production.rb.tt +0 -16
  82. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/staging.rb.tt +0 -17
  83. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/models/.empty_directory +0 -0
  84. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/mounts/.empty_directory +0 -0
  85. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/public/.empty_directory +0 -0
  86. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/tasks/%stack_name%.rake.tt +0 -4
  87. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/tmp/.empty_directory +0 -0
  88. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/views/root.html.haml +0 -2
  89. data/lib/pancake/generators/templates/short/%stack_name%/pancake_init.rb.tt +0 -1
  90. data/lib/pancake/generators/templates/short/%stack_name%/spec/%stack_name%_spec.rb.tt +0 -11
  91. data/lib/pancake/stack/app.rb +0 -10
  92. data/lib/pancake/stack/bootloader.rb +0 -114
  93. data/lib/pancake/stack/middleware.rb +0 -0
  94. data/lib/pancake/stacks/short.rb +0 -3
  95. data/lib/pancake/stacks/short/bootloaders.rb +0 -5
  96. data/lib/pancake/stacks/short/controller.rb +0 -184
  97. data/lib/pancake/stacks/short/default/views/base.html.haml +0 -5
  98. data/lib/pancake/stacks/short/default/views/error.html.haml +0 -12
  99. data/lib/pancake/stacks/short/stack.rb +0 -207
  100. data/spec/helpers/matchers.rb +0 -25
  101. data/spec/pancake/bootloaders_spec.rb +0 -119
  102. data/spec/pancake/stack/app_spec.rb +0 -28
  103. data/spec/pancake/stack/bootloader_spec.rb +0 -41
  104. data/spec/pancake/stack/middleware_spec.rb +0 -0
  105. data/spec/pancake/stacks/short/controller_spec.rb +0 -442
  106. data/spec/pancake/stacks/short/middlewares_spec.rb +0 -22
  107. data/spec/pancake/stacks/short/router_spec.rb +0 -150
  108. data/spec/pancake/stacks/short/stack_spec.rb +0 -117
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'thor/runner'
4
+ require 'pancake'
5
+
6
+ Pancake.load_generators!
7
+
8
+ class PancakeGeneratorRunner < Thor
9
+ map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
10
+
11
+ desc "list [SEARCH]", "List the available pancake tasks (--substring means .*SEARCH)"
12
+ method_options :substring => :boolean, :all => :boolean
13
+ def list(search="")
14
+ search = ".*#{search}" if options["substring"]
15
+ search = /^#{search}.*/i
16
+ group = options[:group] || "standard"
17
+
18
+ klasses = Thor::Base.subclasses.select do |k|
19
+ (options[:all] || k.group == group) && k.namespace =~ search
20
+ end
21
+
22
+ display_klasses(klasses)
23
+ end
24
+
25
+ def method_missing(meth, *args, &blk)
26
+ klass, task = Thor::Util.find_class_and_task_by_namespace(meth.to_s)
27
+ unless klass
28
+ puts "Could not find a generator for #{meth.to_s}"
29
+ exit(1)
30
+ end
31
+ args.unshift(task) if task
32
+ klass.start(args, :shell => self.shell)
33
+ end
34
+
35
+ private
36
+ def display_klasses(klasses)
37
+ klasses -= [Thor, Thor::Runner, Thor::Group]
38
+
39
+ # Remove subclasses
40
+ klasses.dup.each do |klass|
41
+ klasses -= Thor::Util.thor_classes_in(klass)
42
+ end
43
+
44
+ klasses.reject!{|k| k == self.class}
45
+
46
+ list = Hash.new { |h,k| h[k] = [] }
47
+ groups = klasses.select { |k| k.ancestors.include?(Thor::Group) }
48
+
49
+ # Get classes which inherit from Thor
50
+ (klasses - groups).each { |k| list[k.namespace] += k.printable_tasks(false) }
51
+
52
+ # Get classes which inherit from Thor::Base
53
+ groups.map! { |k| k.printable_tasks(false).first }
54
+ list["root"] = groups
55
+
56
+ # Order namespaces with default coming first
57
+ list = list.sort{ |a,b| a[0].sub(/^default/, '') <=> b[0].sub(/^default/, '') }
58
+ list.each { |n, tasks| display_tasks(n, tasks) unless tasks.empty? }
59
+ end
60
+
61
+ def display_tasks(namespace, list)
62
+ list.sort!{ |a,b| a[0] <=> b[0] }
63
+
64
+ say shell.set_color(namespace, :blue, true)
65
+ say "-" * namespace.size
66
+
67
+ print_table(list, :truncate => true)
68
+ say
69
+ end
70
+ end
71
+
72
+ PancakeGeneratorRunner.start
73
+
74
+ #case ARGV.shift
75
+ #when "short"
76
+ # Pancake::Generators::Short.start
77
+ #when "micro"
78
+ # Pancake::Generators::Micro.start
79
+ #when '-v', '--version'
80
+ # version_file = File.dirname(__FILE__) + '/../VERSION'
81
+ # if File.exists?(version_file) and version = File.read(version_file)
82
+ # puts "Pancake Version: #{version}"
83
+ # end
84
+ #else
85
+ # puts %{
86
+ # Usage: pancake-gen [type|options] /path/to/your/app
87
+ #
88
+ # Type can be:
89
+ # micro, short
90
+ #
91
+ # Options:
92
+ # -v, --version Show the version number and quit.
93
+ # -h, --help Show this help message and quit.
94
+ # }
95
+ #end
96
+
@@ -1,11 +1,12 @@
1
1
  require 'rubygems'
2
+ #require 'hashie'
3
+ $:.unshift File.join(File.dirname(__FILE__), "pancake", "vendor", "hashie", "lib")
2
4
  require 'hashie'
3
5
  require 'active_support/core_ext/class'
4
6
  require 'active_support/inflector'
5
7
  require 'active_support/core_ext/string/inflections'
6
8
  require 'active_support/ordered_hash'
7
- require 'usher'
8
- require 'usher/interface/rack'
9
+ require 'http_router'
9
10
  require 'tilt'
10
11
 
11
12
  module Pancake
@@ -14,16 +15,12 @@ module Pancake
14
15
  autoload :Console, "pancake/console"
15
16
  autoload :Paths, "pancake/paths"
16
17
  autoload :Configuration, "pancake/configuration"
17
- autoload :BootLoaderMixin, "pancake/bootloaders"
18
18
  autoload :MimeTypes, "pancake/mime_types"
19
19
  autoload :Middleware, "pancake/middleware"
20
20
  autoload :Router, "pancake/router"
21
21
  autoload :Errors, "pancake/errors"
22
22
  autoload :Stack, "pancake/stack/stack"
23
-
24
- module Stacks
25
- autoload :Short, "pancake/stacks/short"
26
- end
23
+ autoload :PancakeConfig, "pancake/defaults/configuration"
27
24
 
28
25
  module Hooks
29
26
  autoload :OnInherit, 'pancake/hooks/on_inherit'
@@ -45,6 +42,7 @@ module Pancake
45
42
 
46
43
  module Test
47
44
  autoload :Matchers, "pancake/test/matchers"
45
+ autoload :Helpers, "pancake/test/helpers"
48
46
  end
49
47
  end
50
48
 
@@ -71,7 +71,8 @@ module Pancake
71
71
  # If the default is a proc, do not cache it
72
72
  case defaults[name][:value]
73
73
  when Proc
74
- instance_eval(&defaults[name][:value])
74
+ p = defaults[name][:value]
75
+ instance_eval &p
75
76
  else
76
77
  val = defaults[name][:value]
77
78
  val = val.dup rescue val
@@ -111,28 +112,6 @@ module Pancake
111
112
  end # self
112
113
  end # Configuration
113
114
 
114
- class PancakeConfig < Configuration::Base
115
- def stacks(label = nil)
116
- @stacks ||= {}
117
- result = label.nil? ? @stacks : @stacks[label]
118
- yield result if block_given?
119
- result
120
- end
121
-
122
- def configs(label = nil)
123
- @configs ||= Hash.new do |h,k|
124
- if (k.is_a?(Class) || k.is_a?(Module)) && defined?(k::Configuration)
125
- h[k] = k::Configuration.new
126
- else
127
- nil
128
- end
129
- end
130
- result = label.nil? ? @configs : @configs[label]
131
- yield result if block_given?
132
- result
133
- end
134
- end
135
-
136
115
  def self.configuration
137
116
  @configuration ||= PancakeConfig.new
138
117
  end
@@ -19,4 +19,4 @@ unless Object.method_defined?(:instance_exec)
19
19
  ret
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -1,4 +1,4 @@
1
- class Pancake::PancakeConfig
1
+ class Pancake::PancakeConfig < Pancake::Configuration::Base
2
2
  default :log_path, Proc.new{ "log/pancake_#{Pancake.env}.log"}
3
3
  default :log_level, :info
4
4
  default :log_delimiter, " ~ "
@@ -20,4 +20,24 @@ class Pancake::PancakeConfig
20
20
  def reset_log_stream!
21
21
  values.delete(:log_stream)
22
22
  end
23
+
24
+ def stacks(label = nil)
25
+ @stacks ||= {}
26
+ result = label.nil? ? @stacks : @stacks[label]
27
+ yield result if block_given?
28
+ result
29
+ end
30
+
31
+ def configs(label = nil)
32
+ @configs ||= Hash.new do |h,k|
33
+ if (k.is_a?(Class) || k.is_a?(Module)) && defined?(k::Configuration)
34
+ h[k] = k::Configuration.new
35
+ else
36
+ nil
37
+ end
38
+ end
39
+ result = label.nil? ? @configs : @configs[label]
40
+ yield result if block_given?
41
+ result
42
+ end
23
43
  end
@@ -1,8 +1,5 @@
1
1
  require 'thor'
2
2
  require 'thor/group'
3
- require 'extlib'
4
-
5
- require File.join(File.dirname(__FILE__), "generators", "base.rb")
6
3
 
7
4
  Dir[File.join(File.dirname(__FILE__), "generators", "*.rb")].each do |f|
8
5
  require f unless f == 'base.rb'
@@ -3,8 +3,9 @@ module Pancake
3
3
  module InheritableInnerClasses
4
4
  def self.extended(base)
5
5
  base.class_eval do
6
- extlib_inheritable_reader :_inhertiable_inner_classes
7
- @_inhertiable_inner_classes = []
6
+ extlib_inheritable_reader :_inhertiable_inner_classes, :_before_inner_class_inheritance
7
+ @_inhertiable_inner_classes = []
8
+ @_before_inner_class_inheritance = []
8
9
  end
9
10
  end # extended
10
11
 
@@ -40,6 +41,16 @@ module Pancake
40
41
  _inhertiable_inner_classes
41
42
  end
42
43
 
44
+ # Runs any hooks before the inheritance of any inner classes
45
+ #
46
+ # @api public
47
+ # @since 0.3.0
48
+ # @author Daniel Neighman
49
+ def before_inner_class_inheritance(&blk)
50
+ _before_inner_class_inheritance << blk if blk
51
+ _before_inner_class_inheritance
52
+ end
53
+
43
54
  # The inherited hook that sets up inherited inner classes. Remember if you overwrite this method, you should
44
55
  # call super!
45
56
  #
@@ -49,11 +60,13 @@ module Pancake
49
60
  def inherited(base)
50
61
  super
51
62
  class_defs = inheritable_inner_classes.map do |klass|
63
+ _before_inner_class_inheritance.each{|blk| blk.call(base.superclass) }
52
64
  "class #{klass} < superclass::#{klass}; end\n"
53
65
  end
54
66
  base.class_eval(class_defs.join)
55
67
  end
56
68
 
69
+
57
70
  end # InheritableInnerClasses
58
71
  end # Hooks
59
72
  end # Pancake
@@ -7,6 +7,37 @@ module Pancake
7
7
 
8
8
  class << self
9
9
  attr_accessor :root
10
+ attr_accessor :_before_build, :_generators
11
+
12
+ def before_build(&blk)
13
+ unless _before_build
14
+ self._before_build = []
15
+ end
16
+ _before_build << blk if blk
17
+ _before_build
18
+ end
19
+
20
+ def generators(&blk)
21
+ self._generators = [] unless _generators
22
+ _generators << blk if blk
23
+ _generators
24
+ end
25
+
26
+ def load_generators!
27
+ return if @load_generators
28
+ @load_generators = true
29
+ generators.each{|b| b.call}
30
+
31
+ # load any global generator files
32
+ highest = {}
33
+ Gem.find_files("pancake/generators/global.rb").sort.reverse.each do |f|
34
+ f =~ /gems\/([^\/]+?)-(\d\.[^\/]+?)\/lib\/pancake/
35
+ highest[$1] ||= begin
36
+ require f
37
+ f
38
+ end
39
+ end
40
+ end
10
41
 
11
42
  # Start Pancake. This provides a full pancake stack to use inside a rack application
12
43
  #
@@ -18,11 +49,13 @@ module Pancake
18
49
  #
19
50
  # @api public
20
51
  # @author Daniel Neighman
21
- def start(opts, &block)
52
+ def start(opts = {}, &block)
22
53
  self.root = opts[:root] || Dir.pwd
23
54
 
24
55
  # Build Pancake
25
56
  the_app = instance_eval(&block)
57
+ before_build.each{|blk| blk.call}
58
+
26
59
  Pancake::Middleware.build(the_app, middlewares)
27
60
  end
28
61
 
@@ -70,7 +70,6 @@ module Pancake
70
70
  when Template
71
71
  name
72
72
  when String, Symbol
73
-
74
73
  template_names = case __template = _template_name_for(name, opts)
75
74
  when String, Symbol
76
75
  [__template]
@@ -176,7 +175,7 @@ module Pancake
176
175
  end
177
176
 
178
177
  def _partial_template_name_for(name, opts)
179
- "_#{_template_name_for(name, opts)}"
178
+ "_#{name}"
180
179
  end
181
180
  end # InstanceMethods
182
181
  end # Render
@@ -19,7 +19,7 @@ module Pancake
19
19
  end
20
20
  ns = name.split("::")
21
21
  until ns.empty? || klass
22
- r = ns.join("::").constantize
22
+ r = ActiveSupport::Inflector.constantize(ns.join("::"))
23
23
  if r.ancestors.include?(::Pancake::Stack)
24
24
  klass = r
25
25
  else
@@ -1,8 +1,4 @@
1
1
  module Pancake
2
- # Get the ability to mark this as a consuming route.
3
- class ::Usher::Route
4
- attr_accessor :consuming
5
- end
6
2
 
7
3
  # Generate a url for any pancake configuration that has a router
8
4
  #
@@ -28,17 +24,16 @@ module Pancake
28
24
  elsif app_name.respond_to?(:router)
29
25
  raise Pancake::Errors::UnknownRouter
30
26
  end
31
- the_router.base_url(opts)
27
+ the_router.respond_to?(:base_url) ?
28
+ the_router.base_url(opts) :
29
+ "/"
32
30
  end
33
31
 
34
- # The pancake router is a customized version of the Usher router.
35
- # Usher is a fast tree based router that can generate routes, have
36
- # nested routers, and even generate from nested routers.
37
- # @see http://github.com/joshbuddy/usher
32
+ # The pancake router uses a http_router router
33
+ # @see http://github.com/joshbuddy/http_router
38
34
  # @since 0.1.2
39
35
  # @author Daniel Neighman
40
- class Router < Usher::Interface::Rack
41
- attr_writer :router
36
+ class Router < HttpRouter
42
37
  attr_accessor :stack
43
38
 
44
39
  CONFIGURATION_KEY = "pancake.request.configuration".freeze
@@ -56,7 +51,6 @@ module Pancake
56
51
  @mounted_app, @mount_path = mounted_app, mount_path
57
52
  @stackup_with = opts.delete(:_stackup) || :stackup
58
53
  @args = opts.delete(:_args) || []
59
- @exact_match = opts.delete(:_exact_match) || false
60
54
  @options = opts
61
55
  end
62
56
 
@@ -71,14 +65,8 @@ module Pancake
71
65
  !!@mounted
72
66
  end
73
67
 
74
- def exact_match?
75
- !!@exact_match
76
- end
77
-
78
68
  def mount!(route)
79
69
  app = nil
80
- route.consuming = true
81
- route.match_partially! unless exact_match?
82
70
  if mounted_app.respond_to?(stackup_with)
83
71
  app = mounted_app.send(stackup_with, *args)
84
72
  else
@@ -86,10 +74,15 @@ module Pancake
86
74
  end
87
75
  route.to(app)
88
76
  route.name(@name) if @name
77
+ route.partial
89
78
  route
90
79
  end
91
80
  end
92
81
 
82
+ def dup
83
+ puts "Called DUP: #{caller.first}"
84
+ clone
85
+ end
93
86
 
94
87
  # Mounts an application in the router as a sub application in the
95
88
  # url space. This will route directly to the sub application and
@@ -114,37 +107,13 @@ module Pancake
114
107
  end
115
108
  end
116
109
 
117
- # Adds a route to the router.
118
- # @see Usher::Interface::Rack#add
119
- def add(path, opts = {}, &block)
120
- opts = cooerce_options_to_usher(opts)
121
- route = super(path, opts)
122
- if block_given?
123
- route.to(block)
124
- end
125
- route
126
- end
127
-
128
- # Generate a url
129
- def url(name_or_path, options = {})
130
- if Hash === name_or_path
131
- name = nil
132
- options = name_or_path
133
- else
134
- name = name_or_path
135
- end
136
- u = generate(name, options)
137
- return u if u.nil?
138
- u.empty? ? "/" : u
139
- end
140
-
141
110
  def base_url(opts = {})
142
- router.generator.generate_base_url(opts)
111
+ url_mount.nil? ? "/" : url_mount.url(opts)
143
112
  end
144
113
 
145
114
  def call(env)
146
115
  apply_layout = env[LAYOUT_KEY]
147
- env[LAYOUT_KEY] = true if stack.use_layout?
116
+ env[LAYOUT_KEY] = true if stack && stack.use_layout?
148
117
 
149
118
  orig_config = env[CONFIGURATION_KEY]
150
119
  orig_route = env[ROUTE_KEY]
@@ -158,29 +127,15 @@ module Pancake
158
127
  end
159
128
 
160
129
  private
161
- # Canoodles the options into a format that usher is happy to
162
- # accept. This is so that we can have a different interface from
163
- # the raw usher when we're first declaring the route.
164
- # @api private
165
- def cooerce_options_to_usher(opts)
166
- defaults = opts.delete(:_defaults)
167
- opts[:default_values] ||= {}
168
- opts[:default_values].merge!(defaults) if defaults
169
- opts
170
- end
171
-
172
- # Overwrites the method in Rack::Interface::Rack to mash
173
- # the usher.params into the rack request.params
174
- # @api private
175
- def after_match(request, response)
130
+ def process_params(env, response)
131
+ request = Rack::Request.new(env)
176
132
  request.env['rack.request.query_hash'] = request.params.dup
177
133
  super
178
- consume_path!(request, response) if !response.partial_match? && response.path.route.consuming
179
- request.params.merge!(request.env['usher.params']) unless request.env['usher.params'].empty?
180
134
 
181
- request.params.merge!(response.destination) if response.destination.is_a?(Hash)
135
+ env['router.params'] = Hashie::Mash.new(env['router.params']) if env['router.params'] && ! env['router.params'].empty?
182
136
 
183
- request.env[ROUTE_KEY] = response.path.route
137
+ request.env['rack.request.query_hash'].merge!(env['router.params']) unless env['router.params'].nil?
138
+ # make the request params a hashie mash
184
139
  request.env['rack.request.query_hash'] = Hashie::Mash.new(request.params) unless request.params.kind_of?(Hashie::Mash)
185
140
  end
186
141
  end