code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
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 |
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'
spec = Gem::Specification.new do |s|
s.name = 'Aufgabe5'
s.version = '0.0.1'
s.has_... | Ruby |
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'
spec = Gem::Specification.new do |s|
s.name = 'Aufgabe5'
s.version = '0.0.1'
s.has_... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
# Uhr mit drei verschiedenen Implementationen und der Möglichkeit verschiedener
# Umrechnungen in 5 Einzelschritten
#
# clock24 == 24 Stunden Zeitanzeige
# clock12 == 12 Stunden AM und PM Anzeige
# clockSec == Zeita... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
# Uhr mit drei verschiedenen Implementationen und der Möglichkeit verschiedener
# Umrechnungen in 5 Einzelschritten
#
# clock24 == 24 Stunden Zeitanzeige
# clock12 == 12 Stunden AM und PM Anzeige
# clockSec == Zeita... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
class Object
#####################Typprädikate#############################
def dim1?() (point1d? or range1d? or union1d? or shape1d?) end
def dim2?() (point2d? or range2d? or union2d? or shape2d?) end
def point1d... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
class Object
def dim1?()
(self.point1d? or self.range1d? or self.union1d? or self.shape1d?)
end
def dim2?()
(self.point2d? or self.range2d? or self.union2d? or self.shape2d?)
end
def point1d?()
self.int?
end
... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
class GraphObj
def self.[](*args) check_inv(self.new(*args)) end
def ==() abstract end
def invariant() abstract end
def translate() abstract end
def graph_equal_?() abstract end
def graph_equal?() abstract e... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
module Clock_Const
MIN_IN_SEC = 60
HOUR_IN_MIN = 60
DAY_IN_HOUR = 24
HOUR_IN_SEC = HOUR_IN_MIN * MIN_IN_SEC
DAY_IN_SEC = DAY_IN_HOUR * HOUR_IN_SEC
HALF_DAY_IN_SEC = DAY_IN_SEC / 2
HALF_DAY = DAY_IN_HOUR/2
end
# Die Kl... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
class Object
#Shape1d ::= Range1d | Union1d
def shape1d?()
self.range1d? or self== Union1d
end
#Shape2d ::= Range2d | Union2d
def shape2d?()
self== Range2d or self== Union2d
end
#UnionShape ::= Union1d | Union2d
d... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
# Uhr mit drei verschiedenen Implementationen und der Möglichkeit verschiedener
# Umrechnungen in 5 Einzelschritten
#
# clock24 == 24 Stunden Zeitanzeige
# clock12 == 12 Stunden AM und PM Anzeige
# clockSec == Zeitanz... | Ruby |
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'
spec = Gem::Specification.new do |s|
s.name = 'Klausuren'
s.version = '0.0.1'
s.has... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
# hash invert_exact
class Hash
def invert_exact
ret = Hash[]
self.each {|key,value| ret.include?(value) ? check_pre(false) : ret[value]=key}
ret
end
end
#Set symm_diff
class Set
def diff_symm(val)
... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
# erste Böhmklausur
#######################################1.Aufgabe der Klausur#######################################
#cons ::= (obj,list)::(Any x List) -> List
#reverse_endrec() :: List -> reverse List
class List
def r... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
#Übungsblatt für die Programmierpraxis
# List[1,2,3,4,5,6].each {|hallo| puts (hallo*hallo)}
# List[1,2,3,4,5,6].each {|hallo, tschau| if hallo == 5 then puts "Hallo Tim" end}
# List[1,2,3,4,5,6].each {|hallo,haus| haus=... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
#Einfach mehrfach rekursion:
def sum(n)
n==0 ? n : n+sum(n-1)
end
#puts(sum(10))
#Potenzen
def pot(n,e)
if e==0 then n=1
else
e==1 ? n : n * pot(n,e-1)
end
end
#puts(pot(10,3))
#fibonacci
def fibo(n)
i... | Ruby |
# To change this template, choose Tools | Templates
# and open the template in the editor.
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
require 'test/unit'
require 'uebungen'
class Test_uebungen < Test::Unit::TestCase
def test
assert_equal(4,[[1,2],[1,[2,[3,4]]],3,[1,[2,[3,4]]]].tree_depth())
end
... | Ruby |
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'
spec = Gem::Specification.new do |s|
s.name = 'Extensions'
s.version = '0.0.1'
s.ha... | Ruby |
# EXTENSIONS FOR ELEMENTARY TYPES V1
# ==================================
# Michael Boehm, 19.01.12
#require 'Set'
# EXTENSIONS TO OBJECT
#
# COMPACT DEFINITION OF HOOK-METHODS IN OBJECT FOR TYPE-PREDICATES
# type predicates should be compact and defined for all objects (total on Object)
# this requires a la... | Ruby |
# GLOBAL FUNCTIONS FOR ASSERTION CHECKING V1
# ==========================================
# Michael Boehm, 24.10.11
# ASSERTION CHECKING
# ==================
# All functions for assertion checking are based on this principle:
# they consume
#
# a value expression (or|and)
# a logical expression and
# ... | Ruby |
# EXTENSIONS FOR LINKED LISTS V1
# ==============================
# Michael Boehm, 19.01.12
require 'set'
require 'singleton'
class Array
def to_l() List[*self] end
end
class Set
def to_l() List[*(self.to_a)] end
def set?; true end
end
# DEFINITION OF LINKED LISTS
# these are immutable lists
# Li... | Ruby |
# EXTENSIONS TO STRUCTURE AND TO MODULE
# =====================================
# Michael Boehm, 29.11.11
#EXTENSIONS TO STRUCTURE
#=======================
#
# a method to define a class (e.g. Range2d), which does all what a structure definition does, plus
#
# definition of a standard type predicate total on O... | Ruby |
# EXTENSIONS FOR PR1 Jan. 2012
# ============================
# Michael Böhm 19.01.12
require "ext_checks_v1"
require "ext_elems_v2"
require "ext_modules_v2"
require "ext_lists_v2"
# INSTALLING THE EXTENSIONS
# =========================
# create a new project with name 'ext_pr1'
# copy the extension files to the sour... | Ruby |
# EXTENSIONS TO STRUCTURE AND TO MODULE
# =====================================
# Michael Boehm, 24.10.11
#EXTENSIONS TO STRUCTURE
#=======================
#
# a method to define a class, which does all what a structure definition does, plus
#
# definition of a standard type predicate total on Object
#
# de... | Ruby |
# EXTENSIONS FOR ELEMENTARY TYPES V1
# ==================================
# Michael Boehm, 19.01.12
#require 'Set'
# EXTENSIONS TO OBJECT
#
# COMPACT DEFINITION OF HOOK-METHODS IN OBJECT FOR TYPE-PREDICATES
# type predicates should be compact and defined for all objects (total on Object)
# this requires a la... | Ruby |
# GLOBAL FUNCTIONS FOR ASSERTION CHECKING V1
# ==========================================
# Michael Boehm, 24.10.11
# ASSERTION CHECKING
# ==================
# All functions for assertion checking are based on this principle:
# they consume
#
# a value expression (or|and)
# a logical expression and
# ... | Ruby |
# EXTENSIONS FOR LINKED LISTS V1
# ==============================
# Michael Boehm, 19.01.12
require 'set'
require 'singleton'
class Array
def to_l() List[*self] end
end
class Set
def to_l() List[*(self.to_a)] end
def set?; true end
end
# DEFINITION OF LINKED LISTS
# these are immutable lists
# Li... | Ruby |
# EXTENSIONS TO STRUCTURE AND TO MODULE
# =====================================
# Michael Boehm, 29.11.11
#EXTENSIONS TO STRUCTURE
#=======================
#
# a method to define a class (e.g. Range2d), which does all what a structure definition does, plus
#
# definition of a standard type predicate total on O... | Ruby |
# EXTENSIONS FOR PR1 Jan. 2012
# ============================
# Michael Böhm 19.01.12
module Test
module Unit
module Assertions
class AssertionMessage
class << self
def ensure_diffable_string(string)
string = string.dup.force_encoding("ASCII-8BIT") if string.respond_to?(:encod... | Ruby |
# EXTENSIONS TO STRUCTURE AND TO MODULE
# =====================================
# Michael Boehm, 24.10.11
#EXTENSIONS TO STRUCTURE
#=======================
#
# a method to define a class, which does all what a structure definition does, plus
#
# definition of a standard type predicate total on Object
#
# de... | Ruby |
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'
require 'spec/rake/spectask'
spec = Gem::Specification.new do |s|
s.name = 'H_Cube'
s... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
# Uhr vorstellen
# vorstellen_uhr ::= (stunde_alt, minute_alt, sekunde_alt, stunde_add, minute_add, sekunde_add, mode)::
# Nat x Nat x Nat x Int x Int x Int -> Nat where (stunde_alt < 24 and stunde_... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
#Volume of a hollow cube
#hollow_cube_volume ::= (length_outer, length_inner)::
# Nat x Nat -> Nat where (length_outer >= length_inner)
#Test {(3,2)=>19, (2,2) => 0, (0,0) => 0,
#('10', '5')=> Err... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
# Oberflächenberechnung eines Pentagondodekaeders
# berechne_oberflaeche_dodekaeder ::= (Kantenlaenge)::
#
#Test { (-2) = Err, ("Hallo Welt") = Err, (2) = 82,58, (2.0) = 82,58 }
PENTA_CONST = 3.0 ... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
#Zylindervolumenberechnung
# berechne_kreis_flaecheninhalt ::= (radius)::
# Test { (12.0 => 452.39), (12.5 => 530.93), ((-1) => Err), ((0) => Err), (("Welt") => Err)}
#
# berechne_zylinder_volumen ::= (radius, hoehe)::
#
... | Ruby |
# initialize(12, 0, 0)=>NoError, initialize(24, 0, 0)=>Error, initialize(10, 60, 5)=>Error,
# initialize(12, 0, 60)=>Error, initialize(12, 12, 12)=>NoError,
# initialize(12, 0, 0)->vorstellen(0, 30, 0)=>{12, 30, 0},
# initialize(12, 0, 0)->vorstellen(0, 60, 0)=>Error
# initialize(12, 0, 0)->mode_12()->vorstellen(5, 30,... | Ruby |
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'
spec = Gem::Specification.new do |s|
s.name = 'Aufgabe_3'
s.version = '0.0.1'
s.has... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
# Uhr mit drei verschiedenen Implementationen und der Möglichkeit verschiedener
# Umrechnungen in 5 Einzelschritten
#
# clock24 == 24 Stunden Zeitanzeige
# clock12 == 12 Stunden AM und PM Anzeige
# clockSec == Zeita... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
#Datendefinitionen:
#
#1D Objekte
#
#Point1d ::= Int
def_class(:Point1d,[:int]) {
def invariant?()
int.int?
end
}
#Range1d ::= Range[first,last] :: Point1d x Point1d
def_class(:Range1d,[:first,:last]){
def ... | Ruby |
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'
spec = Gem::Specification.new do |s|
s.name = 'Aufgabe_6'
s.version = '0.0.1'
s.has... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
# Zusammenfügen von Listen
class List
def ==(o)
self.equal?(o) or
(o.list? and (first == o.first and rest == o.rest))
end
def reverse_endrec()
self.size < 2 ? self : reverse_endrec_(List[],self)
... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
class Array
def to_int
string = ""
self.each {|x| string+= x.to_s}
string.to_i
end
def even_only
val = []
self.each {|x| x % 2 == 0 ? val << x : nil }
val
end
def flat... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
#Endrekursion
#
#Methoden aus einfach_mehrfach als Endrekursion
def sum_(accu,n)
(n==0 ? accu : sum_(accu + n, n - 1))
end
# sum ::= (var) :: Nat x Nat -> Nat
#
def sum(n)
check_pre((n.nat?))
sum_(0,n)
end
... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
class List
end
class Set
def superset?(set)
val = true
if (self.count() < set.count())
val = false
else
set.each do |elem|
self.each_with_index do |elem2, index|
if (... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
# sum ::= (var) :: Nat x Nat -> Nat
#
def sum(seq)
check_pre((seq.nat?))
(0..seq).reduce(:+)
end
def potenz(x, n)
(n..x).reduce(:*)
end
| Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
class List
def ==(o)
self.equal?(o) or
(o.list? and (first == o.first and rest == o.rest))
end
def reverse_endrec()
self.size < 2 ? self : reverse_endrec_(List[],self)
end
def reverse_endrec_(a... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
def sum_(accu,n)
while (n >= 0)
accu += n
n -= 1
end
accu
end
# sum ::= (var) :: Nat x Nat -> Nat
#
def sum(n)
check_pre((n.nat?))
sum_(0,n)
end
def potenz(x, n)
check_pre((n.nat?... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
# Übungen zur Einfach- und Mehrfachrekursion
#
# Aufgabe 1:
# Summe
#
# sum ::= (var) :: Nat x Nat -> Nat
#
def sum(n)
check_pre((n.nat?))
n = (n == 0 ? 0 : n + sum(n-1))
end
#Aufgabe 2:
#Potenz
#
# po... | Ruby |
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'
spec = Gem::Specification.new do |s|
s.name = 'Aufgabe_2'
s.version = '0.0.1'
s.has... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
# Minimumauswertung
# min_int ::= (int1, int2):: Nat x Nat -> Nat
#
# Test { (1,2) = 1, (2,1) = 1, (2,2) = Err, (2.0,1) = Err, (1,2.0) = Err
def min_int(int1,int2)
check_pre((int1.nat? and int2.nat? and int1 != int2)... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
TEMP_ABS_ZERO = -273
TEMP_MIN = 18
TEMP_MAX = 25
# zu_kalt ::= (temp) :: Int -> Int where (temp >= -273)
# Test {(12)=>true, (18)=>false, (17)=>true, (25)=>false, (26)=>false,
# (-274)=>Err, (-273)=>true, ("Hallo")=>Er... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
# Überprüfung ob ein Element innerhalb eines Intervalls ist
# within? ::= (val, lower, upper) :: Nat x Nat x Nat -> Bool where (val >= lower
# and val <= upper)
#
# Test { (3,1,6) = true, (3,4,5) = false, (3.0,1,6) = Err... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
# larger_sum_square ::= (val1, val2, val3) :: Int x Int x Int -> Int
# returns the 2 biggest objects
# Test {(1, 2, 3)=>13, (3, 2, 1)=>13, (2, 1, 3)=>13, (2, 3, 1)=>13,
# (1, 3, 2)=>13, (3, 1, 2)=>13, (1, 1, 1)=>Err, (1, 1... | Ruby |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
require 'ext_pr1_v4'
# Transformation der Prädikatsfunktion: Angenehm, aus dem Programm
# praedikatsfunktionen_v0.rb
#
# angenehm ::= (temp) :: Int -> where (temp >=-273)
# return true when (temp >=18 and temp <=25) otherwise false
def ange... | Ruby |
#require 'test/unit/ui/console/testrunner'
require 'test/unit'
require_relative 'element_intervall_test'
class TS_MyTests
def self.suite
suite = Test::Unit::TestSuite.new
suite << element_intervall_test.suite
return suite
end
end
Test::Unit::UI::Console::TestRunner.run(TS_MyTests)
| 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 |
environment = :production
project_type = :stand_alone
http_path = "/"
css_dir = "../styles"
sass_dir = "."
images_dir = "images"
sass_options = {
:line_numbers => false,
:debug_info => false
}
# output_style = :compressed
# output_style = :compact
output_style = :expanded
| Ruby |
environment = :production
project_type = :stand_alone
http_path = "/"
css_dir = "../styles"
sass_dir = "."
images_dir = "images"
sass_options = {
:line_numbers => false,
:debug_info => false
}
# output_style = :compressed
# output_style = :compact
output_style = :expanded
| Ruby |
namespace :audit do
desc 'Finds ActiveRecord classes without attr_accessible'
task :mass_assignment => :environment do
puts "Audit mass assignment in models:"
Dir.glob(RAILS_ROOT + '/app/models/**/*.rb').each { |file| require file }
subclasses = Object.subclasses_of(ActiveRecord::Base)
subclasses.de... | Ruby |
class ASYWindowController < NSObject
kvc_accessor :downloads
attr_accessor :downloads
ib_outlet :txtUrl
ib_outlet :arrayController
def init
if super_init
@downloads = NSMutableArray.array
return self
end
end
def getMovie(sender)
pid = @txtUrl.stringValue.to_s
if pid... | Ruby |
#
# rb_main.rb
# Auntie Says Yes
#
# Created by Simon on 05/05/2008.
# Copyright (c) 2008 __MyCompanyName__. All rights reserved.
#
require 'osx/cocoa'
include OSX
def rb_main_init
path = OSX::NSBundle.mainBundle.resourcePath.fileSystemRepresentation
rbfiles = Dir.entries(path).select {|x| /\.rb\z/ =~ x}
r... | Ruby |
require 'iplayer'
require 'thread'
include IPlayer
include IPlayer::Errors
class IPlayerDownload < NSObject
attr_accessor :movie_name
attr_accessor :progress
attr_accessor :time_left
kvc_accessor :movie_name
kvc_accessor :progress
kvc_accessor :time_left
def init
if super_init
@http ... | Ruby |
require 'date'
module IPlayer
module JavaScript
class Parser
# In conjunction with the tokeniser, this parser will turn the BBC iPlayer
# version array into a corresponding Ruby data structure. It assumes that the
# original data is well-formed.
attr_reader :tokens
def initialize(tokens)
@tokens = tok... | Ruby |
module IPlayer
module JavaScript
class Tokenizer
# A very simple JavaScript tokeniser that's just smart enough to handle
# the code used by the BBC iPlayer version array
TOKENS = [
[ %| '([^']+)' |, :string ],
[ %| "([^"]+)" |, :string ],
[ %| new \\s+ Date \\s* \\( |, :date ],
[ %| ([_a-zA-Z][_... | Ruby |
require 'rexml/document'
module IPlayer
class Metadata
METADATA_URL = 'http://www.bbc.co.uk/iplayer/metafiles/episode/%s.xml'
def initialize(pid, browser)
@pid = pid
@browser = browser
end
def metadata
@metadata ||= REXML::Document.new( @browser.get(METADATA_URL % @pid).body )
end
def title... | Ruby |
require 'iplayer/javascript/tokenizer'
require 'iplayer/javascript/parser'
module IPlayer
module JavaScript
def self.parse(js)
tokens = Tokenizer.new(js).tokenize
Parser.new(tokens).parse
end
end
end
| Ruby |
module IPlayer
module Errors
ParsingError = Class.new(RuntimeError)
FileUnavailable = Class.new(RuntimeError)
MP4Unavailable = Class.new(RuntimeError)
end
end
| Ruby |
module IPlayer
class Downloader
include IPlayer::Errors
PROGRAMME_URL = 'http://www.bbc.co.uk/iplayer/page/item/%s.shtml'
SELECTOR_URL = 'http://www.bbc.co.uk/mediaselector/3/auth/iplayer_streaming_http_mp4/%s?%s'
Version = Struct.new(:name, :pid)
attr_reader :browser, :pid
attr_accessor :cookies
d... | Ruby |
require 'net/http'
require 'uri'
class Net::HTTPResponse # Monkey-patch in some 21st-century functionality
include Enumerable
def cookies
inject([]){ |acc, (key, value)|
key == 'set-cookie' ? acc << value.split(/;/).first : acc
}
end
def to_hash
@to_hash ||= inject({}){ |hash, (key, val... | Ruby |
require 'iplayer/errors'
require 'iplayer/browser'
require 'iplayer/metadata'
require 'iplayer/javascript'
require 'iplayer/downloader'
| Ruby |
# -*- mode:ruby; indent-tabs-mode:nil; coding:utf-8 -*-
# vim:ts=2:sw=2:expandtab:
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'pathname'
# Application own Settings
APPNAME = "«PROJECTNAME»"
TARGET = "#{APPNAME}.app"
#APPVERSION = "rev#{... | Ruby |
#!/usr/bin/env ruby
#--
# Created by Matt Todd on 2007-11-10.
# Copyright (c) 2007 The HUB, Clayton State University. All rights reserved.
#++
module Aurora
module Client
class Base
end
end
end
| Ruby |
#!/usr/bin/env ruby
#--
# Created by Matt Todd on 2007-11-10.
# Copyright (c) 2007 The HUB, Clayton State University. All rights reserved.
#++
module Aurora
module Client
class Base
end
end
end
| Ruby |
#!/usr/bin/env ruby
#--
# Created by Matt Todd on 2007-11-10.
# Copyright (c) 2007 The HUB, Clayton State University. All rights reserved.
#++
# dependencies
require 'rubygems'
require 'logger'
require 'uri'
require 'json'
require 'digest/md5'
require 'mongrel'
# module
module Aurora
module Server
# Bas... | Ruby |
#!/usr/bin/env ruby
#--
# Created by Matt Todd on 2007-11-10.
# Copyright (c) 2007 The HUB, Clayton State University. All rights reserved.
#++
# dependencies
require 'rubygems'
require 'logger'
require 'uri'
require 'json'
require 'digest/md5'
require 'mongrel'
# module
module Aurora
module Server
# Bas... | Ruby |
require 'aurora/server/base'
Aurora::Server::Base.new('http://localhost:2828/', :logger_level => Logger::INFO) do |serv, uri, logger|
serv.authenticate do |user, pass|
# ldap = LDAP.new('http://localhost/')
# if ldap.bind("#{user}@domain")
if user == 'mtodd' and pass == 'test'
# successfully bound/... | 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 |
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 |
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 |
# 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 |
#!/usr/bin/env ruby
# encoding: utf-8
project = 'battery-indicator'
user = `cat ~/.netrc | awk '{print $4;}'`.strip
pass = `cat ~/.netrc | awk '{print $6;}'`.strip
version = `grep "android:versionName=" AndroidManifest.xml`.split('"')[1]
apk_location = "BatteryIndicatorPro-#{version}.apk"
system("cp bin/*-release.ap... | Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
LANGS_URI = 'http://ath.darshancomputing.com/bi/langs/'
langs = Net::HTTP.get(URI.parse(LANGS_URI)).split()
langs.each do |lang|
if lang.length == 2
dir = 'res/values-' << lang
else
dir = 'res/values-' << lang[0,2] << '-r' << lang[2,2]
end
if ! D... | Ruby |
#!/usr/bin/env ruby
require 'nokogiri'
string_to_remove = ['pref_cat_themes',
'theme_settings',
'theme_settings_summary',
'theme_settings_help']
string_files = []
Dir.glob('res/values*').each do |d|
file = d << "/strings.xml"
string_files << file if Fil... | Ruby |
#!/usr/bin/env ruby
# encoding: utf-8
require 'nokogiri'
# read in convert.xml to see which how to convert the string-arrays
# for each strings.xml in res/values res/values-?? res/values-??-*
# find the string-arrays that match the ones in convert.xml and for each
# remove opening and closing string-array tag
#... | Ruby |
require 'RMagick'
class NumberImageGenerator
@@IMAGE_DIR = 'numbers-hdpi/'
def generate(text, fs=18)
#filename = "b" + sprintf("%03d", text) + ".png";
filename = "" + sprintf("%03d", text) + ".png";
font_size = fs;
height = 35;
width = 35;
image = Magick::Image.new(width, height) {self.ba... | Ruby |
class <%= class_name %>Observer < ActiveRecord::Observer
def after_create(<%= file_name %>)
<%= class_name %>Notifier.deliver_signup_notification(<%= file_name %>)
end
def after_save(<%= file_name %>)
<%= class_name %>Notifier.deliver_activation(<%= file_name %>) if <%= file_name %>.recently_activated?
... | Ruby |
class <%= class_name %>Notifier < ActionMailer::Base
def signup_notification(<%= file_name %>)
setup_email(<%= file_name %>)
@subject += 'Please activate your new account'
@body[:url] = "http://YOURSITE/account/activate/#{<%= file_name %>.activation_code}"
end
def activation(<%= file_name %>)
... | Ruby |
class AuthenticatedMailerGenerator < Rails::Generator::NamedBase
def manifest
record do |m|
# Check for class naming collisions.
m.class_collisions class_path, "#{class_name}Notifier", "#{class_name}NotifierTest", "#{class_name}Observer"
# Controller, helper, views, and test directories.
... | Ruby |
class <%= controller_class_name %>Controller < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
include AuthenticatedSystem
# If you want "remember me" functionality, add this before_filter to Application Controller
before_filter :login_from_cookie
# say somet... | Ruby |
module AuthenticatedSystem
protected
# Returns true or false if the user is logged in.
# Preloads @current_<%= file_name %> with the user model if they're logged in.
def logged_in?
current_<%= file_name %> != :false
end
# Accesses the current <%= file_name %> from the session.
def c... | Ruby |
module <%= controller_class_name %>Helper
end | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.