code
stringlengths
1
1.73M
language
stringclasses
1 value
# Copyright 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
Ruby
# Copyright 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
Ruby
# Copyright 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
Ruby
# Copyright 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
Ruby
# Copyright 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
Ruby
# Copyright 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
Ruby
# Copyright 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
Ruby
# Copyright 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
Ruby
# Copyright 2012 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
# include the utils rb file which has extra functionality for the ext theme dir = File.dirname(__FILE__) require File.join(dir, 'lib', 'utils.rb') # register ext4 as a compass framework Compass::Frameworks.register 'ext4', dir
Ruby
module ExtJS4 module SassExtensions module Functions module Utils def parsebox(list, n) assert_type n, :Number if !n.int? raise ArgumentError.new("List index #{n} must be an integer") elsif n.to_i < 1 raise ArgumentError.new("List index #{n} must...
Ruby
# $ext_path: This should be the path of the Ext JS SDK relative to this file $ext_path = "../../extjs" # sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder # Generally this will be in a resources/sass folder # <root>/resources/sass sass_path = File.dirname(__FILE__) # css_pat...
Ruby
# $ext_path: This should be the path of where the ExtJS SDK is installed # Generally this will be in a lib/extjs folder in your applications root # <root>/lib/extjs $ext_path = "../../" # sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder # Generally this will be in a resource...
Ruby
# include the utils rb file which has extra functionality for the ext theme dir = File.dirname(__FILE__) require File.join(dir, 'lib', 'utils.rb') # register ext4 as a compass framework Compass::Frameworks.register 'ext4', dir
Ruby
module ExtJS4 module SassExtensions module Functions module Utils def parsebox(list, n) assert_type n, :Number if !n.int? raise ArgumentError.new("List index #{n} must be an integer") elsif n.to_i < 1 raise ArgumentError.new("List index #{n} must...
Ruby
# $ext_path: This should be the path of the Ext JS SDK relative to this file $ext_path = "../../extjs" # sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder # Generally this will be in a resources/sass folder # <root>/resources/sass sass_path = File.dirname(__FILE__) # css_pat...
Ruby
# $ext_path: This should be the path of where the ExtJS SDK is installed # Generally this will be in a lib/extjs folder in your applications root # <root>/lib/extjs $ext_path = "../../" # sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder # Generally this will be in a resource...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
# -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # All Vagrant configuration is done here. The most common configuration # options are documented and commen...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "stylesheets" sass_dir = "sass" images_dir = "images" javascripts_dir = "javascripts" # You can select your preferred output style here (can be overridden via the command line): # o...
Ruby
#!/usr/bin/env ruby require 'rbconfig' require 'erb' # use this script to start and stop the application, it allows you to skip the packaging step by # using an alterate chrome.manifest file that uses file:// instead of jar files module Chrome class Manifest def initialize(root,mode) @root = root @mode = mo...
Ruby
#!/usr/bin/env ruby require 'rbconfig' require 'erb' # use this script to start and stop the application, it allows you to skip the packaging step by # using an alterate chrome.manifest file that uses file:// instead of jar files module Chrome class Manifest def initialize(root,mode) @root = root @mode = mo...
Ruby
#!/usr/bin/env ruby require 'optparse' options = OptionParser.new { |opts| opts.banner = "Usage: #{$0} (view|script|component) name [options]" opts.separator "" opts.separator "Specific options:" } # totally stealing the concepts from rails here and applying them to mozilla environment # xul files are like views ...
Ruby
#!/usr/bin/env ruby require 'optparse' options = OptionParser.new { |opts| opts.banner = "Usage: #{$0} (view|script|component) name [options]" opts.separator "" opts.separator "Specific options:" } # totally stealing the concepts from rails here and applying them to mozilla environment # xul files are like views ...
Ruby
require 'rbconfig' require 'rake' require 'rake/testtask' require 'rake/clean' require 'tools/rakehelp' require 'fileutils' require 'zlib' include FileUtils def platform case PLATFORM when /darwin/i "darwin" when /win32|cygwin/i "win32" when /linux/i "linux" else "unknown" end end setup_tests n...
Ruby
# # setup.rb # # Copyright (c) 2000-2005 Minero Aoki # # This program is free software. # You can distribute/modify this program under the terms of # the GNU LGPL, Lesser General Public License version 2.1. # unless Enumerable.method_defined?(:map) # Ruby 1.4.6 module Enumerable alias map collect end end un...
Ruby
require 'rake' require 'rake/testtask' require 'rake/clean' require 'rake/gempackagetask' require 'rake/rdoctask' require 'tools/rakehelp' require 'fileutils' require 'zlib' include FileUtils setup_tests setup_clean ["pkg", "*.gem", "doc/site/output", ".config"] setup_rdoc ['README', 'doc/**/*.rdoc'] name="xulproject...
Ruby
def make(makedir) Dir.chdir(makedir) do sh(PLATFORM =~ /win32/ ? 'nmake' : 'make') end end def extconf(dir) Dir.chdir(dir) do ruby "extconf.rb" end end def setup_tests Rake::TestTask.new do |t| t.libs << "test" t.test_files = FileList['test/test*.rb'] t.verbose = true end end def setup_c...
Ruby
require 'ostruct' require 'optparse' require 'xulproject' option_values = OpenStruct.new options = OptionParser.new do |opts| opts.banner = "Usage: #{$0} project_name [options]" opts.on( "-b S", "--vendor", "Vendor Name" ){|vendor| option_values.vendor = vendor } opts.on( "-m S", "--version", "Application version...
Ruby
require 'erb' require 'rubygems' require 'uuidtools' require 'active_support' require 'fileutils' include FileUtils class XULProject TEMPLATE_ROOT = "#{File.dirname(__FILE__)}/../templates" TEMPLATES = [ "Rakefile", "application.ini", "Info.plist", "defaults/preferences/prefs.js", "chrome/chrome.ma...
Ruby
$: << "#{File.expand_path(File.dirname(__FILE__))}/../lib" require "runner"
Ruby
require 'test/unit' require 'fileutils' include FileUtils class TestBin < Test::Unit::TestCase PROJECT_ROOT = "#{File.dirname(__FILE__)}/projects" def setup puts "setup" rm_rf PROJECT_ROOT mkdir_p PROJECT_ROOT end def test_binary puts `ruby test/bin.rb sample -p #{PROJECT_ROOT}` assert File.exist?( "#...
Ruby
require 'test/unit' $: << "#{File.expand_path(File.dirname(__FILE__))}/../lib" require 'xulproject' class TestCreate < Test::Unit::TestCase PROJECT_ROOT = "#{File.dirname(__FILE__)}/projects" def setup rm_rf PROJECT_ROOT mkdir_p PROJECT_ROOT end def test_create project = XULProject.new project.project_f...
Ruby
# Copyright 2008-2009 Nokia Siemens Networks Oyj # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or...
Ruby
#!/usr/bin/env ruby class ExampleRemoteLibrary def count_items_in_directory(path) Dir.entries(path).find_all{|i| not i.match('^\.')}.length end def strings_should_be_equal(str1, str2) puts "Comparing '#{str1}' to '#{str2}'" if str1 != str2 raise RuntimeError, "Given strings are not equal" ...
Ruby
class RubyLibraryExample def get_server_language 'ruby' end # Basic communication def passing end def failing(message) raise message end def logging(message, level='INFO') puts "*#{level}* #{message}" end def returning 'returned string' end # Logging def one_message_w...
Ruby
class CreateRoles < ActiveRecord::Migration def self.up create_table "roles" do |t| t.column :name, :string end # generate the join table create_table "roles_users", :id => false do |t| t.column "role_id", :integer t.column "user_id", :integer end add_index "r...
Ruby
class NewEmailAddress < ActiveRecord::Migration def self.up add_column :users, :new_email, :string add_column :users, :email_activation_code, :string, :limit => 40 end def self.down remove_column :users, :email_activation_code remove_column :users, :new_email end end
Ruby
class AddPasswordResetCode < ActiveRecord::Migration def self.up add_column "users", "password_reset_code", :string, :limit => 40 end def self.down remove_column "users", "password_reset_code" end end
Ruby
class AddWorldsUsers < ActiveRecord::Migration def self.up create_table :worlds_users, :id => false do |t| t.column :world_id, :integer t.column :user_id, :integer end add_index :worlds_users, "world_id" add_index :worlds_users, "user_id" end def self.down drop_table :worlds_users...
Ruby
class CreateBuildingLevels < ActiveRecord::Migration def self.up create_table :building_levels do |t| t.column :level_num, :integer t.timestamps end end def self.down drop_table :building_levels end end
Ruby
class CreateZones < ActiveRecord::Migration def self.up create_table :zones do |t| t.column :zone_num, :integer t.column :world_id, :integer t.column :building_id, :integer t.column :zone_type, :string t...
Ruby
class AddDefaultRolesAndUsers < ActiveRecord::Migration def self.up Role.new(:name => 'Administrator').save Role.new(:name => 'Moderator').save User.new(:login => 'admin', :email => 'admin@xurse.com', :password => 'admin', :password_confirmation => 'admin', :roles => [Role.find_by_name('Administrator')])....
Ruby
class CreatePlots < ActiveRecord::Migration def self.up create_table :plots do |t| t.column :plot_num, :integer t.column :city_id, :integer t.timestamps end end def self.down drop_table :plots end end
Ruby
class CreateCities < ActiveRecord::Migration def self.up create_table :cities do |t| t.column :city_num, :integer t.column :zone_id, :integer t.column :user_id, :integer t.timestamps end end def self.down drop_table...
Ruby
class CreateViewings < ActiveRecord::Migration def self.up create_table :viewings do |t| t.column :viewable_type, :string t.column :viewable_id, :integer, :references => nil t.column :views, :integer, :default => 0 t.column :created_at, :datetime, :null => false t....
Ruby
class AddExceptionTable < ActiveRecord::Migration def self.up create_table "logged_exceptions", :force => true do |t| t.column :exception_class, :string t.column :controller_name, :string t.column :action_name, :string t.column :message, :text t.column :backtrace, :...
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table "users", :force => true do |t| t.column :login, :string t.column :email, :string t.column :crypted_password, :string, :limit => 40 t.column :salt, :str...
Ruby
class CreateBuildings < ActiveRecord::Migration def self.up create_table :buildings do |t| t.column :name, :integer t.timestamps end end def self.down drop_table :buildings end end
Ruby
class CreateWorlds < ActiveRecord::Migration def self.up create_table :worlds do |t| t.column :name, :string t.timestamps end end def self.down drop_table :worlds end end
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class Test::Unit::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 datab...
Ruby
#!/usr/local/bin/ruby18 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 imp...
Ruby
#!/usr/local/bin/ruby18 # # 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....
Ruby
load 'deploy' if respond_to?(:namespace) # cap2 differentiator Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } load 'config/deploy'
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/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/environment' world = World.create() (1..10000).each do |zone_num| if rand() <= 0.33 Zone.create(:zone_type => 'forest', :zone_num => zone_num, :world_id => world.id) else zone = Zone.create(:zone_type => 'city', :zone_num => zone_num,...
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/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/destroy'
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/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/about'
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/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/environment' world = World.create() (1..10000).each do |zone_num| if rand() <= 0.33 Zone.create(:zone_type => 'forest', :zone_num => zone_num, :world_id => world.id) else zone = Zone.create(:zone_type => 'city', :zone_num => zone_num,...
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/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
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/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
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/request'
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/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/request'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
module ApplicationHelper def flash_div *keys keys.collect { |key| content_tag(:div, flash[key], :class => "flash #{key}") if flash[key] }.join end def logged_in? if current_user != :false return true end end def format_text(text) white_list(simple_format(auto_link(bbcodeize(h(text)...
Ruby
module CityHelper end
Ruby
module ZoneHelper end
Ruby
module Admin::RoleHelper end
Ruby
module Admin::UserHelper end
Ruby
module AccountHelper end
Ruby
module WorldHelper end
Ruby
class World < ActiveRecord::Base has_many :zones has_and_belongs_to_many :users end
Ruby
class Plot < ActiveRecord::Base belongs_to :city belongs_to :building end
Ruby
class UserObserver < ActiveRecord::Observer def after_create(user) UserNotifier.deliver_signup_notification(user) end def after_save(user) UserNotifier.deliver_activation(user) if user.recently_activated? UserNotifier.deliver_forgot_password(user) if user.recently_forgot_password? UserNotifier.de...
Ruby
class BuildingLevel < ActiveRecord::Base end
Ruby
class Zone < ActiveRecord::Base has_many :cities belongs_to :world end
Ruby
require 'digest/sha1' class User < ActiveRecord::Base # Virtual attribute for the unencrypted password attr_accessor :password validates_presence_of :login, :email validates_presence_of :password, :if => :password_required? validates_presence_of :password_confirmation, ...
Ruby
class Role < ActiveRecord::Base has_and_belongs_to_many :users end
Ruby
class City < ActiveRecord::Base belongs_to :zone belongs_to :user has_many :plots end
Ruby