Browse Source

Merge pull request #1059 from rjnienaber/padrino

Ruby: Added Padrino framework
Hamilton Turner 11 years ago
parent
commit
8e3fcb2ae2
34 changed files with 989 additions and 0 deletions
  1. 1 0
      .travis.yml
  2. 9 0
      frameworks/Ruby/padrino/.components
  3. 21 0
      frameworks/Ruby/padrino/Gemfile
  4. 195 0
      frameworks/Ruby/padrino/Gemfile.lock
  5. 6 0
      frameworks/Ruby/padrino/Rakefile
  6. 0 0
      frameworks/Ruby/padrino/__init__.py
  7. 61 0
      frameworks/Ruby/padrino/app/app.rb
  8. 54 0
      frameworks/Ruby/padrino/app/controllers.rb
  9. 7 0
      frameworks/Ruby/padrino/app/helpers.rb
  10. 44 0
      frameworks/Ruby/padrino/app/mailers.rb
  11. 8 0
      frameworks/Ruby/padrino/app/views/fortunes.slim
  12. 7 0
      frameworks/Ruby/padrino/app/views/layout.slim
  13. 7 0
      frameworks/Ruby/padrino/bash_profile.sh
  14. 143 0
      frameworks/Ruby/padrino/benchmark_config
  15. 9 0
      frameworks/Ruby/padrino/config.ru
  16. 36 0
      frameworks/Ruby/padrino/config/apps.rb
  17. 45 0
      frameworks/Ruby/padrino/config/boot.rb
  18. 18 0
      frameworks/Ruby/padrino/config/database.rb
  19. 158 0
      frameworks/Ruby/padrino/config/nginx.conf
  20. 3 0
      frameworks/Ruby/padrino/config/puma.rb
  21. 10 0
      frameworks/Ruby/padrino/config/thin.yml
  22. 8 0
      frameworks/Ruby/padrino/config/trinidad.yml
  23. 11 0
      frameworks/Ruby/padrino/config/unicorn.rb
  24. 32 0
      frameworks/Ruby/padrino/helper.py
  25. 9 0
      frameworks/Ruby/padrino/install.sh
  26. 9 0
      frameworks/Ruby/padrino/models/fortune.rb
  27. 9 0
      frameworks/Ruby/padrino/models/world.rb
  28. BIN
      frameworks/Ruby/padrino/public/favicon.ico
  29. 10 0
      frameworks/Ruby/padrino/run_jruby_puma.py
  30. 10 0
      frameworks/Ruby/padrino/run_mri_puma.py
  31. 13 0
      frameworks/Ruby/padrino/run_thin.py
  32. 10 0
      frameworks/Ruby/padrino/run_torqbox.py
  33. 10 0
      frameworks/Ruby/padrino/run_trinidad.py
  34. 16 0
      frameworks/Ruby/padrino/run_unicorn.py

+ 1 - 0
.travis.yml

@@ -134,6 +134,7 @@ env:
     - "TESTDIR=Python/wsgi"
     - "TESTDIR=Racket/racket-ws"
     - "TESTDIR=Ruby/grape"
+    - "TESTDIR=Ruby/padrino"
     - "TESTDIR=Ruby/rack"
     - "TESTDIR=Ruby/rails"
     - "TESTDIR=Ruby/rails-stripped"

+ 9 - 0
frameworks/Ruby/padrino/.components

@@ -0,0 +1,9 @@
+---
+:orm: datamapper
+:test: none
+:mock: none
+:script: none
+:renderer: slim
+:stylesheet: none
+:namespace: HelloWorld
+:migration_format: number

+ 21 - 0
frameworks/Ruby/padrino/Gemfile

@@ -0,0 +1,21 @@
+source 'http://rubygems.org'
+
+platforms :jruby do
+  gem "jdbc-mysql", '5.1.31', :require => 'jdbc/mysql'
+  gem 'torqbox', '0.1.7'
+  gem "trinidad", '1.4.6'
+end
+
+platforms :ruby do
+  gem 'mysql2', '0.3.16'
+  gem "unicorn", '4.8.3'
+  gem "thin", '1.6.2'
+end
+
+gem 'puma', '2.9.0'
+gem 'json', '1.8.1'
+
+gem 'slim', '2.0.3'
+gem 'dm-mysql-adapter', '1.2.0'
+gem 'dm-core', '1.2.1'
+gem "padrino", "~> 0.12.3"

+ 195 - 0
frameworks/Ruby/padrino/Gemfile.lock

@@ -0,0 +1,195 @@
+GEM
+  remote: http://rubygems.org/
+  specs:
+    activesupport (4.1.5)
+      i18n (~> 0.6, >= 0.6.9)
+      json (~> 1.7, >= 1.7.7)
+      minitest (~> 5.1)
+      thread_safe (~> 0.1)
+      tzinfo (~> 1.1)
+    addressable (2.3.6)
+    daemons (1.1.9)
+    data_objects (0.10.14)
+      addressable (~> 2.1)
+    dm-core (1.2.1)
+      addressable (~> 2.3)
+    dm-do-adapter (1.2.0)
+      data_objects (~> 0.10.6)
+      dm-core (~> 1.2.0)
+    dm-mysql-adapter (1.2.0)
+      dm-do-adapter (~> 1.2.0)
+      do_mysql (~> 0.10.6)
+    do_jdbc (0.10.14-java)
+      data_objects (= 0.10.14)
+    do_mysql (0.10.14)
+      data_objects (= 0.10.14)
+    do_mysql (0.10.14-java)
+      data_objects (= 0.10.14)
+      do_jdbc (= 0.10.14)
+      jdbc-mysql (>= 5.0.4)
+    eventmachine (1.0.3)
+    http_router (0.11.1)
+      rack (>= 1.0.0)
+      url_mount (~> 0.2.1)
+    i18n (0.6.11)
+    jdbc-mysql (5.1.31)
+    jruby-rack (1.1.16)
+    json (1.8.1)
+    json (1.8.1-java)
+    kgio (2.9.2)
+    mail (2.5.4)
+      mime-types (~> 1.16)
+      treetop (~> 1.4.8)
+    mime-types (1.25.1)
+    minitest (5.4.0)
+    moneta (0.7.20)
+    mysql2 (0.3.16)
+    padrino (0.12.3)
+      padrino-admin (= 0.12.3)
+      padrino-cache (= 0.12.3)
+      padrino-core (= 0.12.3)
+      padrino-gen (= 0.12.3)
+      padrino-helpers (= 0.12.3)
+      padrino-mailer (= 0.12.3)
+      padrino-support (= 0.12.3)
+    padrino-admin (0.12.3)
+      padrino-core (= 0.12.3)
+      padrino-helpers (= 0.12.3)
+    padrino-cache (0.12.3)
+      moneta (~> 0.7.0)
+      padrino-core (= 0.12.3)
+      padrino-helpers (= 0.12.3)
+    padrino-core (0.12.3)
+      activesupport (>= 3.1)
+      http_router (~> 0.11.0)
+      padrino-support (= 0.12.3)
+      rack-protection (>= 1.5.0)
+      sinatra (~> 1.4.2)
+      thor (~> 0.18)
+    padrino-gen (0.12.3)
+      bundler (~> 1.0)
+      padrino-core (= 0.12.3)
+    padrino-helpers (0.12.3)
+      i18n (~> 0.6, >= 0.6.7)
+      padrino-support (= 0.12.3)
+      tilt (~> 1.4.1)
+    padrino-mailer (0.12.3)
+      mail (~> 2.5.3)
+      padrino-core (= 0.12.3)
+    padrino-support (0.12.3)
+      activesupport (>= 3.1)
+    polyglot (0.3.5)
+    puma (2.9.0)
+      rack (>= 1.1, < 2.0)
+    puma (2.9.0-java)
+      rack (>= 1.1, < 2.0)
+    rack (1.5.2)
+    rack-protection (1.5.3)
+      rack
+    raindrops (0.13.0)
+    sinatra (1.4.5)
+      rack (~> 1.4)
+      rack-protection (~> 1.4)
+      tilt (~> 1.3, >= 1.3.4)
+    slim (2.0.3)
+      temple (~> 0.6.6)
+      tilt (>= 1.3.3, < 2.1)
+    temple (0.6.8)
+    thin (1.6.2)
+      daemons (>= 1.0.9)
+      eventmachine (>= 1.0.0)
+      rack (>= 1.0.0)
+    thor (0.19.1)
+    thread_safe (0.3.4)
+    thread_safe (0.3.4-java)
+    tilt (1.4.1)
+    torqbox (0.1.7-java)
+      rack (>= 1.4.0, < 2.0)
+    treetop (1.4.15)
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+    trinidad (1.4.6)
+      jruby-rack (~> 1.1.13)
+      trinidad_jars (>= 1.3.0, < 1.5.0)
+    trinidad_jars (1.4.0)
+    tzinfo (1.2.2)
+      thread_safe (~> 0.1)
+    unicorn (4.8.3)
+      kgio (~> 2.6)
+      rack
+      raindrops (~> 0.7)
+    url_mount (0.2.1)
+      rack
+
+PLATFORMS
+  java
+  ruby
+
+DEPENDENCIES
+  dm-core (= 1.2.1)
+  dm-mysql-adapter (= 1.2.0)
+  jdbc-mysql (= 5.1.31)
+  json (= 1.8.1)
+  mysql2 (= 0.3.16)
+  padrino (~> 0.12.3)
+  puma (= 2.9.0)
+  slim (= 2.0.3)
+  thin (= 1.6.2)
+  torqbox (= 0.1.7)
+  trinidad (= 1.4.6)
+  unicorn (= 4.8.3)

+ 6 - 0
frameworks/Ruby/padrino/Rakefile

@@ -0,0 +1,6 @@
+require 'bundler/setup'
+require 'padrino-core/cli/rake'
+
+PadrinoTasks.use(:database)
+PadrinoTasks.use(:datamapper)
+PadrinoTasks.init

+ 0 - 0
frameworks/Ruby/padrino/__init__.py


+ 61 - 0
frameworks/Ruby/padrino/app/app.rb

@@ -0,0 +1,61 @@
+module HelloWorld
+  class App < Padrino::Application
+    register Padrino::Rendering
+    register Padrino::Mailer
+    register Padrino::Helpers
+
+    enable :sessions
+
+    ##
+    # Caching support.
+    #
+    # register Padrino::Cache
+    # enable :caching
+    #
+    # You can customize caching store engines:
+    #
+    # set :cache, Padrino::Cache::Store::Memcache.new(::Memcached.new('127.0.0.1:11211', :exception_retry_limit => 1))
+    # set :cache, Padrino::Cache::Store::Memcache.new(::Dalli::Client.new('127.0.0.1:11211', :exception_retry_limit => 1))
+    # set :cache, Padrino::Cache::Store::Redis.new(::Redis.new(:host => '127.0.0.1', :port => 6379, :db => 0))
+    # set :cache, Padrino::Cache::Store::Memory.new(50)
+    # set :cache, Padrino::Cache::Store::File.new(Padrino.root('tmp', app_name.to_s, 'cache')) # default choice
+    #
+
+    ##
+    # Application configuration options.
+    #
+    # set :raise_errors, true       # Raise exceptions (will stop application) (default for test)
+    # set :dump_errors, true        # Exception backtraces are written to STDERR (default for production/development)
+    # set :show_exceptions, true    # Shows a stack trace in browser (default for development)
+    # set :logging, true            # Logging in STDOUT for development and file for production (default only for development)
+    # set :public_folder, 'foo/bar' # Location for static assets (default root/public)
+    # set :reload, false            # Reload application files (default in development)
+    # set :default_builder, 'foo'   # Set a custom form builder (default 'StandardFormBuilder')
+    # set :locale_path, 'bar'       # Set path for I18n translations (default your_apps_root_path/locale)
+    # disable :sessions             # Disabled sessions by default (enable if needed)
+    # disable :flash                # Disables sinatra-flash (enabled by default if Sinatra::Flash is defined)
+    # layout  :my_layout            # Layout can be in views/layouts/foo.ext or views/foo.ext (default :application)
+    #
+
+    ##
+    # You can configure for a specified environment like:
+    #
+    #   configure :development do
+    #     set :foo, :bar
+    #     disable :asset_stamp # no asset timestamping for dev
+    #   end
+    #
+
+    ##
+    # You can manage errors like:
+    #
+    #   error 404 do
+    #     render 'errors/404'
+    #   end
+    #
+    #   error 505 do
+    #     render 'errors/505'
+    #   end
+    #
+  end
+end

+ 54 - 0
frameworks/Ruby/padrino/app/controllers.rb

@@ -0,0 +1,54 @@
+HelloWorld::App.controllers  do
+  get '/json', :provides => [:js] do
+    {message: "Hello, World!"}.to_json
+  end
+
+  get '/db', :provides => [:js] do
+    id = Random.rand(10000) + 1
+    World.get(id).attributes.to_json
+  end
+
+  get '/queries', :provides => [:js] do
+    queries = params['queries'].to_i
+    queries = 1 if queries < 1
+    queries = 500 if queries > 500
+
+    results = (1..queries).map do
+      World.get(Random.rand(10000) + 1).attributes
+    end.to_json
+  end
+
+  get '/fortunes' do
+    @fortunes = Fortune.all
+    @fortunes << Fortune.new(:id => 0, :message => "Additional fortune added at request time.")
+    @fortunes = @fortunes.sort_by { |x| x.message }
+
+    render 'fortunes', layout: "layout"
+  end
+
+  get '/updates', :provides => [:js] do
+    queries = params['queries'].to_i
+    queries = 1 if queries < 1
+    queries = 500 if queries > 500
+
+    worlds = (1..queries).map do
+      world = World.get(Random.rand(10000) + 1)
+      world.update(:randomNumber => Random.rand(10000) + 1)
+      world.attributes
+    end
+
+    #mass update
+    values = worlds.map { |h| ['(', h[:id], ',' , h[:randomNumber], ')', ','] }.flatten[0..-2].join
+    sql = "INSERT INTO `World` (`id`,`randomNumber`) VALUES #{values} ON DUPLICATE KEY UPDATE `World`.`randomNumber` = VALUES(`randomNumber`)"
+    adapter = DataMapper.repository(:default).adapter
+    adapter.execute(sql)
+    
+    worlds.to_json
+  end
+
+  get '/plaintext' do
+    content_type 'text/plain'
+    "Hello, World!"
+  end
+
+end

+ 7 - 0
frameworks/Ruby/padrino/app/helpers.rb

@@ -0,0 +1,7 @@
+# Helper methods defined here can be accessed in any controller or view in the application
+
+HelloWorld::App.helpers do
+  # def simple_helper_method
+  #  ...
+  # end
+end

+ 44 - 0
frameworks/Ruby/padrino/app/mailers.rb

@@ -0,0 +1,44 @@
+##
+# Mailer methods can be defined using the simple format:
+#
+# email :registration_email do |name, user|
+#   from '[email protected]'
+#   to   user.email
+#   subject 'Welcome to the site!'
+#   locals  :name => name
+#   content_type 'text/html'       # optional, defaults to plain/text
+#   via     :sendmail              # optional, to smtp if defined, otherwise sendmail
+#   render  'registration_email'
+# end
+#
+# You can set the default delivery settings from your app through:
+#
+#   set :delivery_method, :smtp => {
+#     :address         => 'smtp.yourserver.com',
+#     :port            => '25',
+#     :user_name       => 'user',
+#     :password        => 'pass',
+#     :authentication  => :plain, # :plain, :login, :cram_md5, no auth by default
+#     :domain          => "localhost.localdomain" # the HELO domain provided by the client to the server
+#   }
+#
+# or sendmail (default):
+#
+#   set :delivery_method, :sendmail
+#
+# or for tests:
+#
+#   set :delivery_method, :test
+#
+# or storing emails locally:
+#
+#   set :delivery_method, :file => {
+#     :location => "#{Padrino.root}/tmp/emails",
+#   }
+#
+# and then all delivered mail will use these settings unless otherwise specified.
+#
+
+HelloWorld::App.mailer :notifier do
+  # Message definitions here ...
+end

+ 8 - 0
frameworks/Ruby/padrino/app/views/fortunes.slim

@@ -0,0 +1,8 @@
+table
+  tr
+    th id
+    th message
+  - for fortune in @fortunes
+    tr
+      td =fortune.id
+      td =fortune.message

+ 7 - 0
frameworks/Ruby/padrino/app/views/layout.slim

@@ -0,0 +1,7 @@
+doctype html
+html
+  head
+    title Fortunes
+  body
+    == yield
+

+ 7 - 0
frameworks/Ruby/padrino/bash_profile.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+

+ 143 - 0
frameworks/Ruby/padrino/benchmark_config

@@ -0,0 +1,143 @@
+{
+  "framework": "padrino",
+  "tests": [{
+    "jruby-puma": {
+      "setup_file": "run_jruby_puma",
+      "json_url": "/json",
+      "db_url": "/db", 
+      "query_url": "/queries?queries=", 
+      "fortune_url": "/fortunes",
+      "update_url": "/updates?queries=", 
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "MySQL",
+      "framework": "padrino",
+      "language": "Ruby",
+      "orm": "Full",
+      "platform": "JRuby",
+      "webserver": "Puma",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "jruby-padrino",
+      "notes": "",
+      "versus": "rack-jruby"
+    },
+    "torqbox": {
+      "setup_file": "run_torqbox",
+      "json_url": "/json",
+      "db_url": "/db", 
+      "query_url": "/queries?queries=", 
+      "fortune_url": "/fortunes",
+      "update_url": "/updates?queries=", 
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "MySQL",
+      "framework": "padrino",
+      "language": "Ruby",
+      "orm": "Full",
+      "platform": "JRuby",
+      "webserver": "TorqBox",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "torqbox-padrino",
+      "notes": "",
+      "versus": "rack-torqbox"
+    },
+    "trinidad": {
+      "setup_file": "run_trinidad",
+      "json_url": "/json",
+      "db_url": "/db", 
+      "query_url": "/queries?queries=", 
+      "fortune_url": "/fortunes",
+      "update_url": "/updates?queries=", 
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "MySQL",
+      "framework": "padrino",
+      "language": "Ruby",
+      "orm": "Full",
+      "platform": "JRuby",
+      "webserver": "Trinidad",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "trinidad-padrino",
+      "notes": "",
+      "versus": "rack-trinidad"
+    },
+    "ruby-puma": {
+      "setup_file": "run_mri_puma",
+      "json_url": "/json",
+      "db_url": "/db", 
+      "query_url": "/queries?queries=", 
+      "fortune_url": "/fortunes",
+      "update_url": "/updates?queries=", 
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "MySQL",
+      "framework": "padrino",
+      "language": "Ruby",
+      "orm": "Full",
+      "platform": "Rack",
+      "webserver": "Puma",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "puma-padrino",
+      "notes": "",
+      "versus": "rack-puma"
+    },
+    "thin": {
+      "setup_file": "run_thin",
+      "json_url": "/json",
+      "db_url": "/db", 
+      "query_url": "/queries?queries=", 
+      "fortune_url": "/fortunes",
+      "update_url": "/updates?queries=", 
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "MySQL",
+      "framework": "padrino",
+      "language": "Ruby",
+      "orm": "Full",
+      "platform": "Rack",
+      "webserver": "Thin",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "thin-padrino",
+      "notes": "",
+      "versus": "rack-thin"
+    },
+    "unicorn": {
+      "setup_file": "run_unicorn",
+      "json_url": "/json",
+      "db_url": "/db", 
+      "query_url": "/queries?queries=", 
+      "fortune_url": "/fortunes",
+      "update_url": "/updates?queries=", 
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "MySQL",
+      "framework": "padrino",
+      "language": "Ruby",
+      "orm": "Full",
+      "platform": "Rack",
+      "webserver": "Unicorn",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "unicorn-padrino",
+      "notes": "",
+      "versus": "rack-unicorn"
+    }
+  }]
+}

+ 9 - 0
frameworks/Ruby/padrino/config.ru

@@ -0,0 +1,9 @@
+#!/usr/bin/env rackup
+# encoding: utf-8
+
+# This file can be used to start Padrino,
+# just execute it from the command line.
+
+require File.expand_path("../config/boot.rb", __FILE__)
+
+run Padrino.application

+ 36 - 0
frameworks/Ruby/padrino/config/apps.rb

@@ -0,0 +1,36 @@
+##
+# This file mounts each app in the Padrino project to a specified sub-uri.
+# You can mount additional applications using any of these commands below:
+#
+#   Padrino.mount('blog').to('/blog')
+#   Padrino.mount('blog', :app_class => 'BlogApp').to('/blog')
+#   Padrino.mount('blog', :app_file =>  'path/to/blog/app.rb').to('/blog')
+#
+# You can also map apps to a specified host:
+#
+#   Padrino.mount('Admin').host('admin.example.org')
+#   Padrino.mount('WebSite').host(/.*\.?example.org/)
+#   Padrino.mount('Foo').to('/foo').host('bar.example.org')
+#
+# Note 1: Mounted apps (by default) should be placed into the project root at '/app_name'.
+# Note 2: If you use the host matching remember to respect the order of the rules.
+#
+# By default, this file mounts the primary app which was generated with this project.
+# However, the mounted app can be modified as needed:
+#
+#   Padrino.mount('AppName', :app_file => 'path/to/file', :app_class => 'BlogApp').to('/')
+#
+
+##
+# Setup global project settings for your apps. These settings are inherited by every subapp. You can
+# override these settings in the subapps as needed.
+#
+Padrino.configure_apps do
+  # enable :sessions
+  set :session_secret, 'b941cbcb2d647360c0d1fb3c54a7039ed4f71cc0b7785d2aac689cc37d7757b7'
+  set :protection, true
+  set :protect_from_csrf, true
+end
+
+# Mounts the core application for this project
+Padrino.mount('HelloWorld::App', :app_file => Padrino.root('app/app.rb')).to('/')

+ 45 - 0
frameworks/Ruby/padrino/config/boot.rb

@@ -0,0 +1,45 @@
+# Defines our constants
+PADRINO_ROOT = File.expand_path('../..', __FILE__) unless defined?(PADRINO_ROOT)
+
+# Load our dependencies
+require 'rubygems' unless defined?(Gem)
+require 'bundler/setup'
+Bundler.require(:default, ENV['RACK_ENV'])
+
+##
+# ## Enable devel logging
+#
+# Padrino::Logger::Config[:development][:log_level]  = :devel
+# Padrino::Logger::Config[:development][:log_static] = true
+#
+# ## Configure your I18n
+#
+# I18n.default_locale = :en
+#
+# ## Configure your HTML5 data helpers
+#
+# Padrino::Helpers::TagHelpers::DATA_ATTRIBUTES.push(:dialog)
+# text_field :foo, :dialog => true
+# Generates: <input type="text" data-dialog="true" name="foo" />
+#
+# ## Add helpers to mailer
+#
+# Mail::Message.class_eval do
+#   include Padrino::Helpers::NumberHelpers
+#   include Padrino::Helpers::TranslationHelpers
+# end
+
+##
+# Add your before (RE)load hooks here
+#
+Padrino.before_load do
+end
+
+##
+# Add your after (RE)load hooks here
+#
+Padrino.after_load do
+  DataMapper.finalize
+end
+
+Padrino.load!

+ 18 - 0
frameworks/Ruby/padrino/config/database.rb

@@ -0,0 +1,18 @@
+##
+# A MySQL connection:
+# DataMapper.setup(:default, 'mysql://user:password@localhost/the_database_name')
+#
+# # A Postgres connection:
+# DataMapper.setup(:default, 'postgres://user:password@localhost/the_database_name')
+#
+# # A Sqlite3 connection
+# DataMapper.setup(:default, "sqlite3://" + Padrino.root('db', "development.db"))
+#
+
+DataMapper.logger = logger
+DataMapper::Property::String.length(255)
+
+host = ENV['DB_HOST'] || 'localhost'
+case Padrino.env
+  when :production  then DataMapper.setup(:default, "mysql://benchmarkdbuser:benchmarkdbpass@#{host}/hello_world")
+end

+ 158 - 0
frameworks/Ruby/padrino/config/nginx.conf

@@ -0,0 +1,158 @@
+# This is example contains the bare mininum to get nginx going with
+# Unicorn or Rainbows! servers.  Generally these configuration settings
+# are applicable to other HTTP application servers (and not just Ruby
+# ones), so if you have one working well for proxying another app
+# server, feel free to continue using it.
+#
+# The only setting we feel strongly about is the fail_timeout=0
+# directive in the "upstream" block.  max_fails=0 also has the same
+# effect as fail_timeout=0 for current versions of nginx and may be
+# used in its place.
+#
+# Users are strongly encouraged to refer to nginx documentation for more
+# details and search for other example configs.
+
+# you generally only need one nginx worker unless you're serving
+# large amounts of static files which require blocking disk reads
+worker_processes 8;
+
+# # drop privileges, root is needed on most systems for binding to port 80
+# # (or anything < 1024).  Capability-based security may be available for
+# # your system and worth checking out so you won't need to be root to
+# # start nginx to bind on 80
+# user nobody nogroup; # for systems with a "nogroup"
+#user nobody nobody; # for systems with "nobody" as a group instead
+
+# Feel free to change all paths to suite your needs here, of course
+pid /tmp/nginx.pid;
+#error_log /tmp/nginx.error.log;
+error_log stderr error;
+
+events {
+  worker_connections 4096; # increase if you have lots of clients
+  accept_mutex off; # "on" if nginx worker_processes > 1
+  use epoll; # enable for Linux 2.6+
+  # use kqueue; # enable for FreeBSD, OSX
+}
+
+http {
+  # nginx will find this file in the config directory set at nginx build time
+  include /usr/local/nginx/conf/mime.types;
+
+  # fallback in case we can't determine a type
+  default_type application/octet-stream;
+
+  # click tracking!
+  #access_log /tmp/nginx.access.log combined;
+  access_log off;
+
+  # you generally want to serve static files with nginx since neither
+  # Unicorn nor Rainbows! is optimized for it at the moment
+  sendfile on;
+
+  tcp_nopush on; # off may be better for *some* Comet/long-poll stuff
+  tcp_nodelay off; # on may be better for some Comet/long-poll stuff
+
+  # we haven't checked to see if Rack::Deflate on the app server is
+  # faster or not than doing compression via nginx.  It's easier
+  # to configure it all in one place here for static files and also
+  # to disable gzip for clients who don't get gzip/deflate right.
+  # There are other gzip settings that may be needed used to deal with
+  # bad clients out there, see http://wiki.nginx.org/NginxHttpGzipModule
+  #gzip on;
+  #gzip_http_version 1.0;
+  #gzip_proxied any;
+  #gzip_min_length 500;
+  #gzip_disable "MSIE [1-6]\.";
+  #gzip_types text/plain text/html text/xml text/css
+  #           text/comma-separated-values
+  #           text/javascript application/x-javascript
+  #           application/atom+xml;
+
+  # this can be any application server, not just Unicorn/Rainbows!
+  upstream app_server {
+    # fail_timeout=0 means we always retry an upstream even if it failed
+    # to return a good HTTP response (in case the Unicorn master nukes a
+    # single worker for timing out).
+
+    # for UNIX domain socket setups:
+    server unix:/tmp/.sock fail_timeout=0;
+
+    # for TCP setups, point these to your backend servers
+    # server 192.168.0.7:8080 fail_timeout=0;
+    # server 192.168.0.8:8080 fail_timeout=0;
+    # server 192.168.0.9:8080 fail_timeout=0;
+  }
+
+  server {
+    # enable one of the following if you're on Linux or FreeBSD
+    listen 8080 default deferred; # for Linux
+    # listen 80 default accept_filter=httpready; # for FreeBSD
+
+    # If you have IPv6, you'll likely want to have two separate listeners.
+    # One on IPv4 only (the default), and another on IPv6 only instead
+    # of a single dual-stack listener.  A dual-stack listener will make
+    # for ugly IPv4 addresses in $remote_addr (e.g ":ffff:10.0.0.1"
+    # instead of just "10.0.0.1") and potentially trigger bugs in
+    # some software.
+    # listen [::]:80 ipv6only=on; # deferred or accept_filter recommended
+
+    client_max_body_size 4G;
+    server_name _;
+
+    # ~2 seconds is often enough for most folks to parse HTML/CSS and
+    # retrieve needed images/icons/frames, connections are cheap in
+    # nginx so increasing this is generally safe...
+    keepalive_timeout 10;
+
+    # path for static files
+    root /path/to/app/current/public;
+
+    # Prefer to serve static files directly from nginx to avoid unnecessary
+    # data copies from the application server.
+    #
+    # try_files directive appeared in in nginx 0.7.27 and has stabilized
+    # over time.  Older versions of nginx (e.g. 0.6.x) requires
+    # "if (!-f $request_filename)" which was less efficient:
+    # http://bogomips.org/unicorn.git/tree/examples/nginx.conf?id=v3.3.1#n127
+    try_files $uri/index.html $uri.html $uri @app;
+
+    location @app {
+      # an HTTP header important enough to have its own Wikipedia entry:
+      #   http://en.wikipedia.org/wiki/X-Forwarded-For
+      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+
+      # enable this if you forward HTTPS traffic to unicorn,
+      # this helps Rack set the proper URL scheme for doing redirects:
+      # proxy_set_header X-Forwarded-Proto $scheme;
+
+      # pass the Host: header from the client right along so redirects
+      # can be set properly within the Rack application
+      proxy_set_header Host $http_host;
+
+      # we don't want nginx trying to do something clever with
+      # redirects, we set the Host: header above already.
+      proxy_redirect off;
+
+      # set "proxy_buffering off" *only* for Rainbows! when doing
+      # Comet/long-poll/streaming.  It's also safe to set if you're using
+      # only serving fast clients with Unicorn + nginx, but not slow
+      # clients.  You normally want nginx to buffer responses to slow
+      # clients, even with Rails 3.1 streaming because otherwise a slow
+      # client can become a bottleneck of Unicorn.
+      #
+      # The Rack application may also set "X-Accel-Buffering (yes|no)"
+      # in the response headers do disable/enable buffering on a
+      # per-response basis.
+      # proxy_buffering off;
+
+      proxy_pass http://app_server;
+    }
+
+    # Rails error pages
+    error_page 500 502 503 504 /500.html;
+    location = /500.html {
+      root /path/to/app/current/public;
+    }
+  }
+}

+ 3 - 0
frameworks/Ruby/padrino/config/puma.rb

@@ -0,0 +1,3 @@
+environment 'production'
+threads 8, 32
+bind 'tcp://0.0.0.0:8080'

+ 10 - 0
frameworks/Ruby/padrino/config/thin.yml

@@ -0,0 +1,10 @@
+--- 
+timeout: 30
+wait: 30
+max_conns: 1024
+max_persistent_conns: 512
+environment: production
+port: 8080
+servers: 8
+log: /tmp/thin.log
+quiet: true

+ 8 - 0
frameworks/Ruby/padrino/config/trinidad.yml

@@ -0,0 +1,8 @@
+---
+  port: 8080
+  threadsafe: true
+  environment: production
+  http:
+    address: '*'
+  logging:
+    level: SEVERE

+ 11 - 0
frameworks/Ruby/padrino/config/unicorn.rb

@@ -0,0 +1,11 @@
+worker_processes 8
+listen "/tmp/.sock", :backlog => 4096
+
+preload_app true
+GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true
+
+before_fork do |server, worker|
+end
+
+after_fork do |server, worker|
+end

+ 32 - 0
frameworks/Ruby/padrino/helper.py

@@ -0,0 +1,32 @@
+import os
+import subprocess
+from collections import namedtuple
+
+import setup_util
+
+Command = namedtuple('Command', ['command', 'wait_for_exit'])
+
+def set_database_host(args):
+  database_host = args.database_host or 'localhost'
+  database_file = os.path.join(args.troot, 'config', 'database.yml')
+  setup_util.replace_text(database_file, "  host:.*", "  host: " + database_host)
+
+def run(commands, logfile, errfile, cwd):
+  try:
+    for command in commands:      
+      if command.wait_for_exit:
+        subprocess.check_call(command.command, shell=True, cwd=cwd, stderr=errfile, stdout=logfile)
+      else:
+        subprocess.Popen(command.command, shell=True, cwd=cwd, stderr=errfile, stdout=logfile)
+  except subprocess.CalledProcessError:
+    return 1
+  return 0
+
+def stop(partial_command, logfile, errfile):
+  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
+  out, err = p.communicate()
+  for line in out.splitlines():
+    if partial_command in line and 'run-tests' not in line:
+      pid = int(line.split(None, 2)[1])
+      os.kill(pid, 15)
+  return 0

+ 9 - 0
frameworks/Ruby/padrino/install.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+fw_depends rvm nginx java
+
+rvm install ruby-2.0.0-p0
+rvm ruby-2.0.0-p0 do bundle install --gemfile=$TROOT/Gemfile
+
+rvm install jruby-1.7.8
+rvm jruby-1.7.8 do bundle install --gemfile=$TROOT/Gemfile

+ 9 - 0
frameworks/Ruby/padrino/models/fortune.rb

@@ -0,0 +1,9 @@
+class Fortune
+  include DataMapper::Resource
+
+  storage_names[:default] = 'Fortune'
+
+  # property <name>, <type>
+  property :id, Serial
+  property :message, String
+end

+ 9 - 0
frameworks/Ruby/padrino/models/world.rb

@@ -0,0 +1,9 @@
+class World
+  include DataMapper::Resource
+
+  storage_names[:default] = 'World'
+
+  # property <name>, <type>
+  property :id, Serial
+  property :randomNumber, Integer, field: 'randomNumber'
+end

BIN
frameworks/Ruby/padrino/public/favicon.ico


+ 10 - 0
frameworks/Ruby/padrino/run_jruby_puma.py

@@ -0,0 +1,10 @@
+import helper
+from helper import Command
+
+def start(args, logfile, errfile):
+  db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
+  start_server = db_host + " rvm jruby-1.7.8 do bundle exec puma -C config/puma.rb"
+  return helper.run([Command(start_server, False)], logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  return helper.stop('puma', logfile, errfile)

+ 10 - 0
frameworks/Ruby/padrino/run_mri_puma.py

@@ -0,0 +1,10 @@
+import helper
+from helper import Command
+
+def start(args, logfile, errfile):
+  db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
+  start_server = db_host + " rvm ruby-2.0.0-p0 do bundle exec puma -C config/puma.rb -w 8 --preload"
+  return helper.run([Command(start_server, False)], logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  return helper.stop('puma', logfile, errfile)

+ 13 - 0
frameworks/Ruby/padrino/run_thin.py

@@ -0,0 +1,13 @@
+import os
+
+import helper
+from helper import Command
+
+def start(args, logfile, errfile):
+  db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
+  start_server = db_host + " rvm ruby-2.0.0-p0 do bundle exec thin start -C config/thin.yml"
+  return helper.run([Command(start_server, False)], logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  helper.run([Command('rm -rf tmp/*', True)], logfile, errfile, os.environ['TROOT'])
+  return helper.stop('thin', logfile, errfile)

+ 10 - 0
frameworks/Ruby/padrino/run_torqbox.py

@@ -0,0 +1,10 @@
+import helper
+from helper import Command
+
+def start(args, logfile, errfile):
+  db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
+  start_server = db_host + " rvm jruby-1.7.8 do bundle exec torqbox -b 0.0.0.0 -E production"
+  return helper.run([Command(start_server, False)], logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  return helper.stop('torqbox', logfile, errfile)

+ 10 - 0
frameworks/Ruby/padrino/run_trinidad.py

@@ -0,0 +1,10 @@
+import helper
+from helper import Command
+
+def start(args, logfile, errfile):
+  db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
+  start_server = db_host + " rvm jruby-1.7.8 do bundle exec trinidad --config config/trinidad.yml"
+  return helper.run([Command(start_server, False)], logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  return helper.stop('trinidad', logfile, errfile)

+ 16 - 0
frameworks/Ruby/padrino/run_unicorn.py

@@ -0,0 +1,16 @@
+import os
+
+import helper
+from helper import Command
+
+def start(args, logfile, errfile):
+  db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
+  start_server = db_host + " rvm ruby-2.0.0-p0 do bundle exec unicorn -E production -c config/unicorn.rb"
+  commands = [Command("sudo /usr/local/nginx/sbin/nginx -c $TROOT/config/nginx.conf", True),
+              Command(start_server, False)]
+  return helper.run(commands, logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  command = Command("sudo /usr/local/nginx/sbin/nginx -c $TROOT/config/nginx.conf -s stop ", True)
+  helper.run([command], logfile, errfile, os.environ['TROOT'])
+  return helper.stop('unicorn', logfile, errfile)