code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/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 CalendarHelper
end
| Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
module PlayByPlayHelper
end
| Ruby |
module BoxscoreHelper
end
| Ruby |
module HighlightsHelper
end
| Ruby |
module PitchByPitchHelper
def pitch_data(pitch)
%(<b>Pitch Type:</b> #{Pitch.get_pitch_name(pitch.pitch_type)},
<b>Start Speed:</b> #{pitch.start_speed},
<b>End Speed:</b> #{pitch.end_speed},
<b>Break Length:</b> #{pitch.break_length},
<b>Break Angle:</b> #{pitch.break_angle},
<b... | Ruby |
module ScoreboardHelper
end
| Ruby |
class HighlightsController < ApplicationController
layout 'game'
def index
set_game_info
@media = @game.get_media
@tab = "highlights"
end
end
| Ruby |
class PlayByPlayController < ApplicationController
layout 'game'
def index
set_game_info
@eventlog = EventLog.new
@eventlog.load_from_id(params[:gid])
@tab = "playbyplay"
end
end
| Ruby |
require 'box_score'
class BoxscoreController < ApplicationController
layout 'game'
# Displays the boxscore for the game specified by the gid parameter
def index
set_game_info
@tab = "boxscore"
end
end
| Ruby |
class PitchByPitchController < ApplicationController
layout 'game'
def index
set_game_info
@rosters = @game.get_rosters
@innings = @game.get_innings
@tab = "pitchbypitch"
end
end
| Ruby |
class CalendarController < ApplicationController
def index
end
def today
date = Time.now
# redirect to scoreboard passing today's date as params
redirect_to({:controller=>'Scoreboard', :action => "index", :year=>date.year, :month=>date.month, :date=>date.day})
end
... | 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
helper :all # include all helpers, all the time
# See ActionController::RequestForgeryProtection for details... | Ruby |
require 'scoreboard'
class ScoreboardController < ApplicationController
def index
@year = GamedayUtil.convert_digit_to_string(params[:year].to_i)
@month = GamedayUtil.convert_digit_to_string(params[:month].to_i)
@date = GamedayUtil.convert_digit_to_string(params[:date].to_i)
sb = Scoreboard.new
... | 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 'person',... | Ruby |
# 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.
ActiveRecord::Base.include_root_in_json = true
# Store the full clas... | 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 |
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 |
# 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
def booted?
... | Ruby |
# Be sure to restart your server when you modify this file
ENV['GEM_PATH'] = '/home/timothyf/.gems:/usr/lib/ruby/gems/1.8'
# 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 t... | 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
# Enable threaded mode
# config.threadsafe!
# Use a different logger for distributed setups
# config.... | 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 |
# 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 |
class MediaMobile
attr_accessor :id, :date, :type, :top_play, :player_id
attr_accessor :team_id, :headline, :duration, :thumb_url
attr_accessor :iphone_low_url, :iphone_hi_url
attr_accessor :h264_low_url, :h264_hi_url
def initialize(element)
end
end | Ruby |
# This class represents a single game from a game schedule
# This class is used in conjunction with the Schedule class.
# This is not the class you would use to retrieve game statistics.
class ScheduleGame
attr_accessor :date, :day_of_week, :away_team_abbrev, :away_league, :away_game_number
attr_accessor... | Ruby |
require 'roster'
# This class represents the players.xml file found on the gameday server for each MLB game.
# The players.xml file contains a listing of all players on the home and away teams for the specified game
class Players
attr_accessor :xml_data, :gid, :venue, :date, :rosters
# Loads the p... | Ruby |
require 'player'
# This class represents a single pitcher whom appeared in an MLB game
class Pitcher < Player
# Returns an array of pitcher ids for the game specified
# pitchers are found by looking in the gid/pitchers directory on gameday
def self.get_all_ids_for_game(gid)
pitchers_page = Gam... | Ruby |
class MediaHighlight
attr_accessor :id, :date, :type, :v
attr_accessor :headline, :duration, :thumb_url
attr_accessor :res_400_url, :res_500_url, :res_800_url
def initialize(element)
@id = element.attributes['id']
@date = element.attributes['date']
@type = element.attributes['type']
... | Ruby |
require 'gameday_fetcher'
# This class represents a single MLB player from a single MLB game
class Player
# attributes from players.xml
attr_accessor :gid, :pid, :first, :last, :num, :boxname, :rl, :position, :status, :bat_order, :game_position
attr_accessor :avg, :hr, :std_hr, :rbi, :wins, :losses, :... | Ruby |
class Event
attr_accessor :number, :inning, :description, :team
def load(element, home_or_away)
@xml_doc = element
@team = home_or_away
@number = element.attributes["number"]
@inning = element.attributes["inning"]
@description = element.attributes["description"]
end
end | Ruby |
# This class represents a single pitch in an MLB baseball game.
# Most of the attributes represent the physics of the pitch thrown.
#
# Pitch Type Codes
# FS = Splitter
# SL = Slider
# FF = Fastball
# SI = Sinker
# CH = Change
# FA = Fastball
# CU = Curve
# FC = Cutter
# KN = Knuckle
#
... | Ruby |
class GameStatus
attr_accessor :status, :ind, :reason, :inning, :top_inning, :b, :s, :o
end
| Ruby |
require 'team'
require 'pitching_appearance'
require 'batting_appearance'
require 'gameday_fetcher'
require 'line_score'
require 'hpricot'
require 'rexml/document'
require 'gameday_util'
# Parses the MLB Gameday XML representation of a boxscore and returns data in easy to use
# arrays and hashes. Can be u... | Ruby |
require 'player'
require 'coach'
# This class represents a team's roster for a single game.
# Both players and coaches can be read from the roster.
class Roster
attr_accessor :gid, :id, :team_name, :type, :players, :coaches
# type = home or away
def init(element, gid)
self.gid = gid
s... | Ruby |
# This class represents a single MLB coach
class Coach
attr_accessor :position, :first, :last, :id, :num
def init(element)
self.id = element.attributes['id']
self.first = element.attributes['first']
self.last = element.attributes['last']
self.num= element.attributes['num']... | Ruby |
require 'player'
# This class represents a single batter whom appeared in an MLB game
class Batter < Player
# Returns an array of batter ids for the game specified
# batters are found by looking in the gid/batters directory on gameday
def self.get_all_ids_for_game(gid)
batters_page = GamedayFe... | Ruby |
require 'schedule_game'
# This class is used to retrieve season schedule information and to query
# for information related to the schedule.
class Schedule
attr_accessor :games
# Loads a single season schedule from a schedule text file
def initialize(year)
@games = []
read_file(g... | Ruby |
require 'gameday_util'
require 'team'
require 'players'
require 'game_status'
require 'event_log'
require 'inning'
# This class represents a single MLB game
class Game
attr_accessor :gid, :home_team_name, :home_team_abbrev, :visit_team_name, :visit_team_abbrev,
:year, :month, :day, :... | Ruby |
require 'event'
require 'gameday_fetcher'
# Parses the MLB Gameday eventLog.xml file
class EventLog
attr_accessor :home_team, :away_team, :gid
attr_accessor :home_events, :away_events
attr_accessor :max_inning
# Loads the eventLog XML from the MLB gameday server and parses it using REXML
... | Ruby |
require 'net/http'
require 'md5'
class CacheFetcher
def initialize(cache_dir=File.expand_path(File.dirname(__FILE__)) + '/tmp')
# this is the dir where we store our cache
@cache_dir = cache_dir
end
def fetch(url)
file = MD5.hexdigest(url)
file_path = File.join("", @cache_di... | Ruby |
require 'pitch'
# This class represents a single atbat during a single game
class AtBat
attr_accessor :gid, :inning, :away_team, :home_team
attr_accessor :num, :b, :s, :o, :batter_id, :stand, :b_height, :pitcher_id, :p_throws, :des, :event
attr_accessor :pitches
def init(element, gid)
@xm... | Ruby |
# This class contains data representing a linescore for a single game.
class LineScore
attr_accessor :xml_doc
attr_accessor :away_team_runs, :home_team_runs, :away_team_hits, :home_team_hits, :away_team_errors, :home_team_errors
attr_accessor :innings
# Initialize this instance from an XML elemen... | Ruby |
require 'gameday_fetcher'
require 'media_highlight'
require 'media_mobile'
class Media
attr_accessor :gid, :highlights, :mobile
def load_from_id(gid)
@gid = gid
@highlights = []
@mobile = []
@xml_highlights = GamedayFetcher.fetch_media_highlights(gid)
@xml_doc = REXML::... | Ruby |
#require 'cache_fetcher'
require 'gameday'
require 'gameday_url_builder'
# This class is responsible for retrieving data from the Gameday server
# It contains methods that read or open a connection to the XML files hosted on gd2.mlb.com
#
# The files that can be fetched using this class:
#
# master_sco... | Ruby |
require 'open-uri'
# This class provides a variety of utility methods that are used in other classes
class GamedayUtil
# Parses a string with the date format of YYYYMMDD into an array
# with the following elements:
# [0] = year
# [1] = month
# [2] = day
def self.parse_date_string(da... | Ruby |
require 'gameday'
class GamedayUrlBuilder
def self.build_game_base_url(gid)
gameday_info = GamedayUtil.parse_gameday_id('gid_' + gid)
"#{Gameday::GD2_MLB_BASE}/mlb/year_" + gameday_info['year'] + "/month_" + gameday_info['month'] + "/day_" + gameday_info['day'] + "/gid_"+gid
end
def... | Ruby |
require 'rubygems'
require 'net/http'
require 'hpricot'
require 'erb'
require 'game'
require 'team'
require 'box_score'
class Gameday
GD2_MLB_BASE = "http://gd2.mlb.com/components/game"
def initialize
super
end
# Returns an array of game id's for the given date
def g... | Ruby |
require 'rexml/document'
# This class parses various Gameday data files
# This works with Rails and ActiveRecord
class GamedayParser
def self.parse_player_data(doc, team, logger)
updated_player_count = 0
new_player_count = 0
doc.root.each_element do |player|
gameday_id = player.attributes['id']... | Ruby |
# This class is responsible for retrieving gameday data files from the local file system.
# It contains methods that read or open a connection to the XML files that have been saved to the local filesystem.
#
# The files that can be fetched using this class:
# boxscore.xml
# game.xml
# gamecenter.xm... | Ruby |
require 'player'
# This class represents a batting record for a single player for a single game
# Note that this does NOT represent a single atbat of a player, but rather an appearance is a player's stats over an entire game.
class BattingAppearance
attr_accessor :pid, :batter_name, :pos, :bo, :ab, :po, :... | Ruby |
# This class is used to download data files from the MLB Gameday site to
# local storage. The data that is downloaded will be stored into a path that
# replicates the MLB Gameday paths, for example here is a sample path for
# a specified date:
# /components/game/mlb/year_2008/month_04/day_07
#
class DataDown... | Ruby |
require 'gameday_fetcher'
class Scoreboard
attr_accessor :games # An array of Game objects representing all of the games played on this date
attr_accessor :year, :month, :day
def load_for_date(year, month, day)
@games = []
@year = year
@month = month
@day = day
@xml_data = ... | Ruby |
# This class holds data that represents a single pitching appearance by a pitcher.
class PitchingAppearance
attr_accessor :pid, :pitcher_name, :out, :inn, :er, :r, :h, :so, :hr, :bb, :w, :l, :era, :note, :start
# Used to initialize from box score data
def init(element, count)
self.pid ... | Ruby |
require 'at_bat'
require 'gameday_fetcher'
# This class represents a single inning of an MLB game
class Inning
attr_accessor :gid, :num, :away_team, :home_team, :top_atbats, :bottom_atbats
# loads an Inning object given a game id and an inning number
def load_from_id(gid, inning)
@top_a... | Ruby |
require 'gameday_util'
require 'game'
require 'gameday'
require 'schedule'
# This class
class Team
START_MONTH = 4 # April
END_MONTH = 10 # October
attr_accessor :abrev, :city, :name, :league, :games
# Setup team names, abbreviations, and league
def initialize(abrev)
if (abre... | Ruby |
require 'rubygems'
Gem::manage_gems
require 'rake/gempackagetask'
require 'rake/testtask'
require 'rake/rdoctask'
spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = "base4r"
s.homepage = "http://code.google.com/p/base4r"
s.version = "0.2"
s.author = ... | Ruby |
# Base4R is a ruby interface to Google Base
# Copyright 2007, 2008 Dan Dukeson
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later v... | Ruby |
# Base4R is a ruby interface to Google Base
# Copyright 2007, 2008 Dan Dukeson
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later v... | Ruby |
# Base4R is a ruby interface to Google Base
# Copyright 2007, 2008 Dan Dukeson
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later v... | Ruby |
# Base4R is a ruby interface to Google Base
# Copyright 2007, 2008 Dan Dukeson
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later v... | Ruby |
# Base4R is a ruby interface to Google Base
# Copyright 2007, 2008 Dan Dukeson
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later v... | Ruby |
require 'rubygems'
Gem::manage_gems
require 'rake/gempackagetask'
require 'rake/testtask'
require 'rake/rdoctask'
spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = "base4r"
s.homepage = "http://code.google.com/p/base4r"
s.version = "0.2"
s.author = ... | Ruby |
# Base4R is a ruby interface to Google Base
# Copyright 2007 Dan Dukeson
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version... | Ruby |
# Base4R is a ruby interface to Google Base
# Copyright 2007 Dan Dukeson
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version... | Ruby |
# Base4R is a ruby interface to Google Base
# Copyright 2007 Dan Dukeson
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version... | Ruby |
# Base4R is a ruby interface to Google Base
# Copyright 2007 Dan Dukeson
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version... | Ruby |
# Base4R is a ruby interface to Google Base
# Copyright 2007 Dan Dukeson
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version... | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 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 writ... | Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | 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 |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :handle
t.string :hashed_password
t.string :salt
t.string :first_name
t.string :last_name
t.string :email
t.string :activation_key
t.boolean :active, :default=>false
t.... | Ruby |
class CreatePersistentSessions < ActiveRecord::Migration
def self.up
create_table :persistent_sessions do |t|
t.integer :user_id
t.string :key
t.index :user_id
t.timestamps
end
end
def self.down
drop_table :persistent_sessions
end
end
| Ruby |
class CreatePasswordRecoveries < ActiveRecord::Migration
def self.up
create_table :password_recoveries do |t|
t.integer :user_id
t.string :key
t.timestamps
end
end
def self.down
drop_table :password_recoveries
end
end
| Ruby |
class WebappFunctionalTestCase < ActionController::TestCase
def assert_error_flashed(message,*strs)
#aasert that in the flash exists the :error symbol with the :message
assert_equal sprintf(I18n.t(message),*strs), flash[:error]
end
def assert_notice_flashed(message, *strs)
assert_equal... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
require 'webapp_test_helper'
require 'webapp_exceptions'
require 'webapp_constants'
class ActiveSupport::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# i... | 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
require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
unless ARGV.include?("-p")
ARGV << "-p"
ARGV << "3000"
end
unless ARGV.include?("-b")
ARGV << "-b"
ARGV << "0.0.0.0"
end
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/destroy'
| 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/console'
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.