code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
require 'appwiki/base/base_route.rb'
class Route < BaseRoute
def self.get_handlerpath(request,response,requestpath)
# inject 'index' to forge the path to match real location
workingpath = requestpath[0..0] + ["index"]
handlerpath = requestpath[0..0] + ["index"]
requestpath = handlerpath + requestpat... | Ruby |
require 'cgi'
require 'appwiki/base/base_request.rb'
#
# TODO BROKEN UNUSED
#
@@cookiez = "hi"
@@requestcount = 0
class BaseRequestModProxy < BaseRequest
##########################################################################
# init
###################################################################... | Ruby |
require 'uri'
require 'erb'
require 'time'
require 'thread'
require 'stringio'
require 'ostruct'
require 'optparse'
require 'delegate'
require 'rubygems'
require 'active_record'
require 'logger'
require 'uuid'
require 'date'
require 'parsedate'
require "net/smtp"
require 'pp'
# global config
# TODO not really happy w... | Ruby |
#
# a request abstraction - this is from 'camping' mostly
#
class BaseRequest
attr_accessor :status # http status
attr_accessor :method # a copy of the http method 'GET' or 'POST'
attr_accessor :cookies # the cookies ( from header )
attr_accessor :params # params
attr_accesso... | Ruby |
require 'ruby_gems'
require 'mongrel'
require 'appwiki/base/base_request.rb'
@@testlock = Mutex.new
#
# a request abstraction
#
class BaseRequestMongrel < BaseRequest
##########################################################################
# init
####################################################... | Ruby |
require 'webrick/htmlutils'
require 'webrick/httputils'
require 'webrick/httpstatus'
require 'webrick/httpserver'
require 'appwiki/base/base_request.rb'
@@testlock = Mutex.new
class BaseRequestWebrick < BaseRequest
attr_accessor :request_uri, :host, :path
# parse request and return something that can emul... | Ruby |
#
# Session support
#
class Session < ActiveRecord::Base
def update
super
end
##########################################################################
# slightly modified hash; from camping - probably obsolete now
#########################################################################... | Ruby |
require 'appwiki/base/base_request.rb'
require 'appwiki/base/base_utils.rb'
require 'appwiki/base/base_session.rb'
#
# A base 'servlet' concept that emulates several ruby on rails policies
# The idea is this is subclassed by behavior handlers for specific url patterns or routes
# Controllers are generally invoked by ... | Ruby |
# this is some stuff for youthgive specifically that is in base_utils but seems to crash
# it is a mess anyway
#########################################################################
# utilities
# xxx move this
#########################################################################
# dump all an... | Ruby |
@@controllers_mutex = Mutex.new
@@controllers = Hash.new
#require 'find'
#require 'fileutils'
#
# Routing is the core of most web apps.
#
# A little bit about the idea of "routing" in general in applications in general:
#
# 1) An application usually consists of a bunch of event handlers which respond to certain ev... | Ruby |
# used for saving files
require 'ftools'
require 'uuid'
require 'RMagick'
require 'net/smtp'
#
# some utilities for brad
#
class BaseUtils
#########################################################################
# save something; make thumbs if needed
###################################################... | Ruby |
# used for helping decouple from webrick oddly enough
require 'thread'
require 'webrick/htmlutils'
require 'webrick/httputils'
require 'webrick/httpstatus'
#
# stolen from webrick ... so that i can return files in a standalone or proxied solution
#
# the server class has to provide .logger and .mimetypes
#
class HT... | Ruby |
require 'appwiki/note/note_controller.rb'
class SplashController < NoteController
def index
if @method == 'post'
make_area
else
render :action => :index
end
end
def default
render :action => :invent
end
end
| Ruby |
#!/usr/bin/env ruby
$:.unshift(File.dirname(__FILE__) + '/../lib')
$:.unshift(File.dirname(__FILE__) + '/mocks')
$:.unshift(File.dirname(__FILE__) + '/../lib/active_merchant/billing')
$:.unshift(File.dirname(__FILE__)+ '/extra')
require 'rubygems'
require 'money'
require 'yaml'
require 'net/http'
require 'net/https'
r... | Ruby |
#!/usr/bin/env ruby
$:.unshift(File.dirname(__FILE__) + '/../lib')
$:.unshift(File.dirname(__FILE__) + '/mocks')
$:.unshift(File.dirname(__FILE__) + '/../lib/active_merchant/billing')
$:.unshift(File.dirname(__FILE__)+ '/extra')
require 'rubygems'
require 'money'
require 'yaml'
require 'net/http'
require 'net/https'
r... | Ruby |
# The Breakpoint library provides the convenience of
# being able to inspect and modify state, diagnose
# bugs all via IRB by simply setting breakpoints in
# your applications by the call of a method.
#
# This library was written and is supported by me,
# Florian Gross. I can be reached at flgr@ccan.de
# and enj... | Ruby |
class Continuation # :nodoc:
def self.create(*args, &block) # :nodoc:
cc = nil; result = callcc {|c| cc = c; block.call(cc) if block and args.empty?}
result ||= args
return *[cc, *result]
end
end
class Binding; end # for RDoc
# This method returns the binding of the method that called your
# ... | Ruby |
module Net
remove_const "HTTP"
class Response
def initialize(result)
@result = result
end
def body
@result
end
end
class Request < Struct.new(:host, :port, :query, :post_data)
cattr_accessor :fail
@@fail = false
def post(query, post)
self.query ... | Ruby |
class Module
def mock_methods(mock_methods)
raise "mock methods needs a block" unless block_given?
original = self
namespace = original.name.split("::")
class_name = namespace.last
mod = namespace[0..-2].inject(Object) { |mod, part| mod.const_get(part) }
klass = (original.... | Ruby |
module ActiveMerchant
module Generator
class Manifest
attr_reader :templates, :directories
def initialize
@templates, @directories = [], []
yield self if block_given?
end
def template(input, output)
@templates << { :input => input, :output => output }
end
... | Ruby |
require 'script/generator/manifest'
require 'script/generator/base'
module ActiveMerchant
module Generator
class Generator
def self.run(args = [])
unless args.size == 2
puts <<-BANNER
Usage: script/generate <generator> <ClassName>
Where <generator> is one of:
gateway - Generate a ne... | Ruby |
module ActiveMerchant
module Generator
class Base
attr_reader :class_name, :name
def initialize(name, class_name)
@name = name
@class_name = class_name
end
def root
File.dirname(__FILE__) + '/../..'
end
def run
# Create the required directorie... | Ruby |
class IntegrationGenerator < ActiveMerchant::Generator::Base
def manifest
@manifest ||= record do |m|
m.directory "lib/active_merchant/billing/integrations/#{file_name}"
m.template 'integration.rb',
"lib/active_merchant/billing/integrations/#{file_name}.rb"
m.templ... | Ruby |
require 'net/http'
module ActiveMerchant
module Billing
module Integrations
module <%= class_name %>
class Notification < ActiveMerchant::Billing::Integrations::Notification
def complete?
params['']
end
def item_id
params['']
end
... | Ruby |
module ActiveMerchant
module Billing
module Integrations
module <%= class_name %>
class Helper < ActiveMerchant::Billing::Integrations::Helper
# Replace with the real mapping
mapping :account, ''
mapping :amount, ''
mapping :order, ''
mappi... | Ruby |
require File.dirname(__FILE__) + '/<%= file_name %>/helper.rb'
require File.dirname(__FILE__) + '/<%= file_name %>/notification.rb'
module ActiveMerchant
module Billing
module Integrations
module <%= class_name %>
mattr_accessor :service_url
self.service_url = 'https://www.example.... | Ruby |
module ActiveMerchant
module Billing
class <%= class_name %>Gateway < Gateway
TEST_URL = 'https://example.com/test'
LIVE_URL = 'https://example.com/live'
attr_reader :url
attr_reader :response
attr_reader :options
def initialize(options = {})
#requires!(options... | Ruby |
class GatewayGenerator < ActiveMerchant::Generator::Base
def manifest
record do |m|
m.template 'gateway.rb',
"lib/active_merchant/billing/gateways/#{file_name}.rb"
m.template 'gateway_test.rb',
"test/unit/gateways/#{file_name}_test.rb"
m.template 'remote_gatew... | Ruby |
#!/usr/bin/env ruby
begin
require 'active_support'
rescue LoadError
require 'rubygems'
require 'active_support'
end
require 'erb'
require 'script/generator/generator'
ActiveMerchant::Generator::Generator.run(ARGV)
| Ruby |
#!/usr/bin/env ruby
begin
require 'active_support'
rescue LoadError
require 'rubygems'
require 'active_support'
end
require 'erb'
require 'script/generator/generator'
ActiveMerchant::Generator::Generator.run(ARGV)
| Ruby |
require 'active_merchant'
require 'active_merchant/billing/integrations/action_view_helper'
ActionView::Base.send(:include, ActiveMerchant::Billing::Integrations::ActionViewHelper)
| Ruby |
require 'rubygems'
$:.unshift(File.dirname(__FILE__) + './lib')
require 'money'
require 'active_merchant'
# Using the money library, passing the amount in cents
tendollar = Money.us_dollar(1000)
# Using an approved TC test card
creditcard = ActiveMerchant::Billing::CreditCard.new({
:number => '4111111111111111',
:m... | Ruby |
require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'
require 'rake/contrib/rubyforgepublisher'
require File.dirname(__FILE__) + '/lib/tasks/cia'
PKG_VERSION = "0.6.0"
PKG_NAME = "activemerchant"
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
PKG_FILES = FileLi... | Ruby |
module ActiveMerchant
module Billing
class Error < StandardError
end
class Response
attr_reader :params
attr_reader :message
attr_reader :test
attr_reader :authorization
def success?
@success
end
def test?
@test
end
... | Ruby |
module ActiveMerchant
module Billing
# Bogus Gateway
class BogusGateway < Gateway
def authorize(money, creditcard, options = {})
case creditcard.number
when '1'
Response.new(true, "Bogus Gateway: Forced success", {:autorized_amount => money.to_s}, :test => true, :authori... | Ruby |
require File.join(File.dirname(__FILE__), 'paypal/defaultDriver.rb')
require File.join(File.dirname(__FILE__), 'paypal/requester_credentials_handler.rb')
require 'pp'
module ActiveMerchant
module Billing
class PaypalGateway < Gateway
# This is only for live transactions.
GATEWAY_URL = 'https://api-aa... | Ruby |
# This class implements the Psigate gateway for the ActiveMerchant module.
# Psigate = http://www.psigate.com/ The class is currently set up to use
# the psigate test server while rails is in testing or developement mode.
# The real server will be used while in production mode.
#
# Modifications by Sean O'Hara ... | Ruby |
require File.join(File.dirname(__FILE__), 'default.rb')
require 'soap/rpc/driver'
class PayPalAPIInterface < ::SOAP::RPC::Driver
DefaultEndpointUrl = "https://api.sandbox.paypal.com/2.0/"
MappingRegistry = ::SOAP::Mapping::Registry.new
Methods = [
[ nil,
"refundTransaction",
[ ["in", "RefundTran... | Ruby |
require 'xsd/qname'
# {urn:ebay:api:PayPalAPI}RefundTransactionReq
class RefundTransactionReq
@@schema_type = "RefundTransactionReq"
@@schema_ns = "urn:ebay:api:PayPalAPI"
@@schema_qualified = "true"
@@schema_element = [
["refundTransactionRequest", ["RefundTransactionRequestType", XSD::QName.new("urn:ebay... | Ruby |
require 'soap/header/simplehandler'
module ActiveMerchant
module Billing
module Paypal
class RequesterCredentialsHandler < SOAP::Header::SimpleHandler
HeaderName = XSD::QName.new('urn:ebay:api:PayPalAPI','RequesterCredentials')
CredentialsName = XSD::QName.new('urn:ebay:apis:eBLBaseComp... | Ruby |
begin
require 'tclink'
rescue LoadError
# Ignore, but we will fail hard if someone actually tries to use this gateway
end
module ActiveMerchant
module Billing
# To get started using TrustCommerce with active_merchant, download the tclink library from http://www.trustcommerce.com/tclink.html,
# foll... | Ruby |
require 'rexml/document'
module ActiveMerchant
module Billing
class MonerisGateway < Gateway
attr_reader :url
attr_reader :response
attr_reader :options
def initialize(options = {})
requires!(options, :login, :password)
@options = {
:strict_ssl => true,... | Ruby |
module ActiveMerchant
module Billing
class AuthorizedNetGateway < Gateway
API_VERSION = '3.1'
GATEWAY_URL = "https://secure.authorize.net/gateway/transact.dll"
APPROVED, DECLINED, ERROR = 1, 2, 3
RESPONSE_CODE, RESPONSE_REASON_CODE, RESPONSE_REASON_TEXT = 0, 2, 3
AVS_RESUL... | Ruby |
module ActiveMerchant
module Billing
class UsaEpayGateway < Gateway
GATEWAY_URL = 'https://www.usaepay.com/gate.php'
attr_reader :url
attr_reader :response
attr_reader :options
def initialize(options = {})
requires!(options, :login)
@options = options... | Ruby |
# Author:: Lucas Carlson (mailto:lucas@rufy.com)
# Copyright:: Copyright (c) 2005 Lucas Carlson
# License:: Distributes under the same terms as Ruby
require 'rexml/document'
module ActiveMerchant
module Billing
# TO USE:
# First, make sure you have everything setup correctly and all of your dependenci... | Ruby |
# Portions of the LinkPoint Gateway by Ryan Heneise
#--
# Copyright (c) 2005 Tobias Luetke
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitatio... | Ruby |
require 'active_merchant/billing/integrations/bogus/helper.rb'
require 'active_merchant/billing/integrations/bogus/notification.rb'
module ActiveMerchant
module Billing
module Integrations
module Bogus
mattr_accessor :service_url
self.service_url = 'http://www.bogus.com'
def self.n... | Ruby |
require_library_or_gem 'action_pack'
module ActiveMerchant
module Billing
module Integrations
module ActionViewHelper
# This helper allows the usage of different payment integrations
# through a single form helper. Payment integrations are the
# type of service where the user is re... | Ruby |
module ActiveMerchant
module Billing
module Integrations
class Notification
attr_accessor :params
attr_accessor :raw
def initialize(post)
empty!
parse(post)
end
def status
raise NotImplementedError, "Must implement this method in the su... | Ruby |
require 'active_merchant/billing/integrations/paypal/helper.rb'
require 'active_merchant/billing/integrations/paypal/notification.rb'
module ActiveMerchant
module Billing
module Integrations
module Paypal
# Overwrite this if you want to change the Paypal test url
mattr_accessor :te... | Ruby |
require File.dirname(__FILE__) + '/nochex/helper.rb'
require File.dirname(__FILE__) + '/nochex/notification.rb'
module ActiveMerchant
module Billing
module Integrations
module Nochex
mattr_accessor :service_url
self.service_url = 'https://www.nochex.com/nochex.dll/checkout'
... | Ruby |
require 'net/http'
module ActiveMerchant
module Billing
module Integrations
module Paypal
# Parser and handler for incoming Instant payment notifications from paypal.
# The Example shows a typical handler in a rails application. Note that this
# is an example, please read the Paypa... | Ruby |
module ActiveMerchant
module Billing
module Integrations
module Paypal
class Helper < ActiveMerchant::Billing::Integrations::Helper
CANADIAN_PROVINCES = { 'AB' => 'Alberta',
'BC' => 'British Columbia',
'MB' => 'Manitoba',
... | Ruby |
require 'net/http'
require 'date'
module ActiveMerchant
module Billing
module Integrations
module Nochex
# Parser and handler for incoming Automatic Payment Confirmations from Nochex.
class Notification < ActiveMerchant::Billing::Integrations::Notification
include ActiveMerchant::... | Ruby |
module ActiveMerchant
module Billing
module Integrations
module Nochex
class Helper < ActiveMerchant::Billing::Integrations::Helper
# Required Parameters
# email
# amount
mapping :account, 'email'
mapping :amount, 'amount'
# Set th... | Ruby |
module ActiveMerchant
module Billing
module Integrations
module Bogus
class Notification < ActiveMerchant::Billing::Integrations::Notification
end
end
end
end
end
| Ruby |
module ActiveMerchant
module Billing
module Integrations
module Bogus
class Helper < ActiveMerchant::Billing::Integrations::Helper
mapping :account, 'account'
mapping :order, 'order'
mapping :amount, 'amount'
mapping :currency, 'currency'
mapping :cu... | Ruby |
require 'active_merchant/billing/integrations/chronopay/helper.rb'
require 'active_merchant/billing/integrations/chronopay/notification.rb'
module ActiveMerchant
module Billing
module Integrations
module Chronopay
mattr_accessor :service_url
self.service_url = 'https://secure.chronopay.com/... | Ruby |
module ActiveMerchant
module Billing
module Integrations
class Helper
attr_reader :fields
class_inheritable_accessor :service_url
class_inheritable_hash :mappings
class_inheritable_accessor :country_format
self.country_format = :alpha2
def initialize(order, a... | Ruby |
module ActiveMerchant
module Billing
module Integrations
module Chronopay
class Notification < ActiveMerchant::Billing::Integrations::Notification
def complete?
status == 'Completed'
end
# Status of transaction. List of possible values:
# <tt>onet... | Ruby |
module ActiveMerchant
module Billing
module Integrations
module Chronopay
class Helper < ActiveMerchant::Billing::Integrations::Helper
self.country_format = :alpha3
def initialize(order, account, options = {})
super
add_field('cb_type', 'p')
... | Ruby |
module ActiveMerchant
module Billing
module Base
# Set ActiveMerchant gateways in test mode.
#
# ActiveMerchant::Billing::Base.gateway_mode = :test
mattr_accessor :gateway_mode
# Set ActiveMerchant gateways in test mode.
#
# ActiveMerchant::Billing::Base.gatewa... | Ruby |
require 'net/http'
require 'net/https'
require 'active_merchant/billing/response'
module ActiveMerchant
module Billing
# The Gateway class is the base class for all ActiveMerchant gateway
# implementations. The list of gateway functions that concrete
# gateway classes can and should implement include the... | Ruby |
require 'active_merchant/billing/gateways/bogus'
require 'active_merchant/billing/gateways/psigate'
require 'active_merchant/billing/gateways/authorized_net'
require 'active_merchant/billing/gateways/moneris'
require 'active_merchant/billing/gateways/trust_commerce'
require 'active_merchant/billing/gateways/linkpoint'
... | Ruby |
require 'active_merchant/billing/integrations/notification'
require 'active_merchant/billing/integrations/helper'
require 'active_merchant/billing/integrations/bogus'
require 'active_merchant/billing/integrations/chronopay'
require 'active_merchant/billing/integrations/paypal'
require 'active_merchant/billing/integrati... | Ruby |
module ActiveMerchant
module Billing
class Address
attr_reader :address1, :address2, :city, :state, :country, :zip, :phone, :company
def initialize(options = {})
parse(options)
end
private
def parse(options)
@address1 = options[:address1]
@address2 = options... | Ruby |
require 'time'
require 'delegate'
require 'date'
module ActiveMerchant
module Billing
# This credit card object can be used as a stand alone object. It acts just like a active record object
# but doesn't support the .save method as its not backed by a database.
class CreditCard
include Validatea... | Ruby |
module ActiveMerchant
module Validateable
def valid?
errors.clear
before_validate if respond_to?(:before_validate)
validate if respond_to?(:validate)
errors.empty?
end
def initialize(attributes = {})
self.attributes = attributes
end
def errors
@erro... | Ruby |
module ActiveMerchant
module PostsData
def included?(base)
base.class_eval do
attr_accessor :ssl_strict
end
end
def ssl_post(url, data, headers = {})
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.verify_mode = OpenSSL::SSL::VER... | Ruby |
module ActiveMerchant
module RequiresParameters
def requires!(hash, *params)
keys = hash.keys
params.each do |param|
if param.is_a?(Array)
raise ArgumentError.new("Missing required parameter: #{param}") unless keys.include?(param.first)
valid_options = param[1..-1]
... | Ruby |
module ActiveMerchant
class InvalidCountryCodeError < StandardError
end
class CountryCodeFormatError < StandardError
end
class CountryCode
attr_reader :value, :format
def initialize(value)
@value = value
detect_format
end
def to_s
value
end
private
def detect... | Ruby |
#--
# Copyright (c) 2005 Tobias Luetke
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
#... | Ruby |
# Figure out the root path of this app. The default method will assume that
# its the same as the location of the running Rakefile
ROOT = File.expand_path(FileUtils.pwd) + '/'
# Standard settings, you can override each of them using the environment
# e.g. rake cia EMAIL_TO=your@email.com
#
RAKE_TASK = ENV['RAKE_T... | Ruby |
#
# $Id: sanitize.rb 3 2005-04-05 12:51:14Z dwight $
#
# Copyright (c) 2005 Dwight Shih
# A derived work of the Perl version:
# Copyright (c) 2002 Brad Choate, bradchoate.com
#
# Permission is hereby granted, free of charge, to
# any person obtaining a copy of this software and
# associated documentation file... | Ruby |
require 'appwiki/base/base_controller.rb'
require 'appwiki/group/group.rb'
require 'appwiki/user/user.rb'
class GroupController < BaseController
def whereami() [__FILE__] end
#
# should be the leaf
#
def preload
@group = nil
@group = Group.find_by_uid(@workingpath.last) if @workingp... | Ruby |
require 'appwiki/user/user.rb'
require_gem 'acts_as_taggable'
# a map of users who belong to this group
class GroupsUser < ActiveRecord::Base
belongs_to :user
belongs_to :group
end
# groups
class Group < ActiveRecord::Base
acts_as_taggable
belongs_to :user
has_many :groups_users, :dependent => true... | Ruby |
# Disable Rake-environment-task framework detection by uncommenting/setting to false
# Warbler.framework_detection = false
# Warbler web application assembly configuration file
Warbler::Config.new do |config|
# Features: additional options controlling how the jar is built.
# Currently the following features ... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'pe... | Ruby |
# Use this hook to configure devise mailer, warden hooks and so forth. The first
# four configuration values can also be set straight in your models.
Devise.setup do |config|
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in DeviseMailer.
config.mailer_sender = "please-change-m... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| Ruby |
# Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary ... | Ruby |
# Be sure to restart your server when you modify this file.
Apposs::Application.config.session_store :cookie_store, :key => '_apposs_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "... | Ruby |
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a ... | Ruby |
Apposs::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is tur... | Ruby |
Apposs::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the w... | Ruby |
Apposs::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the t... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Apposs::Application.initialize!
| Ruby |
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
| Ruby |
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)
module Apposs
class Application < Rails::Applicati... | Ruby |
Apposs::Application.routes.draw do
devise_for :users
root :to => 'home#index'
get "home/index"
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign valu... | Ruby |
module HtmlSelectorsHelpers
# Maps a name to a selector. Used primarily by the
#
# When /^(.+) within (.+)$/ do |step, scope|
#
# step definitions in web_steps.rb
#
def selector_for(locator)
case locator
when "the page"
"html > body"
# Add more mappings here.
# Here... | Ruby |
module NavigationHelpers
# Maps a name to a path. Used by the
#
# When /^I go to (.+)$/ do |page_name|
#
# step definition in web_steps.rb
#
def path_to(page_name)
case page_name
when /^the home\s?page$/
'/'
# Add more mappings here.
# Here is an example that pulls ... | Ruby |
module ApplicationHelper
end
| Ruby |
module HomeHelper
end
| Ruby |
module AppsHelper
end
| Ruby |
class Machine < ActiveRecord::Base
belongs_to :room
belongs_to :app
has_many :directives
validates_inclusion_of :port,:in => 1..65535,:message => "port必须在1到65535之间"
validates_presence_of :name
before_create :fulfill_host
def fulfill_host
if self.host.nil? or self.host.empty?
sel... | Ruby |
class Directive < ActiveRecord::Base
belongs_to :machine
belongs_to :operation
default_scope order("operation_id asc, id asc")
scope :normal, where('operation_id <> 0')
def callback( isok, body)
self.isok = isok
self.response = body
isok ? ok : error
end
state_machine :st... | Ruby |
class Operation < ActiveRecord::Base
GLOBAL_ID = 0
belongs_to :operation_template
has_many :directives
has_many :machines, :through => :directives
belongs_to :operator, :class_name => 'User'
belongs_to :app
state_machine :state, :initial => :init do
event :fire do transition :init ... | Ruby |
class OperationTemplate < ActiveRecord::Base
belongs_to :app
has_many :operations
validates_length_of :expression,:minimum => 1,:message => "操作模板中的指令模板不能为空"
# operation_template 创建了一个操作,对于指定的一个operation_id,可以为之创建操作所对应的一组执行指令
def create_operation user, choosed_machine_ids
operation = operations.cre... | Ruby |
class DirectiveGroup < ActiveRecord::Base
has_many :directive_templates, :dependent => :nullify
def to_s
name
end
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.