code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
require 'cards'
require 'board'
require 'helpers'
Surface.autoload_dirs << [File.join(File.dirname(__FILE__), 'images')]
MOVE_DELTAS = [[0, -1], [1, 0], [0, 1], [-1, 1], [-1, 0], [-1, -1]]
class GameSprite
attr_accessor :player
attr_accessor :hp
include Sprites::Sprite
HP_FONT = TTF.new('times_new_yorker.ttf', 12... | Ruby |
require 'yaml'
#Fixes the coloring for windows
if RUBY_PLATFORM =~ /(win|w)32/
class String
%w{yellow red blue green underline bold}.each do |m|
define_method(m){ self }
end
end
else
require 'colorize'
end
CARD_DIR = File.join(File.dirname(__FILE__), 'cards')
RANGE_REPR_TEMPLATE = <<-TEMPLATE
... | Ruby |
class MouseEventManager
def initialize(menu)
end
def tell(event)
end
end
class KeyEventManager
def initialize(menu)
end
def tell(event)
end
end
| Ruby |
#!/usr/bin/ruby
require 'optparse'
require 'ostruct'
def usage()
puts "Usage: udpstat [-6] [-KB|-MB] <interval> <count>"
puts
puts " Options:"
puts " -6 - IPv6 statistics (by default IPv4 is used)"
puts " -KB - show utilization in KB"
puts " -MB - show utilization in MB"
puts
... | 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 'p... | Ruby |
# Be sure to restart your server when you modify this file.
# These settings change the behavior of Rails 2 apps and will be defaults
# for Rails 3. You can remove this initializer when Rails 3 is released.
if defined?(ActiveRecord)
# Include Active Record class name as root for JSON serialized output.
Act... | 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 cookie session data integrity.
# If you change this key, all old sessions 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 attacks... | Ruby |
# A Site key gives additional protection against a dictionary attack if your
# DB is ever compromised. With no site key, we store
# DB_password = hash(user_password, DB_user_salt)
# If your database were to be compromised you'd be vulnerable to a dictionary
# attack on all your stupid users' passwords. With a... | 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 do debug a ... | 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
# Full error reports are disabled and caching is turned on
config.action_controller.consider_al... | 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.
conf... | 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 be... | Ruby |
# Be sure to restart your server when you modify this file
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'bo... | Ruby |
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
... | Ruby |
ActionController::Routing::Routes.draw do |map|
map.logout '/logout', :controller => 'sessions', :action => 'destroy'
map.login '/login', :controller => 'sessions', :action => 'new'
map.register '/register', :controller => 'users', :action => 'create'
map.signup '/signup', :controller => 'users', :action =>... | Ruby |
module NavigationHelpers
# Maps a name to a path. Used by the
#
# When /^I go to (.+)$/ do |page_name|
#
# step definition in webrat_steps.rb
#
def path_to(page_name)
case page_name
when /the homepage/
'/'
when /the list of roles/
admin_roles_path
# A... | Ruby |
# Sets up the Rails environment for Cucumber
ENV["RAILS_ENV"] ||= "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/rails/world'
require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
Cucumber::Rails.use_transact... | Ruby |
#
# Where to go
#
#
# GET
# Go to a given page.
When "$actor goes to $path" do |actor, path|
case path
when 'the home page' then get '/'
else get path
end
end
# POST -- Ex:
# When she creates a book with ISBN: '0967539854' and comment: 'I love this book' and rating: '4'
... | Ruby |
# The flexible code for resource testing came out of code from Ben Mabey
# http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/
#
# Construct resources
#
#
# Build a resource as described, store it as an @instance variable. Ex:
# "Given a user with login: 'mojojojo'"
# produces... | Ruby |
Before do
Fixtures.reset_cache
fixtures_folder = File.join(RAILS_ROOT, 'spec', 'fixtures')
Fixtures.create_fixtures(fixtures_folder, "users")
end
# Make visible for testing
ApplicationController.send(:public, :logged_in?, :current_user, :authorized?)
| Ruby |
# If you have a global stories helper, move this line there:
include AuthenticatedTestHelper
# Most of the below came out of code from Ben Mabey
# http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/
# These allow exceptions to come through as opposed to being caught and having non-h... | Ruby |
#
# What you should see when you get there
#
#
# Destinations. Ex:
# She should be at the new kids page
# Tarkin should be at the destroy alderaan page
# The visitor should be at the '/lolcats/download' form
# The visitor should be redirected to '/hi/mom'
#
# It doesn't know anything about actual r... | Ruby |
Given /^I have roles name (.+)$/ do |names|
names.split(', ').each do |name|
Role.create!(:name => name)
end
end
When /^I go to list of roles$/ do
end
| Ruby |
class MailingsWorker < Workling::Base
def send_mailing(options)
@user = User.find(options[:user_id])
@issue = Issue.find(options[:issue_id])
if options[:way] == "sent"
OrderMailer.deliver_sent(@user, @issue, options[:url])
elsif options[:way] == "reopen"
OrderMailer.deliver_reopen(@... | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def in_place_select_editor_field(object, method, tag_options = {}, in_place_editor_options = {})
tag = ::ActionView::Helpers::InstanceTag.new(object, method, self)
tag_options = { :tag => "sp... | Ruby |
module UsersHelper
#
# Use this to wrap view elements that the user can't access.
# !! Note: this is an *interface*, not *security* feature !!
# You need to do all access control at the controller level.
#
# Example:
# <%= if_authorized?(:index, User) do link_to('List all users', users_path)... | Ruby |
module IssuesHelper
def trans_issue_state_to_chs(string)
case string
when "submitted"
"未分配"
when "assigned"
"打开"
when "resolved"
"待测试"
when "finished"
"已关闭"
when "reopen"
"重新开启"
when "suspend"
"挂起"
end
end
end
| Ruby |
module TagsHelper
def through_line(issue, text)
if issue.state == "resolved"
text = "\<s\>" + text + "\</\s\>"
else
text
end
end
end
| Ruby |
module SessionsHelper
end | Ruby |
module CommentHelper
end
| Ruby |
module MemoesHelper
end
| Ruby |
module IndexHelper
end
| Ruby |
module ProjectsHelper
def trans_current_state_to_chs(string)
case string
when "need_to_release"
"未量产"
when "released"
"已量产"
when "freeze"
"冻结"
end
end
def get_project_state_op(string)
case string
when "need_to_release"
"量产"
when "released"
... | Ruby |
module RequirementsHelper
end
| Ruby |
module RolesHelper
end
| Ruby |
class Log < ActiveRecord::Base
belongs_to :issue
belongs_to :user
end
| Ruby |
class Memo < ActiveRecord::Base
belongs_to :user
end
| Ruby |
class Project < ActiveRecord::Base
has_many :requirements
has_many :issues
has_many :tags
belongs_to :user
state_machine :state, :initial => :need_to_release do
after_transition any => :released, :do => :zero_priority
after_transition any => :freeze, :do => :under_zero_priority
... | Ruby |
class OrderMailer < ActionMailer::Base
def sent(user, issue, url) #sent_at = Time.now
subject '来自RM的通知'
recipients user.email
from 'jira@mikimobile.com'
sent_on Time.now
body :user => user, :issue => issue, :url => url
end
def reopen(user, issue, url) #... | Ruby |
class Unit < ActiveRecord::Base
belongs_to :user
belongs_to :issue
end
| Ruby |
class Tag < ActiveRecord::Base
has_many :taggings, :conditions => ["tag_from IS NOT NULL"], :order => 'taggable_id ASC'
has_many :issues, :through => :taggings
#has_many :tester_issues, :through => :taggings, :source => :issue, :conditions => ["taggings.tag_from = ?", "tester"]
#has_many :system_issues, :th... | Ruby |
class Role < ActiveRecord::Base
has_and_belongs_to_many :users
end | Ruby |
class Requirement < ActiveRecord::Base
belongs_to :user
belongs_to :project
has_many :taggings, :as => :taggable
has_many :tags, :through => :taggings
state_machine :state, :initial => :assigned do
event :assign do
transition :submitted => :assigned
end
event :working do
... | Ruby |
class Tagging < ActiveRecord::Base
belongs_to :tag
belongs_to :issue
belongs_to :requirement
belongs_to :taggable, :polymorphic => true
end
| Ruby |
class Issue < ActiveRecord::Base
#has_and_belongs_to_many :users
has_many :units
has_many :users, :through => :units
has_many :reporter, :through => :units, :source => :user, :conditions => ["units.unit_role = ?", "reporter"]
has_many :developer, :through => :units, :source => :user, :conditions => ["u... | Ruby |
class MemosController < ApplicationController
before_filter :login_required
def index
@memoes = current_user.memos.paginate :page => params[:page],
:order => 'created_at DESC',
:per_page => 10
end
def new
@... | Ruby |
class IssuesController < ApplicationController
before_filter :login_required
helper [:Issues, :Projects]
protect_from_forgery :except => :change_developer_finish
def index
if params[:project_id] != nil
@project = Project.find(params[:project_id])
@issues = []
if params[:i... | Ruby |
class ProjectsController < ApplicationController
before_filter :login_required
helper [:Projects,:Issues]
require_role ["admin","pdm"], :only => [:edit, :change_state]
in_place_edit_for :project, :priority
def index
#@projects = Project.all(:conditions => ["state != ?", "freeze"], :order => ... | Ruby |
class CommentsController < ApplicationController
def index
end
def create
@comment = Log.new
@issue = Issue.find(params[:issue_id])
@comment = @issue.logs.build(params[:comment])
@comment.user_id = current_user.id
@comment.log_type = "user"
@comment.save unless @comment.... | Ruby |
# This controller handles the login/logout function of the site.
class SessionsController < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
# include AuthenticatedSystem
before_filter :login_required, :except => [:new, :create]
# render new.rhtml
d... | Ruby |
class Admin::RolesController < ApplicationController
before_filter :login_required
layout "admin"
require_role ["admin"]
def index
if current_user.has_role?("admin")
@roles = Role.find(:all)
else
@roles = Role.find(:all, :conditions => ["name != ?", "admin"])
end
re... | Ruby |
class Admin::UsersController < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
# include AuthenticatedSystem
require_role ["admin","pdm"]
before_filter :login_required
layout "admin"
# render new.rhtml
def new
@user = User.new
en... | Ruby |
class RequirementsController < ApplicationController
before_filter :login_required
#layout "projects"
protect_from_forgery :except => :change_developer_finish
in_place_edit_for :requirement, :priority
def index
unless params[:user_id] == nil
@user = User.find(params[:user_id])
... | Ruby |
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
# AuthenticatedSystem must be included for RoleRequirement, and is provided by installing acts_as_authentic... | Ruby |
class IndexController < ApplicationController
before_filter :login_required
def index
@projects = Project.all(:conditions => ["state != ?", "freeze"], :order => 'priority DESC, should_be_finish_time ASC')
end
end
| Ruby |
class TagsController < ApplicationController
before_filter :login_required
require_role ["admin","pdm"], :only => [:fill, :in]
def index
@need_to_release_tags = Tag.paginate :page => params[:page], :conditions => ["state = ?", "working"],:order => 'should_release_at ASC', :per_page => 20
@relea... | Ruby |
class UsersController < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
# include AuthenticatedSystem
before_filter :login_required
# render new.rhtml
def new
end
def create
end
def index
@users = User.get_roles_users("pdm"... | 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/dbconsole'
| 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 |
require 'pp'
puts '=> Loading Rails...'
require File.dirname(__FILE__) + '/../config/environment'
require File.dirname(__FILE__) + '/../vendor/plugins/workling/lib/workling/remote/invokers/poller'
require File.dirname(__FILE__) + '/../vendor/plugins/workling/lib/workling/routing/class_and_method_routing'
put... | 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'
$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/... | Ruby |
#!/usr/bin/env ruby
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
puts "Loading Rails environment"
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.dirname(__FILE__) + "/../config/environment") unless defined?(RAILS_ROOT)
require 'optparse'
require 'spec/rails/spec_server'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
workling = File.join(File.dirname(__FILE__), '..', 'vendor', 'plugins', 'workling', 'script', 'listen.rb')
options = {
:app_name => "workling",
:ARGV => ARGV,
:dir_mode => :normal,
:dir => 'log',
:log_output => true,
:mult... | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
begin
load File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/cucumber/bin/cucumber")
rescue LoadError => e
raise unless e.to_s =~ /cucumber/
require "rubygems"
load File.join(Gem.bindir, "cucumber")
end | Ruby |
#!/usr/bin/env ruby
puts "\n>>>>>"
puts ">>>>> This script has been DEPRACATED. Please use script/workling_client instead!"
puts ">>>>>\n\n"
load File.dirname(__FILE__) + '/workling_client' | 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
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... | Ruby |
@routing = Workling::Routing::ClassAndMethodRouting.new
unnormalized = REXML::Text::unnormalize(STDIN.read)
message, command, args = *unnormalized.match(/(^[^ ]*) (.*)/)
options = Hash.from_xml(args)["hash"]
if workling = @routing[command]
options = options.symbolize_keys
method_name = @routing.method_name(... | Ruby |
#!/usr/bin/env ruby
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
puts "Loading Rails environment"
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.dirname(__FILE__) + "/../config/environment") unless defined?(RAILS_ROOT)
require 'optparse'
require 'spec/rails/spec_server'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
workling = File.join(File.dirname(__FILE__), '..', 'vendor', 'plugins', 'workling', 'script', 'listen.rb')
options = {
:app_name => "workling",
:ARGV => ARGV,
:dir_mode => :normal,
:dir => 'log',
:log_output => true,
:mult... | 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
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... | Ruby |
#!/usr/bin/env ruby
puts "\n>>>>>"
puts ">>>>> This script has been DEPRACATED. Please use script/workling_client instead!"
puts ">>>>>\n\n"
load File.dirname(__FILE__) + '/workling_client' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
begin
load File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/cucumber/bin/cucumber")
rescue LoadError => e
raise unless e.to_s =~ /cucumber/
require "rubygems"
load File.join(Gem.bindir, "cucumber")
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/... | Ruby |
class CreateRoles < ActiveRecord::Migration
def self.up
create_table "roles" do |t|
t.string :name
end
# generate the join table
create_table "roles_users", :id => false do |t|
t.integer "role_id", "user_id"
end
add_index "roles_users", "role_id"
add_index "role... | Ruby |
class CreateProjects < ActiveRecord::Migration
def self.up
create_table :projects do |t|
t.string :name
t.string :chs_name
t.text :description
t.string :state
t.integer :priority, :default =>... | Ruby |
require 'active_record/fixtures'
class AddDefaultData < ActiveRecord::Migration
def self.up
down
directory = File.join(File.dirname(__FILE__), 'dev_data' )
Fixtures.create_fixtures(directory, "users" )
Fixtures.create_fixtures(directory, "roles" )
Fixtures.create_fixtures(directory, "ro... | Ruby |
class CreateTaggings < ActiveRecord::Migration
def self.up
create_table :taggings do |t|
t.references :tag
t.string :tag_from
t.integer :taggable_id
t.string :taggable_type
t.timestamps
end
add_index "taggi... | Ruby |
class CreateRequirements < ActiveRecord::Migration
def self.up
create_table :requirements do |t|
t.string :title
t.integer :reqid
t.integer :priority, :default => 0
t.text :description
t.string :state
... | Ruby |
class CreateUnits < ActiveRecord::Migration
def self.up
create_table :units do |t|
t.integer :issue_id
t.integer :user_id
t.string :unit_role
t.timestamps
end
add_index "units", ["issue_id"], :name => "index_units_on_issue_id"
... | Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table "users", :force => true do |t|
t.column :login, :string, :limit => 40
t.column :name, :string, :limit => 100, :default => '', :null => true
t.column :email, :str... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.