code
stringlengths
1
1.73M
language
stringclasses
1 value
STDOUT.sync = true namespace :crawler do desc "Background task that runs continuously and does all the gathering." task :go => :environment do Crawler::Crawler.generate.go end end
Ruby
# lib/tasks/cron_print.rake # prints a set of cron jobs that should be installed by the admin using crontab -e namespace :cron do desc "Print cron jobs to be installed." task :print => :environment do every_5 = "0,5,10,15,20,25,30,35,40,45,50,55" jobs = ["#{every_5} * * * * cd #{Rails.root}; export GEM_HO...
Ruby
require 'rubygems' require 'zlib' JQUERY_MANIFEST_FILE = 'mask.jquery.json' JMASK_FILE = 'jquery.mask.js' JMASK_MIN_FILE = 'jquery.mask.min.js' JMASK_GZIP_FILE = 'jquery.mask.min.js.gz' JMASK_VERSION = `stepup version --next-release`.delete("\n") abort("No notes, do deal.") if JMASK_VERSION.empty? puts '# PUTTING NE...
Ruby
require 'mkmf' $CPPFLAGS = $CPPFLAGS + " -I../../include" $LDFLAGS = $LDFLAGS + " -L../../" $LIBS = $LIBS + " -lhpdf -lpng -lz" create_makefile 'hpdf'
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- demo.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appea...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- encryption.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- font_example.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright noti...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- arc_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear ...
Ruby
# # << Haru Free PDF Library 2.0.6 >> -- ext_gstate_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice ...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- ttfont_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appe...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- text_demo2.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- line_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear...
Ruby
# # << Haru Free PDF Library 2.0.6 >> -- slideshow_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice a...
Ruby
# Install hook code here
Ruby
ActionView::Base.send :include, BoxBuilder ActionView::Base.send :include, BoxFormBuilder ActiveRecord::Base.send :extend, BoxModel
Ruby
# desc "Explaining what the task does" # task :box_builder do # # Task goes here # end
Ruby
# Uninstall hook code here
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the box_builder plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the box_builder plugin...
Ruby
module BoxFormBuilder # BoxFormBuilder extends FormBuilder with various methods that can be # used to create "boxy" forms. class ActionView::Helpers::FormBuilder # include its parent module so we can get access to box_row from within # a form builder include BoxFormBuilder def fields(*fields) html = '' ...
Ruby
module BoxModel class FieldSetter @@all_fields = [] @@fields = {} def fields return @@fields end # def all_fields # return @@all_fields # end def method_missing(method_name, *args) # @@all_fields << method_name.to_sym @@fields.merge!(method_name.to_sym => args[0]) end end def ...
Ruby
module BoxBuilder # The box builder class is used from the "box" method. # When the text method is called, it sets it so that # fields? will return true. box is setup so that it won't # display at all if no fields have value class BoxBuilderClass def initialize(model) @model = model end # <%= f.box_...
Ruby
# This defines a deployment "recipe" that you can feed to capistrano # (http://manuals.rubyonrails.com/read/book/17). It allows you to automate # (among other things) the deployment of your application. # ============================================================================= # REQUIRED VARIABLES # =============...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Use a different logger for distributed setups # config.logger = SyslogLogger.new # Full error repor...
Ruby
# Settings specified here will take precedence over those in config/environment.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 webserver when you make code changes. config.ca...
Ruby
# Settings specified here will take precedence over those in config/environment.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 test suite and is wiped # and recreated between...
Ruby
# Be sure to restart your web server when you modify this file. # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way # ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION ...
Ruby
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb unless defined?(RAILS_ROOT) root_path = File.join(File.dirname(__FILE__), '..') unless RUBY_PLATFORM =~ /mswin32/ require 'pathname' root_path = Pathname.new(root_path).cleanpath(true).to_s end RAILS...
Ruby
ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action # ...
Ruby
module ReleasesHelper end
Ruby
module AdminHelper end
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper def editable_content(options) options[:content] = { :element => 'span' }.merge(options[:content]) options[:url] = {}.merge(options[:url]) options[:ajax] = { :okText => "'ok'", :cancelText => "'c...
Ruby
module TasksHelper end
Ruby
module UserStoriesHelper end
Ruby
module HomeHelper end
Ruby
module IterationsHelper end
Ruby
module ProjectsHelper end
Ruby
class Task < ActiveRecord::Base belongs_to :user_story end
Ruby
class UserStory < ActiveRecord::Base belongs_to :iteration has_many :tasks has_and_belongs_to_many :developers, :class_name => "User" end
Ruby
class Right < ActiveRecord::Base has_and_belongs_to_many :roles end
Ruby
class Project < ActiveRecord::Base has_many :releases end
Ruby
require 'digest/sha2' class User < ActiveRecord::Base has_and_belongs_to_many :roles validates_uniqueness_of :username def password=(pass) salt = [Array.new(6){rand(256).chr}.join].pack("m").chomp self.password_salt, self.password_hash = salt, Digest::SHA256.hexdigest(pass + salt) end def self....
Ruby
class Iteration < ActiveRecord::Base belongs_to :release has_many :user_stories end
Ruby
class Role < ActiveRecord::Base has_and_belongs_to_many :users has_and_belongs_to_many :rights end
Ruby
class Release < ActiveRecord::Base belongs_to :project has_many :iterations validates_presence_of :name validates_presence_of :project, :message => "must be assigned to a project" def validate unless start_at < end_at errors.add(:start_at, "must be earlier than end at date") end end ...
Ruby
class HomeController < ApplicationController skip_before_filter :check_authentication, :check_authorization end
Ruby
class ProjectsController < ApplicationController def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list @pro...
Ruby
class TasksController < ApplicationController def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list @task_pa...
Ruby
class AdminController < ApplicationController def signin if request.post? session[:user] = User.authenticate(params[:username], params[:password]).id redirect_to :action => session[:intended_action], :controller => session[:intended_controller] end rescue flash[:notice]...
Ruby
class ReleasesController < ApplicationController def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list @rele...
Ruby
class UserStoriesController < ApplicationController def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list @u...
Ruby
# Filters added to this controller will be run for all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base before_filter :check_authentication, :check_authorization, :except => [:...
Ruby
class IterationsController < ApplicationController def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list @it...
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.dirname(__FILE__) + '/../config/boot' require 'commands/breakpointer'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/breakpointer'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
class CreateTasks < ActiveRecord::Migration def self.up create_table :tasks do |t| t.column :title, :string t.column :description, :string end end def self.down drop_table :tasks end end
Ruby
class AssociateIterationToRelease < ActiveRecord::Migration def self.up add_column :iterations, :release_id, :integer end def self.down remove_column :iterations, :release_id end end
Ruby
class AssociateUserToRoleToRight < ActiveRecord::Migration def self.up create_table :roles_users, :id => false do |t| t.column :role_id, :integer t.column :user_id, :integer end create_table :rights_roles, :id => false do |t| t.column :right_id, :integer t.column :role_id, :inte...
Ruby
class AssociateTaskToUserStory < ActiveRecord::Migration def self.up add_column :tasks, :user_story_id, :integer end def self.down remove_column :tasks, :user_story_id end end
Ruby
class AddRoles < ActiveRecord::Migration def self.up Role.create(:name => "Admin") Role.create(:name => "Developer") Role.create(:name => "Customer") Role.create(:name => "Tester") end def self.down Role.delete(Role.find(:first, :conditions => [ "name = ?", "Admin" ]).id) Role.delete(Rol...
Ruby
class AssignRightsToRoles < ActiveRecord::Migration def self.up role = Role.find(:first, :conditions => [ "name = ?", "Admin" ]) # Project rights role.rights << Right.find(:first, :conditions => [ "name = ?", "New Project" ]) role.rights << Right.find(:first, :conditions => [ "name = ?", "Create Pro...
Ruby
class CreateProjects < ActiveRecord::Migration def self.up create_table :projects do |t| t.column :name, :string end end def self.down drop_table :projects end end
Ruby
class AssociateUserStoriesToUsers < ActiveRecord::Migration def self.up create_table :user_stories_users, :id => false do |t| t.column :user_story_id, :integer t.column :user_id, :integer end end def self.down drop_table :user_stories_users end end
Ruby
class CreateRoles < ActiveRecord::Migration def self.up create_table :roles do |t| t.column :name, :string end end def self.down drop_table :roles end end
Ruby
class AssociateUserStoriesToIteration < ActiveRecord::Migration def self.up add_column :user_stories, :iteration_id, :integer end def self.down remove_column :user_stories, :iteration_id end end
Ruby
class CreateIterations < ActiveRecord::Migration def self.up create_table :iterations do |t| t.column :name, :string end end def self.down drop_table :iterations end end
Ruby
class AddRights < ActiveRecord::Migration def self.up # Project rights Right.create(:name => "New Project", :controller => "projects", :action => "new") Right.create(:name => "Create Project", :controller => "projects", :action => "create") Right.create(:name => "Edit Project", :controller => "projec...
Ruby
class AssociateReleaseToProject < ActiveRecord::Migration def self.up add_column :releases, :project_id, :integer end def self.down remove_column :releases, :project_id end end
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.column :username, :string t.column :password_salt, :string t.column :password_hash, :string end end def self.down drop_table :users end end
Ruby
class CreateReleases < ActiveRecord::Migration def self.up create_table :releases do |t| t.column :name, :string t.column :start_at, :date t.column :end_at, :date end end def self.down drop_table :releases end end
Ruby
class AddUsers < ActiveRecord::Migration def self.up admin = User.create(:username => "Admin") admin.password = "admin" admin.roles << Role.find(:first, :conditions => [ "name = ?", "Admin" ]) admin.save guest = User.create(:username => "Guest") guest.password = "guest" guest.save ...
Ruby
class CreateUserStories < ActiveRecord::Migration def self.up create_table :user_stories do |t| t.column :title, :string t.column :description, :string end end def self.down drop_table :user_stories end end
Ruby
class CreateRights < ActiveRecord::Migration def self.up create_table :rights do |t| t.column :name, :string t.column :controller, :string t.column :action, :string end end def self.down drop_table :rights end end
Ruby
# ============================================================================= # A set of rake tasks for invoking the Capistrano automation utility. # ============================================================================= # Invoke the given actions via Capistrano def cap(*parameters) begin require 'rubyg...
Ruby
#!C:/ruby/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired...
Ruby
#!C:/ruby/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired...
Ruby
#!C:/ruby/bin/ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log #...
Ruby
#!C:/ruby/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired...
Ruby