pancake 0.1.13 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/README.textile +138 -62
  2. data/TODO +0 -9
  3. data/bin/pancake-gen +0 -2
  4. data/lib/pancake.rb +2 -0
  5. data/lib/pancake/console.rb +27 -0
  6. data/lib/pancake/generators/templates/micro/%stack_name%/{pancake.init.tt → pancake_init.rb.tt} +0 -0
  7. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%.rb.tt +5 -0
  8. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/config.rb.tt +23 -0
  9. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/development.rb.tt +18 -0
  10. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/production.rb.tt +19 -0
  11. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/staging.rb.tt +20 -0
  12. data/lib/pancake/generators/templates/{stack/%stack_name%/lib/%stack_name%/gems/cache → short/%stack_name%/lib/%stack_name%/models}/.empty_directory +0 -0
  13. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/script/console +15 -0
  14. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/tasks/%stack_name%.rake.tt +4 -0
  15. data/lib/pancake/generators/templates/short/%stack_name%/{pancake.init.tt → pancake_init.rb.tt} +0 -0
  16. data/lib/pancake/mime_types.rb +19 -19
  17. data/lib/pancake/mixins/request_helper.rb +7 -7
  18. data/lib/pancake/stack/bootloader.rb +1 -1
  19. data/lib/pancake/stacks/short/bootloaders.rb +0 -6
  20. data/lib/pancake/stacks/short/controller.rb +3 -2
  21. data/lib/pancake/stacks/short/stack.rb +7 -0
  22. data/spec/pancake/mixins/request_helper_spec.rb +1 -1
  23. data/spec/pancake/stacks/short/controller_spec.rb +35 -0
  24. data/spec/pancake/stacks/short/stack_spec.rb +45 -1
  25. metadata +12 -21
  26. data/lib/pancake/generators/stack_generator.rb +0 -17
  27. data/lib/pancake/generators/templates/stack/%stack_name%/LICENSE.tt +0 -20
  28. data/lib/pancake/generators/templates/stack/%stack_name%/README.tt +0 -7
  29. data/lib/pancake/generators/templates/stack/%stack_name%/Rakefile.tt +0 -53
  30. data/lib/pancake/generators/templates/stack/%stack_name%/VERSION.tt +0 -1
  31. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%.rb.tt +0 -4
  32. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config.ru.tt +0 -12
  33. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config/environments/development.rb.tt +0 -18
  34. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config/environments/production.rb.tt +0 -18
  35. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config/router.rb.tt +0 -6
  36. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/mounts/.empty_directory +0 -0
  37. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/public/.empty_directory +0 -0
  38. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/tmp/.empty_directory +0 -0
  39. data/lib/pancake/generators/templates/stack/%stack_name%/pancake.init.tt +0 -1
  40. data/lib/pancake/generators/templates/stack/%stack_name%/spec/%stack_name%_spec.rb.tt +0 -11
  41. data/lib/pancake/generators/templates/stack/%stack_name%/spec/spec_helper.rb.tt +0 -13
@@ -1,35 +1,76 @@
1
1
  h1. Pancake
2
2
 
3
- Pancake is primarily a tool for making rack applictions. "Rack":http://rack.github.com has come up in the Ruby web world as _the framework that matters_ when developing web applications. All the major frameworks use it, although so many application frameworks and middlewares are not really re-usable yet away from their specific implementations.
3
+ Modern web applications often need to be constructed by interacting with numerous independent service/applications, each optimised for a specific task. However, making each of these components interact and work cohesively is difficult and time consuming. Pancake helps you construct clean, modular, re-usable code to create your web masterpieces.
4
4
 
5
- Pancake addresses this by making Rack the fundamental building block of an applicaiton. It provides very useful helpers on top of rack that assist in constructing rack stacks as mixins. Almost all aspects of web frameworks are covered as Pancake mixins to help you create your own re-usable Rack Stacks without worrying about the really low level plumbing.
5
+ Pancake is primarily a tool for making rack applications. "Rack":http://rack.github.com has come up in the Ruby web world as _the framework that matters_ when developing web applications. All the major frameworks use it, although many of the application frameworks and their middlewares are not really re-usable away from their specific implementations yet.
6
+
7
+ Pancake addresses this by making Rack the fundamental building block of an application. It provides very useful helpers on top of Rack that assist in constructing Rack stacks as mixins. Almost all key aspects of web frameworks are covered in Pancake as mixins to help you create your own re-usable Rack Stacks without worrying about the really low level plumbing.
8
+
9
+ This README is a very high level overview only and doesn't really cover a great deal of Pancake unfortunately.
6
10
 
7
11
  h2. Stacks
8
12
 
9
- While Rack provides the framework for building web applications on. Pancake provides a stack as a place to start your application. A stack provides a whole bunch of behavior for you including a router and middleware stack. The stack will accept any valid rack application as the endpoint.
13
+ While Rack provides the low level framework for building web applications on, Pancake provides a stack as a place to start your application. A stack provides a whole bunch of behavior for you including a router and middleware stack. The stack will accept any valid Rack application as the endpoint. If you're not familiar with what makes a "valid Rack application":http://rack.rubyforge.org/doc/SPEC.html it basically comes down to an object that receives the "call" method with exactly one argument, the environment hash, and returns an array with exactly 3 elements. The status, headers and body.
10
14
 
11
15
  The general form of a stack is as follows:
12
-
13
- <pre>
16
+ <pre><code>
14
17
  -----------------------------------
15
18
  | |
16
19
  | Router |
17
20
  | |
18
- -----------------------------------
21
+ |---------------------------------|
19
22
  | Middleware |
20
- -----------------------------------
23
+ |---------------------------------|
21
24
  | Middleware |
22
- -----------------------------------
25
+ |---------------------------------|
23
26
  | Middleware |
24
- -----------------------------------
27
+ |---------------------------------|
25
28
  | |
26
29
  | Application |
27
30
  | Endpoint |
28
31
  | |
29
32
  -----------------------------------
33
+
34
+ </code></pre>
35
+
36
+ Each stack has its own router, middleware stack and application endpoint. Stacks can be combined and also put inside Pancake.
37
+
38
+ Combined into a Pancake application it may look like this:
39
+
40
+ <pre>
41
+
42
+ -------------------------------------------------------------------------------
43
+ | Pancake Middleware |
44
+ |-----------------------------------------------------------------------------|
45
+ | Pancake Middleware |
46
+ |-----------------------------------------------------------------------------|
47
+ | Pancake Middleware |
48
+ |-----------------------------------------------------------------------------|
49
+ | |
50
+ | ----------------------------------- ----------------------------------- |
51
+ | | | | | |
52
+ | | Router | | Router | |
53
+ | | | | | |
54
+ | |---------------------------------| |---------------------------------| |
55
+ | | Middleware | | Middleware | |
56
+ | |---------------------------------| |---------------------------------| |
57
+ | | Middleware | | Middleware | |
58
+ | |---------------------------------| |---------------------------------| |
59
+ | | Middleware | | Middleware | |
60
+ | |---------------------------------| |---------------------------------| |
61
+ | | | | | |
62
+ | | Application | | Application | |
63
+ | | Endpoint | | Endpoint | |
64
+ | | | | | |
65
+ | ----------------------------------- ----------------------------------- |
66
+ | |
67
+ -------------------------------------------------------------------------------
68
+
69
+
70
+
30
71
  </pre>
31
72
 
32
- Stacks are designed to work together. It's trivially easy to mount one stack inside another, or just mount any valid rack application inside your stack. They're also designed to be gemed and used as libraries as full applications.
73
+ Stacks are designed to work together. It's trivially easy to mount one stack inside another, or just mount any valid rack application inside your stack. They're also designed to be gemmed and used as libraries or full applications.
33
74
 
34
75
  <pre><code>MyStack.router do |r|
35
76
  r.mount(OtherStack, "/stack/mount/point")
@@ -39,11 +80,17 @@ A stack doesn't have to mount other stacks. Pancake stacks are full application
39
80
 
40
81
  Rails 3 is shipping with a pluggable router which can be the awesome "Usher":http://github.com/joshbuddy/usher router. If you use Usher in your Rails app, you'll be able to mount Pancake stacks directly. For now, you can mount them as Metals.
41
82
 
83
+ TODO: Demonstrate in a gist mounting pancake in a rails application
84
+
42
85
  All stacks are namespaced. Pancake makes heavy use of namespacing to help construct applications concisely.
43
86
 
44
- h2. Middleware Stacks
87
+ h2. Middleware In Stacks
88
+
89
+ Middleware is a specialised kind of rack application that can either respond to a request, or pass it on to another application.
45
90
 
46
- When you use Pancake middleware management, you can name middleware, set middleware to come before or after other middleware, or be included or not based on a stack type label. Lets have a look at that.
91
+ There's two main places for middleware in Pancake. Pancake level, and stack level. If you attach middleware to Pancake itself, all requests will pass through those middlewares. If you attach it at the stack level, only that stack will have that middleware active for its requests.
92
+
93
+ When you use Pancake middleware management, you can name middleware, set middleware to come before or after other middleware, or be included or not based on a stack type label(s). Lets have a look at that.
47
94
 
48
95
  <pre><code>class MyStack < Pancake::Stack
49
96
  stack(:session).use(Rack::Sessions::Cookie)
@@ -51,7 +98,7 @@ When you use Pancake middleware management, you can name middleware, set middlew
51
98
 
52
99
  stack(:bugz, :labels => [:development]).use(Rack::Bug)
53
100
 
54
- use(AlwaysUse)
101
+ use(AlwaysUseThisMiddleware)
55
102
  end
56
103
  </code></pre>
57
104
 
@@ -59,14 +106,16 @@ h2. What can a stack do
59
106
 
60
107
  Pancake provides a whole bunch of functionality as mixins.
61
108
 
62
- * BootLoaders
63
- * Router ("Usher":http://github.com/joshbuddy/usher Based. Please read.)
64
- * Sophisticated Middlware Configuration
65
- * Stack/Custom Configuration
66
- * Path Management with multiple roots (makes working with gem stacks transparent)
67
- * Content Type negotiation
68
- * Inheritable Templating System
69
- * Action Publish Control
109
+ * "BootLoaders":http://gist.github.com/229784
110
+ * "Router":http://gist.github.com/229785 ("Usher":http://github.com/joshbuddy/usher Based. Please read.)
111
+ * "Sophisticated Middlware Configuration":http://gist.github.com/229787
112
+ * "Stack/Custom Configuration":http://gist.github.com/229788
113
+ * "Path Management with multiple roots":http://gist.github.com/229789 (makes working with gem stacks transparent)
114
+ * "Content Type negotiation":http://gist.github.com/229790
115
+ * "Inheritable Stacks":http://gist.github.com/229792
116
+ * Inheritable Templating System (see below)
117
+
118
+ ("See here for examples":https://gist.github.com/542e8b01412fe4a682bc )
70
119
 
71
120
  Stacks bundle these behaviors together into a cohesive unit.
72
121
 
@@ -74,41 +123,53 @@ The true power of a Pancake stack is that it is fully inheritable.
74
123
 
75
124
  h2. Stack Inheritance
76
125
 
77
- When you inherit a stack, you're really inheriting a full applictation. All the features above are inherited along with the stack class.
126
+ When you inherit a stack, you're really inheriting a full application. All the features above are inherited along with the stack class.
78
127
 
79
128
  The easiest way to explain stack inheritance is perhaps with an example.
80
129
 
81
- Lets take the example of a basic application skeleton. Many times I've seen github repos with pre-generated applications with some basic functionality. This is then cloned as a start point for further app development. It's basically the same as a generator but a little more flexible. What if rather than generate an application skeleton with the basic functionality, you could construct a stack complete with router, default configuration, base templates, css and javascript, even mounted applications, and gem it up. Then when you want to start an application you just require the gem and inherit the stack class. This is what Pancake stacks provide.
130
+ Let's take the example of a basic application skeleton. Many times I've seen GitHub repos with pre-generated applications with some basic functionality. This is then cloned as a start point for further app development. It's basically the same as a generator but a little more flexible. What if rather than generate an application skeleton with the basic functionality, you could construct a stack complete with router, default configuration, base templates, css and javascript, even mounted applications, and gem it up? Then when you want to start an application you just require the gem and inherit the stack class. This is what Pancake stacks provide.
82
131
 
83
132
  <pre><code>class MyStack < SomeOtherStack; end # A full application </code></pre>
84
133
 
85
134
  h3. Namespacing
86
135
 
87
- Pancake makes heavy use of namespacing. Namespacing is a good idea to begin with, but inside mounted applications it's a must. By embracing the constraint of namespacing, there are many benefits. Unexpected name clashes of course being the big one.
136
+ Pancake makes heavy use of namespacing. Namespacing is a good idea to begin with, but inside mounted applications it's a must. Embracing the constraint of namespacing provides many benefits. Avoiding unexpected name clashes, of course, is the big one.
88
137
 
89
138
  h3. Inheritable Inner Classes
90
139
 
91
- There a fairly unique issue with inheriting a full application. Model data clashes.
140
+ There is a fairly unique issue when inheriting a full application. Model data may clash.
92
141
 
93
- Normally when you inherit a class in Ruby, when you reference an inner class in the child, it's actually a reference to the inner class in the parent. Lets see why this is a problem.
142
+ Normally when you inherit a class in Ruby, when you reference an inner class in the child, it's actually a reference to the inner class in the parent. Let's see why this is a problem:
94
143
 
95
- <pre><code>class AStack < Pancake::Stack
144
+ <pre><code>class BlogStack < Pancake::Stack
96
145
  class Post < ActiveRecord::Base
97
146
  # post code
98
147
  end
99
148
  end
100
149
 
101
- class AnotherStack < AStack; end
102
- class ADifferentOne < AStack; end
150
+ class BobsBlog < BlogStack; end
151
+ class RosesBlog < BlogStack; end
103
152
 
104
- AnotherStack::Post == ADifferentOne::Post == AStack::Post
153
+ BobsBlog::Post == RosesBlog::Post == BlogStack::Post
154
+ </code></pre>
155
+
156
+ Now, let's mount those inside some master stack:
157
+
158
+ <pre><code>class MyMasterStack < Pancake::Stack
159
+ router.mount(RobsBlog, "/rob")
160
+ router.mount(RosesBlog, "/rose")
161
+ end
105
162
  </code></pre>
106
163
 
107
- When we create posts in all 3 stacks, and then select the posts in AStack::Post.all we'll actually get the posts from all of the stacks. This referencing of inner classes is great for ruby efficiency, but not so good when we want to keep data seperate.
164
+ Now, Bob creates a post at his blog. Then goes away and creates the model (BlogStack::Post).
108
165
 
109
- Awesomely some of the ORM's include STI (Single Table Inheritance) that we can make use of. When using Pancake, we can set an inner class to inherit along with the parent. Lets have another look at that example:
166
+ Now someone visits Rose's blog. Because both Bob's and Rose's blogs _reference_ the same BlogStack::User model, Bob's post is fetched when we do a RosesBlog::Post.all
110
167
 
111
- <pre><code>class AStack < Pancake::Stack
168
+ It's efficient for Ruby to reference the parent class's inner class like this, but it's not always what we want.
169
+
170
+ Awesomely, some of the ORM's include STI (Single Table Inheritance) that we can make use of. When using Pancake, we can set an inner class to inherit along with the parent. Lets have another look at that example:
171
+
172
+ <pre><code>class BlogStack < Pancake::Stack
112
173
  inheritable_inner_classes :Post
113
174
 
114
175
  class Post < ActiveRecord::Base
@@ -116,39 +177,41 @@ Awesomely some of the ORM's include STI (Single Table Inheritance) that we can m
116
177
  end
117
178
  end
118
179
 
119
- class AnotherStack < AStack; end
120
- class ADifferentOne < AStack; end
180
+ class BobsBlog < BlogStack; end
181
+ class RosesBlog < BlogStack; end
121
182
 
122
- class FurtherDown < AnotherStack; end
183
+ class RosesOtherBlog < RosesBlog; end
123
184
 
124
185
  # Results in
125
186
 
126
- class AnotherStack::Post < AStack::Post; end
127
- class ADifferentOne::Post < AStack::Post; end
128
- class FurtherDown::Post < AnotherStack::Post; end
187
+ class BobsBlog::Post < BlogStack::Post; end
188
+ class RosesBlog::Post < BlogStack::Post; end
189
+ class RosesOtherBlog::Post < RosesBlog::Post; end
129
190
  </code></pre>
130
191
 
131
- In this case STI will be activated and each stack will use it's own sti version of the Post model, segregating the data between the stacks.
192
+ In this case STI will be activated and each stack will use its own STI version of the Post model, segregating the data between the stacks.
132
193
 
133
- If your Data layer doesn't support STI there are on_inherit hooks for all classes provided by Pancake to make any changes you need to.
194
+ If your Data layer doesn't support STI, there are on_inherit hooks for all classes provided by Pancake to make any changes you need to.
134
195
 
135
196
  h2. Mounting Applications
136
197
 
137
- You can mount any valid rack application inside pancake.
198
+ You can mount any valid Rack application inside Pancake. See "Rack Spec":http://rack.rubyforge.org/SPEC.html for guidance on what a valid Rack application is.
138
199
 
139
- Stacks look inside their root(s) for a "mounts" directory. Where they in-turn look for a sub-directory containing the file "pancake.init". When you want to mount an application you just include that file (and any support files) and the pancake stack will load it.
200
+ Stacks look inside their root(s) for a "mounts" directory. Where they in-turn look for a sub-directory containing the file "pancake_init.rb". When you want to mount an application you just include that file (and any support files) and the Pancake stack will load it.
140
201
 
141
202
  <pre><code>my_stack
142
203
  -- mounts
143
204
  -- another_app
144
- -- pancake.init # Called to initialize the mounted app
205
+ -- pancake_init.rb # Called to initialize the mounted app
145
206
  </code></pre>
146
207
 
208
+ Usually pancake_init.rb would just require the files for your application. But there's nothing stopping you from defining the entire application in there if you wanted.
209
+
147
210
  h2. Inheritable Templates
148
211
 
149
- Templates in Pancake are similar to Django templates. They define named content_blocks that can supply a default, but that can also be inherited from, and have their content either combined with some other content, or replaced. Unlike Django, templates are built on known templating languages like ERB and Haml. The templating system in Pancake is built on top of the great "Tilt":http://github.com/rtomayko/tilt project.
212
+ Templates in Pancake are similar to Django templates. They define named content_blocks that can supply a default, but that can also be inherited from, and have their content combined with some other content or replaced. Unlike Django, templates are built on known Ruby templating languages like ERB and Haml. The templating system in Pancake is built on top of the great "Tilt":http://github.com/rtomayko/tilt project.
150
213
 
151
- Really this is best demonstrated with an example:
214
+ This is best demonstrated with an example:
152
215
 
153
216
  <pre><code># base.html.erb
154
217
  <html>
@@ -188,13 +251,13 @@ Really this is best demonstrated with an example:
188
251
  <% end -%>
189
252
  </code></pre>
190
253
 
191
- When you @render :index@ in your stack, the index template will be activated, rendering the :base template but replacing the content_block, :content, with new data. And appending to the :navigation block.
254
+ When you <code>render :index</code> in your stack, the index template will be activated, rendering the :base template but replacing the content_block, :content, with new data. And appending to the :navigation block.
192
255
 
193
- Templates can be inherited as many times as required, so you could inherit from the :index template to build on it's content.
256
+ Templates can be inherited as many times as required, so you could inherit from the :index template to build on its content.
194
257
 
195
258
  When specifying which template to inherit from, you can dynamically specify which template you'd like to use if it makes sense to do so.
196
259
 
197
- At the moment only ERB, Erubis and Haml are supported with inheritable templates. Other tilt templates are able to be rendered, but not inherited.
260
+ At the moment only ERB, Erubis and Haml are supported with inheritable templates. Other Tilt templates are able to be rendered, but the inheritance features are not supported.
198
261
 
199
262
  h2. Short Stack
200
263
 
@@ -208,13 +271,13 @@ h3. Get Started
208
271
 
209
272
  h4. Install
210
273
 
211
- @$ gem install pancake@
274
+ <code>$ gem install pancake</code>
212
275
 
213
276
  h4. Generate your stack
214
277
 
215
278
  To start with a short stack use pancakes built in generator:
216
279
 
217
- @$ pancake-gen short my_stack@
280
+ <code>$ pancake-gen short my_stack</code>
218
281
 
219
282
  This will generate the basic stack for you. It's generated as a gem and based on Jeweler so you can gem it up super easy.
220
283
 
@@ -226,18 +289,18 @@ This will generate the basic stack for you. It's generated as a gem and based o
226
289
  provides :html, :xml, :json
227
290
 
228
291
  get "(/)", :_name => :home do
229
- v[:some_models] = SomeModel.all
292
+ vars[:some_models] = SomeModel.all
230
293
  render :welcome
231
294
  end
232
295
 
233
296
  get "/new", :_name => :new do
234
- v[:some_model] = SomeModel.new(params[:some_model])
297
+ vars[:some_model] = SomeModel.new(params[:some_model])
235
298
  render :new
236
299
  end
237
300
 
238
301
  post "(/)" do
239
- v[:some_model] = SomeModel.new(params[:some_model])
240
- if v[:some_model].save
302
+ vars[:some_model] = SomeModel.new(params[:some_model])
303
+ if vars[:some_model].save
241
304
  redirect url(:home)
242
305
  else
243
306
  render :new
@@ -246,27 +309,40 @@ This will generate the basic stack for you. It's generated as a gem and based o
246
309
  end
247
310
  </code></pre>
248
311
 
249
- h4. The Vault
312
+ h4. The Vars
250
313
 
251
- In the example above you can see the "v" method. This method accesses the vault. The vault is where per-request data may be stored for later use. In this case, the data is stored so that we can access it in the views.
314
+ In the example above you can see the "vars" method. This method provides a place for variables on a per-request basis for later use. In this case, the data is stored so that we can access it in the views. It could just as easily be used to share information between middlewares.
252
315
 
253
- This is a way to seperate the concerns of Controller and View. These contexts are supposed to be seperate. Breaking the encapsulation of instance variables does not need to be done in a short stack.
316
+ This is a way to separate the concerns of Controller and View. These contexts are supposed to be separate. Breaking the encapsulation of instance variables does not need to be done in a short stack.
254
317
 
255
318
  h4. Templates
256
319
 
257
320
  Templates are searched for in (stack root)/views/<name>.<format>.<template_engine> and rendered.
258
321
 
322
+ Templates are separate in each sub-application and will not clash. They're able to be looked up in parent stacks, however. Meaning, if you inherit from AStack, all of AStacks views will be used unless you replace them in the child stacks views directory.
323
+
259
324
  h2. URL generation
260
325
 
261
- When you're in a stack, you can call @url(named_url) to generate a url. This will generate the url, taking into account the mount path for the stack.
326
+ When you're in a stack, you can call @url(named_url)@ to generate a url. This will generate the url, taking into account the mount path for the stack.
262
327
 
263
328
  You can generate urls for other stacks also by using the global Pancake.url helper.
264
329
 
265
330
  <pre><code>Pancake.url(SomeStack, :named_url)</code></pre>
266
331
 
267
- There's a whole bunch more to Pancake than what I can go over here. But hopefully I've been able to provide a taste of what it is and why I think it's pretty awesome in the up-coming Rack landscape.
332
+ There's a whole bunch more to Pancake than I can go over here. But hopefully I've been able to provide a taste of what it is and why I think it's pretty awesome in the upcoming Rack landscape.
333
+
334
+ h2. Community
335
+
336
+ IRC: #pancake
337
+ "Google Group":http://groups.google.com.au/group/pancake-stacks
338
+ Twitter: #pancakestacks (hashtag)
339
+ "Blog / News":http://pancakestacks.wordpress.com
340
+
341
+ h2. Bugs
342
+
343
+ If you find a bug please report it at "our tails account":http://www.bugtails.com/projects/259/show.html, create a fork, and publish your fix in a topic branch.
268
344
 
269
- h4. Note on Patches/Pull Requests
345
+ h3. Note on Patches/Pull Requests
270
346
 
271
347
  * Fork the project.
272
348
  * Make your feature addition or bug fix.
@@ -275,7 +351,7 @@ h4. Note on Patches/Pull Requests
275
351
  * Commit, do not mess with rakefile, version, or history.
276
352
  (if you want to have your own version, that is fine but
277
353
  bump version in a commit by itself I can ignore when I pull)
278
- * h4. me a pull request. Bonus points for topic branches.
354
+ * send me a pull request. Bonus points for topic branches.
279
355
 
280
356
  h4. Copyright
281
357
 
data/TODO CHANGED
@@ -2,16 +2,7 @@ TODO:
2
2
 
3
3
  * Add default middleware to the short stack
4
4
  * Add a default base template and some default css to the short stack
5
- * Add a global logger
6
- * Add some view helpers
7
- ** url, link_to, form_for, form_field_helpers (can we use formtastic), v[:data]
8
- * Add partial support
9
- * Add sass support so that a stack can compile sass
10
- * Add a mechanism for a rake task to be called on the parent and all mounted stacks
11
- * Add a way to cache public files into the pancake roots public directory
12
5
  * Add bundler support
13
6
  * Do some introductory posts
14
7
  * optimise template lookup
15
- * Add caching / symlinking option for static middlware to prevent lookup
16
- * Add a rake task to copy / symlink all mounted apps public files into the public Pancake.public directory
17
8
 
@@ -6,8 +6,6 @@ require 'pancake/generators'
6
6
 
7
7
  # TODO update for pancake to have a version
8
8
  case ARGV.shift
9
- when "stack"
10
- Pancake::Generators::Stack.start
11
9
  when "short"
12
10
  Pancake::Generators::Short.start
13
11
  when "micro"
@@ -8,6 +8,7 @@ require 'extlib/object'
8
8
  require 'extlib/symbol'
9
9
  require 'extlib/blank'
10
10
  require "extlib/dictionary"
11
+ require 'extlib/mash'
11
12
  require 'extlib/logger'
12
13
  require 'usher'
13
14
  require 'usher/interface/rack_interface'
@@ -18,6 +19,7 @@ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
18
19
  module Pancake
19
20
  autoload :Logger, "pancake/logger"
20
21
  autoload :Constants, "pancake/constants"
22
+ autoload :Console, "pancake/console"
21
23
 
22
24
  module Stacks
23
25
  autoload :Short, "pancake/stacks/short"
@@ -0,0 +1,27 @@
1
+ require 'rack/test'
2
+ class Pancake::Console
3
+ attr_accessor :app
4
+ include Rack::Test::Methods
5
+
6
+ def initialize(stack)
7
+ @stack = stack
8
+ @app = stack.stackup(:master => true)
9
+ app = self
10
+ Object.__send__(:define_method, :stack){ app }
11
+ Pancake.handle_errors! true
12
+ Pancake.configuration.log_to_file = false
13
+
14
+ require 'irb'
15
+ require 'irb/completion'
16
+ if File.exists? ".irbrc"
17
+ ENV['IRBRC'] = ".irbrc"
18
+ end
19
+
20
+ catch(:IRB_EXIT) do
21
+ IRB.start
22
+ exit
23
+ end
24
+ end
25
+ end
26
+
27
+
@@ -1,5 +1,10 @@
1
1
  class <%= stack_name.camel_case %> < Pancake::Stacks::Short
2
2
  add_root(__FILE__, "<%= stack_name %>")
3
+
4
+ # Hook to use before we mount any applications
5
+ # before_mount_applications do
6
+ # end
7
+
3
8
  initialize_stack
4
9
  end
5
10
 
@@ -0,0 +1,23 @@
1
+ # Enter any global configuration for the stack in this file.
2
+
3
+ class <%= stack_name.camel_case %>
4
+ # include middleware for the development stack
5
+ # Labels can be set in the config/environments/<env>.rb file to limit
6
+ # middleware loading.
7
+ # stack(:middleware_name, :labels => [:development, :production]).use(MiddlewareClass)
8
+
9
+ class self::Configuration
10
+ # Add defaults to your stack configuration.
11
+ # This is scoped to this stack, and is inhertied into child stacks
12
+ #
13
+ # Fixed value defaults:
14
+ # default :var_name, :value, "A description of the variable"
15
+ #
16
+ # Lazy Defaults:
17
+ # default :var_name, lambda{ configuration_method }, "Some Description"
18
+
19
+ # Declare methods on your configuraiton
20
+ # def configuration_method; #stuff; end
21
+ end
22
+ end
23
+
@@ -0,0 +1,18 @@
1
+ Pancake.logger.info "Loading Development Environment"
2
+
3
+ # Set the middleware lables to load
4
+ Pancake.stack_labels = [:development]
5
+
6
+ # Pancake.handle_errors!(true) # uncomment to have the stack handle any errors that occur
7
+
8
+ class <%= stack_name.camel_case %>
9
+ # include middleware for the development stack
10
+ # stack(:middleware_name).use(MiddlewareClass)
11
+ end
12
+
13
+ # Add code to hooks. Default available hooks:
14
+ # :before_build_stack, :before_mount_applications, :after_initialize_application, :after_build_stack
15
+
16
+ # <%= stack_name.camel_case %>.before_build_stack do
17
+ # # stuff to do
18
+ # end
@@ -0,0 +1,19 @@
1
+ Pancake.logger.info "Loading Production Environment"
2
+
3
+ # Set the middleware lables to load
4
+ Pancake.stack_labels = [:production]
5
+
6
+ Pancake.handle_errors!(true) # uncomment to have the stack handle any errors that occur
7
+
8
+ class <%= stack_name.camel_case %>
9
+ # include middleware for the development stack
10
+ # stack(:middleware_name).use(MiddlewareClass)
11
+ end
12
+
13
+ # Add code to hooks. Default available hooks:
14
+ # :before_build_stack, :before_mount_applications, :after_initialize_application, :after_build_stack
15
+
16
+ # <%= stack_name.camel_case %>.before_build_stack do
17
+ # # stuff to do
18
+ # end
19
+
@@ -0,0 +1,20 @@
1
+ Pancake.logger.info "Loading Staging Environment"
2
+
3
+ # Set the middleware lables to load
4
+ Pancake.stack_labels = [:staging]
5
+
6
+ Pancake.handle_errors!(true) # uncomment to have the stack handle any errors that occur
7
+
8
+ class <%= stack_name.camel_case %>
9
+ # include middleware for the development stack
10
+ # stack(:middleware_name).use(MiddlewareClass)
11
+ end
12
+
13
+ # Add code to hooks. Default available hooks:
14
+ # :before_build_stack, :before_mount_applications, :after_initialize_application, :after_build_stack
15
+
16
+ # <%= stack_name.camel_case %>.before_build_stack do
17
+ # # stuff to do
18
+ # end
19
+
20
+
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['RACK_ENV'] ||= ARGV[0] || "development"
3
+
4
+ ARGV.clear # Don't pass args to irb
5
+
6
+ require 'rubygems'
7
+ require 'pancake'
8
+
9
+ Pancake.root = Pancake.get_root(__FILE__, "..")
10
+
11
+ # Load the <%= stack_class.camel_case %> stack
12
+ require File.join(Pancake.root, "..", "<%= stack_class %>")
13
+ Pancake::Console.new(<%= stack_class.camel_case %>)
14
+
15
+
@@ -0,0 +1,4 @@
1
+ namespace :<%= stack_name %> do
2
+ # Create your tasks here
3
+ end
4
+
@@ -15,7 +15,7 @@ module Pancake
15
15
  def self.types
16
16
  @types || reset! && @types
17
17
  end
18
-
18
+
19
19
  # Finds a Pancake::MimeTypes::Type object by the provided
20
20
  # extension
21
21
  #
@@ -35,9 +35,9 @@ module Pancake
35
35
  ext = ext.to_s
36
36
  types.detect{|t| t.extension == ext}
37
37
  end
38
-
38
+
39
39
  # Pancake manages mime types by grouping them together.
40
- #
40
+ #
41
41
  # @return [Set<Pancake::MimeTypes::Type>] - A enumerable of Type
42
42
  # objects associated with this group
43
43
  #
@@ -47,11 +47,11 @@ module Pancake
47
47
  def self.groups
48
48
  @groups || reset! && @groups
49
49
  end
50
-
50
+
51
51
  # Pancake::MimeTypes are managed by grouping them together.
52
52
  # Each group may consist of many mime types by extension
53
53
  # By Accessing a group that doesn't yet exist, the group is
54
- # created and initialized with the matching type wwith extension
54
+ # created and initialized with the matching type with extension
55
55
  # A group may have many mime type / accept types associated with
56
56
  # it
57
57
  #
@@ -71,7 +71,7 @@ module Pancake
71
71
  def self.group(name)
72
72
  groups[name.to_s]
73
73
  end
74
-
74
+
75
75
  # Creates a group of mime types. Any group of mimes can be
76
76
  # arbitrarily grouped under the specified name. The group is
77
77
  # initilized with the mime type whose extension matches the name,
@@ -92,7 +92,7 @@ module Pancake
92
92
  end
93
93
  group(name)
94
94
  end
95
-
95
+
96
96
  # Resets the Pancake::MimeType cache and re-creates the
97
97
  # Pancake::MimeTypes default types and groups
98
98
  # Good for use in specs
@@ -121,13 +121,13 @@ module Pancake
121
121
  e = $1
122
122
  t = type_by_extension(ext)
123
123
  if t
124
- t.type_strings << type
124
+ t.type_strings << type
125
125
  else
126
- t = Type.new(e, type)
126
+ t = Type.new(e, type)
127
127
  end
128
128
  end
129
129
  end
130
-
130
+
131
131
  # Used in specs to reset the default mime groups of
132
132
  # pancake::MimeTypes
133
133
  # @api private
@@ -139,7 +139,7 @@ module Pancake
139
139
 
140
140
  group_as(:svg, "svgz")
141
141
  end
142
-
142
+
143
143
  # Negotiates the type and group that the accept_type string
144
144
  # matches
145
145
  # @param type [String] the accept_type header string from the
@@ -162,16 +162,16 @@ module Pancake
162
162
  provided = provided.flatten
163
163
  key = [accepted_types, provided]
164
164
  return negotiated_accept_types[key] if negotiated_accept_types[key]
165
-
165
+
166
166
  accepted_type = nil
167
-
167
+
168
168
  if accepted_types.include?("*/*")
169
169
  name = provided.first
170
170
  accepted_type = group(name).first
171
171
  negotiated_accept_types[key] = [name, accepted_type.type_strings.first, accepted_type]
172
172
  return negotiated_accept_types[key]
173
173
  end
174
-
174
+
175
175
  # Check to see if any accepted types match
176
176
  accepted_types.each do |at|
177
177
  provided.flatten.each do |name|
@@ -190,7 +190,7 @@ module Pancake
190
190
  end
191
191
  nil
192
192
  end
193
-
193
+
194
194
  # Negotiates the content type based on the extension and the
195
195
  # provided groups to see if there is a match.
196
196
  #
@@ -223,7 +223,7 @@ module Pancake
223
223
  end
224
224
  result
225
225
  end # self.negotiate_by_extension
226
-
226
+
227
227
 
228
228
  # A basic type for mime types
229
229
  # Each type can have an extension and many type strings that
@@ -243,7 +243,7 @@ module Pancake
243
243
  MimeTypes.types << self
244
244
  end
245
245
  end
246
-
246
+
247
247
  private
248
248
  # Checks to see if a group matches an accept type string
249
249
  # @api private
@@ -252,13 +252,13 @@ module Pancake
252
252
  t.type_strings.include?(accept_type) || accept_type == "*/*"
253
253
  end
254
254
  end
255
-
255
+
256
256
  # Provides a cache for already negotiated types
257
257
  # @api private
258
258
  def self.negotiated_accept_types
259
259
  @negotiated_accept_types ||= {}
260
260
  end
261
-
261
+
262
262
  end # MimeTypes
263
263
  end # Pancake
264
264
 
@@ -3,20 +3,20 @@ module Pancake
3
3
  # Some helpers for requests that come in handy for applications that
4
4
  # are part of stacks
5
5
  module RequestHelper
6
- VAULT_KEY = 'pancake.request.vault'
6
+ VARS_KEY = 'pancake.request.vars'
7
7
 
8
- # A data vault that allows you to carry data accross middlewares, controller / views etc.
8
+ # A data area that allows you to carry data accross middlewares, controller / views etc.
9
9
  # Stores the data in session for the length of the request.
10
10
  #
11
11
  # @example
12
- # vault[:user] = @user
12
+ # vars[:user] = @user
13
13
  # v[:user] == vault[:user]
14
14
  # # This is now stored in the environment and is available later
15
- def vault
16
- env[VAULT_KEY] ||= {}
17
- env[VAULT_KEY]
15
+ def vars
16
+ env[VARS_KEY] ||= {}
17
+ env[VARS_KEY]
18
18
  end
19
- alias_method :v, :vault
19
+ alias_method :v, :vars
20
20
 
21
21
  # Generate a url for the current stacks router.
22
22
  #
@@ -19,7 +19,7 @@ Pancake::Stack::BootLoader.add(:load_mounted_inits, :level => :init) do
19
19
  def run!
20
20
  # Mount any stacks this stack may have in it.
21
21
  stack_class.roots.each do |root|
22
- Dir["#{root}/mounts/*/pancake.init"].each{|f| load f if File.exists?(f)}
22
+ Dir["#{root}/mounts/*/pancake_init.rb"].each{|f| load f if File.exists?(f)}
23
23
  end
24
24
  end
25
25
  end
@@ -1,9 +1,3 @@
1
- Pancake::Stacks::Short::BootLoader.add(:paths, :before => :load_mounted_inits ) do
2
- def run!
3
- stack_class::Controller.push_paths :views, ["app/views", "views"], "**/*"
4
- end
5
- end
6
-
7
1
  Pancake::Stacks::Short::BootLoader.add(:default_middlewares, :before => :load_mounted_inits) do
8
2
  def run!
9
3
  stack_class.stack(:static_files).use(Pancake::Middlewares::Static, stack_class)
@@ -12,6 +12,7 @@ module Pancake
12
12
 
13
13
  class_inheritable_accessor :_handle_exception
14
14
 
15
+ push_paths(:views, ["app/views", "views"], "**/*")
15
16
 
16
17
  DEFAULT_EXCEPTION_HANDLER = lambda do |error|
17
18
  "#{error.name}: #{error.description}"
@@ -64,14 +65,14 @@ module Pancake
64
65
  # set the response header
65
66
  headers["Content-Type"] = ct
66
67
 
67
- result = self.send(params['action'])
68
+ result = catch(:halt){ self.send(params['action']) }
68
69
  case result
69
70
  when Array
70
71
  result
71
72
  when Rack::Response
72
73
  result.finish
73
74
  else
74
- Rack::Response.new(self.send(params["action"]), status, headers).finish
75
+ Rack::Response.new((result || ""), status, headers).finish
75
76
  end
76
77
 
77
78
  rescue Errors::HttpError => e
@@ -3,6 +3,8 @@ module Pancake
3
3
  class Short < Pancake::Stack
4
4
  add_root(__FILE__, "default")
5
5
 
6
+ push_paths(:models,"models", "**/*.rb")
7
+
6
8
  def self.new_app_instance
7
9
  self::Controller
8
10
  end
@@ -32,6 +34,11 @@ module Pancake
32
34
  self::Controller.handle_exception(*args, &block)
33
35
  end
34
36
 
37
+ def self.helpers(&blk)
38
+ m = Module.new(&blk)
39
+ self::Controller.class_eval{ include m }
40
+ end
41
+
35
42
  # Gets a resource at a given path
36
43
  #
37
44
  # The block should finish with the final result of the action
@@ -30,7 +30,7 @@ describe Pancake::Mixins::RequestHelper do
30
30
  foo = FooBar.new
31
31
  foo.env = env
32
32
  foo.v[:data] = :some_data
33
- env[Pancake::Mixins::RequestHelper::VAULT_KEY][:data].should == :some_data
33
+ env[Pancake::Mixins::RequestHelper::VARS_KEY][:data].should == :some_data
34
34
  end
35
35
  end
36
36
  end
@@ -402,5 +402,40 @@ describe Pancake::Stacks::Short::Controller do
402
402
  result.body.should include("Not the default pancake")
403
403
  end
404
404
  end
405
+
406
+ describe "throwing" do
407
+ before do
408
+ ShortFoo.get("/plain_throw"){ throw :halt }
409
+ ShortFoo.get("/string_throw"){ throw :halt, "output string" }
410
+ ShortFoo.get("/status_n_throw"){ self.status = 204; throw :halt }
411
+ ShortFoo.get("/headers_n_throw") do
412
+ headers["some-header"] = Time.now.to_s
413
+ throw :halt
414
+ end
415
+ end
416
+
417
+ it "should handle a plain throw" do
418
+ result = get "/plain_throw"
419
+ result.should be_successful
420
+ result.body.should == ""
421
+ end
422
+
423
+ it "should handle a string throw" do
424
+ result = get "/string_throw"
425
+ result.should be_successful
426
+ result.body.should == "output string"
427
+ end
428
+
429
+ it "should handle a change in the status" do
430
+ result = get "/status_n_throw"
431
+ result.status.should == 204
432
+ result.body.should == ""
433
+ end
434
+
435
+ it "should handle a change in the headers" do
436
+ result = get "/headers_n_throw"
437
+ result.headers["some-header"].should_not be_blank
438
+ end
439
+ end
405
440
  end
406
441
  end
@@ -32,6 +32,8 @@ describe Pancake::Stacks::Short do
32
32
  render :inherited_from_base
33
33
  end
34
34
  end
35
+
36
+ @app = ShortFoo
35
37
  end
36
38
 
37
39
  after do
@@ -39,7 +41,7 @@ describe Pancake::Stacks::Short do
39
41
  end
40
42
 
41
43
  def app
42
- ShortFoo.stackup
44
+ @app.stackup
43
45
  end
44
46
 
45
47
  it "should go through the middleware to get to the actions" do
@@ -62,4 +64,46 @@ describe Pancake::Stacks::Short do
62
64
  last_response.should match(/inherited from base/)
63
65
  end
64
66
  end
67
+
68
+ describe "helpers" do
69
+ before do
70
+ $captures = []
71
+ class ::ShortFoo
72
+ helpers do
73
+ def in_helper?
74
+ $captures << :in_helper?
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ it "should allow me to setup a helper method in the stack" do
81
+ ShortFoo.get("/with_helper"){ in_helper?; "OK" }
82
+ result = get "/with_helper"
83
+ result.should be_successful
84
+ $captures.should include(:in_helper?)
85
+ end
86
+
87
+ it "should provide the helpers in child stacks" do
88
+ class ::OtherFoo < ShortFoo; end
89
+ OtherFoo.get("/helper_action"){ in_helper?; "OK" }
90
+ @app = OtherFoo
91
+ result = get "/helper_action"
92
+ result.should be_successful
93
+ $captures.should include(:in_helper?)
94
+ end
95
+
96
+ it "should let me mixin modules to the helpers" do
97
+ module ::OtherFoo
98
+ def other_helper
99
+ $captures << :other_helper
100
+ end
101
+ end
102
+ ShortFoo.helpers{ include OtherFoo }
103
+ ShortFoo.get("/foo"){ other_helper; "OK" }
104
+ result = get "/foo"
105
+ result.should be_successful
106
+ $captures.should include(:other_helper)
107
+ end
108
+ end
65
109
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pancake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Neighman
@@ -9,7 +9,7 @@ autorequire: pancake
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-09 00:00:00 +11:00
12
+ date: 2009-11-12 00:00:00 +11:00
13
13
  default_executable: pancake-gen
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -102,6 +102,7 @@ files:
102
102
  - lib/pancake.rb
103
103
  - lib/pancake/bootloaders.rb
104
104
  - lib/pancake/configuration.rb
105
+ - lib/pancake/console.rb
105
106
  - lib/pancake/constants.rb
106
107
  - lib/pancake/core_ext/class.rb
107
108
  - lib/pancake/core_ext/object.rb
@@ -113,12 +114,11 @@ files:
113
114
  - lib/pancake/generators/base.rb
114
115
  - lib/pancake/generators/micro_generator.rb
115
116
  - lib/pancake/generators/short_generator.rb
116
- - lib/pancake/generators/stack_generator.rb
117
117
  - lib/pancake/generators/templates/common/dotgitignore
118
118
  - lib/pancake/generators/templates/common/dothtaccess
119
119
  - lib/pancake/generators/templates/micro/%stack_name%/%stack_name%.rb.tt
120
120
  - lib/pancake/generators/templates/micro/%stack_name%/config.ru.tt
121
- - lib/pancake/generators/templates/micro/%stack_name%/pancake.init.tt
121
+ - lib/pancake/generators/templates/micro/%stack_name%/pancake_init.rb.tt
122
122
  - lib/pancake/generators/templates/micro/%stack_name%/public/.empty_directory
123
123
  - lib/pancake/generators/templates/micro/%stack_name%/tmp/.empty_directory
124
124
  - lib/pancake/generators/templates/micro/%stack_name%/views/root.html.haml
@@ -129,29 +129,20 @@ files:
129
129
  - lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%.rb.tt
130
130
  - lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/%stack_name%.rb.tt
131
131
  - lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config.ru.tt
132
+ - lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/config.rb.tt
133
+ - lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/development.rb.tt
134
+ - lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/production.rb.tt
135
+ - lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/staging.rb.tt
136
+ - lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/models/.empty_directory
132
137
  - lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/mounts/.empty_directory
133
138
  - lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/public/.empty_directory
139
+ - lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/script/console
140
+ - lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/tasks/%stack_name%.rake.tt
134
141
  - lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/tmp/.empty_directory
135
142
  - lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/views/root.html.haml
136
- - lib/pancake/generators/templates/short/%stack_name%/pancake.init.tt
143
+ - lib/pancake/generators/templates/short/%stack_name%/pancake_init.rb.tt
137
144
  - lib/pancake/generators/templates/short/%stack_name%/spec/%stack_name%_spec.rb.tt
138
145
  - lib/pancake/generators/templates/short/%stack_name%/spec/spec_helper.rb.tt
139
- - lib/pancake/generators/templates/stack/%stack_name%/LICENSE.tt
140
- - lib/pancake/generators/templates/stack/%stack_name%/README.tt
141
- - lib/pancake/generators/templates/stack/%stack_name%/Rakefile.tt
142
- - lib/pancake/generators/templates/stack/%stack_name%/VERSION.tt
143
- - lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%.rb.tt
144
- - lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config.ru.tt
145
- - lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config/environments/development.rb.tt
146
- - lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config/environments/production.rb.tt
147
- - lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config/router.rb.tt
148
- - lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/gems/cache/.empty_directory
149
- - lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/mounts/.empty_directory
150
- - lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/public/.empty_directory
151
- - lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/tmp/.empty_directory
152
- - lib/pancake/generators/templates/stack/%stack_name%/pancake.init.tt
153
- - lib/pancake/generators/templates/stack/%stack_name%/spec/%stack_name%_spec.rb.tt
154
- - lib/pancake/generators/templates/stack/%stack_name%/spec/spec_helper.rb.tt
155
146
  - lib/pancake/hooks/inheritable_inner_classes.rb
156
147
  - lib/pancake/hooks/on_inherit.rb
157
148
  - lib/pancake/logger.rb
@@ -1,17 +0,0 @@
1
- module Pancake
2
- module Generators
3
- class Stack < Base
4
- argument :stack_name, :banner => "Name of stack"
5
-
6
- desc "Generates a stack"
7
- def stack
8
- say "Creating The Stack For #{stack_name}"
9
- directory "stack/%stack_name%", stack_name
10
- template File.join(self.class.source_root, "common/dotgitignore"), "#{stack_name}/.gitignore"
11
- template File.join(self.class.source_root, "common/dothtaccess"), "#{stack_name}/lib/#{stack_name}/public/.htaccess"
12
- end
13
-
14
-
15
- end
16
- end
17
- end
@@ -1,20 +0,0 @@
1
- Copyright (c) <%= Date.today.year %> <YOUR NAME HERE>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,7 +0,0 @@
1
- = <%= stack_name %>
2
-
3
- Description goes here.
4
-
5
- == Copyright
6
-
7
- Copyright (c) <%= Date.today.year %> <YOUR NAME HERE>. See LICENSE for details.
@@ -1,53 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "<%= stack_name %>"
8
- gem.summary = %Q{TODO}
9
- gem.email = "TODO"
10
- gem.homepage = "TODO"
11
- gem.authors = ["TODO"]
12
- gem.add_dependency "pancake", ">=0.1.8"
13
- gem.files = FileList["[A-Z]*", "pancake.init", "{lib,spec,rails}/**/*"]
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
-
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
- end
20
-
21
- require File.join(File.dirname(__FILE__), "lib", "<%= stack_name %>")
22
- <%= stack_name.camel_case %>.load_rake_tasks!
23
-
24
- require 'spec/rake/spectask'
25
- Spec::Rake::SpecTask.new(:spec) do |spec|
26
- spec.libs << 'lib' << 'spec'
27
- spec.spec_files = FileList['spec/**/*_spec.rb']
28
- end
29
-
30
- Spec::Rake::SpecTask.new(:rcov) do |spec|
31
- spec.libs << 'lib' << 'spec'
32
- spec.pattern = 'spec/**/*_spec.rb'
33
- spec.rcov = true
34
- end
35
-
36
-
37
- task :default => :spec
38
-
39
- require 'rake/rdoctask'
40
- Rake::RDocTask.new do |rdoc|
41
- if File.exist?('VERSION.yml')
42
- config = YAML.load(File.read('VERSION.yml'))
43
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
44
- else
45
- version = ""
46
- end
47
-
48
- rdoc.rdoc_dir = 'rdoc'
49
- rdoc.title = "foo #{version}"
50
- rdoc.rdoc_files.include('README*')
51
- rdoc.rdoc_files.include('lib/**/*.rb')
52
- end
53
-
@@ -1,4 +0,0 @@
1
- class <%= stack_name.camel_case %> < Pancake::Stack
2
- add_root __FILE__, "<%= stack_name %>"
3
- initialize_stack
4
- end
@@ -1,12 +0,0 @@
1
- require 'rubygems'
2
-
3
- require 'pancake'
4
- require Pancake.get_root(__FILE__, "<%= stack_name %>")
5
-
6
- # get the application to run. The applicadtion in the Pancake.start block
7
- # is the master application. It will have all requests directed to it through the
8
- # pancake middleware
9
- # This should be a very minimal file, but should be used when any stand alone code needs to be included
10
- app = Pancake.start(:root => Pancake.get_root(__FILE__)){ <%= stack_name.camel_case %>.stackup(:master => true) }
11
-
12
- run app
@@ -1,18 +0,0 @@
1
- puts "Loading Development Environment"
2
-
3
- # Get Access
4
- Pancake.configuration.configs(<%= stack_name.camel_case %> ) do |config|
5
- config.foo = :foo
6
- end
7
-
8
- # Allows Pancake to selectively apply middlewares in the stack.
9
- # If a middleware is not declared with a specific stack label then it will always be loaded
10
- # You can specify Middleware to be active under particular stack labels only however.
11
- #
12
- # Example
13
- # <%= stack_name.camel_case %>.stack(:my_middlware, :labels => [:demo, :development]).use(Middlware, :with => :opts)
14
- #
15
- # This would only include the middleware Middlware in stacks with either the :demo, or :development label
16
- #
17
- # Setting The Pancake.stack_labels will use any relevant stacks
18
- Pancake.stack_labels = [:development]
@@ -1,18 +0,0 @@
1
- puts "Loading Production Environment"
2
-
3
- # Get Access
4
- Pancake.configuration.configs(<%= stack_name.camel_case %> ) do |config|
5
- # config.foo = :foo
6
- end
7
-
8
- # Allows Pancake to selectively apply middlewares in the stack.
9
- # If a middleware is not declared with a specific stack label then it will always be loaded
10
- # You can specify Middleware to be active under particular stack labels only however.
11
- #
12
- # Example
13
- # <%= stack_name.camel_case %>.stack(:my_middlware, :labels => [:demo, :development]).use(Middlware, :with => :opts)
14
- #
15
- # This would only include the middleware Middlware in stacks with either the :demo, or :development label
16
- #
17
- # Setting The Pancake.stack_labels will use any relevant stacks
18
- Pancake.stack_labels = [:production]
@@ -1,6 +0,0 @@
1
- <%= stack_name.camel_case %>.router do |r|
2
- # Add your routes here
3
- r.add("/") do |e|
4
- Rack::Response.new("Hi From <%= stack_name.camel_case %>").finish
5
- end
6
- end
@@ -1 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "lib", "<%= stack_name %>")
@@ -1,11 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "<%= stack_name %>" do
4
- def app
5
- <%= stack_name %>.stackup
6
- end
7
-
8
- it "fails" do
9
- fail "hey buddy, you should probably rename this file and start specing for real"
10
- end
11
- end
@@ -1,13 +0,0 @@
1
- require 'spec'
2
- require 'rack/test'
3
- require 'pancake'
4
-
5
-
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
- require '<%= stack_name -%>'
9
-
10
- Spec::Runner.configure do |config|
11
- config.include(Rack::Test::Methods)
12
- config.include(Pancake::Test::Matchers)
13
- end