- OHM =
(<<-OHM) unless defined?(OHM)
# Ohm does not have the concept of namespaces.
# This means that you will not be able to have
# a distinct test, development, or production database.
#
# You can, however, run multiple redis servers on the same host
# and point to them based on the environment:
#
# case Tennpipes.env
# when :development then Ohm.connect(:port => 6379)
# when :production then Ohm.connect(:port => 6380)
# when :test then Ohm.connect(:port => 6381)
# end
# Alternatively, you can try specifying a difference :db
# which, outside of confirmation, appears to provide distinct
# namespaces from testing:
# case Tennpipes.env
# when :development then Ohm.connect(:db => 0)
# when :production then Ohm.connect(:db => 1)
# when :test then Ohm.connec
- OHM_MODEL =
(<<-MODEL) unless defined?(OHM_MODEL)
class !NAME! < Ohm::Model
# Examples:
# attribute :name
# attribute :email
# reference :venue, Venue
# set :participants, Person
# counter :votes
#
# index :name
#
# def validate
# assert_present :name
- RACK_ENV =
ENV['RACK_ENV'] ||= 'development'
- TENNPIPES_ROOT =
File.expand_path('../..', __FILE__)
- RIOT_SETUP =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(RIOT_SETUP)
RACK_ENV = 'test' unless defined?(RACK_ENV)
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
# Specify your app using the #app helper inside a context.
# Takes either an app class or a block argument.
# app { Tennpipes.application }
# app { CLASS_NAME.tap { |app| } }
class Riot::Situation
include Rack::Test::Methods
# You can use this method to custom specify a Rack app
# you want rack-test to invoke:
#
# app CLASS_NAME
# app CLASS_NAME.tap { |a| }
# app(CLASS_NAME) do
# set :foo, :bar
# end
#
def app(app = nil, &blk)
@app ||= block_given? ? app.instance_eval(&blk) : app
@app ||= Tennpipes.application
end
end
c
- RIOT_CONTROLLER_TEST =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(RIOT_CONTROLLER_TEST)
require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb')
context "!PATH!" do
context "description here" do
setup do
get "!EXPANDED_PATH!"
end
asserts("the response body") { last_response.body
- RIOT_RAKE =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(RIOT_RAKE)
require 'rake/testtask'
test_tasks = Dir['test/*/'].map { |d| File.basename(d) }
test_tasks.each do |folder|
Rake::TestTask.new("test:\#{folder}") do |test|
test.pattern = "test/\#{folder}/**/*_test.rb"
test.verbose = true
end
end
desc "Run application test suite"
task 'test' => test_tasks.ma
- RIOT_MODEL_TEST =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(RIOT_MODEL_TEST)
require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
context "!NAME! Model" do
context 'can be created' do
setup do
!NAME!.new
end
asserts("that record is not nil
- RIOT_HELPER_TEST =
(<<-TEST) unless defined?(RIOT_HELPER_TEST)
require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
describe "!NAME!" do
setup do
helpers = Class.new
helpers.extend !NAME!
[helpers.foo]
end
asserts("
- RIPPLE_DB =
(<<-RIAK) unless defined?(RIPPLE_DB)
development:
http_port: 8098
pb_port: 8087
host: localhost
# The test environment has additional keys for configuring the
# Riak::TestServer for your test/spec suite:
#
# * bin_dir specifies the path to the "riak" script that you use to
# start Riak (just the directory)
# * js_source_dir specifies where your custom Javascript functions for
# MapReduce should be loaded from. Usually app/mapreduce.
test:
http_port: 9000
pb_port: 9002
host: localhost
bin_dir: /usr/local/bin # Default for Homebrew.
js_source_dir: <%%= Tennpipes.root + "app/mapreduce" %>
production:
http_port: 8098
pb_port:
- RIPPLE_CFG =
(<<RIAK) unless defined?(RIPPLE_CFG)
# encoding: utf-8
require 'ripple'
if File.exist?(Tennpipes.root + "config/riak.yml")
Ripple.load_configuration Tennpipes.root.join('config', 'riak.yml
- RIPPLE_MODEL =
(<<-MODEL) unless defined?(RIPPLE_MODEL)
# encoding: utf-8
class !NAME!
include Ripple::Document
# Standart properties
# property :name, String
!FIELDS!
# Relations
# many :addresses
# many :friends, :class_name => "Perso
- SEQUEL =
(<<-SEQUEL) unless defined?(SEQUEL)
Sequel::Model.plugin(:schema)
Sequel::Model.raise_on_save_failure = false # Do not throw exceptions on failure
Sequel::Model.db = case Tennpipes.env
when :development then Sequel.connect(!DB_DEVELOPMENT!, :loggers => [logger])
when :production then Sequel.connect(!DB_PRODUCTION!, :loggers => [logger])
when :test then Sequel.connect(!DB_TEST!, :loggers
- SQ_MODEL =
(<<-MODEL) unless defined?(SQ_MODEL)
class !NAME!
- SQ_MIGRATION =
(<<-MIGRATION) unless defined?(SQ_MIGRATION)
Sequel.migration do
up do
!UP!
end
down do
- SQ_MODEL_UP_MG =
(<<-MIGRATION).gsub(/^/, ' ') unless defined?(SQ_MODEL_UP_MG)
create_table :!TABLE! do
primary_
- SQ_MODEL_DOWN_MG =
(<<-MIGRATION) unless defined?(SQ_MODEL_DOWN
- SQ_CHANGE_MG =
(<<-MIGRATION).gsub(/^/, ' ') unless defined?(SQ_CHANGE_MG)
alter_table :!TABLE
- BACON_SETUP =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(BACON_SETUP)
RACK_ENV = 'test' unless defined?(RACK_ENV)
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
class Bacon::Context
include Rack::Test::Methods
end
# You can use this method to custom specify a Rack app
# you want rack-test to invoke:
#
# app CLASS_NAME
# app CLASS_NAME.tap { |a| }
# app(CLASS_NAME) do
# set :foo, :bar
# end
#
def app(app = nil, &blk)
@app ||= block_given? ? app.instance_eval(&blk) : app
@app ||= T
- BACON_CONTROLLER_TEST =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(BACON_CONTROLLER_TEST)
require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb')
describe "!PATH!" do
it 'returns text at root' do
get "!EXPANDED_PATH!"
last_response.bo
- BACON_RAKE =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(BACON_RAKE)
require 'rake/testtask'
test_tasks = Dir['test/*/'].map { |d| File.basename(d) }
test_tasks.each do |folder|
Rake::TestTask.new("test:\#{folder}") do |test|
test.pattern = "test/\#{folder}/**/*_test.rb"
test.verbose = true
end
end
desc "Run application test suite"
task 'test' => test_tasks.m
- BACON_MODEL_TEST =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(BACON_MODEL_TEST)
require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
describe "!NAME! Model" do
it 'can be created' do
@!DNAME! = !NAME!.new
@!DNAME
- BACON_HELPER_TEST =
<<-TEST unless defined?(BACON_HELPER_TEST)
require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
describe "!NAME!" do
before do
@helpers = Class.new
@helpers.extend !NAME!
end
it "should return nil" do
@helpers.
- RSPEC_SETUP =
(<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_SETUP)
RACK_ENV = 'test' unless defined?(RACK_ENV)
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
RSpec.configure do |conf|
conf.include Rack::Test::Methods
end
# You can use this method to custom specify a Rack app
# you want rack-test to invoke:
#
# app CLASS_NAME
# app CLASS_NAME.tap { |a| }
# app(CLASS_NAME) do
# set :foo, :bar
# end
#
def app(app = nil, &blk)
@app ||= block_given? ? app.instance_eval(&blk) : app
@app ||= T
- RSPEC_CONTROLLER_TEST =
(<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_CONTROLLER_TEST)
require 'spec_helper'
RSpec.describe "!PATH!" do
pending "add some examples to \#{__FILE__}" do
before do
get "!EXPANDED_PATH!"
end
it "returns hello world" do
expect(last_response.body).to
- RSPEC_RAKE =
(<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_RAKE)
begin
require 'rspec/core/rake_task'
spec_tasks = Dir['spec/*/'].each_with_object([]) do |d, result|
result << File.basename(d) unless Dir["\#{d}*"].empty?
end
spec_tasks.each do |folder|
desc "Run the spec suite in \#{folder}"
RSpec::Core::RakeTask.new("spec:\#{folder}") do |t|
t.pattern = "./spec/\#{folder}/**/*_spec.rb"
t.rspec_opts = "--color"
end
end
desc "Run complete application spec suite"
task 'spec' => spec_tasks.map { |f| "spec:\#{f}" }
rescue LoadError
puts "RSpec is not part of this b
- RSPEC_MODEL_TEST =
(<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_MODEL_TEST)
require 'spec_helper'
RSpec.describe !NAME! do
pending "add some examples to
- RSPEC_HELPER_TEST =
(<<-TEST) unless defined?(RSPEC_HELPER_TEST)
require 'spec_helper'
RSpec.describe "!NAME!" do
pending "add some examples to (or delete) \#{__FILE__}" do
let(:helpers){ Class.new }
before { helpers.extend !NAME! }
subject { helpers }
it "should return nil" do
expect(subject.fo
- STEAK_SETUP =
(<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_SETUP)
RACK_ENV = 'test' unless defined?(RACK_ENV)
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
RSpec.configure do |conf|
conf.include Rack::Test::Methods
conf.include Capybara
end
def app
##
# You can handle all tennpipes applications using instead:
# Tennpipes.application
CLASS_NAME.tap { |app| }
- STEAK_CONTROLLER_TEST =
(<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_CONTROLLER_TEST)
require 'spec_helper'
describe "!PATH!" do
before do
get "!EXPANDED_PATH!"
end
it "returns hello world" do
last_response.body
- STEAK_CONTROLLER_ACCEPTANCE_TEST =
(<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_CONTROLLER_ACCEPTANCE_TEST)
require 'spec_helper'
feature "!PATH!" do
background do
visit "!EXPANDED_PATH!"
end
scenario "returns hello world" do
page.s
- STEAK_RAKE =
(<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_RAKE)
require 'rspec/core/rake_task'
spec_tasks = Dir['spec/*/'].map { |d| File.basename(d) }
spec_tasks.each do |folder|
RSpec::Core::RakeTask.new("spec:\#{folder}") do |t|
t.pattern = "./spec/\#{folder}/**/*_spec.rb"
t.rspec_opts = %w(-fs --color)
end
end
desc "Run complete application spec suite"
task 'spec' => spec_tasks.m
- STEAK_MODEL_TEST =
(<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_MODEL_TEST)
require 'spec_he
- STEAK_HELPER_TEST =
<<-TEST unless defined?(STEAK_HELPER_TEST)
require 'spec_helper'
describe "!NAME!" do
let(:helpers){ Class.new }
before { helpers.extend !NAME! }
subject { helpers }
it "should return nil" do
expect(su
- MONGOID =
(<<-MONGO) unless defined?(MONGOID)
# Connection.new takes host and port
host = 'localhost'
port = Mongo::Connection::DEFAULT_PORT
database_name = case Tennpipes.env
when :development then '!NAME!_development'
when :production then '!NAME!_production'
when :test then '!NAME!_test'
end
Mongoid.database = Mongo::Connection.new(host, port).db(database_name)
# You can also configure Mongoid this way:
# Mongoid.configure do |config|
# name = @settings["database"]
# host = @settings["host"]
# config.master = Mongo::Connection.new.db(name)
# config.slaves = [
# Mongo::Connection.new(host, @settings["slave_one"]["port"], :slave_ok => true).db(name),
# Mongo::Connection.new(host, @settings["slave_two"]["port"], :slave_ok => true).db(name)
# ]
# end
#
# More installation and setup notes are on h
- MONGOID3 =
(<<-MONGO) unless defined?(MONGOID3)
# Connection.new takes host and port.
host = 'localhost'
port = 27017
database_name = case Tennpipes.env
when :development then '!NAME!_development'
when :production then '!NAME!_production'
when :test then '!NAME!_test'
end
# Use MONGO_URI if it's set as an environmental variable.
Mongoid::Config.sessions =
if ENV['MONGO_URI']
{default: {uri: ENV['MONGO_URI'] }}
else
{default: {hosts: ["#\{host\}:#\{port\}"], database: database_name}}
end
# If you want to use a YML file for config, use this instead:
#
# Mongoid.load!(File.join(Tennpipes.root, 'config', 'database.yml'), Tennpipes.env)
#
# And add a config/database.yml file like this:
# development:
# sessions:
# default:
# database: !NAME!_development
# hosts:
# - localhost:27017
# production:
# sessions:
# default:
# database: !NAME!_production
# hosts:
# - localhost:27017
# test:
# sessions:
# default:
# database: !NAME!_test
# hosts:
# - localhost:27017
#
#
# More installation and setup notes are on http://mongoid.org/en/mongoid/docs/installatio
- MONGOID_MODEL =
(<<-MODEL) unless defined?(MONGOID_MODEL)
class !NAME!
include Mongoid::Document
include Mongoid::Timestamps # adds created_at and updated_at fields
# field <name>, :type => <type>, :default => <value>
!FIELDS!
# You can define indexes on documents using the index macro:
# index :field <, :unique => true>
# You can create a composite key in mongoid to replace the default id using the key macro:
# key :field <, :another_f
- DYNAMOID =
(<<-DYNAMOID) unless defined?(DYNAMOID)
AWS.config({
:access_key_id => ENV['AWS_ACCESS_KEY'],
:secret_access_key => ENV['AWS_SECRET_KEY'],
:dynamo_db_endpoint => 'dynamodb.ap-southeast-1.amazonaws.com'
})
Dynamoid.configure do |config|
config.adapter = 'aws_sdk' # This adapter establishes a connection to the DynamoDB servers using Amazon's own AWS gem.
config.read_capacity = 100 # Read capacity for your tables
config.write_capacity = 20 # Write capacity for your tables
end
# If you use mock in testing [for example in case of using fake_dynamo],
# the way is as following:
#
# - install fake_dynamo
# gem install fake_dynamo --version 0.1.3
# - run
# fake_dynamo --port 4567
#
# And then setting for AWS.config is as following:
#
# AWS.config({
# :access_key_id => 'xxx', # everything is ok
# :secret_access_key => 'xxx', # everything is ok
# :dynamo_db_endpoint => 'localhost', # fake_dynamo runs hostname
# :dynamo_db_port => 4567, # fake_dynamo listens port
# :use_ssl => false # fake_dynamo don't speak ssl
# })
#
# Additional information on https://github.com/ananthaku
- DYNAMOID_MODEL =
(<<-MODEL) unless defined?(DYNAMOID_MODEL)
class !NAME!
include Dynamoid:
- SHOULDA_SETUP =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(SHOULDA_SETUP)
RACK_ENV = 'test' unless defined?(RACK_ENV)
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
require "test/unit"
class Test::Unit::TestCase
include Rack::Test::Methods
# You can use this method to custom specify a Rack app
# you want rack-test to invoke:
#
# app CLASS_NAME
# app CLASS_NAME.tap { |a| }
# app(CLASS_NAME) do
# set :foo, :bar
# end
#
def app(app = nil, &blk)
@app ||= block_given? ? app.instance_eval(&blk) : app
@app ||= Tennp
- SHOULDA_CONTROLLER_TEST =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(SHOULDA_CONTROLLER_TEST)
require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb')
class !NAME!ControllerTest < Test::Unit::TestCase
context "!NAME!Controller" do
setup do
get '/'
end
should "return hello world text" do
assert_equal "Hello World",
- SHOULDA_RAKE =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(SHOULDA_RAKE)
require 'rake/testtask'
test_tasks = Dir['test/*/'].map { |d| File.basename(d) }
test_tasks.each do |folder|
Rake::TestTask.new("test:\#{folder}") do |test|
test.pattern = "test/\#{folder}/**/*_test.rb"
test.verbose = true
end
end
desc "Run application test suite"
task 'test' => test_tasks
- SHOULDA_MODEL_TEST =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(SHOULDA_MODEL_TEST)
require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
class !NAME!Test < Test::Unit::TestCase
context "!NAME! Model" do
should 'construct new instance' do
@!DNAME! = !NAME!.new
assert_not
- SHOULDA_HELPER_TEST =
(<<-TEST) unless defined?(SHOULDA_HELPER_TEST)
require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
class !NAME!Test < Test::Unit::TestCase
context "!NAME!" do
setup do
@helpers = Class.new
@helpers.extend !NAME!
end
should "return nil" do
assert_equal nil
- COUCHREST =
(<<-COUCHREST) unless defined?(COUCHREST)
case Tennpipes.env
when :development then db_name = '!NAME!_development'
when :production then db_name = '!NAME!_production'
when :test then db_name = '!NAME!_test'
end
CouchRest::Model::Base.configure do |conf|
conf.model_type_key = 'type' # compatibility with CouchModel 1.1
conf.database = CouchRest.database!(db_name)
conf.environment = Tennpipes.env
# conf.connection = {
# :protocol => 'http',
# :host => 'localhost',
# :port => '5984',
# :prefix => 'tennpipes',
# :suffix => nil,
# :join => '_',
# :username => nil,
# :password
- CR_MODEL =
(<<-MODEL) unless defined?(CR_MODEL)
class !NAME! < CouchRest::Model::Base
unique_id :id
# property <
- CUCUMBER_SETUP =
(<<-TEST) unless defined?(CUCUMBER_SETUP)
RACK_ENV = 'test' unless defined?(RACK_ENV)
require File.expand_path(File.dirname(__FILE__) + "/../../config/boot")
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
require 'capybara/cucumber'
require 'rspec/expectations'
##
# You can handle all tennpipes applications using instead:
# Tennpipes.application
Capybara.app
- CUCUMBER_YML =
(<<-TEST) unless defined?(CUCUMBER_YML)
default: --tags ~@wip --strict features
html_report: --tags ~@wip --strict --format html --out=feat
- CUCUMBER_FEATURE =
(<<-TEST) unless defined?(CUCUMBER_FEATURE)
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
Scenario: Add two numbers
Given I visit the calculator page
And I fill in '50' for 'first'
And I fill in '70' for 'second'
When I press 'Add'
Th
- CUCUMBER_STEP =
(<<-TEST) unless defined?(CUCUMBER_STEP)
Given /^I visit the calculator page$/ do
visit '/add'
end
Given /^I fill in '(.*)' for '(.*)'$/ do |value, field|
fill_in(field, :with => value)
end
When /^I press '(.*)'$/ do |name|
click_button(name)
end
Then /^I should see '(.*)'$/ do |text|
page.sho
- CUCUMBER_URL =
(<<-TEST) unless defined?(CUCUMBER_URL)
module Cucumber
module Web
module URLs
def url_for(*names)
Capybara.app.url_for(*names)
end
alias_method :url, :url_for
def absolute_url_for(*names)
"http://www.example.com" + Capybara.app.url_for(*names)
end
alias_method :absolute_url, :absolute_url_for
end
end
end
W
- MINITEST_SETUP =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(MINITEST_SETUP)
RACK_ENV = 'test' unless defined?(RACK_ENV)
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
class MiniTest::Spec
include Rack::Test::Methods
# You can use this method to custom specify a Rack app
# you want rack-test to invoke:
#
# app CLASS_NAME
# app CLASS_NAME.tap { |a| }
# app(CLASS_NAME) do
# set :foo, :bar
# end
#
def app(app = nil, &blk)
@app ||= block_given? ? app.instance_eval(&blk) : app
@app ||= Tenn
- MINITEST_RAKE =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(MINITEST_RAKE)
require 'rake/testtask'
test_tasks = Dir['test/*/'].map { |d| File.basename(d) }
test_tasks.each do |folder|
Rake::TestTask.new("test:\#{folder}") do |test|
test.pattern = "test/\#{folder}/**/*_test.rb"
test.verbose = true
end
end
desc "Run application test suite"
task 'test' => test_task
- MINITEST_CONTROLLER_TEST =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(MINITEST_CONTROLLER_TEST)
require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb')
describe "!PATH!" do
before do
get "!EXPANDED_PATH!"
end
it "should return hello world text" do
assert_equal "Hello
- MINITEST_MODEL_TEST =
(<<-TEST).gsub(/^ {10}/, '') unless defined?(MINITEST_MODEL_TEST)
require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
describe "!NAME! Model" do
it 'can construct a new instance' do
@!DNAME! = !NAME!.new
- MINITEST_HELPER_TEST =
(<<-TEST) unless defined?(MINITEST_HELPER_TEST)
require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
describe "!NAME!" do
before do
@helpers = Class.new
@helpers.extend !NAME!
end
def helpers
@helpers
end
it "should return nil" do
assert
- DM =
(<<-DM) unless defined?(DM)
##
# 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://" + Tennpipes.root('db', "development.db"))
#
# # Setup DataMapper using config/database.yml
# DataMapper.setup(:default, YAML.load_file(Tennpipes.root('config/database.yml'))[RACK_ENV])
#
# config/database.yml file:
#
# ---
# development: &defaults
# adapter: mysql
# database: example_development
# username: user
# password: Pa55w0rd
# host: 127.0.0.1
#
# test:
# <<: *defaults
# database: example_test
#
# production:
# <<: *defaults
# database: example_production
#
DataMapper.logger = logger
DataMapper::Property::String.length(255)
case Tennpipes.env
when :development then DataMapper.setup(:default, !DB_DEVELOPMENT!)
when :production then DataMapper.setup(:default, !DB_PRODUCTION!)
when :test then DataMapper.setup(:defaul
- DM_MODEL =
(<<-MODEL) unless defined?(DM_MODEL)
class !NAME!
include DataMapper::Resource
# property <name>, <type>
property :id, S
- DM_MIGRATION =
(<<-MIGRATION) unless defined?(DM_MIGRATION)
migration !VERSION!, :!FILENAME! do
up do
!UP!
end
down do
- DM_MODEL_UP_MG =
(<<-MIGRATION).gsub(/^/, ' ') unless defined?(DM_MODEL_UP_MG)
create_table :!TABLE! do
column :id, Integer, :serial
- DM_MODEL_DOWN_MG =
(<<-MIGRATION) unless defined?(DM_MODEL_DOWN
- DM_CHANGE_MG =
(<<-MIGRATION).gsub(/^/, ' ') unless defined?(DM_CHANGE_MG)
modify_table :!TABLE
- MR =
(<<-MR) unless defined?(MR)
##
# You can use other adapters like:
#
# ActiveRecord::Base.configurations[:development] = {
# :adapter => 'mysql2',
# :encoding => 'utf8',
# :reconnect => true,
# :database => 'your_database',
# :pool => 5,
# :username => 'root',
# :password => '',
# :host => 'localhost',
# :socket => '/tmp/mysql.sock'
# }
#
ActiveRecord::Base.configurations[:development] = {
!DB_DEVELOPMENT!
}
ActiveRecord::Base.configurations[:production] = {
!DB_PRODUCTION!
}
ActiveRecord::Base.configurations[:test] = {
!DB_TEST!
}
# Setup our logger.
ActiveRecord::Base.logger = logger
if ActiveRecord::VERSION::MAJOR.to_i < 4
# Raise exception on mass assignment protection for Active Record models.
ActiveRecord::Base.mass_assignment_sanitizer = :strict
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL).
ActiveRecord::Base.auto_explain_threshold_in_seconds = 0.5
end
# Doesn't include Active Record class name as root for JSON serialized output.
ActiveRecord::Base.include_root_in_json = false
# Store the full class name (including module namespace) in STI type column.
ActiveRecord::Base.store_full_sti_class = true
# Use ISO 8601 format for JSON serialized times and dates.
ActiveSupport.use_standard_json_time_format = true
# Don't escape HTML entities in JSON, leave that for the #json_escape helper
# if you're including raw JSON in an HTML page.
ActiveSupport.escape_html_entities_in_json = false
# Now we can establish connection with our db.
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[Tennpipes.env])
# Timestamps are in the utc by default.
ActiveRecord::Base.defaul
- MYSQL =
(<<-MYSQL) unless defined?(MYSQL)
:adapter => 'mysql',
:encoding => 'utf8',
:reconnect => true,
:database => !DB_NAME!,
:pool => 5,
:username => 'root',
:password => '',
:host => 'localhost',
:socket =>
- MYSQL2 =
(<<-MYSQL2) unless defined?(MYSQL2)
:adapter => 'mysql2',
:encoding => 'utf8',
:reconnect => true,
:database => !DB_NAME!,
:pool => 5,
:username => 'root',
:password => '',
:host => 'localhost',
:socket =>
- POSTGRES =
(<<-POSTGRES) unless defined?(POSTGRES)
:adapter => 'postgresql',
:database => !DB_NAME!,
:username => 'root',
:password => '',
:host => 'localhost',
:
- SQLITE =
(<<-SQLITE) unless defined?(SQLITE)
:adapter => 'sqlite3',
:data
- CONNECTION_POOL_MIDDLEWARE =
<<-MIDDLEWARE
class ConnectionPoolManagement
def initialize(app)
@app = app
end
def call(env)
ActiveRecord::Base.connection_pool.with_connection { @app.call(env) }
end
end
MIDDLEWARE
- MR_MODEL =
(<<-MODEL) unless defined?(MR_MODEL)
class !NAME! < ActiveRecord::Base
# F
- MONGOMATIC =
(<<-MONGO) unless defined?(MONGOMATIC)
case Tennpipes.env
when :development then Mongomatic.db = Mongo::Connection.new.db("!NAME!_development")
when :production then Mongomatic.db = Mongo::Connection.new.db("!NAME!_production")
when :test then Mongomatic.db = Mongo::Connection.new
- MONGOMATIC_MODEL =
(<<-MODEL) unless defined?(MONGOMATIC_MODEL)
class !NAME! < Mongomatic::Base
include Mongomatic::Expectations::Helper
# Mongomatic does not have the traditional
# model definition that AR/MM/DM et. al. have.
# Staying true to the "ad-hoc" nature of MongoDB,
# there are no explicit column definitions in the
# model file.
# However you can "fake it" by making a column
# required using expectations
# For the sake of tennpipes g model,
# we'll assume that any property defined
# on the command-line is required
# In the case of Integer types, we'll add
# the expectation: be_a_number
# Future enhancement may allow a regex for
# String datatypes
# Examples:
# def validate
# expectations do
# be_present self['name'], "Name cannot be blank"
# be_present self['email'], "Email cannot be blank"
# be_present self['age'], "Age cannot be blank"
# be_present self['password'], "Password cannot be blank"
# be_a_number self['age'], "Age must be a number"
# be_of_length self['password'], "Password must be at least 8 characters", :minimum => 8
# end
# end
# def create_indexes
# self.collection.create_index('name', :unique => true)
# self.collection.create_index('email', :unique => true)
# self.collection.create_index('age')
# end
def validate
expectations do
!FIELDS!
!
- MONGO =
(<<-MONGO) unless defined?(MONGO)
MongoMapper.connection = Mongo::Connection.new('localhost', nil, :logger => logger)
case Tennpipes.env
when :development then MongoMapper.database = '!NAME!_development'
when :production then MongoMapper.database = '!NAME!_production'
when :test then MongoMapper.database =
- MM_MODEL =
(<<-MODEL) unless defined?(MM_MODEL)
class !NAME!
include MongoMapper::Document
# key <name>, <type>
!FIELD
- LESS_INIT =
<<-LESS unless defined?(LESS_INIT)
# Enables support for Less template reloading for rack.
# Store Less files by default within 'app/stylesheets/'.
# See http://github.com/kelredd/rack-less for more details.
require 'rack/less'
# optional - use as necessary
Rack::Less.configure do |config|
config.compress = true
# config.cache = true
# other configs ...
end
app.use Rack::Less,
:root => Tennpipes.root,
:source => 'app/stylesheets',
:public => 'public',
:host
- SASS_INIT =
<<-SASS unless defined?(SASS_INIT)
# Enables support for SASS template reloading in rack applications.
# See http://nex-3.com/posts/88-sass-supports-rack for more details.
# Store SASS files (by default) within 'app/stylesheets'.
require 'sass/plugin/rack'
Sass::Plugin.options[:template_location] = Tennpipes.root("app/stylesheets")
Sass::Plugin.options[:css_location] = Tennpipes.root("public/stylesheets")
app.
- SCSS_INIT =
<<-SCSS unless defined?(SCSS_INIT)
# Enables support for SCSS template reloading in rack applications.
# See http://nex-3.com/posts/88-sass-supports-rack for more details.
# Store SCSS files (by default) within 'app/stylesheets'.
require 'sass/plugin/rack'
Sass::Plugin.options[:syntax] = :scss
Sass::Plugin.options[:template_location] = Tennpipes.root("app/stylesheets")
Sass::Plugin.options[:css_location] = Tennpipes.root("public/stylesheets")
app.
- AR =
(<<-AR) unless defined?(AR)
##
# You can use other adapters like:
#
# ActiveRecord::Base.configurations[:development] = {
# :adapter => 'mysql2',
# :encoding => 'utf8',
# :reconnect => true,
# :database => 'your_database',
# :pool => 5,
# :username => 'root',
# :password => '',
# :host => 'localhost',
# :socket => '/tmp/mysql.sock'
# }
#
ActiveRecord::Base.configurations[:development] = {
!DB_DEVELOPMENT!
}
ActiveRecord::Base.configurations[:production] = {
!DB_PRODUCTION!
}
ActiveRecord::Base.configurations[:test] = {
!DB_TEST!
}
# Setup our logger
ActiveRecord::Base.logger = logger
if ActiveRecord::VERSION::MAJOR.to_i < 4
# Raise exception on mass assignment protection for Active Record models.
ActiveRecord::Base.mass_assignment_sanitizer = :strict
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL).
ActiveRecord::Base.auto_explain_threshold_in_seconds = 0.5
end
# Doesn't include Active Record class name as root for JSON serialized output.
ActiveRecord::Base.include_root_in_json = false
# Store the full class name (including module namespace) in STI type column.
ActiveRecord::Base.store_full_sti_class = true
# Use ISO 8601 format for JSON serialized times and dates.
ActiveSupport.use_standard_json_time_format = true
# Don't escape HTML entities in JSON, leave that for the #json_escape helper
# if you're including raw JSON in an HTML page.
ActiveSupport.escape_html_entities_in_json = false
# Now we can establish connection with our db.
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[Tennpipes.env])
# Timestamps are in the utc by default.
ActiveRecord::Base.defaul
- AR_MODEL =
(<<-MODEL) unless defined?(AR_MODEL)
class !NAME! < Act
- AR_MIGRATION =
(<<-MIGRATION) unless defined?(AR_MIGRATION)
class !FILECLASS! < ActiveRecord::Migration
def self.up
!UP!
end
def self.down
- AR_MODEL_UP_MG =
(<<-MIGRATION).gsub(/^/,' ') unless defined?(AR_MODEL_UP_MG)
create_table :!TABLE! do |t|
!FIEL
- AR_MODEL_DOWN_MG =
(<<-MIGRATION) unless defined?(AR_MODEL_DOWN
- AR_CHANGE_MG =
(<<-MIGRATION).gsub(/^/, ' ') unless defined?(AR_CHANGE_MG)
change_table :!TABLE! do
- COMPASS_INIT =
<<-COMPASS unless defined?(COMPASS_INIT)
# Enables support for Compass, a stylesheet authoring framework based on SASS.
# See http://compass-style.org/ for more details.
# Store Compass/SASS files (by default) within 'app/stylesheets'.
module CompassInitializer
def self.registered(app)
require 'sass/plugin/rack'
Compass.configuration do |config|
config.project_path = Tennpipes.root
config.sass_dir = "app/stylesheets"
config.project_type = :stand_alone
config.http_path = "/"
config.css_dir = "public/stylesheets"
config.images_dir = "public/images"
config.javascripts_dir = "public/javascripts"
config.output_style = :compressed
end
Compass.configure_sass_plugin!
Compass.handle_configuration_change!
app.use Sass::
- COMPASS_REGISTER =
<<-COMPASSR unless defined?(COMPASS_REGISTER)
regi