code
stringlengths
1
1.73M
language
stringclasses
1 value
class Text < Gtk::TextView def initialize super self.wrap_mode = Gtk::TextTag::WRAP_WORD self.set_size_request(0, 0) apply_config self.buffer.signal_connect('changed') { $main.dirty = true } end def apply_config self.modify_font(Pango::FontDescription.new($conf.font)) self.modify_text(Gtk...
Ruby
class Place attr_accessor \ :name, :text end
Ruby
class Chapter attr_accessor \ :name, :text def initialize(name=nil) @name = name @text = [] end end
Ruby
require 'character' require 'place' require 'chapter' class Book attr_accessor \ :title, :subtitle, :authors, :word_goal attr_reader \ :characters, :places, :chapters def initialize @authors = [] @characters = [] @places = [] @chapters = [] end def export(filename...
Ruby
class Character attr_accessor \ :name, :text end
Ruby
class MenuButton < Gtk::Button def initialize(image) super() self.relief = Gtk::RELIEF_NONE self.modify_bg(Gtk::STATE_NORMAL, $conf.bg) if image.class == Symbol # stock self << Gtk::Image.new(image, Gtk::IconSize::LARGE_TOOLBAR) elsif image.class == String self << Gtk::Image.new("#{DIR}/src/"...
Ruby
class Gtk::Widget @@tips = Gtk::Tooltips.new def tip=(t) @@tips.set_tip(self, t, '') end end
Ruby
# Since all internationalization options for ruby suck, I decided to roll my # own. require 'yaml' class Object def _(str, *args) return str % args if $l == nil x = $l[str] if x == nil return str % args else return x % args end end def load_language(language=nil) $l = nil i...
Ruby
class Help < Gtk::Dialog def initialize(it) super(_('Help'), $main, Gtk::Dialog::MODAL | Gtk::Dialog::DESTROY_WITH_PARENT, [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_ACCEPT]) table = Gtk::Table.new(2, 2) table.column_spacings = 24 table.row_spacings = 6 table.border_width = 24 r = 0 it.each do ...
Ruby
class NewBookButton < MenuButton def initialize super(Gtk::Stock::NEW) self.tip = _('Create a new book (Ctrl+N)') self.signal_connect('clicked') { NewBookButton.new_book } end def NewBookButton.new_book(or_open = false) a = Gtk::Assistant.new a.title = _('Book Wizard') a.set_size_request(500...
Ruby
class ExportBookButton < MenuButton def initialize super(Gtk::Stock::CONVERT) self.tip = _('Export this book in a different format (Ctrl+E)') self.signal_connect('clicked') { ExportBookButton.export_book } end def ExportBookButton.export_book $main.save_book a = Gtk::Assistant.new a.title ...
Ruby
class Main < Gtk::Window attr_reader :book, :text, :dirty attr_accessor :filename def initialize $main = self super build_window self.dirty = false @on_fullscreen = false @filename = $conf.last_file begin @book = YAML::load(File.open(@filename)) @chapterlist.refresh_buttons ...
Ruby
class Configurations < Gtk::Dialog def initialize super(_('Choose an option'), $main, Gtk::Dialog::MODAL, [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_ACCEPT], [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_REJECT]) build_window end private def build_window options = Gtk::Notebook.new opti...
Ruby
class ChapterList < Gtk::ScrolledWindow BOOK_OPEN = Gdk::Pixbuf.new("#{DIR}/src/book_open.png") BOOK_CLOSED = Gdk::Pixbuf.new("#{DIR}/src/book_closed.png") attr_reader :current_chapter def initialize super() self.hscrollbar_policy = Gtk::POLICY_NEVER self.vscrollbar_policy = Gtk::POLICY_AUTOMATIC...
Ruby
class Conf attr_accessor :font, :text_width, :last_file, :bg_array, :fg_array, :toolbox_visible def initialize # load @font = 'Consolas 10' @text_width = 400 @last_file = nil @bg_array = [65535, 65535, 65535] @fg_array = [0, 0, 0] @toolbox_visible = true end def bg return Gdk::Colo...
Ruby
class Export def Export.filename_format(f) str = f.sub(' ', '_').downcase begin str = Iconv.conv('iso-8859-1', 'utf-8', str) rescue; end return str end def Export.export_txt(book, path, type, line_ending, encoding) chapters = [] book.chapters.each_index { |i| chapters[i] = '' } i = ...
Ruby
#!/usr/bin/env ruby # # Get platform (code from Matt Mower <self@mattmower.com>) # if RUBY_PLATFORM =~ /darwin/i OS = :unix IMPL = :macosx elsif RUBY_PLATFORM =~ /linux/i OS = :unix IMPL = :linux elsif RUBY_PLATFORM =~ /freebsd/i OS = :unix IMPL = :freebsd elsif RUBY_PLATFORM =~ /netbsd/i OS = :unix IMPL = :ne...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/RWD/bootstrap-rwd" css_dir = "css" sass_dir = "sass" images_dir = "img" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): # ou...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "css" sass_dir = "sass" images_dir = "img" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): # output_style = :expan...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "css" sass_dir = "sass" images_dir = "img" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): # output_style = :expan...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/RWD/bootstrap-rwd" css_dir = "css" sass_dir = "sass" images_dir = "img" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): # ou...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "css" sass_dir = "sass" images_dir = "img" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): # output_style = :expan...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/RWD/bootstrap-rwd" css_dir = "css" sass_dir = "sass" images_dir = "img" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): # ou...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "css" sass_dir = "sass" images_dir = "img" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): # output_style = :expan...
Ruby
=begin Jekyll tag to include Markdown text from _includes directory preprocessing with Liquid. Usage: {% markdown <filename> %} =end module Jekyll class MarkdownTag < Liquid::Tag def initialize(tag_name, text, tokens) super @text = text.strip end def render(context) tmpl = File...
Ruby
module Jekyll @parsedlangs = {} def self.langs @parsedlangs end def self.setlangs(l) @parsedlangs = l end class Site alias :process_org :process def process if !self.config['baseurl'] self.config['baseurl'] = "" end #Variables config['baseurl_root'] = self.con...
Ruby
class CreateServicos < ActiveRecord::Migration def self.up create_table :servicos do |t| t.string :nome t.float :valor t.text :descricao t.timestamps end end def self.down drop_table :servicos end end
Ruby
class CreateHospedes < ActiveRecord::Migration def self.up create_table :hospedes do |t| t.string :nome t.string :endereco t.date :nascimento t.string :pais t.string :sexo t.string :estCivil t.timestamps end end def self.down drop_table :hospedes end end
Ruby
module TiposApartamentosHelper end
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module TiposPagamentosHelper end
Ruby
module ReservasHelper end
Ruby
module ClienteHelper end
Ruby
module HospedesHelper end
Ruby
module AdminHelper end
Ruby
module ServicosHelper end
Ruby
module ApartamentosHelper end
Ruby
module HomeHelper end
Ruby
class ContasPagamento < ActiveRecord::Base end
Ruby
class ContasEncerrada < ActiveRecord::Base end
Ruby
class ContasApartamento < ActiveRecord::Base belongs_to :conta belongs_to :apartamento def initialize attributes = {} super end end
Ruby
class TiposApartamento < ActiveRecord::Base validates_presence_of :nome, :descricao, :valor validates_numericality_of :valor validates_uniqueness_of :nome protected def validate errors.add(:valor, "deve ser positivo") unless valor.nil? || valor > 0.0 end end
Ruby
class Reserva < ActiveRecord::Base validates_presence_of :hospede_id, :tiposApartamento_id validate :okToReserve belongs_to :tipos_apartamentos belongs_to :hospedes def self.meses %w[Janeiro Fevereiro Março Abril Maio Junho Julho Agosto Setembro Outubro Novembro Dezembro] end def okToReserve if dataEntra...
Ruby
require "digest/sha1" class Recepcionista < ActiveRecord::Base attr_accessor :password attr_reader :id attr_accessible :nome, :endereco, :nascimento, :sexo, :estCivil, :login, :password validates_uniqueness_of :login def before_create self.f.hashed_password = User.hash_password(self.password) end def after...
Ruby
class Apartamento < ActiveRecord::Base has_one :conta belongs_to :tipos_apartamentos validates_presence_of :num, :tiposApartamento_id validates_uniqueness_of :num validates_numericality_of :num def hospedar(hospede,numAcomp,dataEntr) atrib = { :hospede => Hospede.find(hospede), :numAcomp => numAcomp, :dataEn...
Ruby
require "digest/sha1" class Hospede < ActiveRecord::Base validates_presence_of :nome, :endereco, :nascimento, :pais, :sexo, :estCivil, :login, :password validates_uniqueness_of :login # attr_accessor :password # attr_accessible :login, :password def before_create self.password = Hospede.hash_password(self.passwor...
Ruby
class Pagamento < ActiveRecord::Base end
Ruby
class TiposPagamento < ActiveRecord::Base end
Ruby
class Conta < ActiveRecord::Base belongs_to :hospede has_many :aluguel @encerrada def initialize attributes = {} super end def total total_aluguel = 0 total_diaria = 0 alugueis = Aluguel.find(:all,:conditions => [" conta_id = ?", id]) apts = ContasApartamento.find(:all, :conditions => ["conta_id = ?...
Ruby
class Aluguel < ActiveRecord::Base set_table_name 'alugueis' belongs_to :conta belongs_to :servico belongs_to :apartamento end
Ruby
class Servico < ActiveRecord::Base validates_presence_of :nome, :descricao, :valor validates_numericality_of :valor validates_uniqueness_of :nome protected def validate errors.add(:valor, "deve ser positivo") unless valor.nil? || valor > 0.0 end end
Ruby
class ApartamentosController < ApplicationController layout 'layout' before_filter :authorize # GET /apartamentos # GET /apartamentos.xml def index @apartamentos = Apartamento.find(:all, :order => "num") respond_to do |format| format.html # index.html.erb format.xml { render :xml => @ap...
Ruby
class ContasController < ApplicationController layout 'layout' before_filter :authorize def show @conta = Conta.find(params[:id]) @alugueis = Aluguel.find(:all,:conditions => [" conta_id = ?", @conta.id]) @apts = ContasApartamento.find(:all, :conditions => ["conta_id = ?", @conta.id]) respond_to do |f...
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
class HospedesController < ApplicationController layout 'layout' before_filter :authorize, :except => [:new, :create] # GET /hospedes # GET /hospedes.xml def index @hospedes = Hospede.find(:all, :order => "nome, nascimento, endereco, pais, sexo, estCivil") respond_to do |format| format.html # i...
Ruby
class ReservasController < ApplicationController layout 'layout' # before_filter :authorize # GET /reservas # GET /reservas.xml def index if session[:admin] @reservas = Reserva.find(:all, :order => "dataEntrada, dataSaida, tiposApartamento_id, hospede_id") elsif session[:cliente] @reservas = Reserva.fi...
Ruby
class TiposPagamentosController < ApplicationController layout 'layout' before_filter :authorize # GET /tipos_pagamentos # GET /tipos_pagamentos.xml def index @tipos_pagamentos = TiposPagamento.find(:all, :order => "nome") respond_to do |format| format.html # index.html.erb format.xml {...
Ruby
class ClienteController < ApplicationController layout 'layout' before_filter :authorize_cliente, :except => :login def login unless session[:cliente] if request.get? session[:cliente] = nil @user = Hospede.new else @user = Hospede.new(params[:hospede]) logged_in_user = @user.try_to_login if ...
Ruby
class HomeController < ApplicationController layout 'layout' def index @hello = "Bem vindos ao hotel boradois!" end end
Ruby
class ConsultasController < ApplicationController layout 'layout' before_filter :authorize def index respond_to do |format| format.html # index.html.erb format.xml { render :xml } end end def con1 if request.post? data = Date.civil(params[:post][:"data(1i)"].to_i,params[:post][:"data...
Ruby
class ServicosController < ApplicationController layout 'layout' before_filter :authorize # GET /servicos # GET /servicos.xml def index @servicos = Servico.find(:all, :order => "nome, valor") respond_to do |format| format.html # index.html.erb format.xml { render :xml => @servicos } ...
Ruby
class TiposApartamentosController < ApplicationController layout 'layout' before_filter :authorize, :except => :index # GET /tipos_apartamentos # GET /tipos_apartamentos.xml def index @tipos_apartamentos = TiposApartamento.find(:all, :order => "nome, valor") respond_to do |format| format.html ...
Ruby
class AdminController < ApplicationController layout 'layout' before_filter :authorize, :except => :login def login unless session[:admin] if request.get? session[:admin] = nil @user = Recepcionista.new else @user = Recepcionista.new(params[:recepcionista]) logged_in_user = @user.try_to_login ...
Ruby
class AlugueisController < ApplicationController layout 'layout' before_filter :authorize # GET /alugueis # GET /alugueis.xml def index @servicos = Servico.find(:all, :order => "nome, valor") @apartamento = Apartamento.find(params[:ap]) respond_to do |format| format.html # index.html.erb ...
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
ActionController::Routing::Routes.draw do |map| map.resources :tipos_pagamentos map.resources :apartamentos map.resources :reservas map.resources :tipos_apartamentos map.resources :servicos map.resources :hospedes map.connect '/contas/view', :controller => 'contas', :action => 'view' map.resources...
Ruby
# Copyright 2013 Lou Parslow # # 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 agre...
Ruby
# Copyright 2012-2013 Lou Parslow # # 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
source "http://rubygems.org" Encoding.default_external=Encoding::UTF_8 Encoding.default_internal=Encoding::UTF_8 # Specify your gem's dependencies in sample.gemspec gem 'rake' gem 'rspec' gem 'cucumber' gem 'semver' gem 'bundler' gem 'sqlite3' gem 'systemu' gem 'rainbow' gem 'countloc' gem 'rubyzip' #...
Ruby
require 'rubygems' puts __FILE__ class B2 def self.dev_home ["DEV_HOME","DEV_ROOT","USERPROFILE","HOME"].each {|v| return ENV[v].gsub('\\','/') unless ENV[v].nil? } nil end def self.cmd_available?(cmd) testCmd="which #{cmd}" testCmd="where #{cmd}" if RUBY_PLATFORM.include?("mingw") ...
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
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
Ruby
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attac...
Ruby
VestalVersions.configure do |config| # Place any global options here. For example, in order to specify your own version model to use # throughout the application, simply specify: # # config.class_name = "MyCustomVersion" # # Any options passed to the "versioned" method in the model itself will override this...
Ruby
# Be sure to restart your server when you modify this file. Marketplace::Application.config.session_store :cookie_store, :key => '_Marketplace_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table wi...
Ruby
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a probl...
Ruby
Marketplace::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turne...
Ruby
Marketplace::Application.configure do # Settings specified here will take precedence over those in config/application.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 w...
Ruby
Marketplace::Application.configure do # Settings specified here will take precedence over those in config/application.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 t...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Marketplace::Application.initialize!
Ruby
require 'rubygems' # Set up gems listed in the Gemfile. gemfile = File.expand_path('../../Gemfile', __FILE__) begin ENV['BUNDLE_GEMFILE'] = gemfile require 'bundler' Bundler.setup rescue Bundler::GemNotFound => e STDERR.puts e.message STDERR.puts "Try running `bundle install`." exit! end if File.exist?(gem...
Ruby
require File.expand_path('../boot', __FILE__) require 'rails/all' # If you have a Gemfile, require the gems listed there, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) if defined?(Bundler) module Marketplace class Application < Rails::Application ...
Ruby
Marketplace::Application.routes.draw do root :to => "apps#index" resources :apps do collection do post 'exists', 'ids' end resources :visuals do collection do post 'exists' end end end resources :app_targets do collection do post 'exists' end end ...
Ruby
module ApplicationHelper end
Ruby
module PermissionsHelper end
Ruby
module VisualsHelper end
Ruby
module AppTargetHelper end
Ruby
module AppPermissionHelper end
Ruby
module CommentsHelper end
Ruby
module AppsHelper end
Ruby
class AppTarget < ActiveRecord::Base belongs_to :app belongs_to :target end
Ruby
class App < ActiveRecord::Base validates_uniqueness_of :packageName has_one :rating, :dependent => :destroy has_many :visuals, :dependent => :destroy has_many :comments, :dependent => :destroy has_many :app_targets has_many :targets, :through => :app_targets has_many :app_permissions has_many :...
Ruby
class Permission < ActiveRecord::Base validates_uniqueness_of :name validates_presence_of :name has_many :app_permissions has_many :apps, :through => :app_permissions end
Ruby
class Target < ActiveRecord::Base has_many :app_targets has_many :apps, :through => :app_targets end
Ruby
class Comment < ActiveRecord::Base belongs_to :app end
Ruby
class Rating < ActiveRecord::Base versioned belongs_to :app end
Ruby
class Visual < ActiveRecord::Base belongs_to :app has_attached_file :image, :url => "/:attachment/:id/:style/:basename.:extension", :path => ":rails_root/public/:attachment/:id/:style/:basename.:extension" validates_attachment_presence :image validates_attachment_co...
Ruby
class AppPermission < ActiveRecord::Base belongs_to :app belongs_to :permission end
Ruby
class AppsController < ApplicationController # GET /apps # GET /apps.xml # GET /apps.json def index @apps = App.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @apps } format.json { render :json => @apps } end end # GET /apps/1 ...
Ruby
class Record attr_accessor :id, :exists end
Ruby