source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/app/presenters/fields/multiple_select_field_presenter.rb | Ruby | mit | 188 | master | 735 | # frozen_string_literal: true
module Fields
class MultipleSelectFieldPresenter < FieldPresenter
MAX_HARD_CODE_ITEMS_SIZE = 20
def include_blank?
required?
end
def value_for_preview
super&.join(", ")
end
def can_custom_value?
!@model.options.strict_select
end
def ... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/app/presenters/fields/multiple_choice_field_presenter.rb | Ruby | mit | 188 | master | 370 | # frozen_string_literal: true
module Fields
class MultipleChoiceFieldPresenter < FieldPresenter
def value_for_preview
ids = value
return if ids.blank?
if choices.loaded?
choices.target.select { |choice| ids.include?(choice.id) }.map(&:label)
else
choices.where(id: ids).ma... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/app/presenters/fields/attachment_field_presenter.rb | Ruby | mit | 188 | master | 347 | # frozen_string_literal: true
module Fields
class AttachmentFieldPresenter < FieldPresenter
def value_for_preview
id = value
return if id.blank?
blob = ActiveStorage::Blob.find_by id: id
return unless blob
@view.link_to blob.filename, @view.rails_blob_path(blob, disposition: "atta... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/app/presenters/fields/choice_field_presenter.rb | Ruby | mit | 188 | master | 328 | # frozen_string_literal: true
module Fields
class ChoiceFieldPresenter < FieldPresenter
def value_for_preview
id = value
return if id.blank?
if choices.loaded?
choices.target.find { |choice| choice.id == id }&.label
else
choices.find_by(id: id)&.label
end
end
... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/app/presenters/fields/select_field_presenter.rb | Ruby | mit | 188 | master | 501 | # frozen_string_literal: true
module Fields
class SelectFieldPresenter < FieldPresenter
def include_blank?
required?
end
def can_custom_value?
!@model.options.strict_select
end
def collection
collection = @model.choices.map(&:label)
if can_custom_value? && value.present?... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/app/presenters/fields/resource_field_presenter.rb | Ruby | mit | 188 | master | 834 | # frozen_string_literal: true
module Fields
class ResourceFieldPresenter < FieldPresenter
def value_for_preview
return unless @model.collection
return if @model.collection.none?
id = value
return if id.blank?
collection
.where(@model.data_source.value_method => id)
... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/app/presenters/fields/datetime_range_field_presenter.rb | Ruby | mit | 188 | master | 3,048 | # frozen_string_literal: true
module Fields
class DatetimeRangeFieldPresenter < CompositeFieldPresenter
def value_for_preview
record = value
return unless record
from =
(I18n.l(record.begin.in_time_zone) if record.begin && record.begin != -Float::INFINITY)
to =
(I18n.l(re... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/app/presenters/fields/datetime_field_presenter.rb | Ruby | mit | 188 | master | 1,891 | # frozen_string_literal: true
module Fields
class DatetimeFieldPresenter < FieldPresenter
def value
super&.in_time_zone
end
def value_for_preview
value = self.value
I18n.l(value) if value
end
def field_options
return {} if access_readonly?
options = {}
curre... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/app/presenters/fields/field_presenter.rb | Ruby | mit | 188 | master | 874 | # frozen_string_literal: true
class Fields::FieldPresenter < ApplicationPresenter
def required
@model.validations&.presence
end
alias required? required
def target
@options[:target]
end
def value
target&.read_attribute(@model.name)
end
def value_for_preview
target&.read_attribute(@mo... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/app/presenters/fields/boolean_field_presenter.rb | Ruby | mit | 188 | master | 260 | # frozen_string_literal: true
module Fields
class BooleanFieldPresenter < FieldPresenter
def required
@model.validations&.acceptance
end
def value_for_preview
super ? I18n.t("values.true") : I18n.t("values.false")
end
end
end |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/app/presenters/fields/resource_select_field_presenter.rb | Ruby | mit | 188 | master | 657 | # frozen_string_literal: true
module Fields
class ResourceSelectFieldPresenter < FieldPresenter
def include_blank?
required?
end
def can_custom_value?
!@model.options.strict_select
end
def collection
values =
if @model.collection
# TODO: limit 100 for perform... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/app/presenters/fields/integer_range_field_presenter.rb | Ruby | mit | 188 | master | 2,716 | # frozen_string_literal: true
module Fields
class IntegerRangeFieldPresenter < CompositeFieldPresenter
def value_for_preview
record = value
return unless record
"#{record.begin} ~ #{record.end}"
end
def begin_options
{ min: min_begin, max: max_begin, disabled: begin_disabled? }.... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/config/application.rb | Ruby | mit | 188 | master | 1,222 | # frozen_string_literal: true
require_relative "boot"
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
# require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
# require "action_mailer/railtie"
require "action_view... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/config/routes.rb | Ruby | mit | 188 | master | 897 | # frozen_string_literal: true
Rails.application.routes.draw do
resources :dictionaries, except: %i[show]
resources :forms, except: %i[show] do
collection do
post "random"
end
scope module: :forms do
resource :preview, only: %i[show create]
resource :load, only: %i[show create]
... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/config/environments/production.rb | Ruby | mit | 188 | master | 3,439 | # frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, a... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/config/environments/test.rb | Ruby | mit | 188 | master | 1,644 | # frozen_string_literal: true
Rails.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 "s... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/config/environments/development.rb | Ruby | mit | 188 | master | 2,030 | # frozen_string_literal: true
Rails.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... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/config/initializers/cookies_serializer.rb | Ruby | mit | 188 | master | 274 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid fields are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :json |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/config/initializers/inflections.rb | Ruby | mit | 188 | master | 677 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflect... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/config/initializers/actionview.rb | Ruby | mit | 188 | master | 334 | # frozen_string_literal: true
ActionView::Base.field_error_proc = proc do |html_tag, _instance|
if /<(input|label|textarea|select)/.match?(html_tag)
html_field = Nokogiri::HTML::DocumentFragment.parse(html_tag)
html_field.children.add_class "is-danger"
html_field.to_s.html_safe
else
html_tag.html_s... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/config/initializers/form_core.rb | Ruby | mit | 188 | master | 288 | # frozen_string_literal: true
Rails.configuration.to_prepare do
FormCore.virtual_model_class = ::VirtualModel
FormCore.virtual_model_coder_class = FormCore::YAMLCoder
FormCore::YAMLCoder.safe_mode = true
FormCore::YAMLCoder.whitelist_classes.concat [BigDecimal, Date, Time]
end |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/config/initializers/validates_timeliness.rb | Ruby | mit | 188 | master | 1,448 | # frozen_string_literal: true
ValidatesTimeliness.setup do |config|
# Extend ORM/ODMs for full support (:active_record included).
config.extend_orms = [:active_record]
#
# Default timezone
# config.default_timezone = :utc
#
# Set the dummy date part for a time type values.
# config.dummy_date_for_time_... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/db/schema.rb | Ruby | mit | 188 | master | 4,392 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rai... |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/db/migrate/20180220232604_create_choices.rb | Ruby | mit | 188 | master | 244 | # frozen_string_literal: true
class CreateChoices < ActiveRecord::Migration[6.0]
def change
create_table :choices do |t|
t.text :label, null: false
t.references :field, foreign_key: true
t.timestamps
end
end
end |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/db/migrate/20170613184106_add_attachable_to_forms.rb | Ruby | mit | 188 | master | 214 | # frozen_string_literal: true
class AddAttachableToForms < ActiveRecord::Migration[6.0]
def change
change_table :forms do |t|
t.references :attachable, polymorphic: true, index: true
end
end
end |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/db/migrate/20170504214301_create_sections.rb | Ruby | mit | 188 | master | 302 | # frozen_string_literal: true
class CreateSections < ActiveRecord::Migration[6.0]
def change
create_table :sections do |t|
t.string :title, default: ""
t.boolean :headless, null: false, default: false
t.references :form, foreign_key: true
t.timestamps
end
end
end |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/db/migrate/20170504211819_add_columns_to_forms.rb | Ruby | mit | 188 | master | 222 | # frozen_string_literal: true
class AddColumnsToForms < ActiveRecord::Migration[6.0]
def change
change_table :forms do |t|
t.string :title, default: ""
t.text :description, default: ""
end
end
end |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/db/migrate/20170515212355_create_dictionaries.rb | Ruby | mit | 188 | master | 298 | # frozen_string_literal: true
class CreateDictionaries < ActiveRecord::Migration[6.0]
def change
create_table :dictionaries do |t|
t.string :value, null: false, default: "", index: true
t.string :scope, null: false, default: "", index: true
t.timestamps
end
end
end |
github | rails-engine/form_core | https://github.com/rails-engine/form_core | test/dummy/db/migrate/20170504225506_add_columns_to_fields.rb | Ruby | mit | 188 | master | 266 | # frozen_string_literal: true
class AddColumnsToFields < ActiveRecord::Migration[6.0]
def change
change_table :fields do |t|
t.string :label, default: ""
t.string :hint, default: ""
t.references :section, foreign_key: true
end
end
end |
github | r7kamura/rspec-request_describer | https://github.com/r7kamura/rspec-request_describer | rspec-request_describer.gemspec | Ruby | mit | 188 | main | 945 | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rspec/request_describer/version'
Gem::Specification.new do |spec|
spec.name = 'rspec-request_describer'
spec.version = RSpec::RequestDescriber::VERSION
spec.author... |
github | r7kamura/rspec-request_describer | https://github.com/r7kamura/rspec-request_describer | lib/rspec/request_describer.rb | Ruby | mit | 188 | main | 2,151 | # frozen_string_literal: true
require 'rspec/request_describer/version'
module RSpec
module RequestDescriber
class IncorrectDescribe < StandardError; end
RESERVED_HEADER_NAMES = %w[
content-type
host
https
].freeze
SUPPORTED_METHODS = %w[
DELETE
GET
HEAD
P... |
github | r7kamura/rspec-request_describer | https://github.com/r7kamura/rspec-request_describer | spec/spec_helper.rb | Ruby | mit | 188 | main | 545 | # frozen_string_literal: true
require 'rspec/request_describer'
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.sha... |
github | r7kamura/rspec-request_describer | https://github.com/r7kamura/rspec-request_describer | spec/rspec/request_describer_spec.rb | Ruby | mit | 188 | main | 3,296 | # frozen_string_literal: true
require 'openssl'
RSpec.describe RSpec::RequestDescriber do
include RSpec::RequestDescriber
def get(*args)
[__method__, *args]
end
describe 'GET /users' do
it 'calls #get' do
is_expected.to eq(
[
:get,
'/users',
{ headers: {},... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | Gemfile | Ruby | mit | 188 | master | 233 | source "https://rubygems.org"
gemspec
def get_env(name)
(ENV[name] && !ENV[name].empty?) ? ENV[name] : nil
end
gem 'rails', get_env("RAILS_VERSION")
db_gem = get_env("DB_GEM") || "sqlite3"
gem db_gem, get_env("DB_GEM_VERSION") |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | active_snapshot.gemspec | Ruby | mit | 188 | master | 1,083 | require_relative 'lib/active_snapshot/version'
Gem::Specification.new do |s|
s.name = "active_snapshot"
s.version = ActiveSnapshot::VERSION
s.authors = ["Weston Ganger"]
s.email = ["weston@westonganger.com"]
s.summary = "Dead simple snapshot versioning for ActiveRecord mod... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | Rakefile | Ruby | mit | 188 | master | 374 | require File.expand_path(File.dirname(__FILE__) + '/lib/active_snapshot/version.rb')
require "bundler/gem_tasks"
require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
end
task default: [:test]
task :console do
require_relative ... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | test/test_helper.rb | Ruby | mit | 188 | master | 2,139 | #$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
ENV["RAILS_ENV"] = "test"
require "logger" # Fix for Rails 7.0 and below, https://github.com/rails/rails/pull/54264
require "active_support/all"
ActiveSupport.on_load(:active_record) do
### To ensure belongs_to :optional validation errors are being caught pro... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | test/models/snapshot_item_test.rb | Ruby | mit | 188 | master | 1,926 | require "test_helper"
class SnapshotItemTest < ActiveSupport::TestCase
def setup
@snapshot_klass = ActiveSnapshot::Snapshot
@snapshot_item_klass = ActiveSnapshot::SnapshotItem
end
def teardown
end
def test_relationships
instance = @snapshot_item_klass.new
assert instance.snapshot.nil?
... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | test/models/snapshots_concern_test.rb | Ruby | mit | 188 | master | 2,760 | require "test_helper"
class SnapshotsConcernTest < ActiveSupport::TestCase
def setup
end
def teardown
end
def test_relationships
instance = Post.new
assert instance.snapshots.empty?
assert instance.snapshot_items.empty?
assert_raises do
instance.snapshots << instance
end
i... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | test/models/snapshot_test.rb | Ruby | mit | 188 | master | 12,983 | require "test_helper"
class SnapshotTest < ActiveSupport::TestCase
def setup
@snapshot_klass = ActiveSnapshot::Snapshot
end
def teardown
end
def test_relationships
shared_post = Post.first!
instance = @snapshot_klass.new
assert instance.user.nil?
assert instance.item.nil?
assert ... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | test/generators/active_snapshot/install_generator_test.rb | Ruby | mit | 188 | master | 854 | require "test_helper"
require File.expand_path("../../../lib/generators/active_snapshot/install/install_generator", __dir__)
class InstallGeneratorTest < Rails::Generators::TestCase
tests ActiveSnapshot::InstallGenerator
destination File.expand_path("tmp", __dir__)
setup do
prepare_destination # cleanup the... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | test/unit/active_snapshot_test.rb | Ruby | mit | 188 | master | 1,497 | require "test_helper"
class ActiveSnapshotTest < ActiveSupport::TestCase
def test_exposes_main_module
assert ActiveSnapshot.is_a?(Module)
end
def test_exposes_version
assert ActiveSnapshot::VERSION
end
def test_snapshot_lifecycle
identifier = "snapshot-1"
klass = Post
parent = klass.... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | test/unit/config_test.rb | Ruby | mit | 188 | master | 2,715 | require "test_helper"
class ActiveSnapshot::ConfigTest < ActiveSupport::TestCase
describe "storage_method" do
def setup
@orig_storage_method = ActiveSnapshot.config.storage_method
end
def teardown
ActiveSnapshot.config.storage_method = @orig_storage_method
end
def test_defaults_to_... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | test/dummy_app/config/routes.rb | Ruby | mit | 188 | master | 246 | Dummy::Application.routes.draw do
get 'spreadsheets/csv', to: 'spreadsheets#csv'
get 'spreadsheets/ods', to: 'spreadsheets#ods'
get 'spreadsheets/xlsx', to: 'spreadsheets#xlsx'
get 'spreadsheets/alt_xlsx', to: 'spreadsheets#alt_xlsx'
end |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | test/dummy_app/config/application.rb | Ruby | mit | 188 | master | 1,926 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require
module Dummy
class Application < Rails::Application
config.load_defaults Rails::VERSION::STRING.to_f
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go in... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | test/dummy_app/config/environments/test.rb | Ruby | mit | 188 | master | 1,737 | Dummy::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 test su... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | test/dummy_app/db/migrate/20210306100122_create_snapshots_tables.rb | Ruby | mit | 188 | master | 1,012 | class CreateSnapshotsTables < ActiveRecord::Migration::Current
def change
create_table :snapshots do |t|
t.belongs_to :item, polymorphic: true, null: false, index: true
t.belongs_to :user, polymorphic: true
t.string :identifier, index: true
t.index [:identifier, :item_id, :item_type], un... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | test/dummy_app/db/migrate/20210128155312_set_up_test_tables.rb | Ruby | mit | 188 | master | 644 | class SetUpTestTables < ActiveRecord::Migration::Current
def change
create_table :posts do |t|
t.integer :a, :b
t.integer :status, default: 0
t.timestamps
end
create_table :comments do |t|
t.string :content
t.references :post
t.timestamps
end
create_table... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | test/dummy_app/app/models/post.rb | Ruby | mit | 188 | master | 420 | class Post < ActiveRecord::Base
include ActiveSnapshot
if Rails::VERSION::MAJOR >= 7
enum :status, [:draft, :published]
else
enum status: [:draft, :published]
end
has_many :comments
has_many :notes
has_snapshot_children do
instance = self.class.includes(:comments, :notes).find(id)
{
... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | test/dummy_app/app/models/task.rb | Ruby | mit | 188 | master | 233 | class Task < ApplicationRecord
include ActiveSnapshot
belongs_to :requester, class_name: "User"
belongs_to :assignee, class_name: "User"
has_snapshot_children do
{ requester: requester, assignee: assignee }
end
end |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | lib/active_snapshot.rb | Ruby | mit | 188 | master | 642 | require "active_snapshot/version"
require "active_snapshot/config"
require 'active_support/lazy_load_hooks'
module ActiveSnapshot
@@config = ActiveSnapshot::Config.new
def self.config(&block)
if block_given?
block.call(@@config)
else
return @@config
end
end
end
ActiveSupport.on_load(:a... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | lib/generators/active_snapshot/migration_generator.rb | Ruby | mit | 188 | master | 2,407 | require "rails/generators"
require "rails/generators/active_record"
module ActiveSnapshot
# Basic structure to support a generator that builds a migration
class MigrationGenerator < ::Rails::Generators::Base
include ::Rails::Generators::Migration
def self.next_migration_number(dirname)
::ActiveRecor... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | lib/generators/active_snapshot/install/install_generator.rb | Ruby | mit | 188 | master | 488 | require "generators/active_snapshot/migration_generator"
module ActiveSnapshot
class InstallGenerator < MigrationGenerator
source_root File.expand_path("templates", __dir__)
desc "Generates a migration to add a the `snapshots` and `snapshot_items` tables"
def create_migration_file
add_migration(... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | lib/active_snapshot/config.rb | Ruby | mit | 188 | master | 1,165 | module ActiveSnapshot
class Config
def initialize
end
def storage_method
if @storage_method.nil?
if ActiveSnapshot::SnapshotItem.table_exists? && ActiveSnapshot::SnapshotItem.type_for_attribute(:object).type == :text
# for legacy active_snapshot configurations only
self.... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | lib/active_snapshot/models/snapshot.rb | Ruby | mit | 188 | master | 8,010 | module ActiveSnapshot
class Snapshot < ActiveRecord::Base
self.table_name = "snapshots"
if defined?(ProtectedAttributes)
attr_accessible :item_id, :item_type, :identifier, :user_id, :user_type
end
belongs_to :user, polymorphic: true, optional: true
belongs_to :item, polymorphic: true
h... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | lib/active_snapshot/models/snapshot_item.rb | Ruby | mit | 188 | master | 1,938 | module ActiveSnapshot
class SnapshotItem < ActiveRecord::Base
self.table_name = "snapshot_items"
if defined?(ProtectedAttributes)
attr_accessible :object, :item_id, :item_type, :child_group_name
end
belongs_to :snapshot, class_name: 'ActiveSnapshot::Snapshot'
belongs_to :item, polymorphic:... |
github | westonganger/active_snapshot | https://github.com/westonganger/active_snapshot | lib/active_snapshot/models/concerns/snapshots_concern.rb | Ruby | mit | 188 | master | 3,743 | module ActiveSnapshot
module SnapshotsConcern
extend ActiveSupport::Concern
included do
### We do NOT mark these as dependent: :destroy, the developer must manually destroy the snapshots or individual snapshot items
has_many :snapshots, as: :item, class_name: 'ActiveSnapshot::Snapshot'
has_... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | rghost.gemspec | Ruby | mit | 187 | master | 1,206 | # shairon.toledo@gmail.com
# 14 de Dezembro de 2007
require_relative "lib/rghost/version"
Gem::Specification.new do |s|
s.name = "rghost"
s.version = RGhost::VERSION::STRING
s.authors = ["Shairon Toledo"]
s.email = "shairon.toledo@gmail.com"
s.homepage = "https://github.com/shairontoledo/rghost"
s.platfor... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | Gemfile | Ruby | mit | 187 | master | 227 | source "https://rubygems.org"
# Specify runtime dependencies in rghost.gemspec
gemspec
gem "pry-byebug", group: [:development, :test], platforms: [:ruby]
gem "rspec", group: :test
gem "standard", group: [:development, :test] |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost.rb | Ruby | mit | 187 | master | 331 | $LOAD_PATH << File.dirname(__FILE__) + File::SEPARATOR + "rghost"
require "fileutils"
module RGhost
class RenderException < Exception; end
end
require "rghost/version"
require "rghost/ps_object"
require "rghost/variable"
require "rghost/ps_facade"
require "rghost/function"
require "rghost/document"
require "rghost/... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/point.rb | Ruby | mit | 187 | master | 409 | require "rghost/ps_object"
require "rghost/units"
# Creates one point using default unit defined in RGhost::Config::GS[:unit]
class RGhost::Point < RGhost::PsObject
attr_accessor :x, :y
def initialize(x, y)
if x.is_a? Hash
point = x
@x, @y = point[:x], point[:y]
else
@x, @y = x, y
en... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/gif.rb | Ruby | mit | 187 | master | 1,121 | require "rghost/ps_object"
require "rghost/graphic"
require "rghost/cursor"
require "rghost/variable"
require "rghost/image"
require "rghost/function"
require "rghost/scale"
# Loads GIF image from file
#===Examples
# doc=Document.new
# doc.set Gif.new "../public/images/button.gif", :x => 10, :y => 3
# Using Image.for f... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/function.rb | Ruby | mit | 187 | master | 600 | require "rghost/ps_object"
# Creates postscript internal function. Example
# f=RGhost::Function.new :foo do
# set Show.new("A Test")
# end
# In ps stack will be
# /foo (A Test) show def
class RGhost::Function < RGhost::PsObject
attr_reader :name
def initialize(name, body_function = nil, &block)
if block
... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/virtual_pages.rb | Ruby | mit | 187 | master | 881 | # Defines virtual pages for the Document by method virtual_pages
class RGhost::VirtualPages < RGhost::PsObject
DEFAULT_OPTIONS = {width: 5, margin_left: 0}
include RGhost::RubyToPs
def initialize(&block)
super("") {}
@pages = []
instance_eval(&block) if block
end
def new_page(options = RGhost::Vi... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/ps_facade.rb | Ruby | mit | 187 | master | 5,721 | [:ps_object, :dynamic_document_callback, :static_document_callback, :paper, :load,
:cursor, :show, :color, :graphic, :newpath, :line, :parse_text, :line_width, :textarea,
:variable, :eps, :jpeg, :gif, :text_in, :text_link_in, :ruby_ghost_engine, :convert,
:text, :dash, :border, :shape_content, :vertical_line, :ho... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/line_width.rb | Ruby | mit | 187 | master | 473 | require "rghost/ps_object"
# Sets the line width parameter in the graphics state.
class RGhost::LineWidth < RGhost::PsObject
# Examples
# The more tiny line
# doc=Document.new
# doc.line_width 0
#
# link:images/line_width01.png
#
# doc.line_width 1
#
# link:images/line_width02.png
#
# doc.line_w... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/circle.rb | Ruby | mit | 187 | master | 3,249 | require "rghost/ps_object"
require "rghost/units"
# Draw a circle to the current path(or current row by default).
#===Options
#
# * <tt>:x and :y</tt> - as center of the circle.
# * <tt>:radius</tt> - as radius(in points).
# * <tt>:ang1</tt> - the angle of a vector from (:x , :y ) of length :radius to the first endpoin... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/constants.rb | Ruby | mit | 187 | master | 35,050 | require "rghost/helpers"
module RGhost::Constants
module HashKeyMethod # :nodoc:
def method_missing(method, *args)
self[method.to_sym]
end
end
class HashKeyMethodClass < Hash # :nodoc:
include RGhost::Constants::HashKeyMethod
end
module Devices
# Standard Devices
STANDARD = RGhost... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/text_in.rb | Ruby | mit | 187 | master | 1,740 | require "rghost/ps_object"
require "rghost/cursor"
require "rghost/ruby_to_ps"
# TextIn is a helper to combine the cursor positioning and text output into one step.
class RGhost::TextIn < RGhost::PsObject
include RGhost::RubyToPs
DEFAULT_OPTIONS = {x: :limit_left, y: :current_row, tag: :default_font, write: "Ruby G... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/scale.rb | Ruby | mit | 187 | master | 554 | require "rghost/ps_object"
# Scales objects
class RGhost::Scale < RGhost::PsObject
#===Examples
# doc.scale(1,1) #default document scale
#
# link:images/scale01.png
#
# doc.scale(1,3)
#
# link:images/scale02.png
#
# doc.scale(3,3)
#
# link:images/scale03.png
def initialize(sx, sy)
su... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/variable.rb | Ruby | mit | 187 | master | 257 | require "rghost/ps_object"
# Creates Postscript variable
class RGhost::Variable < RGhost::PsObject
#===Example
# v=Variable.new(:mytext, Show.new("Fooo Barrr") )
# doc.set v
def initialize(name, value)
super("/#{name} #{value} def")
end
end |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/color.rb | Ruby | mit | 187 | master | 5,422 | require "rghost/ps_object"
require "rghost/constants"
require "rghost/ruby_to_ps" # array_to_stack
# Creates color for postscript components
class RGhost::Color < RGhost::PsObject
include RGhost::RubyToPs
# The method create is a color factory depends when parameter is used. The parameter variate between 0 and 1, ... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/line.rb | Ruby | mit | 187 | master | 2,184 | require "rghost/ps_object"
require "rghost/point"
# Creates straight lines
class RGhost::Line < RGhost::PsObject
DEFAULT_POINT = {x: :limit_left, y: :current_row}
# Draw line the one pont until another, the first point is creates by moveto and de last point using the method lineto.
#===Examples
# doc=Document... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/helpers.rb | Ruby | mit | 187 | master | 231 | module RGhost::UnlessHelpers # :nodoc:
module HashKeyMethod # :nodoc:
def method_missing(method, *args)
self[method.to_sym]
end
end
class HashKeyMethodClass < Hash # :nodoc:
include HashKeyMethod
end
end |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/ruby_to_ps.rb | Ruby | mit | 187 | master | 2,901 | # Converts Ruby types to Postscript types
module RGhost::RubyToPs
UTF8_ENCODINGS = {
"¡" => 0xA1, "¢" => 0xA2, "£" => 0xA3, "€" => 0xA4, "¥" => 0xA5, "Š" => 0xA6, "§" => 0xA7,
"š" => 0xA8, "©" => 0xA9, "ª" => 0xAA, "«" => 0xAB, "¬" => 0xAC, "®" => 0xAE, "¯" => 0xAF,
"°" => 0xB0, "±" => 0xB1, "²" => 0xB2, ... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/text_link_in.rb | Ruby | mit | 187 | master | 1,497 | require "rghost/ps_object"
require "rghost/cursor"
require "rghost/ruby_to_ps"
# TextLinkIn is a helper to combine the cursor positioning and text with hyperlink output into one step as TextIn.
# It works only PDF format
class RGhost::TextLinkIn < RGhost::PsObject
include RGhost::RubyToPs
DEFAULT_OPTIONS = {x: :lim... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/eps.rb | Ruby | mit | 187 | master | 753 | require "rghost/ps_object"
# Load new EPS file.
class RGhost::Eps < RGhost::PsObject
#===Examples
# doc=Document.new
# doc.set Eps.new "/local/templates/myform.eps", :x => 10, :y => 3
# Using Image.for facade
# doc.set Image.for "/local/templates/myform.eps", :x => 10, :y => 3
# Using PsFacade or Document
... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/newpath.rb | Ruby | mit | 187 | master | 350 | require "rghost/ps_object"
require "rghost/cursor"
require "rghost/point"
require "rghost/line_width"
# Initializes the current path to be empty, causing the current point to become undefined.
class RGhost::NewPath < RGhost::PsObject
def initialize(&)
@body = RGhost::PsFacade.new(&)
end
def ps
"newpath ... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/dynamic_document_callback.rb | Ruby | mit | 187 | master | 363 | require "rghost/callback"
class RGhost::DynamicDocumentCallback < RGhost::Callback # :nodoc:
ACCEPT = [:before_page_create,
:after_page_create,
:odd_pages,
:even_pages]
def initialize(name, options = {}, &block)
raise NameError.new("#{name} no accept in #{self.class}") unless ACCEPT.include? name
... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/dash.rb | Ruby | mit | 187 | master | 1,527 | # Sets the dash pattern on border lines. It accepts an array of
# non-negative numbers with atleast one non-zero. Samples:
# [2,1] #=> 2 turn on and 1 off, 2 turn on and 1 off ...
# [3,1,2,5] #=> 3 on, 1 off, 2 on, 5 off ... repeating until end
#
#
#===Examples using dash as border parameter
# d=Document.new
# d.ho... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/point_with_command.rb | Ruby | mit | 187 | master | 315 | require "rghost/ps_object"
require "rghost/units"
class RGhost::PointWithCommand # :nodoc:
DEFAULT_POINT = {x: :limit_left, y: :current_row}
def self.to(command, point = {})
p = DEFAULT_POINT.dup.merge(point)
p = RGhost::Point.new(p[:x], p[:y])
RGhost::PsObject.new "#{p.ps}#{command}"
end
end |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/which.rb | Ruby | mit | 187 | master | 1,033 | module RGhost
# A cross-platform way of finding an executable in the $PATH.
#
# RGhost::Which.('ruby') #=> /usr/bin/ruby
class Which
def self.call(cmd)
new.call(cmd)
end
def initialize(env: ENV)
@env = env
end
def call(cmd)
cmd_path = Pathname(cmd)
return cmd_path... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/polygon.rb | Ruby | mit | 187 | master | 1,781 | # Draw one shape based in relative node points.
#===Options
#
# * <tt>:x and :y</tt> - Initial position.
# * <tt>:content</tt> - Facade to ShapeContent with same parameters.
# * <tt>:border</tt> - Facade to Border with same parameters.
#===Examples
#
# doc.polygon :x => 3.5, :y => 5.5 do
# node :x => 4, :y => 0
# ... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/parse_text.rb | Ruby | mit | 187 | master | 1,391 | module RGhost::ParseText # :nodoc:
def text_to_ps
unless @tag_parse
case @options[:text_align]
when :center, :right
@text.split("\n").map { |l| "#{to_string(l)} :text_proc_cr :nbw " }.to_s
jump_with = ":nbw"
when :left, nil
if instance_of?(RGhost::Text)
return @... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/pdf_security.rb | Ruby | mit | 187 | master | 877 | class RGhost::PdfSecurity
PERMISSION_VALUES = {
base: -4,
print: -4,
modify: -8,
copy: -16,
annotate: -32,
interactive: -256,
copy_access: -512,
assemble: -1024,
high_quality_print: -2048,
all: -3904
}
attr_accessor :owner_password, :user_password, :key_length
def initia... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/jpeg.rb | Ruby | mit | 187 | master | 1,095 | require "rghost/ps_object"
require "rghost/graphic"
require "rghost/cursor"
require "rghost/variable"
require "rghost/image"
# Loads JPEG image from file
#===Examples
# doc=Document.new
# doc.set Jpeg.new "../public/images/button.jpg", :x => 10, :y => 3
# Using Image.for facade
# doc.set Image.for "../public/images/but... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/ps_object.rb | Ruby | mit | 187 | master | 1,093 | # Postscript wrapper class
class RGhost::PsObject
# Creates new instance of PsObject. Example
# PsObject.new("/my_proc { 33 45 2 10 sub mul div} bind def")
# Or by block code
# PsObject.new do
# set PsObject.new("(A test) show")
# raw "(Other Test in raw) show "
# end
def initialize(body =... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/font.rb | Ruby | mit | 187 | master | 1,170 | require "rghost/ps_object"
require "rghost/constants"
require "rghost/helpers"
class RGhost::Font < RGhost::PsObject # :nodoc:
DEFAULT_OPTONS = {size: 8, name: "Helvetica", encoding: true}
include RGhost::Constants::Fonts
attr_reader :name
def initialize(options)
@options = DEFAULT_OPTONS.dup.merge(optio... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/font_map.rb | Ruby | mit | 187 | master | 1,180 | # NetDeseigners <www.ndesigners.com.br>
# Shairon Toledo <shairon.toledo@gmail.com>
require "rghost/ps_object"
require "rghost/font"
require "rghost/function"
class RGhost::FontMap < RGhost::PsObject # :nodoc:
include RGhost::RubyToPs
def initialize(options = {font: "Helvetica", size: 8}, &block)
# options[:na... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/dsc_entry.rb | Ruby | mit | 187 | master | 389 | require "rghost/ps_object"
# Specifiesnew DSC (Document Structuring Conventions)
class RGhost::DSCEntry < RGhost::PsObject
#===Example
# DSCEntry.new do |entry|
# entry << "BoundingBox: 0 0 612 792"
# entry << "Pages: 45"
# entry << "BeginSetup"
# end
def initialize
yield @entries = [... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/gs_alone.rb | Ruby | mit | 187 | master | 468 | class RGhost::GSAlone # :nodoc:
def initialize(params, debug = false)
@params = params.dup
@params[0] = " " # Get rid of the "gs" command from RGhost::Config::GS[:default_params]
@debug = debug
end
def run
cmd = @params.join(" ")
unless File.exist?(RGhost::Config::GS[:path].to_s)
RGhost... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/ruby_ghost_engine.rb | Ruby | mit | 187 | master | 4,863 | require "rghost/ruby_ghost_config"
require "rghost/constants"
class RGhost::Engine
attr_reader :errors, :error, :output
DEFAULT_OPTIONS = {device: :pdf}
include RGhost::Constants::Devices
def initialize(document, options = {})
@document = document
@options = DEFAULT_OPTIONS.merge(options)
@errors... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/show.rb | Ruby | mit | 187 | master | 2,566 | require "rghost/ps_object"
require "rghost/ruby_to_ps" # to_string
# Writes a text on the current row or point with align.
class RGhost::Show < RGhost::PsObject
attr_accessor :text, :align, :tag
DEFAULT_OPTIONS = {tag: :default_font, align: :show_left}
include RGhost::RubyToPs
#===Options
#
# * <tt>:tag o... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/graphic.rb | Ruby | mit | 187 | master | 382 | require "rghost/ps_object"
require "rghost/cursor"
require "rghost/point"
require "rghost/line_width"
# Creates a new graphic state between gsave and grestore postscript primitives. Example
# doc=Document.new
# doc.graphic do
# set LineWidth.new(0)
# set Line.lineto(5,7)
# end
class RGhost::Graphic < RGho... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/how_to.rb | Ruby | mit | 187 | master | 3,835 | #=Ruby Ghostscript engine - Document Builder
#==About
# RubyGhost (RGhost) is a library for document developers wanting a quick and easy
# way to generate pdf files. Notable features include: inserting images,
# vector drawing , font suppoort , EPS template support and multiple output formats.
# RGhost acts as Ruby a w... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/convert.rb | Ruby | mit | 187 | master | 1,224 | # Convert PDF file to another format using commom render parameters of the Engine
# A additional parameter for this method is :range. Below someone examples:
#
# ====Only cover page
# Convert.new("/dir/myfile.pdf").to :jpeg, :filename => "/tmp/test.jpg"
#
# ====One page per file
# It's generate file with pattern test_... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/ruby_ghost_config.rb | Ruby | mit | 187 | master | 8,838 | require "rghost/font_map"
require "rghost/ps_object"
require "rghost/which"
# Rghost setup with Ghostscript.
# Ghostscript runs on a variety of platforms, this is why we recommend the non coupled install for non *nix environments.
# The gem already comes with a set of defaults but you can change the settings using the... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/units.rb | Ruby | mit | 187 | master | 1,896 | require "rghost/function"
require "rghost/ps_object"
# The postscript default unit is the 1/72th inch. RGhost uses the centimeters (cm) as it's default, mainly for positioning coordinates and numeric object sizes (if the size is a String, it won't be parsed to the default unit). This setting can be changed setting the ... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/document.rb | Ruby | mit | 187 | master | 19,663 | # Ruby Ghost Engine - Document Builder.
# http://rghost.rubyforge.org
# Author Shairon Toledo <shairon.toledo at gmail.com> http://www.hashcode.eti.br
# Brazil Jun/2007
require "rghost/ps_object"
require "rghost/ps_facade"
require "rghost/document_callback_facade"
require "rghost/virtual_pages"
require "rghost/variabl... |
github | shairontoledo/rghost | https://github.com/shairontoledo/rghost | lib/rghost/paper.rb | Ruby | mit | 187 | master | 5,173 | require "rghost/ps_object"
require "rghost/units"
require "rghost/load"
require "rghost/constants"
require "rghost/ruby_to_ps"
# Paper is the area where the Postscript elements/objects are drawn.
# The margin is the document's non-printable area (both by the cursors and by the page's internal controllers).
# The :area_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.