code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
require 'test/unit'
require 'stringio'
class TC_Pages < Test::Unit::TestCase
def setup
@target = PDF.new
@output = StringIO.new
end
# def teardown
# end
def test_appendpage
p1, p2, p3 = Page.new, Page.new, Page.new
assert_nothing_raised do
@target.append_page p1... | Ruby |
require 'test/unit'
class TC_PdfParse < Test::Unit::TestCase
def setup
@data =
%w{
test/dataset/empty.pdf
test/dataset/calc.pdf
test/dataset/crypto.pdf
}
@dict = StringScanner.new "<</N 2 0 R/x1 null/Pi 3.14 /a <<>>>>"
@bytestring = StringSca... | Ruby |
require 'test/unit'
require 'stringio'
class TC_Streams < Test::Unit::TestCase
def setup
@target = PDF.new
@output = StringIO.new
@data = "0123456789" * 1024
end
# def teardown
# end
def test_predictors
stm = Stream.new(@data, :Filter => :FlateDecode)
stm.set_... | Ruby |
require 'test/unit/testsuite'
require 'tc_pdfparse.rb'
require 'tc_streams.rb'
require 'tc_pdfencrypt.rb'
require 'tc_pdfsig.rb'
require 'tc_pdfattach.rb'
require 'tc_pages.rb'
require 'tc_actions.rb'
require 'tc_annotations.rb'
require 'tc_pdfnew.rb'
begin
require 'origami'
rescue LoadError
ORIGAMIDIR = "#{File.d... | Ruby |
require 'test/unit'
class TC_Actions < Test::Unit::TestCase
def setup
@target = PDF.new
@page = Page.new
@action = Action::JavaScript.new "app.alert(null);"
end
# def teardown
# end
def test_pdf_actions
@target.onDocumentOpen @action
@target.onDocumentClose @action... | Ruby |
require 'test/unit'
require 'stringio'
class TC_PdfNew < Test::Unit::TestCase
def setup
@output = StringIO.new
end
# def teardown
# end
def test_pdf_struct
pdf = PDF.new
null = Null.new
assert_nothing_raised do
pdf << null
end
assert_nothing_raise... | Ruby |
require 'test/unit'
require 'stringio'
class TC_PdfAttach < Test::Unit::TestCase
def setup
@target = PDF.new
@attachment = "test/dataset/test.dummycrt"
@output = StringIO.new
end
# def teardown
# end
def test_attachfile
assert_nothing_raised do
fspec = @target.at... | Ruby |
require 'test/unit'
require 'stringio'
class TC_PdfEncrypt < Test::Unit::TestCase
def setup
@target = PDF.read("test/dataset/calc.pdf", :ignore_errors => false, :verbosity => Parser::VERBOSE_QUIET)
@output = StringIO.new
end
# def teardown
# end
def test_encrypt_rc4_40b
@outpu... | Ruby |
require 'test/unit'
require 'stringio'
class TC_PdfSig < Test::Unit::TestCase
def setup
@target = PDF.read("test/dataset/calc.pdf", :ignore_errors => false, :verbosity => Parser::VERBOSE_QUIET)
@output = StringIO.new
@cert = OpenSSL::X509::Certificate.new(File.read("test/dataset/test.dummycr... | Ruby |
require 'test/unit'
require 'stringio'
class TC_Annotations< Test::Unit::TestCase
def setup
@target = PDF.new
@page = Page.new
@action = Action::JavaScript.new "app.alert(null);"
@output = StringIO.new
end
# def teardown
# end
def test_annotations
circle = A... | 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 |
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 |
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 |
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 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 |
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 |
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 |
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 |
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 'administrate_me'
require 'test_administrate_me'
require 'admin_scaffold'
require 'admin_view'
require 'elegant_presentation'
require 'presenter'
require 'presentation_builder'
ActionController::Base.extend AdministrateMeBase
| Ruby |
class AdminViewGenerator < Rails::Generator::NamedBase
attr_accessor :klass, :form_type
def initialize(*args)
super
@klass = name.classify.constantize
@form_type = Hash.new('text_field')
@form_type[:text] = 'text_area'
@form_type[:boolean] = 'check_box'
@form_type[:datetime] = 'datetime_s... | Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the administrate_me plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the administrate_m... | Ruby |
namespace :admin do
desc "Importar al proyecto los archivos para el admin"
task :import_files do
require 'railties_path'
path_to_css = RAILS_ROOT + "/public/stylesheets/"
stylesheets = Dir["./vendor/plugins/administrate_me/files/stylesheets/*.css"]
FileUtils.cp(stylesheets, path_to_css, :verbos... | Ruby |
# Uninstall hook code here
| Ruby |
# Install hook code here
| Ruby |
module AdministrateMe
module ClassMethods
class AdministrateMeConfig
attr_accessor :options
def initialize
@options = {}
@options[:secured] = true
@options[:except] = []
end
# Sometimes it's necesary to include controllers in the a... | Ruby |
class AdminBuilder < ActionView::Helpers::FormBuilder
attr_reader :options
def initialize(object_name, object, template, options, proc)
super
@options[:show_nil] = true if @options[:show_nil].nil?
@form_columns = []
end
(field_helpers - %w(check_box radio_button hidden... | Ruby |
module AdminView::Presenter
class Presenter
attr_reader :lines
class HTMLBuilder
def method_missing(tag, content)
"<#{tag}>#{content}</#{tag}>"
end
end
class Fielder
def initialize(type)
@type = type
@mybuilder = HTMLBuilder.new
... | Ruby |
module AdminView
def generate_navigation
html = ""
if modules = get_modules
modules.each do |tab|
tab_name = get_tab_name
selector = (tab_name == tab[:name].to_s) ? 'current' : 'available'
html << content_tag('li',
link_to(content_tag(... | Ruby |
module AdministrateMeBase
# El método set_module toma como parámetros el nombre de módulo a definir y
# opcionalmente un hash de opciones. El hash de opciones permite reemplazar
# los siguientes valores por defecto:
# :caption = Nombre a mostrar en la pestaña. Por defecto se toma el nombre
# del módulo... | Ruby |
module AdminView::ElegantPresentation
def render_context_with(attr)
condition = controller.respond_to?("render_context_condition") ? controller.render_context_condition : true
nspace = controller.class.namespace ? "#{controller.class.namespace}_" : ""
if condition
html = "#{@parent.class} > "
... | Ruby |
module AdminView::PresentationBuilder
class PresentationBuilder
class ListColumn
def initialize(field, options={})
@field = field
@options = options
end
def value_for(item)
@options[:with] ? related_value_for(item.send(@field)) : item.send(@field)
end
... | Ruby |
module TestAdministrateMe
module ClassMethods
class TestOptions
attr_accessor :params
def initialize
@params = {}
end
def set_params(action, options = {})
@params[action] = options
end
end
# Testear un controllador que utilice admi... | Ruby |
module AdministrateMe::AdminScaffold
module InstanceMethods
def get_list
session[:mini] = ''
@search_key = params[:search_key]
model_class.send(:with_scope, :find => { :conditions => parent_scope }) do
model_class.send(:with_scope, :find => { :conditions => global_scope }... | Ruby |
require 'administrate_me'
require 'test_administrate_me'
require 'admin_scaffold'
require 'admin_view'
require 'elegant_presentation'
require 'presenter'
| Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the administrate_me plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the administrate_m... | Ruby |
namespace :admin do
desc "Importar al proyecto los archivos para el admin"
task :import_files do
require 'railties_path'
path_to_css = RAILS_ROOT + "/public/stylesheets/"
stylesheets = Dir["./vendor/plugins/administrate_me/files/stylesheets/*.css"]
FileUtils.cp(stylesheets, path_to_css)
... | Ruby |
# Uninstall hook code here
| Ruby |
# Install hook code here
| Ruby |
module AdministrateMe
module ClassMethods
def administrate_me(options = {})
@administrate_me_options = options
@administrate_me_options[:except] = [@administrate_me_options[:except]].flatten
include AdministrateMe::AdminScaffold::InstanceMethods
layout 'admin_layout'
b... | Ruby |
class AdminBuilder < ActionView::Helpers::FormBuilder
attr_reader :options
def initialize(object_name, object, template, options, proc)
super
@options[:show_nil] = true if @options[:show_nil].nil?
@form_columns = []
end
(field_helpers - %w(check_box radio_button hidden... | Ruby |
module AdminView::Presenter
class Presenter
attr_reader :lines
class HTMLBuilder
def method_missing(tag, content)
"<#{tag}>#{content}</#{tag}>"
end
end
class Fielder
def initialize(type)
@type = type
@mybuilder = HTMLBuilder.new
... | Ruby |
module AdminView
def generate_navigation
html = ""
controller.modules.each do |tab|
tab_name = get_tab_name
selector = (tab_name == tab[:name].to_s) ? 'selected' : 'available'
html << content_tag('li',
link_to(tab[:caption].humanize, tab[:url]),
... | Ruby |
module AdminView::ElegantPresentation
def render_resource_context(options={})
html = ""
unless controller.respond_to?(:render_context_condition) && controller.render_context_condition == false
unless controller.options[:parent].blank?
html << content_tag('span', controller.options[:parent].... | Ruby |
module TestAdministrateMe
module ClassMethods
class TestOptions
attr_accessor :params
def initialize
@params = {}
end
def set_params(action, options = {})
@params[action] = options
end
end
def test_administrate_me(options = {})
... | Ruby |
module AdministrateMe::AdminScaffold
module InstanceMethods
def get_list
session[:mini] = ''
@search_key = params[:search_key]
model_class.with_scope(:find => {:conditions => global_scope}) do
model_class.with_scope(:find => {:conditions => search_scope}) do
... | 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_VERSION... | 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.resources :rubros
map.resources :productos do |productos|
productos.resources :archivos
end
map.namespace :admin do |admin|
admin.resources :rubros
admin.resources :productos do |productos|
productos.resources :archivos
end
end
ma... | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def render_action_label
case controller.action_name
when "new"
label = "Nuevo registro de #{controller.controller_name.humanize}"
when "edit"
label = "Editando un registro de ... | Ruby |
module RubrosHelper
end
| Ruby |
module ArchivosHelper
end
| Ruby |
module ProductosHelper
end
| Ruby |
class Archivo < ActiveRecord::Base
belongs_to :producto
validates_presence_of :nombre
end
| Ruby |
class Rubro < ActiveRecord::Base
end
| Ruby |
class Producto < ActiveRecord::Base
has_many :archivos
validates_presence_of :nombre
def resumen_breve
self.resumen.to(110) + "..."
end
end
| Ruby |
class RubrosController < ApplicationController
administrate_me do |a|
a.search :nombre
a.public_access!
end
end
| Ruby |
class ProductosController < ApplicationController
administrate_me do |a|
a.search :nombre
a.public_access!
end
end
| Ruby |
class ArchivosController < ApplicationController
administrate_me do |a|
a.set_parent :producto
a.search :nombre
a.public_access!
end
def context
{ :highlight => 'nombre', :description => 'resumen_breve' }
end
end
| Ruby |
class ApplicationController < ActionController::Base
session :session_key => '_admin_session_id'
set_module :productos
set_module :rubros
# Personalizaciones opcionales.
def title
'Demo para administrate_me'
end
def owner
"Kuyay"
end
def app_name
"EasyShop"
end
end
| Ruby |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
| Ruby |
#!/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/console' | 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/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.