rango 0.2 → 0.2.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (261) hide show
  1. data/.gitignore +9 -0
  2. data/.gitmodules +3 -0
  3. data/CHANGELOG +5 -0
  4. data/CONTRIBUTORS +1 -0
  5. data/Gemfile +20 -0
  6. data/LICENSE +1 -1
  7. data/README.textile +5 -4
  8. data/benchmarks/ab.rb +6 -0
  9. data/benchmarks/bm/boot.rb +20 -0
  10. data/{spec/rango/version_spec.rb → benchmarks/bm/callbacks.rb} +0 -0
  11. data/benchmarks/bm/request.rb +4 -0
  12. data/benchmarks/bm/routers.rb +22 -0
  13. data/benchmarks/bm/stack.rb +19 -0
  14. data/{spec/stubs/acqs/dir/lib.rb → benchmarks/bm/templates.rb} +0 -0
  15. data/benchmarks/helper.rb +7 -0
  16. data/benchmarks/stubs/merb-app/.gitignore +21 -0
  17. data/benchmarks/stubs/merb-app/Rakefile +35 -0
  18. data/benchmarks/stubs/merb-app/app/controllers/application.rb +4 -0
  19. data/benchmarks/stubs/merb-app/app/controllers/exceptions.rb +15 -0
  20. data/benchmarks/stubs/merb-app/app/helpers/global_helpers.rb +7 -0
  21. data/benchmarks/stubs/merb-app/app/models/user.rb +19 -0
  22. data/benchmarks/stubs/merb-app/app/views/exceptions/not_acceptable.html.erb +63 -0
  23. data/benchmarks/stubs/merb-app/app/views/exceptions/not_found.html.erb +47 -0
  24. data/benchmarks/stubs/merb-app/app/views/layout/application.html.erb +12 -0
  25. data/benchmarks/stubs/merb-app/autotest/discover.rb +4 -0
  26. data/benchmarks/stubs/merb-app/autotest/merb.rb +154 -0
  27. data/benchmarks/stubs/merb-app/autotest/merb_rspec.rb +167 -0
  28. data/benchmarks/stubs/merb-app/config/database.yml +33 -0
  29. data/benchmarks/stubs/merb-app/config/dependencies.rb +36 -0
  30. data/benchmarks/stubs/merb-app/config/environments/development.rb +17 -0
  31. data/benchmarks/stubs/merb-app/config/environments/production.rb +12 -0
  32. data/benchmarks/stubs/merb-app/config/environments/rake.rb +13 -0
  33. data/benchmarks/stubs/merb-app/config/environments/staging.rb +12 -0
  34. data/benchmarks/stubs/merb-app/config/environments/test.rb +14 -0
  35. data/benchmarks/stubs/merb-app/config/init.rb +26 -0
  36. data/benchmarks/stubs/merb-app/config/rack.rb +13 -0
  37. data/benchmarks/stubs/merb-app/config/router.rb +46 -0
  38. data/benchmarks/stubs/merb-app/doc/rdoc/generators/merb_generator.rb +1364 -0
  39. data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/api_grease.js +640 -0
  40. data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/index.html.erb +37 -0
  41. data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/merb.css +252 -0
  42. data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/merb.rb +353 -0
  43. data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/merb_doc_styles.css +492 -0
  44. data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/prototype.js +2515 -0
  45. data/benchmarks/stubs/merb-app/merb/merb-auth/setup.rb +46 -0
  46. data/benchmarks/stubs/merb-app/merb/merb-auth/strategies.rb +13 -0
  47. data/benchmarks/stubs/merb-app/merb/session/session.rb +11 -0
  48. data/benchmarks/stubs/merb-app/public/.htaccess +17 -0
  49. data/benchmarks/stubs/merb-app/public/favicon.ico +0 -0
  50. data/benchmarks/stubs/merb-app/public/images/merb.jpg +0 -0
  51. data/benchmarks/stubs/merb-app/public/javascripts/application.js +1 -0
  52. data/benchmarks/stubs/merb-app/public/javascripts/jquery.js +19 -0
  53. data/benchmarks/stubs/merb-app/public/merb.fcgi +22 -0
  54. data/benchmarks/stubs/merb-app/public/robots.txt +5 -0
  55. data/benchmarks/stubs/merb-app/public/stylesheets/master.css +119 -0
  56. data/{spec/stubs/acqs/dir/lib_spec.rb → benchmarks/stubs/merb-app/spec/spec.opts} +0 -0
  57. data/benchmarks/stubs/merb-app/spec/spec_helper.rb +27 -0
  58. data/benchmarks/stubs/merb-app/tasks/doc.thor +151 -0
  59. data/benchmarks/stubs/merb-app/tasks/merb.thor/app_script.rb +33 -0
  60. data/benchmarks/stubs/merb-app/tasks/merb.thor/common.rb +70 -0
  61. data/benchmarks/stubs/merb-app/tasks/merb.thor/gem_ext.rb +127 -0
  62. data/benchmarks/stubs/merb-app/tasks/merb.thor/main.thor +152 -0
  63. data/benchmarks/stubs/merb-app/tasks/merb.thor/ops.rb +95 -0
  64. data/benchmarks/stubs/merb-app/tasks/merb.thor/utils.rb +42 -0
  65. data/benchmarks/stubs/merb-core/.gitignore +21 -0
  66. data/benchmarks/stubs/merb-core/Rakefile +35 -0
  67. data/benchmarks/stubs/merb-core/app/controllers/application.rb +4 -0
  68. data/benchmarks/stubs/merb-core/app/controllers/exceptions.rb +15 -0
  69. data/benchmarks/stubs/merb-core/app/helpers/global_helpers.rb +7 -0
  70. data/benchmarks/stubs/merb-core/app/views/exceptions/not_acceptable.html.erb +63 -0
  71. data/benchmarks/stubs/merb-core/app/views/exceptions/not_found.html.erb +47 -0
  72. data/benchmarks/stubs/merb-core/app/views/layout/application.html.erb +12 -0
  73. data/benchmarks/stubs/merb-core/autotest/discover.rb +1 -0
  74. data/benchmarks/stubs/merb-core/autotest/merb.rb +151 -0
  75. data/benchmarks/stubs/merb-core/autotest/merb_rspec.rb +167 -0
  76. data/benchmarks/stubs/merb-core/config/environments/development.rb +17 -0
  77. data/benchmarks/stubs/merb-core/config/environments/production.rb +12 -0
  78. data/benchmarks/stubs/merb-core/config/environments/rake.rb +13 -0
  79. data/benchmarks/stubs/merb-core/config/environments/staging.rb +12 -0
  80. data/benchmarks/stubs/merb-core/config/environments/test.rb +14 -0
  81. data/benchmarks/stubs/merb-core/config/init.rb +27 -0
  82. data/benchmarks/stubs/merb-core/config/rack.rb +13 -0
  83. data/benchmarks/stubs/merb-core/config/router.rb +43 -0
  84. data/benchmarks/stubs/merb-core/doc/rdoc/generators/merb_generator.rb +1364 -0
  85. data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/api_grease.js +640 -0
  86. data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/index.html.erb +37 -0
  87. data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/merb.css +252 -0
  88. data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/merb.rb +353 -0
  89. data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/merb_doc_styles.css +492 -0
  90. data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/prototype.js +2515 -0
  91. data/benchmarks/stubs/merb-core/public/.htaccess +17 -0
  92. data/benchmarks/stubs/merb-core/public/favicon.ico +0 -0
  93. data/benchmarks/stubs/merb-core/public/images/merb.jpg +0 -0
  94. data/benchmarks/stubs/merb-core/public/javascripts/application.js +1 -0
  95. data/benchmarks/stubs/merb-core/public/merb.fcgi +22 -0
  96. data/benchmarks/stubs/merb-core/public/robots.txt +5 -0
  97. data/benchmarks/stubs/merb-core/public/stylesheets/master.css +119 -0
  98. data/{spec/stubs/acqs/lib.rb → benchmarks/stubs/merb-core/spec/spec.opts} +0 -0
  99. data/benchmarks/stubs/merb-core/spec/spec_helper.rb +22 -0
  100. data/benchmarks/stubs/merb-core/tasks/merb.thor/app_script.rb +33 -0
  101. data/benchmarks/stubs/merb-core/tasks/merb.thor/common.rb +70 -0
  102. data/benchmarks/stubs/merb-core/tasks/merb.thor/gem_ext.rb +127 -0
  103. data/benchmarks/stubs/merb-core/tasks/merb.thor/main.thor +152 -0
  104. data/benchmarks/stubs/merb-core/tasks/merb.thor/ops.rb +95 -0
  105. data/benchmarks/stubs/merb-core/tasks/merb.thor/utils.rb +42 -0
  106. data/benchmarks/stubs/merb-flat/.gitignore +21 -0
  107. data/benchmarks/stubs/merb-flat/README.txt +10 -0
  108. data/benchmarks/stubs/merb-flat/Rakefile +35 -0
  109. data/benchmarks/stubs/merb-flat/application.rb +17 -0
  110. data/benchmarks/stubs/merb-flat/config/framework.rb +9 -0
  111. data/benchmarks/stubs/merb-flat/config/init.rb +42 -0
  112. data/benchmarks/stubs/merb-flat/spec/spec_helper.rb +26 -0
  113. data/benchmarks/stubs/merb-flat/tasks/merb.thor/app_script.rb +33 -0
  114. data/benchmarks/stubs/merb-flat/tasks/merb.thor/common.rb +70 -0
  115. data/benchmarks/stubs/merb-flat/tasks/merb.thor/gem_ext.rb +127 -0
  116. data/benchmarks/stubs/merb-flat/tasks/merb.thor/main.thor +152 -0
  117. data/benchmarks/stubs/merb-flat/tasks/merb.thor/ops.rb +95 -0
  118. data/benchmarks/stubs/merb-flat/tasks/merb.thor/utils.rb +42 -0
  119. data/benchmarks/stubs/merb-flat/views/foo.html.erb +3 -0
  120. data/benchmarks/stubs/merb-very-flat/.gitignore +21 -0
  121. data/benchmarks/stubs/merb-very-flat/Rakefile +35 -0
  122. data/benchmarks/stubs/merb-very-flat/merb-very-flat.rb +61 -0
  123. data/benchmarks/stubs/merb-very-flat/spec/spec_helper.rb +26 -0
  124. data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/app_script.rb +33 -0
  125. data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/common.rb +70 -0
  126. data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/gem_ext.rb +127 -0
  127. data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/main.thor +152 -0
  128. data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/ops.rb +95 -0
  129. data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/utils.rb +42 -0
  130. data/benchmarks/stubs/rails/README +243 -0
  131. data/benchmarks/stubs/rails/Rakefile +10 -0
  132. data/benchmarks/stubs/rails/app/controllers/application_controller.rb +12 -0
  133. data/benchmarks/stubs/rails/app/helpers/application_helper.rb +5 -0
  134. data/benchmarks/stubs/rails/config/boot.rb +112 -0
  135. data/benchmarks/stubs/rails/config/database.yml +22 -0
  136. data/benchmarks/stubs/rails/config/environment.rb +43 -0
  137. data/benchmarks/stubs/rails/config/environments/development.rb +19 -0
  138. data/benchmarks/stubs/rails/config/environments/production.rb +30 -0
  139. data/benchmarks/stubs/rails/config/environments/test.rb +30 -0
  140. data/benchmarks/stubs/rails/config/initializers/backtrace_silencers.rb +9 -0
  141. data/benchmarks/stubs/rails/config/initializers/inflections.rb +12 -0
  142. data/benchmarks/stubs/rails/config/initializers/mime_types.rb +7 -0
  143. data/benchmarks/stubs/rails/config/initializers/new_rails_defaults.rb +21 -0
  144. data/benchmarks/stubs/rails/config/initializers/session_store.rb +17 -0
  145. data/benchmarks/stubs/rails/config/locales/en.yml +5 -0
  146. data/benchmarks/stubs/rails/config/routes.rb +45 -0
  147. data/benchmarks/stubs/rails/doc/README_FOR_APP +2 -0
  148. data/{spec/stubs/acqs/tasks.thor → benchmarks/stubs/rails/log/development.log} +0 -0
  149. data/{stubs/stack/content/TODO.txt → benchmarks/stubs/rails/log/production.log} +0 -0
  150. data/benchmarks/stubs/rails/log/server.log +0 -0
  151. data/benchmarks/stubs/rails/log/test.log +0 -0
  152. data/benchmarks/stubs/rails/public/404.html +30 -0
  153. data/benchmarks/stubs/rails/public/422.html +30 -0
  154. data/benchmarks/stubs/rails/public/500.html +30 -0
  155. data/benchmarks/stubs/rails/public/favicon.ico +0 -0
  156. data/benchmarks/stubs/rails/public/images/rails.png +0 -0
  157. data/benchmarks/stubs/rails/public/index.html +275 -0
  158. data/benchmarks/stubs/rails/public/javascripts/application.js +2 -0
  159. data/benchmarks/stubs/rails/public/javascripts/controls.js +963 -0
  160. data/benchmarks/stubs/rails/public/javascripts/dragdrop.js +973 -0
  161. data/benchmarks/stubs/rails/public/javascripts/effects.js +1128 -0
  162. data/benchmarks/stubs/rails/public/javascripts/prototype.js +4320 -0
  163. data/benchmarks/stubs/rails/public/robots.txt +5 -0
  164. data/benchmarks/stubs/rails/script/about +4 -0
  165. data/benchmarks/stubs/rails/script/console +3 -0
  166. data/benchmarks/stubs/rails/script/dbconsole +3 -0
  167. data/benchmarks/stubs/rails/script/destroy +3 -0
  168. data/benchmarks/stubs/rails/script/generate +3 -0
  169. data/benchmarks/stubs/rails/script/performance/benchmarker +3 -0
  170. data/benchmarks/stubs/rails/script/performance/profiler +3 -0
  171. data/benchmarks/stubs/rails/script/plugin +3 -0
  172. data/benchmarks/stubs/rails/script/runner +3 -0
  173. data/benchmarks/stubs/rails/script/server +3 -0
  174. data/benchmarks/stubs/rails/test/performance/browsing_test.rb +11 -0
  175. data/benchmarks/stubs/rails/test/test_helper.rb +40 -0
  176. data/benchmarks/stubs/ramaze.rb +0 -0
  177. data/benchmarks/stubs/sinatra.rb +11 -0
  178. data/bin/rango +2 -2
  179. data/deps.rip +7 -0
  180. data/deps.rip.rbe +7 -0
  181. data/gems/cache/abstract-1.0.0.gem +0 -0
  182. data/gems/cache/code-cleaner-0.1.gem +0 -0
  183. data/gems/cache/code-cleaner-0.2.gem +0 -0
  184. data/gems/cache/code-cleaner-0.3.gem +0 -0
  185. data/gems/cache/code-cleaner-0.4.gem +0 -0
  186. data/gems/cache/code-cleaner-0.5.gem +0 -0
  187. data/gems/cache/code-cleaner-0.6.gem +0 -0
  188. data/gems/cache/code-cleaner-0.7.gem +0 -0
  189. data/gems/cache/code-cleaner-0.8.1.gem +0 -0
  190. data/gems/cache/code-cleaner-0.8.gem +0 -0
  191. data/gems/cache/erubis-2.6.5.gem +0 -0
  192. data/gems/cache/extlib-0.9.14.gem +0 -0
  193. data/gems/cache/haml-2.2.16.gem +0 -0
  194. data/gems/cache/haml-2.2.17.gem +0 -0
  195. data/gems/cache/nake-0.0.2.gem +0 -0
  196. data/gems/cache/nake-0.0.3.gem +0 -0
  197. data/gems/cache/nake-0.0.5.gem +0 -0
  198. data/gems/cache/nake-0.0.6.gem +0 -0
  199. data/gems/cache/nake-0.0.8.gem +0 -0
  200. data/gems/cache/rack-1.0.1.gem +0 -0
  201. data/gems/cache/rack-1.1.0.gem +0 -0
  202. data/gems/cache/rspec-1.2.9.gem +0 -0
  203. data/gems/cache/rspec-1.3.0.gem +0 -0
  204. data/gems/cache/term-ansicolor-1.0.4.gem +0 -0
  205. data/gems/cache/tilt-0.4.gem +0 -0
  206. data/gems/cache/tilt-0.5.gem +0 -0
  207. data/lib/rango.rb +28 -28
  208. data/lib/rango/cli.rb +34 -0
  209. data/lib/rango/contrib/pagination/adapters/datamapper.rb +21 -17
  210. data/lib/rango/controller.rb +36 -4
  211. data/lib/rango/environments.rb +1 -15
  212. data/lib/rango/exceptions.rb +144 -86
  213. data/lib/rango/helpers.rb +10 -2
  214. data/lib/rango/mailer.rb +48 -0
  215. data/lib/rango/mixins/action_args.rb +5 -7
  216. data/lib/rango/mixins/filters.rb +18 -14
  217. data/lib/rango/mixins/message.rb +30 -24
  218. data/lib/rango/mixins/rendering.rb +54 -0
  219. data/lib/rango/orm/tasks/datamapper.nake +81 -0
  220. data/lib/rango/orm/tasks/sequel.nake +43 -0
  221. data/lib/rango/router/adapters/usher.rb +2 -1
  222. data/lib/rango/stacks/controller.rb +12 -0
  223. data/lib/rango/tasks/spec.nake +9 -0
  224. data/lib/rango/templates/exts/haml.rb +1 -1
  225. data/lib/rango/templates/exts/tilt.rb +10 -0
  226. data/lib/rango/templates/helpers.rb +29 -25
  227. data/lib/rango/templates/template.rb +7 -6
  228. data/rango.gemspec +52 -0
  229. data/rango.pre.gemspec +8 -0
  230. data/spec/rango/environments_spec.rb +1 -1
  231. data/spec/rango/exceptions_spec.rb +8 -7
  232. data/spec/rango/mixins/render_spec.rb +1 -1
  233. data/spec/rango/templates/template_spec.rb +1 -1
  234. data/stubs/stack/content/%name%.gemspec.rbt +52 -0
  235. data/stubs/stack/content/%name%.pre.gemspec.rbt +8 -0
  236. data/stubs/stack/content/CHANGELOG +0 -0
  237. data/stubs/stack/content/Gemfile.rbt +22 -11
  238. data/stubs/stack/content/README.textile.rbt +7 -0
  239. data/stubs/stack/content/config.ru.rbt +33 -62
  240. data/stubs/stack/content/deps.rip +0 -0
  241. data/stubs/stack/content/init.rb.rbt +14 -39
  242. data/stubs/stack/content/lib/%name%.rb.rbt +8 -0
  243. data/stubs/stack/content/lib/%name%/config.rb.rbt +0 -0
  244. data/stubs/stack/content/{environments.rb.rbt → lib/%name%/environments/development.rb.rbt} +5 -0
  245. data/stubs/stack/content/lib/%name%/environments/production.rb.rbt +0 -0
  246. data/stubs/stack/content/lib/%name%/environments/stagging.rb.rbt +0 -0
  247. data/stubs/stack/content/lib/%name%/initializers/middlewares.rb.rbt +5 -0
  248. data/stubs/stack/content/lib/%name%/initializers/urls.rb.rbt +24 -0
  249. data/stubs/stack/content/{models.rb.rbt → lib/%name%/models.rb.rbt} +7 -0
  250. data/stubs/stack/content/{views.rb.rbt → lib/%name%/views.rb.rbt} +2 -8
  251. data/stubs/stack/content/rackup.rb.rbt +41 -0
  252. data/stubs/stack/content/tasks.rb.rbt +52 -0
  253. data/stubs/stack/setup.rb +7 -1
  254. data/support/hooks/pre-commit +12 -0
  255. data/tasks.rb +49 -0
  256. metadata +250 -54
  257. data/Rakefile +0 -33
  258. data/lib/rango/rack/middlewares/email_obfuscator.rb +0 -25
  259. data/lib/rango/version.rb +0 -7
  260. data/stubs/stack/content/.rvmrc.rbt +0 -2
  261. data/stubs/stack/content/Rakefile.rbt +0 -12
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
4
+ require 'commands/about'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/console'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/dbconsole'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/destroy'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/generate'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/performance/benchmarker'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/performance/profiler'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/plugin'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/runner'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/server'
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test_helper'
4
+ require 'performance_test_help'
5
+
6
+ # Profiling results for each test method are written to tmp/performance.
7
+ class BrowsingTest < ActionController::PerformanceTest
8
+ def test_homepage
9
+ get '/'
10
+ end
11
+ end
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ ENV["RAILS_ENV"] = "test"
4
+ require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
5
+ require 'test_help'
6
+
7
+ class ActiveSupport::TestCase
8
+ # Transactional fixtures accelerate your tests by wrapping each test method
9
+ # in a transaction that's rolled back on completion. This ensures that the
10
+ # test database remains unchanged so your fixtures don't have to be reloaded
11
+ # between every test method. Fewer database queries means faster tests.
12
+ #
13
+ # Read Mike Clark's excellent walkthrough at
14
+ # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
15
+ #
16
+ # Every Active Record database supports transactions except MyISAM tables
17
+ # in MySQL. Turn off transactional fixtures in this case; however, if you
18
+ # don't care one way or the other, switching from MyISAM to InnoDB tables
19
+ # is recommended.
20
+ #
21
+ # The only drawback to using transactional fixtures is when you actually
22
+ # need to test transactions. Since your test is bracketed by a transaction,
23
+ # any transactions started in your code will be automatically rolled back.
24
+ self.use_transactional_fixtures = true
25
+
26
+ # Instantiated fixtures are slow, but give you @david where otherwise you
27
+ # would need people(:david). If you don't want to migrate your existing
28
+ # test cases which use the @david style and don't mind the speed hit (each
29
+ # instantiated fixtures translates to a database query per test method),
30
+ # then set this back to true.
31
+ self.use_instantiated_fixtures = false
32
+
33
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
34
+ #
35
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
36
+ # -- they do not yet inherit this setting
37
+ fixtures :all
38
+
39
+ # Add more helper methods to be used by all tests here...
40
+ end
File without changes
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ class BenchmarkApp < Sinatra::Mocked
4
+ get "/success" do
5
+ "Hello World"
6
+ end
7
+
8
+ get "/:foo/:bar" do
9
+ "Hello World"
10
+ end
11
+ end
data/bin/rango CHANGED
@@ -31,8 +31,8 @@ HELP
31
31
  end
32
32
 
33
33
  begin
34
- ARGV.shift || usage # create
35
- generator_name = ARGV.shift
34
+ ARGV.shift.eql?("create") || abort(usage)
35
+ generator_name = ARGV.shift || abort(usage)
36
36
  templater = SimpleTemplater.new(:rango)
37
37
  # This enables you to create custom generators for Rango
38
38
  load File.join(File.dirname(base), "..", "simple-templater.scope") # neccesary if we run rango locally and not from RubyGems
data/deps.rip ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rip install
2
+
3
+ # Syntax:
4
+ # repository [tag or commit to install]
5
+ git://github.com/botanicus/media-path.git 777914f46e195b7f570c0e7ab3582d69f99b33a7
6
+ git://github.com/botanicus/simple-templater.git 87e47a38da9ce4795e38d88131c535c198cda1f3
7
+ git://github.com/rack/rack.git 4cc6af9b4f0b633b076f27d3a76bf86ebf9fe64e
data/deps.rip.rbe ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rip install
2
+
3
+ # Syntax:
4
+ # repository [tag or commit to install]
5
+ git://github.com/botanicus/media-path.git #{commits["media-path"]}
6
+ git://github.com/botanicus/simple-templater.git #{commits["simple-templater"]}
7
+ git://github.com/rack/rack.git #{commits["rack"]}
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/lib/rango.rb CHANGED
@@ -4,12 +4,11 @@ if RUBY_VERSION < "1.9.1"
4
4
  raise "Rango requires at least Ruby 1.9.1. If you run JRuby, please ensure you used the --1.9 switch for JRuby command."
5
5
  end
6
6
 
7
- rango_lib = File.dirname(__FILE__)
8
- unless $:.include?(rango_lib) || $:.include?(File.expand_path(rango_lib))
9
- $:.unshift(rango_lib)
10
- end
7
+ require "rango/cli"
11
8
 
12
9
  module Rango
10
+ VERSION = "0.2.1"
11
+
13
12
  # all the helpers are in Rango::Helpers
14
13
  # so if you want to register your own, just
15
14
  # Rango::Helpers.send(:include, Pupu::Helpers)
@@ -31,6 +30,31 @@ module Rango
31
30
  @@media_root ||= File.join(self.root, "media")
32
31
  end
33
32
 
33
+ # Basic environment support. Use rango/environments.rb for more advanced behaviour.
34
+ #
35
+ # @since 0.0.1
36
+ # @return [String] Returns current environment name.
37
+ def self.environment
38
+ @@environment
39
+ rescue NameError
40
+ self.set_environment
41
+ end
42
+
43
+ def self.set_environment
44
+ @@environment ||= ENV["RACK_ENV"] || (RACK_ENV if defined?(RACK_ENV)) || "development"
45
+ end
46
+
47
+ def self.environment=(environment)
48
+ ENV["RACK_ENV"] = environment
49
+ @@environment = environment
50
+ const_set(:RACK_ENV, environment)
51
+ end
52
+
53
+ def self.environment?(environment)
54
+ self.environment.eql?(environment.to_s)
55
+ end
56
+
57
+ # logger
34
58
  def self.logger
35
59
  @@logger ||= begin
36
60
  require "simple-logger"
@@ -85,28 +109,4 @@ module Rango
85
109
  full_path = File.expand_path(File.join(File.dirname(__FILE__), relative_path))
86
110
  $LOADED_FEATURES.any? { |file| file == full_path }
87
111
  end
88
-
89
- # Start IRB interactive session
90
- # @since 0.0.1
91
- def self.interactive
92
- require "irb"
93
- require "rango/utils"
94
-
95
- begin
96
- require "racksh/boot"
97
- rescue LoadError
98
- Rango.logger.info("For more goodies install racksh gem")
99
- else
100
- Rango::Utils.load_rackup # so you can use Rango::Router.app etc
101
- end
102
-
103
- begin
104
- require "irb/completion"
105
- rescue LoadError
106
- # some people can have ruby compliled without readline
107
- end
108
-
109
- ARGV.delete("-i") # otherwise irb will read it
110
- IRB.start
111
- end
112
112
  end
data/lib/rango/cli.rb ADDED
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+
3
+ module Rango
4
+ def self.parse(args = ARGV)
5
+ # if you will run this script with -i argument, interactive session will begin
6
+ Rango.interactive if ARGV.delete("-i")
7
+ # so it can work as a runner
8
+ load ARGV.shift if File.exist?(ARGV.first)
9
+ end
10
+
11
+ # Start IRB interactive session
12
+ # @since 0.0.1
13
+ def self.interactive
14
+ require "irb"
15
+ require "rango/utils"
16
+
17
+ begin
18
+ require "racksh/boot"
19
+ rescue LoadError
20
+ Rango.logger.info("For more goodies install racksh gem")
21
+ else
22
+ Rango::Utils.load_rackup # so you can use Rango::Router.app etc
23
+ end
24
+
25
+ begin
26
+ require "irb/completion"
27
+ rescue LoadError
28
+ # some people can have ruby compliled without readline
29
+ end
30
+
31
+ ARGV.delete("-i") # otherwise irb will read it
32
+ IRB.start
33
+ end
34
+ end
@@ -2,24 +2,28 @@
2
2
 
3
3
  require "dm-aggregates"
4
4
 
5
- module DataMapper
6
- module Model
7
- # @since 0.0.2
8
- # @example Post.paginate(page, order: [:updated_at.desc])
9
- def paginate(pagenum = 1, options = Hash.new)
10
- pagenum = 1 if pagenum.nil?
11
- page = self.page(pagenum.to_i, options)
12
- Page.current = page
13
- offset = page.number(:db) * page.per_page
14
- self.all(options.merge!(offset: offset, limit: page.per_page))
15
- end
5
+ module Rango
6
+ module Pagination
7
+ module DataMapper
8
+ module Model
9
+ # @since 0.0.2
10
+ # @example Post.paginate(page, order: [:updated_at.desc])
11
+ def paginate(pagenum = 1, options = Hash.new)
12
+ pagenum = 1 if pagenum.nil?
13
+ page = self.page(pagenum.to_i, options)
14
+ Page.current = page
15
+ offset = page.number(:db) * page.per_page
16
+ self.all(options.merge!(offset: offset, limit: page.per_page))
17
+ end
16
18
 
17
- # @since 0.0.2
18
- def page(current, options = Hash.new)
19
- per_page = defined?(PER_PAGE) ? PER_PAGE : 10
20
- # the count options are very important
21
- # Product.count vs. Product.count(online: true)
22
- Page.new(current: current, count: self.count(options), per_page: per_page)
19
+ # @since 0.0.2
20
+ def page(current, options = Hash.new)
21
+ per_page = defined?(PER_PAGE) ? PER_PAGE : 10
22
+ # the count options are very important
23
+ # Product.count vs. Product.count(online: true)
24
+ Page.new(current: current, count: self.count(options), per_page: per_page)
25
+ end
26
+ end
23
27
  end
24
28
  end
25
29
  end
@@ -10,6 +10,7 @@ require "rango/rack/request"
10
10
  module Rango
11
11
  class Controller
12
12
  include Rango::UrlHelper
13
+ include Rango::Exceptions
13
14
  extend Forwardable
14
15
  # for routers
15
16
  def self.dispatcher(action)
@@ -52,6 +53,8 @@ module Rango
52
53
  self.run_action
53
54
  #self.response.finish # do we need this?
54
55
  [response.status, response.headers, [response.body]] # this way we got real body rather than response object
56
+ rescue Redirection => redirection
57
+ redirection.to_response
55
58
  rescue HttpError => exception
56
59
  self.rescue_http_error(exception)
57
60
  end
@@ -65,11 +68,27 @@ module Rango
65
68
  def_delegators :response, :status, :status=
66
69
  def_delegators :response, :headers, :headers=
67
70
 
71
+ # absolute_uri "http://google.com" => "http://google.com"
72
+ # absolute_uri "/products" => "http://localhost:4000/products"
73
+ def absolute_uri(path)
74
+ if path.match(/^https?:\/{2}/)
75
+ path
76
+ else
77
+ (request.base_url.chomp("/") + path).chomp("/")
78
+ end
79
+ end
80
+
68
81
  # @since 0.0.2
82
+ # @version 0.2.1
69
83
  # @return [String] Escaped URL (which is RFC recommendation)
70
- def redirect(url, options = Hash.new)
71
- self.status = 302
72
- self.headers["Location"] = URI.escape(url)
84
+ def redirect(location, status = 301)
85
+ if (300..399).include?(status)
86
+ exception = Redirection.new(absolute_uri(location))
87
+ exception.status = status
88
+ raise exception
89
+ else
90
+ raise ArgumentError, "Status has to be between 300 and 399"
91
+ end
73
92
  end
74
93
 
75
94
  attr_reader :env
@@ -89,7 +108,20 @@ module Rango
89
108
 
90
109
  def router_params
91
110
  @router_params ||= begin
92
- self.env["rango.router.params"].symbolize_keys || raise("rango.router.params property has to be setup at least to empty hash")
111
+ params = self.env["rango.router.params"]
112
+ raise "rango.router.params property has to be setup at least to empty hash" if params.nil?
113
+
114
+ symbolize_keys = lambda do |hash|
115
+ hash.reduce(Hash.new) do |hash, pair|
116
+ if pair.last.is_a?(Hash)
117
+ hash.merge(pair.first.to_sym => symbolize_keys.call(pair.last))
118
+ else
119
+ hash.merge(pair.first.to_sym => pair.last)
120
+ end
121
+ end
122
+ end
123
+
124
+ symbolize_keys.call(params)
93
125
  end
94
126
  end
95
127