rango 0.2 → 0.2.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/.gitmodules +3 -0
- data/CHANGELOG +5 -0
- data/CONTRIBUTORS +1 -0
- data/Gemfile +20 -0
- data/LICENSE +1 -1
- data/README.textile +5 -4
- data/benchmarks/ab.rb +6 -0
- data/benchmarks/bm/boot.rb +20 -0
- data/{spec/rango/version_spec.rb → benchmarks/bm/callbacks.rb} +0 -0
- data/benchmarks/bm/request.rb +4 -0
- data/benchmarks/bm/routers.rb +22 -0
- data/benchmarks/bm/stack.rb +19 -0
- data/{spec/stubs/acqs/dir/lib.rb → benchmarks/bm/templates.rb} +0 -0
- data/benchmarks/helper.rb +7 -0
- data/benchmarks/stubs/merb-app/.gitignore +21 -0
- data/benchmarks/stubs/merb-app/Rakefile +35 -0
- data/benchmarks/stubs/merb-app/app/controllers/application.rb +4 -0
- data/benchmarks/stubs/merb-app/app/controllers/exceptions.rb +15 -0
- data/benchmarks/stubs/merb-app/app/helpers/global_helpers.rb +7 -0
- data/benchmarks/stubs/merb-app/app/models/user.rb +19 -0
- data/benchmarks/stubs/merb-app/app/views/exceptions/not_acceptable.html.erb +63 -0
- data/benchmarks/stubs/merb-app/app/views/exceptions/not_found.html.erb +47 -0
- data/benchmarks/stubs/merb-app/app/views/layout/application.html.erb +12 -0
- data/benchmarks/stubs/merb-app/autotest/discover.rb +4 -0
- data/benchmarks/stubs/merb-app/autotest/merb.rb +154 -0
- data/benchmarks/stubs/merb-app/autotest/merb_rspec.rb +167 -0
- data/benchmarks/stubs/merb-app/config/database.yml +33 -0
- data/benchmarks/stubs/merb-app/config/dependencies.rb +36 -0
- data/benchmarks/stubs/merb-app/config/environments/development.rb +17 -0
- data/benchmarks/stubs/merb-app/config/environments/production.rb +12 -0
- data/benchmarks/stubs/merb-app/config/environments/rake.rb +13 -0
- data/benchmarks/stubs/merb-app/config/environments/staging.rb +12 -0
- data/benchmarks/stubs/merb-app/config/environments/test.rb +14 -0
- data/benchmarks/stubs/merb-app/config/init.rb +26 -0
- data/benchmarks/stubs/merb-app/config/rack.rb +13 -0
- data/benchmarks/stubs/merb-app/config/router.rb +46 -0
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/merb_generator.rb +1364 -0
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/api_grease.js +640 -0
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/index.html.erb +37 -0
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/merb.css +252 -0
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/merb.rb +353 -0
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/merb_doc_styles.css +492 -0
- data/benchmarks/stubs/merb-app/doc/rdoc/generators/template/merb/prototype.js +2515 -0
- data/benchmarks/stubs/merb-app/merb/merb-auth/setup.rb +46 -0
- data/benchmarks/stubs/merb-app/merb/merb-auth/strategies.rb +13 -0
- data/benchmarks/stubs/merb-app/merb/session/session.rb +11 -0
- data/benchmarks/stubs/merb-app/public/.htaccess +17 -0
- data/benchmarks/stubs/merb-app/public/favicon.ico +0 -0
- data/benchmarks/stubs/merb-app/public/images/merb.jpg +0 -0
- data/benchmarks/stubs/merb-app/public/javascripts/application.js +1 -0
- data/benchmarks/stubs/merb-app/public/javascripts/jquery.js +19 -0
- data/benchmarks/stubs/merb-app/public/merb.fcgi +22 -0
- data/benchmarks/stubs/merb-app/public/robots.txt +5 -0
- data/benchmarks/stubs/merb-app/public/stylesheets/master.css +119 -0
- data/{spec/stubs/acqs/dir/lib_spec.rb → benchmarks/stubs/merb-app/spec/spec.opts} +0 -0
- data/benchmarks/stubs/merb-app/spec/spec_helper.rb +27 -0
- data/benchmarks/stubs/merb-app/tasks/doc.thor +151 -0
- data/benchmarks/stubs/merb-app/tasks/merb.thor/app_script.rb +33 -0
- data/benchmarks/stubs/merb-app/tasks/merb.thor/common.rb +70 -0
- data/benchmarks/stubs/merb-app/tasks/merb.thor/gem_ext.rb +127 -0
- data/benchmarks/stubs/merb-app/tasks/merb.thor/main.thor +152 -0
- data/benchmarks/stubs/merb-app/tasks/merb.thor/ops.rb +95 -0
- data/benchmarks/stubs/merb-app/tasks/merb.thor/utils.rb +42 -0
- data/benchmarks/stubs/merb-core/.gitignore +21 -0
- data/benchmarks/stubs/merb-core/Rakefile +35 -0
- data/benchmarks/stubs/merb-core/app/controllers/application.rb +4 -0
- data/benchmarks/stubs/merb-core/app/controllers/exceptions.rb +15 -0
- data/benchmarks/stubs/merb-core/app/helpers/global_helpers.rb +7 -0
- data/benchmarks/stubs/merb-core/app/views/exceptions/not_acceptable.html.erb +63 -0
- data/benchmarks/stubs/merb-core/app/views/exceptions/not_found.html.erb +47 -0
- data/benchmarks/stubs/merb-core/app/views/layout/application.html.erb +12 -0
- data/benchmarks/stubs/merb-core/autotest/discover.rb +1 -0
- data/benchmarks/stubs/merb-core/autotest/merb.rb +151 -0
- data/benchmarks/stubs/merb-core/autotest/merb_rspec.rb +167 -0
- data/benchmarks/stubs/merb-core/config/environments/development.rb +17 -0
- data/benchmarks/stubs/merb-core/config/environments/production.rb +12 -0
- data/benchmarks/stubs/merb-core/config/environments/rake.rb +13 -0
- data/benchmarks/stubs/merb-core/config/environments/staging.rb +12 -0
- data/benchmarks/stubs/merb-core/config/environments/test.rb +14 -0
- data/benchmarks/stubs/merb-core/config/init.rb +27 -0
- data/benchmarks/stubs/merb-core/config/rack.rb +13 -0
- data/benchmarks/stubs/merb-core/config/router.rb +43 -0
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/merb_generator.rb +1364 -0
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/api_grease.js +640 -0
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/index.html.erb +37 -0
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/merb.css +252 -0
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/merb.rb +353 -0
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/merb_doc_styles.css +492 -0
- data/benchmarks/stubs/merb-core/doc/rdoc/generators/template/merb/prototype.js +2515 -0
- data/benchmarks/stubs/merb-core/public/.htaccess +17 -0
- data/benchmarks/stubs/merb-core/public/favicon.ico +0 -0
- data/benchmarks/stubs/merb-core/public/images/merb.jpg +0 -0
- data/benchmarks/stubs/merb-core/public/javascripts/application.js +1 -0
- data/benchmarks/stubs/merb-core/public/merb.fcgi +22 -0
- data/benchmarks/stubs/merb-core/public/robots.txt +5 -0
- data/benchmarks/stubs/merb-core/public/stylesheets/master.css +119 -0
- data/{spec/stubs/acqs/lib.rb → benchmarks/stubs/merb-core/spec/spec.opts} +0 -0
- data/benchmarks/stubs/merb-core/spec/spec_helper.rb +22 -0
- data/benchmarks/stubs/merb-core/tasks/merb.thor/app_script.rb +33 -0
- data/benchmarks/stubs/merb-core/tasks/merb.thor/common.rb +70 -0
- data/benchmarks/stubs/merb-core/tasks/merb.thor/gem_ext.rb +127 -0
- data/benchmarks/stubs/merb-core/tasks/merb.thor/main.thor +152 -0
- data/benchmarks/stubs/merb-core/tasks/merb.thor/ops.rb +95 -0
- data/benchmarks/stubs/merb-core/tasks/merb.thor/utils.rb +42 -0
- data/benchmarks/stubs/merb-flat/.gitignore +21 -0
- data/benchmarks/stubs/merb-flat/README.txt +10 -0
- data/benchmarks/stubs/merb-flat/Rakefile +35 -0
- data/benchmarks/stubs/merb-flat/application.rb +17 -0
- data/benchmarks/stubs/merb-flat/config/framework.rb +9 -0
- data/benchmarks/stubs/merb-flat/config/init.rb +42 -0
- data/benchmarks/stubs/merb-flat/spec/spec_helper.rb +26 -0
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/app_script.rb +33 -0
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/common.rb +70 -0
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/gem_ext.rb +127 -0
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/main.thor +152 -0
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/ops.rb +95 -0
- data/benchmarks/stubs/merb-flat/tasks/merb.thor/utils.rb +42 -0
- data/benchmarks/stubs/merb-flat/views/foo.html.erb +3 -0
- data/benchmarks/stubs/merb-very-flat/.gitignore +21 -0
- data/benchmarks/stubs/merb-very-flat/Rakefile +35 -0
- data/benchmarks/stubs/merb-very-flat/merb-very-flat.rb +61 -0
- data/benchmarks/stubs/merb-very-flat/spec/spec_helper.rb +26 -0
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/app_script.rb +33 -0
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/common.rb +70 -0
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/gem_ext.rb +127 -0
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/main.thor +152 -0
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/ops.rb +95 -0
- data/benchmarks/stubs/merb-very-flat/tasks/merb.thor/utils.rb +42 -0
- data/benchmarks/stubs/rails/README +243 -0
- data/benchmarks/stubs/rails/Rakefile +10 -0
- data/benchmarks/stubs/rails/app/controllers/application_controller.rb +12 -0
- data/benchmarks/stubs/rails/app/helpers/application_helper.rb +5 -0
- data/benchmarks/stubs/rails/config/boot.rb +112 -0
- data/benchmarks/stubs/rails/config/database.yml +22 -0
- data/benchmarks/stubs/rails/config/environment.rb +43 -0
- data/benchmarks/stubs/rails/config/environments/development.rb +19 -0
- data/benchmarks/stubs/rails/config/environments/production.rb +30 -0
- data/benchmarks/stubs/rails/config/environments/test.rb +30 -0
- data/benchmarks/stubs/rails/config/initializers/backtrace_silencers.rb +9 -0
- data/benchmarks/stubs/rails/config/initializers/inflections.rb +12 -0
- data/benchmarks/stubs/rails/config/initializers/mime_types.rb +7 -0
- data/benchmarks/stubs/rails/config/initializers/new_rails_defaults.rb +21 -0
- data/benchmarks/stubs/rails/config/initializers/session_store.rb +17 -0
- data/benchmarks/stubs/rails/config/locales/en.yml +5 -0
- data/benchmarks/stubs/rails/config/routes.rb +45 -0
- data/benchmarks/stubs/rails/doc/README_FOR_APP +2 -0
- data/{spec/stubs/acqs/tasks.thor → benchmarks/stubs/rails/log/development.log} +0 -0
- data/{stubs/stack/content/TODO.txt → benchmarks/stubs/rails/log/production.log} +0 -0
- data/benchmarks/stubs/rails/log/server.log +0 -0
- data/benchmarks/stubs/rails/log/test.log +0 -0
- data/benchmarks/stubs/rails/public/404.html +30 -0
- data/benchmarks/stubs/rails/public/422.html +30 -0
- data/benchmarks/stubs/rails/public/500.html +30 -0
- data/benchmarks/stubs/rails/public/favicon.ico +0 -0
- data/benchmarks/stubs/rails/public/images/rails.png +0 -0
- data/benchmarks/stubs/rails/public/index.html +275 -0
- data/benchmarks/stubs/rails/public/javascripts/application.js +2 -0
- data/benchmarks/stubs/rails/public/javascripts/controls.js +963 -0
- data/benchmarks/stubs/rails/public/javascripts/dragdrop.js +973 -0
- data/benchmarks/stubs/rails/public/javascripts/effects.js +1128 -0
- data/benchmarks/stubs/rails/public/javascripts/prototype.js +4320 -0
- data/benchmarks/stubs/rails/public/robots.txt +5 -0
- data/benchmarks/stubs/rails/script/about +4 -0
- data/benchmarks/stubs/rails/script/console +3 -0
- data/benchmarks/stubs/rails/script/dbconsole +3 -0
- data/benchmarks/stubs/rails/script/destroy +3 -0
- data/benchmarks/stubs/rails/script/generate +3 -0
- data/benchmarks/stubs/rails/script/performance/benchmarker +3 -0
- data/benchmarks/stubs/rails/script/performance/profiler +3 -0
- data/benchmarks/stubs/rails/script/plugin +3 -0
- data/benchmarks/stubs/rails/script/runner +3 -0
- data/benchmarks/stubs/rails/script/server +3 -0
- data/benchmarks/stubs/rails/test/performance/browsing_test.rb +11 -0
- data/benchmarks/stubs/rails/test/test_helper.rb +40 -0
- data/benchmarks/stubs/ramaze.rb +0 -0
- data/benchmarks/stubs/sinatra.rb +11 -0
- data/bin/rango +2 -2
- data/deps.rip +7 -0
- data/deps.rip.rbe +7 -0
- data/gems/cache/abstract-1.0.0.gem +0 -0
- data/gems/cache/code-cleaner-0.1.gem +0 -0
- data/gems/cache/code-cleaner-0.2.gem +0 -0
- data/gems/cache/code-cleaner-0.3.gem +0 -0
- data/gems/cache/code-cleaner-0.4.gem +0 -0
- data/gems/cache/code-cleaner-0.5.gem +0 -0
- data/gems/cache/code-cleaner-0.6.gem +0 -0
- data/gems/cache/code-cleaner-0.7.gem +0 -0
- data/gems/cache/code-cleaner-0.8.1.gem +0 -0
- data/gems/cache/code-cleaner-0.8.gem +0 -0
- data/gems/cache/erubis-2.6.5.gem +0 -0
- data/gems/cache/extlib-0.9.14.gem +0 -0
- data/gems/cache/haml-2.2.16.gem +0 -0
- data/gems/cache/haml-2.2.17.gem +0 -0
- data/gems/cache/nake-0.0.2.gem +0 -0
- data/gems/cache/nake-0.0.3.gem +0 -0
- data/gems/cache/nake-0.0.5.gem +0 -0
- data/gems/cache/nake-0.0.6.gem +0 -0
- data/gems/cache/nake-0.0.8.gem +0 -0
- data/gems/cache/rack-1.0.1.gem +0 -0
- data/gems/cache/rack-1.1.0.gem +0 -0
- data/gems/cache/rspec-1.2.9.gem +0 -0
- data/gems/cache/rspec-1.3.0.gem +0 -0
- data/gems/cache/term-ansicolor-1.0.4.gem +0 -0
- data/gems/cache/tilt-0.4.gem +0 -0
- data/gems/cache/tilt-0.5.gem +0 -0
- data/lib/rango.rb +28 -28
- data/lib/rango/cli.rb +34 -0
- data/lib/rango/contrib/pagination/adapters/datamapper.rb +21 -17
- data/lib/rango/controller.rb +36 -4
- data/lib/rango/environments.rb +1 -15
- data/lib/rango/exceptions.rb +144 -86
- data/lib/rango/helpers.rb +10 -2
- data/lib/rango/mailer.rb +48 -0
- data/lib/rango/mixins/action_args.rb +5 -7
- data/lib/rango/mixins/filters.rb +18 -14
- data/lib/rango/mixins/message.rb +30 -24
- data/lib/rango/mixins/rendering.rb +54 -0
- data/lib/rango/orm/tasks/datamapper.nake +81 -0
- data/lib/rango/orm/tasks/sequel.nake +43 -0
- data/lib/rango/router/adapters/usher.rb +2 -1
- data/lib/rango/stacks/controller.rb +12 -0
- data/lib/rango/tasks/spec.nake +9 -0
- data/lib/rango/templates/exts/haml.rb +1 -1
- data/lib/rango/templates/exts/tilt.rb +10 -0
- data/lib/rango/templates/helpers.rb +29 -25
- data/lib/rango/templates/template.rb +7 -6
- data/rango.gemspec +52 -0
- data/rango.pre.gemspec +8 -0
- data/spec/rango/environments_spec.rb +1 -1
- data/spec/rango/exceptions_spec.rb +8 -7
- data/spec/rango/mixins/render_spec.rb +1 -1
- data/spec/rango/templates/template_spec.rb +1 -1
- data/stubs/stack/content/%name%.gemspec.rbt +52 -0
- data/stubs/stack/content/%name%.pre.gemspec.rbt +8 -0
- data/stubs/stack/content/CHANGELOG +0 -0
- data/stubs/stack/content/Gemfile.rbt +22 -11
- data/stubs/stack/content/README.textile.rbt +7 -0
- data/stubs/stack/content/config.ru.rbt +33 -62
- data/stubs/stack/content/deps.rip +0 -0
- data/stubs/stack/content/init.rb.rbt +14 -39
- data/stubs/stack/content/lib/%name%.rb.rbt +8 -0
- data/stubs/stack/content/lib/%name%/config.rb.rbt +0 -0
- data/stubs/stack/content/{environments.rb.rbt → lib/%name%/environments/development.rb.rbt} +5 -0
- data/stubs/stack/content/lib/%name%/environments/production.rb.rbt +0 -0
- data/stubs/stack/content/lib/%name%/environments/stagging.rb.rbt +0 -0
- data/stubs/stack/content/lib/%name%/initializers/middlewares.rb.rbt +5 -0
- data/stubs/stack/content/lib/%name%/initializers/urls.rb.rbt +24 -0
- data/stubs/stack/content/{models.rb.rbt → lib/%name%/models.rb.rbt} +7 -0
- data/stubs/stack/content/{views.rb.rbt → lib/%name%/views.rb.rbt} +2 -8
- data/stubs/stack/content/rackup.rb.rbt +41 -0
- data/stubs/stack/content/tasks.rb.rbt +52 -0
- data/stubs/stack/setup.rb +7 -1
- data/support/hooks/pre-commit +12 -0
- data/tasks.rb +49 -0
- metadata +250 -54
- data/Rakefile +0 -33
- data/lib/rango/rack/middlewares/email_obfuscator.rb +0 -25
- data/lib/rango/version.rb +0 -7
- data/stubs/stack/content/.rvmrc.rbt +0 -2
- data/stubs/stack/content/Rakefile.rbt +0 -12
@@ -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
|
data/bin/rango
CHANGED
@@ -31,8 +31,8 @@ HELP
|
|
31
31
|
end
|
32
32
|
|
33
33
|
begin
|
34
|
-
ARGV.shift || usage
|
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
|
-
|
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
|
6
|
-
module
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
data/lib/rango/controller.rb
CHANGED
@@ -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(
|
71
|
-
|
72
|
-
|
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"]
|
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
|
|