Examples for Template Contexts in Rango
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BareTest.new_component :datamapper do | |
require 'dm-core' | |
DataMapper.auto_migrate! | |
setup do | |
DataMapper.repository do |r| | |
transaction = DataMapper::Transaction.new(r) | |
transaction.begin | |
r.adapter.push_transaction(transaction) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app = proc do |env| | |
body = Hash[ENV].merge(env).map {|k,v| k.inspect + " => " + v.inspect }.join("\n") | |
response = Rack::Response.new([body], 200, { 'Content-Type' => 'text/plain', 'Content-Length' => body.size.to_s}) | |
response.finish | |
end | |
run app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
app = proc do |env| | |
doc = Nokogiri::HTML('<html><head></head><body><div id="hello">Hello World</div></body></html>') | |
body = doc.css('#hello').content | |
[body, 200, { 'Content-Type' => 'text/plain', 'Content-Length' => body.size.to_s }] | |
end | |
run app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
module DataMapper | |
module Validate | |
class SizeValidator < GenericValidator | |
def call(target) | |
return true if valid?(target) | |
# Copied from within_validator | |
size = @options[:size] | |
msg = @options[:message] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# High-level wmii configuration. | |
# | |
# Ruby code in this file has access | |
# to a CONFIG constant which contains | |
# the data in this configuration file. | |
# | |
## | |
# A list of configuration files (partials) to import before |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'erector' | |
module Rango | |
module ErectorMixin | |
# Erects a html using the given class | |
# | |
# @param klass [Erector::Widget] the class to render with | |
# @param options [Hash] | |
# :exclude Array<Symbols> | |
# ivars not to pass via serializing | |
# :explicit Hash<Symbol, Object> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add PROJECT/lib to $LOAD_PATH | |
$LOAD_PATH.unshift(File.expand_path("#{__FILE__}/../../lib")) | |
# Ensure baretest is required | |
require 'baretest' | |
# Some defaults on BareTest (see Kernel#BareTest) | |
BareTest do | |
require_baretest "0.4.0" # minimum baretest version to run these tests | |
require_ruby "1.9.1" # minimum ruby version to run these tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative 'init' | |
require 'baretest' | |
require 'rack/test' | |
module Rack::Test::Methods | |
def app | |
Rango::Router.app | |
end | |
end | |
BareTest::Assertion::Context.send :include, Rack::Test::Methods |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
from numpy import sqrt, linspace | |
from scipy.integrate import odeint | |
from pylab import plot, axis, show | |
# Define the initial conditions for each of the four ODEs | |
#inic = [0.5,0,0.2,0] # chaotic | |
#inic = [0.7,0,0,0] # Secondary | |
#inic = [0,0.2,0.3,0.5] # Primary | |
E = 0.2 |