code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
ENV['RSPEC'] = 'true' # allows autotest to discover rspec
ENV['AUTOTEST'] = 'true' # allows autotest to run w/ color on linux
system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) ||
$stderr.puts("Unable to find auto... | Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
if vendored_cucumber_bin
load File.expand_path(vendored_cucumber_bin)
else
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'cucumber'
load Cucumber::BINARY
end
| Ruby |
#!/usr/bin/env ruby
if ARGV.any? {|arg| %w[--drb -X --generate-options -G --help -h --version -v].include?(arg)}
require 'rubygems' unless ENV['NO_RUBYGEMS']
else
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.dirname(__FILE__) + "/../config/enviro... | Ruby |
class CreateRanks < ActiveRecord::Migration
def self.up
create_table :ranks do |t|
t.string :name
t.string :abbr
t.integer :service_branch_id
t.integer :value
t.string :grade
t.timestamps
end
end
def self.down
drop_table :ranks
end
end
| Ruby |
class CreateEmployments < ActiveRecord::Migration
def self.up
create_table :employments do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :employments
end
end
| Ruby |
class CreateStatuses < ActiveRecord::Migration
def self.up
create_table :statuses do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :statuses
end
end
| Ruby |
class CreateOrganizations < ActiveRecord::Migration
def self.up
create_table :organizations do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :organizations
end
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :email
t.string :first_name, :null => false, :limit => 50
t.string :last_name, :null => false, :limit => 75
t.string :phone_number, :limit => 25
t.integer :organization_id
t.integ... | Ruby |
class CreateServiceBranches < ActiveRecord::Migration
def self.up
create_table :service_branches do |t|
t.string :name
t.string :abbr
t.timestamps
end
end
def self.down
drop_table :service_branches
end
end
| Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Major.create(:name... | Ruby |
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment'))
require 'spec/autorun'
require 'spec/rails'
# Uncomment the next line to use webrat's matchers... | Ruby |
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
rspec_gem_dir = nil
Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir|
rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb")
end
rspec_plugin_dir = File.expand_path(Fil... | 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 values o... | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def page_title
@title ? "#{@title} - AFSMS" : "AFSMS"
end
def content_for?(name)
instance_variable_get("@content_for_#{name.to_s}").present?
end
def js(*args)
content_for(:js){ java... | Ruby |
module UsersHelper
end
| Ruby |
module UserSessionsHelper
end
| Ruby |
module DashboardsHelper
end
| Ruby |
module AnnouncementsHelper
end
| Ruby |
class Announcement < ActiveRecord::Base
belongs_to :user
class << self
def latest(amount = 20)
Announcement.all(:limit => amount, :order => 'created_at DESC')
end
end
end
| Ruby |
class Status < ActiveRecord::Base
has_many :users
end
| Ruby |
class User < ActiveRecord::Base
acts_as_authentic
acts_as_tree
acts_as_authorization_subject
acts_as_authorization_object
has_many :announcements
belongs_to :organization
belongs_to :status
belongs_to :employment
belongs_to :rank
validates_presence_of :email, :first_name, :last_name, :organiza... | Ruby |
class Organization < ActiveRecord::Base
has_many :users
end
| Ruby |
class UserSession < Authlogic::Session::Base
end | Ruby |
class Role < ActiveRecord::Base
acts_as_authorization_role
end
| Ruby |
class Rank < ActiveRecord::Base
has_many :users
end
| Ruby |
class Employment < ActiveRecord::Base
has_many :users
end
| Ruby |
class UserSessionsController < ApplicationController
access_control do
allow logged_in, :to => :destroy
allow anonymous, :to => [:new, :create]
end
def new
@user_session = UserSession.new
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
... | Ruby |
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance_tag|
"<span class='field_error'>#{html_tag}</span>"
end
class ApplicationController < ActionController::Base
helper :all
helper_method :current_user, :logged_in?, :redirect_back_or_default
filter_parameter_logging :password, :password_confirma... | Ruby |
class DashboardsController < ApplicationController
access_control do
allow logged_in
end
def show
@announcements = Announcement.latest
@subordinates = current_user.children.all
end
end
| Ruby |
class UsersController < ApplicationController
def index
@users = User.all
end
def show
@user = User.find(params[:id])
end
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
flash[:success] = 'User created successfully'
redirect_to... | Ruby |
class AnnouncementsController < ApplicationController
def index
@announcements = Announcement.all(:order => 'created_by DESC')
end
def show
@announcement = Announcement.find(params[:id])
end
end
| Ruby |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
if ARGV.any? {|arg| %w[--drb -X --generate-options -G --help -h --version -v].include?(arg)}
require 'rubygems' unless ENV['NO_RUBYGEMS']
else
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.dirname(__FILE__) + "/../config/enviro... | Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
if vendored_cucumber_bin
load File.expand_path(vendored_cucumber_bin)
else
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'cucumber'
load Cucumber::BINARY
end
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
ENV['RSPEC'] = 'true' # allows autotest to discover rspec
ENV['AUTOTEST'] = 'true' # allows autotest to run w/ color on linux
system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) ||
$stderr.puts("Unable to find auto... | Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
ENV['RSPEC'] = 'true' # allows autotest to discover rspec
ENV['AUTOTEST'] = 'true' # allows autotest to run w/ color on linux
system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) ||
$stderr.puts("Unable to find auto... | Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
if vendored_cucumber_bin
load File.expand_path(vendored_cucumber_bin)
else
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'cucumber'
load Cucumber::BINARY
end
| Ruby |
#!/usr/bin/env ruby
if ARGV.any? {|arg| %w[--drb -X --generate-options -G --help -h --version -v].include?(arg)}
require 'rubygems' unless ENV['NO_RUBYGEMS']
else
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.dirname(__FILE__) + "/../config/enviro... | Ruby |
bundle_path 'vendor/bundler_gems'
gem 'rails', '2.3.5'
gem 'rack', '1.0.1'
gem 'acts_as_tree'
gem 'authlogic'
gem 'acl9', :require_as => nil
gem 'will_paginate'
only :test do
gem 'cucumber'
gem 'cucumber-rails', :require_as => nil
gem 'rspec'
gem 'rspec-rails', :require_as => nil
gem 'factory_girl'
gem '... | Ruby |
class CreateRoles < ActiveRecord::Migration
def self.up
create_table :roles, :force => true do |t|
t.string :name, :limit => 40
t.string :authorizable_type, :limit => 40
t.integer :authorizable_id
t.timestamps
end
create_table :roles_users, :id => false, :force => true do |t|
... | Ruby |
class CreateEmployments < ActiveRecord::Migration
def self.up
create_table :employments do |t|
t.string :name, :null => false
t.timestamps
end
end
def self.down
drop_table :employments
end
end
| Ruby |
class CreateStatuses < ActiveRecord::Migration
def self.up
create_table :statuses do |t|
t.string :name, :null => false
t.timestamps
end
end
def self.down
drop_table :statuses
end
end
| Ruby |
class CreateAnnouncements < ActiveRecord::Migration
def self.up
create_table :announcements do |t|
t.string :title
t.string :body
t.integer :user_id
t.timestamps
end
end
def self.down
drop_table :announcements
end
end
| Ruby |
class CreateRanks < ActiveRecord::Migration
def self.up
create_table :ranks do |t|
t.integer :value, :null => false
t.string :full_name
t.string :short_name, :null => false
t.string :grade
t.timestamps
end
end
def self.down
drop_table :ranks
end
end
| Ruby |
class CreateOrganizations < ActiveRecord::Migration
def self.up
create_table :organizations do |t|
t.string :name, :null => false
t.timestamps
end
end
def self.down
drop_table :organizations
end
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :email
t.string :first_name, :limit => 50, :null => false
t.string :last_name, :limit => 50, :null => false
t.string :phone_number, :limit => 10
t.integer :parent_id
t.integer :... | Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Major.create(:name... | Ruby |
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment'))
require 'spec/autorun'
require 'spec/rails'
# Uncomment the next line to use webrat's matchers... | Ruby |
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
rspec_gem_dir = nil
Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir|
rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb")
end
rspec_plugin_dir = File.expand_path(Fil... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class ActiveSupport::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test da... | Ruby |
require 'fileutils'
# Install hook code here
public_dir = File.dirname(__FILE__) + "/../../../public"
plugin_dir = File.dirname(__FILE__) + "/public"
FileUtils.install(plugin_dir + "/javascripts/SWFUpload.js", public_dir + "/javascripts")
FileUtils.install(plugin_dir + "/javascripts/swfupload_callbacks.js", public_di... | Ruby |
# Include hook code here
require 'assay_depot/activeupload'
| Ruby |
class CreateAttachments < ActiveRecord::Migration
def self.up
create_table :attachments, :force => true do |t|
t.column :filename, :string
t.column :size, :integer
t.column :attachable_id, :integer
t.column :attachable_type, :string
t.column :created_at, :dat... | Ruby |
class Attachment < ActiveRecord::Base
belongs_to :attachable, :polymorphic => true
def dirname
padded_id = sprintf("%6.6d", id)
dirnames = padded_id.match("(...)(...)")
dirname = "public/attachments/#{dirnames[1]}/#{dirnames[2]}"
end
def path
"#{dirname}/#{filename}"
end
def to_label
... | Ruby |
require 'fileutils'
class AttachmentsController < ApplicationController
def create
@f = Attachment.new()
if @f.save
render :text => "#{@f.id}"
end
end
def upload
@f = Attachment.find(params[:id])
@f.filename = params[:Filename]
@f.size = params[:Filedata].size
if @f.save
... | Ruby |
class ActiveuploadGenerator < Rails::Generator::Base
def manifest
record do |m|
# m.directory "lib"
# m.template 'README', "README"
m.template 'model.rb',
File.join('app/models',
"attachment.rb")
m.template 'controller.rb',
Fi... | Ruby |
require 'fileutils'
# Uninstall hook code here
public_dir = File.dirname(__FILE__) + "/../../../public"
FileUtils.rm(public_dir + "/javascripts/SWFUpload.js")
FileUtils.rm(public_dir + "/javascripts/swfupload_callbacks.js")
FileUtils.rm(public_dir + "/stylesheets/swfupload_theme.css")
FileUtils.rm(public_dir + "/imag... | Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the file_upload plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the file_upload plugin... | Ruby |
# FileUpload
module ActionView
module Helpers
module ActiveUploadHelper
def attachments_field(options = {})
defaults = { :filesize => 30720, :filetypes => [ "*.*" ] }
options = defaults.merge(options)
html = ""
attachment_ids = Array.new
object.attachments.each do ... | Ruby |
# desc "Explaining what the task does"
# task :acts_as_messages do
# # Task goes here
# end
| Ruby |
class ActsAsMessagesMigration < ActiveRecord::Migration
def self.up
create_table :messages do |t|
t.integer :sender_id, :null => false
t.integer :receiver_id, :null => false
t.integer :parent_id, :default => 0
t.string :title, :null => false
t.text :body
t.integer :r... | Ruby |
# ActsAsMessages Generator Model
class Message < ActiveRecord::Base
belongs_to :sender, :class_name => 'User', :foreign_key => 'sender_id'
belongs_to :receiver, :class_name => 'User', :foreign_key => 'receiver_id'
validates_presence_of :title,:body
# make the message is read
def mark_read
update_... | Ruby |
class ActsAsMessagesGenerator < Rails::Generator::Base
def manifest
record do |m|
# Models
m.file "models/message.rb", "app/models/message.rb"
#Migrations
m.migration_template 'migration.rb', 'db/migrate' ,
:migration_file_name => "acts_as_messages_migration"
m.re... | Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the acts_as_messages plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the acts_as_messa... | Ruby |
# Include hook code here
require 'acts_as_messages'
# add acts_as_messages into ActiveRecord::Base
#ActiveRecord::Base.send(:include, Raecoo::Acts::Messages) | Ruby |
# ActsAsMessages
module Raecoo
module Acts #:nodoc:
module Messages #:nodoc:
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def acts_as_messages
has_many :sent_messages, :class_name => 'Message', :foreign_key => "sender_id", ... | Ruby |
require 'active_record'
module ArtOfRails
module Rdf #:nodoc:
module Acts #:nodoc:
def self.included(base)
base.extend(ClassMethods)
end
# Class-level methods
module ClassMethods
# Provides a to_rdf function for model obejcts and arrays of rdf-enabled object... | Ruby |
module ArtOfRails
module Rdf
class Namespaces
@@namespaces = {
:rdf => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
:rdfs => 'http://www.w3.org/2000/01/rdf-schema#',
:owl => 'http://www.w3.org/2002/07/owl#',
:xsd => 'http://www.w3.org/2001/XMLSchema#',
:foaf =>... | Ruby |
require 'attribute'
module ArtOfRails
module Rdf
module ActiveRecord
class RdfSerializer #:nodoc:
attr_accessor :global_options
def initialize(rdf_source, options = {})
@rdf_source, @global_options = rdf_source, options.dup
end
def options_for... | Ruby |
module ArtOfRails
module Rdf
module ActiveRecord
class RdfSerializer #:nodoc:
class Attribute #:nodoc:
attr_reader :name, :value, :type, :property
def initialize(name, record)
@name = name
@record = record
property = @record.clas... | Ruby |
require 'acts_as_rdf/rdf_serializer'
require 'acts_as_rdf/namespaces'
require 'acts_as_rdf/core'
| Ruby |
class CreateMessagesRecipients < ActiveRecord::Migration
def self.up
create_table :messages_recipients, :id => false do |t|
t.column :message_id, :integer, :null => false
t.column :recipient_id, :integer, :null => false
end
#i use foreign keys but its a custom method, so i'm leaving it up... | Ruby |
class CreateMessages < ActiveRecord::Migration
def self.up
create_table :messages do |t|
t.column :body, :text
t.column :subject, :string, :default => ""
t.column :headers, :text
t.column :sender_id, :integer, :null => false
t.column :conversation_id, :integer
t.column :... | Ruby |
class CreateMail < ActiveRecord::Migration
def self.up
create_table :mail do |t|
t.column :user_id, :integer, :null => false
t.column :message_id, :integer, :null => false
t.column :conversation_id, :integer
t.column :read, :boolean, :default => false
t.column :trashed, :boolean... | Ruby |
class CreateConversations < ActiveRecord::Migration
def self.up
create_table :conversations do |t|
t.column :subject, :string, :default => ""
t.column :created_at, :datetime, :null => false
end
end
def self.down
drop_table :conversations
end
end
| Ruby |
class Message < ActiveRecord::Base
#any additional info that needs to be sent in a message (ex. I use these to determine request types)
serialize :headers
class_inheritable_accessor :on_deliver_callback
protected :on_deliver_callback
belongs_to :sender, :class_name => 'User', :foreign_key => 'sen... | Ruby |
class Mail < ActiveRecord::Base
self.table_name = "mail"
belongs_to :message
belongs_to :user
belongs_to :conversation
#sets the read attribute of the mail message to true.
def mark_as_read()
update_attribute('read', true)
end
#sets the read attribute of the mail message to false.
... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.