code
stringlengths
1
1.73M
language
stringclasses
1 value
ActionController::Routing::Routes.draw do |map| map.resources :premiaciones_escalas map.resources :factores_reconocimientos map.resources :capacitaciones_evaluaciones map.resources :escalas map.resources :capacitaciones_procesos map.resources :capacitaciones_areas_conocimientos do |cac| cac.r...
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
# Use this file to easily define all of your cron jobs. # # It's helpful, but not entirely necessary to understand cron before proceeding. # http://en.wikipedia.org/wiki/Cron # Example: # # set :output, "/path/to/my/cron_log.log" # # every 2.hours do # command "/usr/bin/some_great_command" # runner "MyModel.some_m...
Ruby
# -*- coding: utf-8 -*- { :'es-AR' => { :authlogic => { :error_messages => { :email_invalid => "deberia parecer una direccion email." } }, :years => "años", :months => "meses", :weeks => "semanas", :days => "dias", :hours => "horas", :minutes =...
Ruby
# Be sure to restart your server when you modify this file # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.3.11' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') ...
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 # Full error reports are disabled and caching is turned on config.action_controller.consider_all_reque...
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
module Jqgrid def find_by_params(params, opts) clase = opts[:class] page = params[:page] ? (params[:page]).to_i : 1 rp = params[:rows] ? (params[:rows]).to_i : 10 sortname = params[:sidx] sortorder = params[:sord] ? params[:sord] : "desc" tipo = opts[:tipo_join] ? opts[:tipo_join] : :joi...
Ruby
namespace :fix do desc "Recolecta todas las preguntas de la evaluacion 360 con id 4\n y las agrupa por el metodo 'all_data'; que contiene todos los valores relevantes de la pregunta;\n por cada par de preguntas duplicadas, busca las respuestas y las agrupa por el metodo usuario_y_evaluado\n Asi tenemos l...
Ruby
# -*- coding: utf-8 -*- require 'pathname' namespace(:generar) do desc "Genera el reporte de la evaluacion en formato csv" task :reporte => :environment do puts "** Generando Reporte ..." def row(*args) args.join('|') end def clear(text) text.gsub("\r",'').gsub("\n",'') end #TO...
Ruby
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9 rspec_gem_dir = nil Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir| rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb") end rspec_plugin_dir = File.expand_path(Fil...
Ruby
namespace(:evaluacion) do task :merge_comentarios => :environment do corresponde_pregunta_id=758 no_corresponde_pregunta_id=775 puts "recolectando comentarios de las respuestas a la pregunta que si le corresponden.\n" corresponde={} Respuesta.find_all_by_evaluado_id_and_pregunta_id(274,correspond...
Ruby
namespace :plan_accion do desc "Asigna sus afectados a los planes de accion, teniendo en cuenta el campo 'usuario_id' de la tabla 'planes_acciones_usuarios'\n La tabla se usaba para representar relacion uno-a-uno" task :set_afectado => :environment do puts "Starting" Usuario.all.each do |u| id...
Ruby
require 'pathname' namespace(:generar) do desc "Genera el reporte de la evaluacion en formato csv" task :totalizado => :environment do def row(*args) args.join('|') end def tipo_evaluador(tipo, evaluado_id, evaluador_id) case tipo when "subordinado" "superior" when "sup...
Ruby
namespace(:actualizar) do task :build_all => :environment do [:datos_usuarios,:asignar_preguntas,:resultado_preguntas,:competencia_a_preguntas ,:resultado_competencias].each{|t| build t} end task :iva_aguinaldo_visitadores => :environment do Usuario.update_all("iva_aguinaldo=1", "cargo_id=45") end ...
Ruby
# -*- coding: utf-8 -*- require 'rubygems' require 'faster_csv' namespace :competencias do desc "" task :set_descripciones => :environment do Descripcion.find(:all,:include=>:competencia_cargo).each do |descripcion| descripcion.competencia_id=descripcion.competencia_cargo.competencia_id descripcion....
Ruby
PARAMETROS_ATTRIBUTES=[ {:codigo=>'PV00', :nombre=>"Salario Minimo.", :descripcion=>"Salario Minimo vigente.", }, {:codigo=>'PV01', :nombre=>"Tolerancia llegadas tardias.", :descripcion=>"Cantidad maxima de minutos a tolerar en las marcaciones de entrada, utilizado para el descuento por llegadas t...
Ruby
require 'rubygems' require 'faster_csv' namespace :load do desc "Carga las jearaquias en el sistema" task :jerarquias => :environment do [Cargo, Subordinado, Par, Superior].map(&:delete_all) filename = "#{RAILS_ROOT}/doc/csv/estructura_de_cargos.csv" # posicion = 0 FasterCSV.foreach(filename, :quote_ch...
Ruby
namespace(:evaluacion) do desc "Asignar las preguntas correspondientes a los usuarios evaluados" task :asignar_preguntas => :environment do Evaluacion.all.each do |evaluacion| puts "\n\n\nEvaluacion #{evaluacion.nombre}" puts "------------------\n\n" #evaluados=evaluacion.evaluados.all(:select...
Ruby
#Seguridad. #Se definen los módulos y la relación entre ellos en el método "load_modules", #este utiliza "create_or_update_modulo(attributes,nom_padre='')" para crear o #actualizar los módulos. Una vez cargados todos los módulos, se cargan #los controllers y sus acciones con el metodo "load_controllers_actions". #La pa...
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
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'data_mapper', '~> 1.2' gem 'dm-postgres-adapter' gem 'google-api-client', '>= 0.4.3' group :development do gem 'dm-sqlite-adapter', '~> 1.2' gem 'do_sqlite3', '~> 0.10' 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
#!/usr/bin/ruby require 'find' require 'fileutils' require 'getoptlong' languages=nil opts = GetoptLong.new( [ "--valid-languages", "-l", GetoptLong::REQUIRED_ARGUMENT ] ) opts.each do |opt, arg| case opt when "--valid-languages" languages = arg.split(",") end e...
Ruby
#!/usr/bin/ruby require 'find' require 'fileutils' require 'getoptlong' build_dir = ENV['BUILT_PRODUCTS_DIR'] executable_path = ENV['EXECUTABLE_PATH'] command = ['install_name_tool', '-change', '@executable_path/../Frameworks/Growl.framework/Versions/A/Growl', '@loader_path/../Frameworks/Growl.framework/Versions/A/G...
Ruby
#!/usr/bin/ruby require 'find' require 'fileutils' Find.find(ARGV.shift) do |path| if File.basename(path) == 'Headers' or File.basename(path) == 'PrivateHeaders' puts "Deleting #{path}" FileUtils.rm_r(path) Find.prune end end
Ruby
#!/usr/bin/env ruby # Simple Ruby XML Socket Server # # This is a a simple socket server implementation in ruby # to communicate with flash clients via Flash XML Sockets. # # The socket code is based on the tutorial # "Sockets programming in Ruby" # by M. Tim Jones (mtj@mtjones.com). # # Date:: Tue, 05 Mar 2008 # A...
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' }]) # Mayor.create(:name =>...
Ruby
class CreateAppPermissions < ActiveRecord::Migration def self.up create_table :app_permissions do |t| t.references :app t.references :permission t.timestamps end add_index :app_permissions, :app_id add_index :app_permissions, :permission_id end def self.down drop_table :ap...
Ruby
class CreateTargets < ActiveRecord::Migration def self.up create_table :targets do |t| t.string :name t.timestamps end add_index :targets, :name, :unique => true end def self.down drop_table :targets end end
Ruby
class CreateVisuals < ActiveRecord::Migration def self.up create_table :visuals do |t| t.references :app t.timestamps end add_index :visuals, :app_id end def self.down drop_table :visuals end end
Ruby
class CreatePermissions < ActiveRecord::Migration def self.up create_table :permissions do |t| t.string :name t.timestamps end add_index :permissions, :name, :unique => true end def self.down drop_table :permissions end end
Ruby
class CreateComments < ActiveRecord::Migration def self.up create_table :comments do |t| t.integer :rating t.string :creationTime t.string :authorName t.string :text t.string :authorId t.references :app t.timestamps end add_index :comments, :app_id add_index ...
Ruby
class CreateRatings < ActiveRecord::Migration def self.up create_table :ratings do |t| t.string :rating t.integer :ratingCount t.integer :downloadCount t.string :downloadCountText t.references :app t.timestamps end add_index :ratings, :app_id, :unique => true end ...
Ruby
class AddAttachmentImageToVisual < ActiveRecord::Migration def self.up add_column :visuals, :image_file_name, :string add_column :visuals, :image_content_type, :string add_column :visuals, :image_file_size, :integer add_column :visuals, :image_updated_at, :datetime end def self.down remove_co...
Ruby
class CreateVestalVersions < ActiveRecord::Migration def self.up create_table :versions do |t| t.belongs_to :versioned, :polymorphic => true t.belongs_to :user, :polymorphic => true t.string :user_name t.text :modifications t.integer :number t.integer :reverted_from t...
Ruby
class CreateAppTargets < ActiveRecord::Migration def self.up create_table :app_targets do |t| t.references :app t.references :target t.timestamps end add_index :app_targets, :app_id add_index :app_targets, :target_id end def self.down drop_table :app_targets end end
Ruby
class CreateApps < ActiveRecord::Migration def self.up create_table :apps do |t| t.string :creator t.string :packageName t.string :title t.text :description t.string :appId t.string :category t.text :recentChanges t.string :email t.string :phone t.string...
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. # # Note: You'll currently still have to declare fixtures explicitly in integrati...
Ruby
source 'http://rubygems.org' gem 'rails', '3.0.3' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'mysql2' gem 'paperclip' gem 'will_paginate' gem 'vestal_versions', :git => 'git://github.com/adamcooper/vestal_versions' # Use unicorn as the web server # gem 'unicorn' # D...
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
module ApplicationHelper end
Ruby
module VisualsHelper end
Ruby
module AppPermissionHelper end
Ruby
module AppTargetHelper end
Ruby
module PermissionsHelper end
Ruby
module AppsHelper end
Ruby
module CommentsHelper 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 Target < ActiveRecord::Base has_many :app_targets has_many :apps, :through => :app_targets end
Ruby
class Rating < ActiveRecord::Base versioned belongs_to :app end
Ruby
class Comment < ActiveRecord::Base belongs_to :app end
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 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 AppTarget < ActiveRecord::Base belongs_to :app belongs_to :target end
Ruby
class Record attr_accessor :id, :exists end
Ruby
class ApplicationController < ActionController::Base # protect_from_forgery end
Ruby
class AppTargetsController < ApplicationController # POST /app_targets.xml # POST /app_targets.json def create @app_target = AppTarget.new(params[:app_target]) respond_to do |format| if @app_target.save format.xml { render :xml => @app_target, :status => :created, :location => @app_targ...
Ruby
class CommentsController < ApplicationController # POST /comments.xml # POST /comments.json def create @app = App.find(params[:app_id]) @comment = @app.comments.new(params[:comment]) respond_to do |format| if @comment.save format.xml { render :xml => @comment, :status => :...
Ruby
class PermissionsController < ApplicationController # POST /permission.xml # POST /permission.json def create @permission = Permission.new(:name => params[:permission]) respond_to do |format| if @permission.save format.xml { render :xml => @permission, :status => :created, :location => @...
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 VisualsController < ApplicationController # POST /visuals def create @app = App.find(params[:app_id]) @visual = @app.visuals.new(:image => params[:image]) respond_to do |format| if @visual.save format.html { render :json => @visual, :status => :created} else ...
Ruby
class AppPermissionsController < ApplicationController # POST /app_permissions/update_permissions.xml # POST /app_permissions/update_permissions.json def update_permissions app = App.find(params[:app_id]) app.permission_ids = params[:permissions] respond_to do |format| if app.save! ...
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. # 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
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. # 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
# 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. 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
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
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
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Marketplace::Application.initialize!
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
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Marketplace::Application
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.expand_path('../config/application', __FILE__) require 'rake' Marketplace::Application.load_tasks
Ruby
# Copyright 2008-2009 Nokia Siemens Networks Oyj # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or...
Ruby
#!/usr/bin/env ruby class ExampleRemoteLibrary def count_items_in_directory(path) Dir.entries(path).find_all{|i| not i.match('^\.')}.length end def strings_should_be_equal(str1, str2) puts "Comparing '#{str1}' to '#{str2}'" if str1 != str2 raise RuntimeError, "Given strings are not equal" ...
Ruby
class RubyLibraryExample def get_server_language 'ruby' end # Basic communication def passing end def failing(message) raise message end def logging(message, level='INFO') puts "*#{level}* #{message}" end def returning 'returned string' end # Logging def one_message_w...
Ruby
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 'Win32API' language = Win32API.new("kernel32.dll", "GetLocaleInfoA", ['L', 'L', 'P', 'L'], 'L') x = " " * 255 language.Call(1024, 4097, x, 255) puts x.strip
Ruby
class String def escape t = self begin t["'"] = "''" rescue end return t end end
Ruby
class Error def Error.db_error(e) $glade["error_title"].label = '<span weight="bold" size="larger">' + _("Database Error") + '</span>' $glade["error"].label = _("The database returned the following error:") + "\n#{e.message}" $glade["error_details"].buffer.text = e.backtrace.join("\n") $glade["exception...
Ruby
require "#{SRC}/string" require "#{SRC}/exception" class Book public def initialize $gbook = GladeXML.new("#{GLADE}/book.glade") {|handler| method(handler)} $gbook["flagview"].clear $gbook["flagview"].model = flagview_model renderer = Gtk::CellRendererPixbuf.new $gbook["flagview"].pack_start(render...
Ruby
require "#{SRC}/filter" require "#{SRC}/book" require "#{SRC}/translate" class List attr_reader :list_store public def initialize @book = Book.new @popup = nil $glade = GladeXML.new("#{GLADE}/bibliomori.glade") {|handler| method(handler)} translate_labels # Populate list @l...
Ruby
class List private # Right-click on the books list def filter(w, e) if e.kind_of? Gdk::EventButton and e.button == 3 path = $glade["livros"].get_path_at_pos(e.x, e.y) if path != nil $glade["livros"].selection.select_path(path[0]) else $glade["livros"].selection.unselect_all ...
Ruby
class List def translate_labels # List # Book Edit $gbook['l_book_cover'].label = '<b>' + _("Book Cover") + '</b>' $gbook['l_book_information'].label = '<b>' + _("Book Information") + '</b>' $gbook['l_book_content'].label = "\n<b>" + _("Book Content") + '</b>' $gbook['l_isbn'].label = _("_ISBN...
Ruby
#!/usr/bin/env ruby require 'getoptlong' share_dir = '/usr/local/share/bibliomori' bin_dir = '/usr/local/bin' man_dir = '/usr/local/share/man' uninstall = false opts = GetoptLong.new( [ '--help', '-h', GetoptLong::NO_ARGUMENT], [ '--uninstall', '-u', GetoptLong::NO_ARGUMENT], [ '--share-dir', GetoptLong::REQUIRED...
Ruby