code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/breakpointer'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
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/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
class DeleteMp < ActiveRecord::Migration def self.up drop_table :mps end def self.down end end
Ruby
class AddIndexes < ActiveRecord::Migration def self.up add_index :votes, [:politician_id] add_index :votes, [:question_id] add_index :attendances, [:politician_id] add_index :speeches, [:politician_id] end def self.down remove_index :votes, [:politician_id] remove_index :votes, [:question...
Ruby
class CreateSessions < ActiveRecord::Migration def self.up create_table :sessions do |t| t.string :name t.date :from t.date :to, {:null => true} end end def self.down drop_table :sessions end end
Ruby
class VoteActionType < ActiveRecord::Migration def self.up change_column :votes, :action, :integer end def self.down change_column :votes, :action, :string end end
Ruby
class AddSessionIdColumn < ActiveRecord::Migration def self.up add_column :sittings, :session_id, :int end def self.down remove_column :sittings, :session_id end end
Ruby
class CreateDebateReferences < ActiveRecord::Migration def self.up create_table :debate_references do |t| t.integer :politician_id, :name_reference_id, :sitting_id end end def self.down drop_table :debate_references end end
Ruby
class ReinsertPartiesInUnicode < ActiveRecord::Migration def self.up drop_table :political_groups CreatePoliticalGroups.up AddPilietinesDemokratijosFrakcija.up end def self.down end end
Ruby
class ChangeFormulationToText < ActiveRecord::Migration def self.up change_column :questions, :formulation, :text end def self.down change_column :questions, :formulation, :string end end
Ruby
class ChangePoliticalGroupIdType < ActiveRecord::Migration def self.up change_column :votes, :political_group_id, :int end def self.down change_column :votes, :political_group_id, :string end end
Ruby
class RenameQuestionType < ActiveRecord::Migration def self.up rename_column :questions, :type, :stage end def self.down rename_column :questions, :stage, :type end end
Ruby
class AddVlpdFrakcija < ActiveRecord::Migration def self.up pg = PoliticalGroup.new pg.name = "Valstiečių liaudininkų ir pilietinės demokratijos frakcija" pg.code = "VLPD" pg.save end def self.down end end
Ruby
class CreateAttendances < ActiveRecord::Migration def self.up create_table :attendances do |t| t.integer :politician_id t.integer :sitting_id t.boolean :present end end def self.down drop_table :attendances end end
Ruby
class ChangeCachePoliticianId < ActiveRecord::Migration def self.up rename_column :mp_caches, :mp_id, :politician_id end def self.down rename_column :mp_caches, :politician_id, :mp_id end end
Ruby
#http://woss.name/2006/10/25/migrating-your-rails-application-to-unicode/ class MakeUnicodeFriendly < ActiveRecord::Migration def self.up alter_database_and_tables_charsets "utf8", "utf8_general_ci" end def self.down alter_database_and_tables_charsets end private def self.alter_datab...
Ruby
class CreatePoliticalGroups < ActiveRecord::Migration def self.up create_table :political_groups do |t| t.string :name t.string :code, :limit=>10 end pg = PoliticalGroup.new pg.name = "Lietuvos socialdemokratų partijos frakcija" pg.code = "LSDPF" pg.save pg = PoliticalGroup.n...
Ruby
class RemoveFullName < ActiveRecord::Migration def self.up remove_column :politicians, :full_name end def self.down add_column :politicians, :full_name, :string end end
Ruby
class SplitMpNames < ActiveRecord::Migration def self.up add_column :politicians, :last_name, :string add_column :politicians, :first_name, :string add_column :politicians, :second_name, :string Politician.find(:all).each do |mp| fn = mp.full_name.split mp.first_name = fn[0] ...
Ruby
class AddRebelionColumns< ActiveRecord::Migration def self.up add_column :votes, :group_rebellion, :boolean add_column :votes, :parliament_rebellion, :boolean end def self.down remove_column :votes, :group_rebellion remove_column :votes, :parliament_rebellion end end
Ruby
class AddSpeechesAttendancesQuestionsIndex < ActiveRecord::Migration def self.up add_index :speeches, [:question_id] add_index :attendances, [:sitting_id] add_index :sittings, [:session_id] add_index :questions, [:sitting_id] end def self.down remove_index :speeches, [:question_id] remove...
Ruby
class AddPilietinesDemokratijosFrakcija < ActiveRecord::Migration def self.up pg = PoliticalGroup.new pg.name = "Pilietinės demokratijos frakcija" pg.code = "PDF" pg.save end def self.down end end
Ruby
class RemovePoliticiansFromToColumns < ActiveRecord::Migration def self.up remove_column :politicians, :from remove_column :politicians, :to end def self.down add_column :politicians, :from, :date add_column :politicians, :to, :date end end
Ruby
class ChangePoliticiansTypeColumnName < ActiveRecord::Migration def self.up rename_column :positions, :type, :department end def self.down rename_column :positions, :department, :type end end
Ruby
class AddLrsIdColumn < ActiveRecord::Migration def self.up add_column :politicians, :id_in_lrs, :string, :limit => 16 end def self.down remove_column :politicians, :id_in_lrs end end
Ruby
class ChangeMpToPoliticianId < ActiveRecord::Migration def self.up rename_column :trips, :mp_id, :politician_id end def self.down rename_column :trips, :politician_id, :mp_id end end
Ruby
class CreatePoliticalGroupVotes < ActiveRecord::Migration def self.up create_table :political_group_votes do |t| t.integer :political_group_id t.integer :question_id t.string :time, :limit => 8 t.integer :action_yes t.integer :action_no t.integer :action_absent t.integer...
Ruby
class ExtendSessionNameColumn < ActiveRecord::Migration def self.up change_column :sittings, :name, :string, { :limit=> 20 } end def self.down end end
Ruby
class RenamePartyColumn < ActiveRecord::Migration def self.up rename_column :votes, :party_id, :political_group_id end def self.down rename_column :votes, :political_group_id, :party_id end end
Ruby
require 'rubygems' require 'hpricot' require 'open-uri' url = 'http://www3.lrs.lt/pls/inter/' doc = Hpricot(open('http://www3.lrs.lt/pls/inter/w5_vaizdas.home?p_kat=103187').read) img_url = (doc/"//a[@href ^= 'w5_vaizdas.nuotrauka' and position()]").first.attributes['href'] img_page = Hpricot(open(url+img_url).read) i...
Ruby
RAILS_ENV = 'development' require File.dirname(__FILE__) + "/../config/environment" require 'jcode' $KCODE = 'u' def strip_last_name(name) name.gsub(/(ai|as|ą|čiui|čio|is|io|į|iuj|iu|iaus|iui|ius|ių|iumi|os|iaus|o|u|ui|ys)$/, '').gsub(/(|ė|ės|ei|e|ę|a)$/, '') end def capitalize_name(name) c_name = '' index = 1 ...
Ruby
#!/usr/local/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impai...
Ruby
#!/usr/local/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impai...
Ruby
#!/usr/local/bin/ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.lo...
Ruby
#!/usr/local/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impai...
Ruby
#!/usr/local/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impai...
Ruby
#!/usr/local/bin/ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.lo...
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
# Settings specified here will take precedence over those in config/environment.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Use a different logger for distributed setups # config.logger = SyslogLogger.new # Full error repor...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.ca...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between...
Ruby
# Be sure to restart your web server when you modify this file. # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way #ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present #RAILS_GEM_VERSI...
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
ActionController::Routing::Routes.draw do |map| map.connect '', :controller => 'kpi', :action => 'index' map.connect 'komandiruotes', :controller => 'travel', :action => 'index' map.connect 'xml', :controller => 'data_service' map.connect 'xml/seimo_nariai', :controller => 'data_service', :action=>'lrs_mps' m...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper def current_parliament "2008 - 2012" end def stat_percent( x, y ) sprintf("%2.2f%", x.to_f / y.to_f * 100 ) end def link_to_with_current( name, options = {}, html_options = {...
Ruby
# Provides a tag for embedding sparklines graphs into your Rails app. # # To use, load it in your controller with # # helper :sparklines # # AUTHOR # # Geoffrey Grosenbach[mailto:boss@topfunky.com] # # http://topfunky.com # # License # # This code is licensed under the MIT license. # module SparklinesHelper # Cal...
Ruby
module TravelHelper #wrap argumentas reikalingas kai kviecia is union_trips2html #nes union kitaip auksti pasiskaiciuoja def trips2html(state, wrap = true) trips = state.trips height = trips.size > 14 ? 330 : (trips.size * 20 + 80) cache = StateInfowindowHtmlCache.find_by_state_id(state.id) html =...
Ruby
module DataServiceHelper def state_to_xml(xml, state) xml.salis do state_info(xml, state) end end # mp != nil kai iskvieciamas trip_by_mp def trip_to_xml(xml, state, mp=nil) xml.salis do xml.sn_id @mp.id_in_lrs if mp state_info(xml, state) for trip in state.trips xml...
Ruby
module PoliticiansHelper end
Ruby
module QuestionsHelper end
Ruby
module VotesHelper end
Ruby
module KpiHelper end
Ruby
class StateLabel < ActiveRecord::Base belongs_to :state end
Ruby
class DebateReference < ActiveRecord::Base #http://railsforum.com/viewtopic.php?id=16760 belongs_to :politician belongs_to :name_reference, :class_name => 'Politician', :foreign_key => 'name_reference_id' end
Ruby
class VotePattern < ActiveRecord::Base belongs_to :politician belongs_to :similar_voter, :class_name => 'Politician', :foreign_key => 'similar_voter_id' end
Ruby
class Position < ActiveRecord::Base belongs_to :politician end
Ruby
class State < ActiveRecord::Base has_many :state_labels has_many :trips belongs_to :state_union def to_a ["lng" => lng, "lat" => lat, "label" => trips.size, "info" => trips2html(self)] end private def trips2html(state, wrap = true) trips = state.trips height = trips.size > 1...
Ruby
class Attendance < ActiveRecord::Base belongs_to :sitting belongs_to :politician end
Ruby
class Trip < ActiveRecord::Base belongs_to :state belongs_to :politician end
Ruby
class MpCache < ActiveRecord::Base belongs_to :politician end
Ruby
class Politician < ActiveRecord::Base #has_many :name_references, :through => :debate_references has_many :debate_references, :dependent => :destroy #has_many :similar_voters, :through => :vote_patterns has_many :vote_patterns, :dependent => :destroy, :order => 'score' has_many :positions, :dependent...
Ruby
class ParliamentVote < ActiveRecord::Base end
Ruby
class Session < ActiveRecord::Base has_many :sittings, :dependent => :destroy end
Ruby
class Vote < ActiveRecord::Base include PoliticiansHelper belongs_to :question belongs_to :political_group belongs_to :politician validates_presence_of :political_group ABSENT = 1 NOVOTE = 2 ABSTAIN = 3 NO = 4 YES = 5 end
Ruby
class Speech < ActiveRecord::Base belongs_to :question belongs_to :politician end
Ruby
class StateUnion < ActiveRecord::Base has_many :states def trips trips = [] states.each{|st| trips << st.trips } return trips.flatten end end
Ruby
class Question < ActiveRecord::Base #TODO stage: dabar 'Svarstymas' 'Priėmimas' bet buna ir 'grazinta ....' http://www3.lrs.lt/pls/inter/w5_sale.klaus_stadija?p_svarst_kl_stad_id=-2675 belongs_to :sitting has_many :votes, :dependent => :destroy has_many :political_group_votes, :dependent => :destroy has_...
Ruby
class PoliticalGroupVote < ActiveRecord::Base belongs_to :question belongs_to :political_group end
Ruby
class PoliticalGroup < ActiveRecord::Base has_many :politicians has_many :political_group_votes end
Ruby
class Sitting < ActiveRecord::Base has_many :questions, :dependent => :destroy has_many :votes, :through => :questions has_many :attendances, :dependent => :destroy belongs_to :session def approved_questions aq = Array.new questions.find(:all,:conditions=>{:stage=>'Priėmimas'}).each { |q| a = q...
Ruby
# Handles requests for sparkline graphs. # # You shouldn't need to edit or extend this, but you can read # the documentation for SparklinesHelper to see how to call it from # another view. # # AUTHOR # # Geoffrey Grosenbach[mailto:boss@topfunky.com] # # http://topfunky.com # class SparklinesController < ApplicationCo...
Ruby
class VotesController < ApplicationController def show v = Vote.find(:all, :conditions=>{:sid=>params[:id]}) respond_to { |format| format.xml {render :xml => v.to_xml(:include => :politician)} format.json {render :json => v.to_json(:include => :politician) } } end end
Ruby
require "rexml/document" class KpiController < ApplicationController helper :sparklines def index doc = REXML::Document.new( File.new(File.join(RAILS_ROOT,'papildomi_duomenys', 'lrs_rss.pranesimai_spaudai')).read ) @feed = Array.new doc.elements.each("//item") {|item| @feed << {:title=>item.e...
Ruby
class DataServiceController < ApplicationController def index end def lrs_mps @mps = Politician.find(:all) render :layout => false end def trips_by_mp @mp = Politician.find_by_id_in_lrs( params[:sn] ) @states = State.find(:all, :include => [:trips], :conditions => ['trips.politician_id = ?', ...
Ruby
class QuestionsController < ApplicationController helper :sparklines def index @questions = Question.find :all end def auto_complete_for_politician_full_name search = params[:politician][:full_name] @politicians = Politician.find(:all, :conditions => [ 'LOWER(last_name) LIKE ?', sea...
Ruby
class PoliticiansController < ApplicationController helper :sparklines def index politicians = Politician.find :all @politicians_active = politicians.reject{|mp| mp.current_positions_by_type('seimas').size == 0 } @politicians_inactive = politicians.reject{|mp| mp.current_positions_by_type('seimas').s...
Ruby
# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. require 'rubygems' require 'sparklines' #require 'jcode' #$KCODE = 'u' class ApplicationController < ActionController::Base # Pick a unique cookie name to distinguis...
Ruby
class TravelController < ApplicationController def lrsmap @travelers = Politician.find(:all, :include => [:trips], :order =>'last_name') end def lrslist @states = State.find(:all, :include => [:trips, :state_labels]).sort{|x,y| y.trips.size <=> x.trips.size} @travelers = Politician.find(:all, :incl...
Ruby
require 'rubygems' require 'log4r' module Log @@lg = Log4r::Logger.new 'atviras-seimas' @@lg.outputters = Log4r::Outputter.stdout def log @@lg end end
Ruby
#!/usr/bin/env ruby #RAILS_ENV = 'development' #require File.dirname(__FILE__) + "/../config/environment" require 'rubygems' require 'hpricot' require 'open-uri' require 'lrs/utils' require 'jcode' $KCODE = 'u' require 'iconv' include Utils url = 'http://www3.lrs.lt/pls/inter/' main_page = open('http://www3.lrs.lt/p...
Ruby
require 'rubygems' require 'active_record' require 'app/models/question' require 'app/models/political_group' require 'lrs/log' # # Klausimo duomenu klases konstravimas. Cia jau nebeatliekama html parsinimas, bet gali # buti atliekama tolesne duomenu analize su RegExp # # http://www3.lrs.lt/pls/inter/w5_sale.kl...
Ruby
require 'rubygems' require 'hpricot' require 'open-uri' require 'lrs/utils' require 'lrs/balsavimas/sitting_builder' require 'lrs/balsavimas/question_builder' require 'lrs/balsavimas/debate_analyser' require 'lrs/balsavimas/statistician' require 'app/models/sitting' require 'app/models/vote' require 'lrs/log' # # Visa...
Ruby
require 'lrs/utils' class DebateAnalyser include Utils def analyse(url) mp_references = {} doc = utf_page url current_mp = nil # sneka galie eiti per kelis paragrafus, todel issaugom pradejusi sneketi sitting = (doc/"caption.pav").first.inner_text[/\d+/,0] (doc/"p.Roman").each do |el| ...
Ruby