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 | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/context_spec.rb | Ruby | mit | 306 | main | 4,047 | require "spec_helper"
RSpec.describe Lumberjack::Context do
describe "#level" do
it "should have a level" do
context = Lumberjack::Context.new
expect(context.level).to be_nil
context.level = :info
expect(context.level).to eq(Logger::INFO)
context.level = nil
expect(context.lev... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/template_registry_spec.rb | Ruby | mit | 306 | main | 1,610 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::TemplateRegistry do
it "has :default, :stdlib, and :local registered by default" do
expect(Lumberjack::TemplateRegistry.registered_templates).to eq({
default: Lumberjack::Template::DEFAULT_FIRST_LINE_TEMPLATE,
stdlib: Lum... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/attribute_formatter_spec.rb | Ruby | mit | 306 | main | 13,257 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::AttributeFormatter do
let(:attributes) { {"foo" => "bar", "baz" => "boo", "count" => 1} }
describe "#build" do
it "builds an attribute formatter in a block" do
attribute_formatter = Lumberjack::AttributeFormatter.build do |c... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/logger_spec.rb | Ruby | mit | 306 | main | 23,742 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Logger do
describe "compatibility" do
it "should implement the same public API as the ::Logger class" do
logger = ::Logger.new($stdout)
lumberjack = Lumberjack::Logger.new($stdout)
(logger.public_methods - Object.pu... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/attributes_helper_spec.rb | Ruby | mit | 306 | main | 3,484 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::AttributesHelper do
let(:attributes) { {} }
let(:tag_context) { Lumberjack::AttributesHelper.new(attributes) }
describe "expand_runtime_values" do
it "should return the identical hash as is if there are no Procs" do
hash =... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/forked_logger_spec.rb | Ruby | mit | 306 | main | 4,824 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::ForkedLogger do
let(:logger) { TestContextLogger.new(Lumberjack::Context.new) }
it "logs to the parent logger" do
forked_logger = Lumberjack::ForkedLogger.new(logger)
forked_logger.info("Test message")
expect(logger.entr... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/entry_formatter_spec.rb | Ruby | mit | 306 | main | 8,787 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::EntryFormatter do
describe "building formatters" do
it "starts with an empty message formatter and attribute formatter" do
entry_formatter = Lumberjack::EntryFormatter.new
expect(entry_formatter.message_formatter).to_not ... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/tags_spec.rb | Ruby | mit | 306 | main | 522 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Tags, deprecation_mode: :silent do
describe "stringify_keys" do
it "transforms hash keys to strings" do
hash = {foo: 1, bar: 2}
expect(Lumberjack::Tags.stringify_keys(hash)).to eq({"foo" => 1, "bar" => 2})
end
it... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/device_registry_spec.rb | Ruby | mit | 306 | main | 1,647 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::DeviceRegistry do
it "has :stdout, :stderr, :null and :test registered by default" do
expect(Lumberjack::DeviceRegistry.registered_devices).to eq({
stdout: :stdout,
stderr: :stderr,
null: Lumberjack::Device::Null,
... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/severity_spec.rb | Ruby | mit | 306 | main | 3,027 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Severity do
describe "#level_to_label" do
it "converts a level to a label" do
expect(Lumberjack::Severity.level_to_label(Logger::DEBUG)).to eq("DEBUG")
expect(Lumberjack::Severity.level_to_label(Logger::INFO)).to eq("INFO... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/device_spec.rb | Ruby | mit | 306 | main | 3,652 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Device do
describe ".open_device" do
it "passes the options to the underlying device" do
device = Lumberjack::Device.open_device(:test, max_entries: 5)
expect(device.max_entries).to eq(5)
end
it "returns a Null d... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/template_spec.rb | Ruby | mit | 306 | main | 6,497 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Template do
let(:time_string) { "2011-01-15T14:23:45.123" }
let(:time) { Time.parse(time_string) }
let(:entry) { Lumberjack::LogEntry.new(time, Logger::INFO, "line 1#{Lumberjack::LINE_SEPARATOR}line 2#{Lumberjack::LINE_SEPARATOR}line... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter/id_formatter_spec.rb | Ruby | mit | 306 | main | 495 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter::IdFormatter do
it "is registered as :id" do
expect(Lumberjack::FormatterRegistry.formatter(:id)).to be_a(Lumberjack::Formatter::IdFormatter)
end
it "should format an object as a hash of class and id" do
obj = Obje... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter/truncate_formatter_spec.rb | Ruby | mit | 306 | main | 862 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter::TruncateFormatter do
it "is registered as :truncate" do
expect(Lumberjack::FormatterRegistry.formatter(:truncate)).to be_a(Lumberjack::Formatter::TruncateFormatter)
end
it "should truncate a string longer than the lim... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter/strip_formatter_spec.rb | Ruby | mit | 306 | main | 554 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter::StripFormatter do
it "is registered as :strip" do
expect(Lumberjack::FormatterRegistry.formatter(:strip)).to be_a(Lumberjack::Formatter::StripFormatter)
end
it "should format objects as strings with leading and traili... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter/structured_formatter_spec.rb | Ruby | mit | 306 | main | 2,176 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter::StructuredFormatter do
it "is registered as :structured" do
expect(Lumberjack::FormatterRegistry.formatter(:structured)).to be_a(Lumberjack::Formatter::StructuredFormatter)
end
it "should recursively format arrays and... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter/object_formatter_spec.rb | Ruby | mit | 306 | main | 456 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter::ObjectFormatter do
it "is registered as :object" do
expect(Lumberjack::FormatterRegistry.formatter(:object)).to be_a(Lumberjack::Formatter::ObjectFormatter)
end
it "should return the object itself" do
formatter = ... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter/date_time_formatter_spec.rb | Ruby | mit | 306 | main | 1,318 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter::DateTimeFormatter do
it "is registered as :date_time" do
expect(Lumberjack::FormatterRegistry.formatter(:date_time, "YYYY-mm-dd")).to be_a(Lumberjack::Formatter::DateTimeFormatter)
end
it "should format a time object"... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter/round_formtter_spec.rb | Ruby | mit | 306 | main | 1,014 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter::RoundFormatter do
it "is registered as :round" do
expect(Lumberjack::FormatterRegistry.formatter(:round, 1)).to be_a(Lumberjack::Formatter::RoundFormatter)
end
it "should round a numeric value" do
formatter = Lumb... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter/redact_formatter_spec.rb | Ruby | mit | 306 | main | 930 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter::RedactFormatter do
it "is registered as :redact" do
expect(Lumberjack::FormatterRegistry.formatter(:redact)).to be_a(Lumberjack::Formatter::RedactFormatter)
end
it "should redact long strings" do
formatter = Lumbe... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter/pretty_print_formatter_spec.rb | Ruby | mit | 306 | main | 558 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter::PrettyPrintFormatter do
it "is registered as :pretty_print" do
expect(Lumberjack::FormatterRegistry.formatter(:pretty_print)).to be_a(Lumberjack::Formatter::PrettyPrintFormatter)
end
it "should convert an object to a ... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter/tagged_message_spec.rb | Ruby | mit | 306 | main | 304 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter::TaggedMessage, deprecation_mode: :silent do
it "is a MessageAttributes" do
obj = Lumberjack::Formatter::TaggedMessage.new("foo", bar: "baz")
expect(obj).to be_a(Lumberjack::MessageAttributes)
end
end |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter/multiply_formatter_spec.rb | Ruby | mit | 306 | main | 1,052 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter::MultiplyFormatter do
it "is registered as :multiply" do
expect(Lumberjack::FormatterRegistry.formatter(:multiply, 2)).to be_a(Lumberjack::Formatter::MultiplyFormatter)
end
it "multiplies a numeric value" do
format... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter/tags_formatter_spec.rb | Ruby | mit | 306 | main | 1,295 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter::TagsFormatter do
it "is registered as :tags" do
expect(Lumberjack::FormatterRegistry.formatter(:tags)).to be_a(Lumberjack::Formatter::TagsFormatter)
end
describe "#call" do
it "formats a hash of tags" do
for... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter/string_formatter_spec.rb | Ruby | mit | 306 | main | 538 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter::StringFormatter do
it "is registered as :string" do
expect(Lumberjack::FormatterRegistry.formatter(:string)).to be_a(Lumberjack::Formatter::StringFormatter)
end
it "should format objects as string by calling their to_... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter/inspect_formatter_spec.rb | Ruby | mit | 306 | main | 620 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter::InspectFormatter do
it "is registered as :inspect" do
expect(Lumberjack::FormatterRegistry.formatter(:inspect)).to be_a(Lumberjack::Formatter::InspectFormatter)
end
it "should format objects as string by calling their... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter/exception_formatter_spec.rb | Ruby | mit | 306 | main | 1,243 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter::ExceptionFormatter do
it "is registered as :exception" do
expect(Lumberjack::FormatterRegistry.formatter(:exception)).to be_a(Lumberjack::Formatter::ExceptionFormatter)
end
it "should convert an exception without a ba... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/log_entry_matcher/score_spec.rb | Ruby | mit | 306 | main | 8,526 | # frozen_string_literal: true
require_relative "../../spec_helper"
RSpec.describe Lumberjack::LogEntryMatcher::Score do
let(:logger) { Lumberjack::Logger.new(:test) }
# Create real log entries using the capture device
let(:entries) do
logger.info("User logged in successfully")
logger.warn("Database con... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/rack/context_spec.rb | Ruby | mit | 306 | main | 1,101 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Rack::Context do
it "should create a context for a request" do
app = lambda { |env| [200, {"Context" => Lumberjack.in_context?}, ["OK"]] }
handler = Lumberjack::Rack::Context.new(app)
response = handler.call("Content-Type" =... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/device/log_file_spec.rb | Ruby | mit | 306 | main | 1,636 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Device::LogFile do
let(:out) { StringIO.new }
it "wraps a ::Logger::LogDevice" do
device = Lumberjack::Device::LogFile.new(out, template: "{{severity}} {{message}}")
expect(device.class).to eq(Lumberjack::Device::LogFile)
... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/device/multi_spec.rb | Ruby | mit | 306 | main | 1,506 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Device::Multi do
let(:output_1) { StringIO.new }
let(:output_2) { StringIO.new }
let(:device_1) { Lumberjack::Device::Writer.new(output_1, template: "{{message}}") }
let(:device_2) { Lumberjack::Device::Writer.new(output_2, templat... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/device/writer_spec.rb | Ruby | mit | 306 | main | 5,604 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Device::Writer do
let(:time_string) { "2011-01-15T14:23:45.123" }
let(:time) { Time.parse(time_string) }
let(:stream) { StringIO.new }
let(:entry) { Lumberjack::LogEntry.new(time, Logger::INFO, "test message", "app", 12345, "foo" =... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/device/size_rolling_log_file_spec.rb | Ruby | mit | 306 | main | 559 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Device::SizeRollingLogFile do
it "is a deprecated alias for Lumberjack::Device::LogFile", deprecation_mode: :silent do
file = Tempfile.new("lumberjack_test")
begin
device = Lumberjack::Device::SizeRollingLogFile.new(file.pa... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/device/test_spec.rb | Ruby | mit | 306 | main | 8,106 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Device::Test do
let(:device) { Lumberjack::Device::Test.new }
it "is registered as :test" do
expect(Lumberjack::DeviceRegistry.device_class(:test)).to eq(Lumberjack::Device::Test)
end
describe "#max_entries" do
it "is 100... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/device/buffer_spec.rb | Ruby | mit | 306 | main | 4,154 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Device::Buffer do
let(:device) { Lumberjack::Device::Test.new }
let(:entry_1) { Lumberjack::LogEntry.new(Time.now, Logger::INFO, "Message 1", nil, Process.pid, nil) }
let(:entry_2) { Lumberjack::LogEntry.new(Time.now, Logger::INFO, "... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/device/date_rolling_log_file_spec.rb | Ruby | mit | 306 | main | 545 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Device::DateRollingLogFile do
it "is a deprecated alias for Lumberjack::Device::LogFile", deprecation_mode: :silent do
file = Tempfile.new("lumberjack_test")
begin
device = Lumberjack::Device::DateRollingLogFile.new(file.pa... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/device/null_spec.rb | Ruby | mit | 306 | main | 451 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Device::Null do
it "is registered as :null" do
expect(Lumberjack::DeviceRegistry.device_class(:null)).to eq(Lumberjack::Device::Null)
end
it "should not generate any output" do
device = Lumberjack::Device::Null.new
devic... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/device/logger_wrapper_spec.rb | Ruby | mit | 306 | main | 2,092 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Device::LoggerWrapper do
it "wraps another Lumberjack logger as a device" do
logger = Lumberjack::Logger.new(:test)
outer_logger = Lumberjack::Logger.new(Lumberjack::Device::LoggerWrapper.new(logger), progname: "MyApp")
outer... |
github | ncri/nested_form_fields | https://github.com/ncri/nested_form_fields | nested_form_fields.gemspec | Ruby | mit | 306 | master | 1,383 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/nested_form_fields/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Nico Ritsche"]
gem.email = ["ncrdevmail@gmail.com"]
gem.description = %q{Rails gem for dynamically adding and removing nested has_many association fiel... |
github | ncri/nested_form_fields | https://github.com/ncri/nested_form_fields | Appraisals | Ruby | mit | 306 | master | 352 | # frozen_string_literal: true
appraise 'rails-5.2' do
gem 'activeresource'
gem 'haml'
gem 'haml-rails'
gem 'puma'
gem 'rails', '~> 5.2.4.1'
gem 'sassc-rails'
gem 'sqlite3'
end
appraise 'rails-6.0' do
gem 'activeresource'
gem 'haml'
gem 'haml-rails'
gem 'puma'
gem 'rails', '~> 6.0.2.1'
gem 's... |
github | ncri/nested_form_fields | https://github.com/ncri/nested_form_fields | spec/spec_helper.rb | Ruby | mit | 306 | master | 1,497 | # This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper.rb"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
EN... |
github | ncri/nested_form_fields | https://github.com/ncri/nested_form_fields | spec/integration/nested_form_fields_spec.rb | Ruby | mit | 306 | master | 2,741 | require 'spec_helper'
describe 'a form with nested projects with nested todos', :js => true do
it 'creates a user with nested projects with nested todos' do
visit '/'
fill_in 'user_name', with: 'user name'
click_link 'Add Project'
page.should have_css('fieldset.nested_user_projects')
fill_in '... |
github | ncri/nested_form_fields | https://github.com/ncri/nested_form_fields | spec/dummy/config/application.rb | Ruby | mit | 306 | master | 2,359 | require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
require 'jquery-rails'
require 'haml'
requ... |
github | ncri/nested_form_fields | https://github.com/ncri/nested_form_fields | spec/dummy/config/initializers/secret_token.rb | Ruby | mit | 306 | master | 499 | # 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... |
github | ncri/nested_form_fields | https://github.com/ncri/nested_form_fields | spec/dummy/config/environments/development.rb | Ruby | mit | 306 | master | 1,237 | Dummy::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 web serv... |
github | ncri/nested_form_fields | https://github.com/ncri/nested_form_fields | spec/dummy/config/environments/test.rb | Ruby | mit | 306 | master | 1,419 | 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 suit... |
github | ncri/nested_form_fields | https://github.com/ncri/nested_form_fields | spec/dummy/db/schema.rb | Ruby | mit | 306 | master | 1,510 | # encoding: UTF-8
# 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.
#
# Note that this schema.rb definition is the authoritative sou... |
github | ncri/nested_form_fields | https://github.com/ncri/nested_form_fields | spec/dummy/db/migrate/20120523095357_create_todos.rb | Ruby | mit | 306 | master | 278 | class CreateTodos < ActiveRecord::Migration
def change
create_table :todos do |t|
t.string :description
t.belongs_to :model_with_todos, polymorphic: true
end
add_index :todos, :model_with_todos_id
add_index :todos, :model_with_todos_type
end
end |
github | ncri/nested_form_fields | https://github.com/ncri/nested_form_fields | spec/dummy/db/migrate/20120523095218_create_projects.rb | Ruby | mit | 306 | master | 218 | class CreateProjects < ActiveRecord::Migration
def change
create_table :projects do |t|
t.string :name
t.text :description
t.belongs_to :user
end
add_index :projects, :user_id
end
end |
github | ncri/nested_form_fields | https://github.com/ncri/nested_form_fields | spec/dummy/app/controllers/users_controller.rb | Ruby | mit | 306 | master | 760 | class UsersController < ApplicationController
def edit
@user = User.find(params[:id])
end
def update
@user = User.find(params[:id])
if @user.update params.require(:user).permit(:name, projects_attributes: [:id, :name, :description, :_destroy, todos_attributes: [:id, :description, :_destroy]])
... |
github | ncri/nested_form_fields | https://github.com/ncri/nested_form_fields | lib/nested_form_fields.rb | Ruby | mit | 306 | master | 6,522 | require "nested_form_fields/version"
module NestedFormFields
module Rails
class Engine < ::Rails::Engine
end
end
end
module ActionView::Helpers
class FormBuilder
def nested_fields_for(record_name, record_object = nil, fields_options = {}, &block)
fields_options, record_object = record_object... |
github | jamis/castaway | https://github.com/jamis/castaway | castaway.gemspec | Ruby | mit | 305 | master | 936 | $LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'castaway/version'
Gem::Specification.new do |s|
s.name = 'castaway'
s.version = Castaway::VERSION
s.authors = ['Jamis Buck']
s.email = ['jamis@jamisbuck.org']
s.homepage = 'https://github.com/jamis/castaway'
s.summary ... |
github | jamis/castaway | https://github.com/jamis/castaway | test/delta_test.rb | Ruby | mit | 305 | master | 1,456 | require 'test_setup'
class DeltaTest < Minitest::Test
Reifiable = Struct.new(:reify)
def test_delta_should_interpolate_values
delta = Castaway::Delta.new(0 => 1, 1 => 5)
assert_equal 1, delta[0]
assert_equal 3, delta[0.5]
assert_equal 5, delta[1]
end
def test_delta_should_interpolate_multiple... |
github | jamis/castaway | https://github.com/jamis/castaway | test/element/base_test.rb | Ruby | mit | 305 | master | 3,236 | require 'test_setup'
module Element
class BaseTest < Minitest::Test
def setup
@production = Castaway::Production.new
@scene = Castaway::Scene.new('Test Scene', @production)
@element = Castaway::Element::Base.new(@production, @scene)
end
def test_at_with_single_point_parameter_becomes_d... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/effect.rb | Ruby | mit | 305 | master | 1,892 | module Castaway
module Effect
@effects = {}
def self.register(name, &implementation)
@effects[name] = implementation
end
def self.invoke(name, element, options)
@effects.fetch(name).call(element, options)
end
register :dissolve_in do |element, options|
element.alpha(0 => 0... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/colors.rb | Ruby | mit | 305 | master | 23,751 | module Castaway
# color definitions from ImageMagick
# https://www.imagemagick.org/script/color.php
COLORS = {
aliceblue: [240, 248, 255, 255],
antiquewhite1: [255, 239, 219, 255],
antiquewhite2: [238, 223, 204, 255],
antiquewhite3: [205, 192, 176, 255],
antiquewhite4: [139, 131, 120, 255],
... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/animation.rb | Ruby | mit | 305 | master | 976 | require 'castaway/interpolation'
module Castaway
class Animation
attr_reader :from, :to, :duration
def self.from_options(options)
factory = Castaway::Interpolation.lookup(options)
initial = options[:initial] || 0.0
final = options[:final] || (initial + 1.0)
interpolator = factory.ne... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/range.rb | Ruby | mit | 305 | master | 1,613 | require 'castaway/times'
module Castaway
class Range
include Castaway::Times
attr_accessor :start_frame, :end_frame
def self.at_frame(production, frame)
new(production).tap do |range|
range.start_frame = frame
range.end_frame = frame
end
end
def self.at_time(produc... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/scene.rb | Ruby | mit | 305 | master | 4,101 | require 'castaway/element/matte'
require 'castaway/element/still'
require 'castaway/element/pointer'
require 'castaway/element/text'
require 'castaway/relative_to'
require 'castaway/times'
module Castaway
class Scene
include Castaway::Times
attr_reader :title
attr_reader :production
attr_reader :fi... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/embedded_audio.rb | Ruby | mit | 305 | master | 449 | module Castaway
class EmbeddedAudio
attr_reader :source, :element, :delay
def initialize(source, element, delay = 0, duration = nil)
@source = source
@source = element.production.resource(@source) if @source.is_a?(String)
@element = element
@delay = delay
@duration = duration
... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/relative_to.rb | Ruby | mit | 305 | master | 446 | require 'mini_magick'
require 'castaway/point'
module Castaway
class RelativeTo
def initialize(image_file_name, production)
path = production.resource(image_file_name)
image = MiniMagick::Image.new(path)
@width = image.width.to_f
@height = image.height.to_f
@production = production
... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/size.rb | Ruby | mit | 305 | master | 924 | module Castaway
class Size < Struct.new(:width, :height)
def *(factor)
if factor.is_a?(Size)
Size.new(width * factor.width, height * factor.height)
else
Size.new(width * factor, height * factor)
end
end
def present?
width || height
end
def empty?
(w... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/box.rb | Ruby | mit | 305 | master | 1,580 | require 'castaway/point'
module Castaway
class Box
def self.from_size(size)
new(
Point.new(0, 0),
Point.new(size.width - 1, 0),
Point.new(size.width - 1, size.height - 1),
Point.new(0, size.height - 1))
end
def initialize(a, b, c, d, other = {})
@a = a
@... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/color.rb | Ruby | mit | 305 | master | 1,420 | require 'castaway/colors'
module Castaway
class Color
def self.create(arg)
if arg.is_a?(String) || arg.is_a?(Symbol)
from_string(arg)
elsif arg.is_a?(Integer)
from_hex(arg)
else
raise ArgumentError, "cannot create color with #{arg.inspect}"
end
end
def sel... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/delta.rb | Ruby | mit | 305 | master | 1,913 | module Castaway
class Delta
class Leg
attr_reader :initial, :final
def initialize(t1, v1, t2, v2)
@t1 = t1
@t2 = t2
@initial = v1
@final = v2
@duration = t2 - t1
@distance = v2 - v1
end
def >(t)
@t1 > t
end
def contains... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/point.rb | Ruby | mit | 305 | master | 1,200 | module Castaway
class Point < Struct.new(:x, :y)
def self.make(*args)
if args.length == 1 && args[0].is_a?(Array)
new(args[0][0], args[0][1])
elsif args.length == 1 && args[0].is_a?(Point)
args[0]
else
raise ArgumentError, "can't make a point from #{args.inspect}"
... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/times.rb | Ruby | mit | 305 | master | 749 | module Castaway
module Times
def _parse_time(spec)
_parse_numeric_time(spec) ||
_parse_timespec_time(spec) ||
raise(ArgumentError, "unsupported time #{spec.inspect}")
end
def _parse_numeric_time(spec)
if spec.is_a?(Numeric)
spec
elsif spec =~ /^\d+(\.\d+)?s?$/
... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/interpolation.rb | Ruby | mit | 305 | master | 500 | module Castaway
module Interpolation
def self.lookup(options)
_lookup_by_class(options) ||
_lookup_by_type(options) ||
raise(ArgumentError, "cannot find interpolation for #{value.inspect}")
end
def self._lookup_by_class(options)
options[:interpolator]
end
def self._l... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/timeline.rb | Ruby | mit | 305 | master | 1,760 | require 'logger'
require 'fileutils'
module Castaway
class Timeline
attr_reader :resolution, :fps
def initialize(resolution, fps)
@resolution = resolution
@elements = []
@fps = fps
@cached_command = nil
@cached_file = nil
end
def add(element)
@elements << eleme... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/production.rb | Ruby | mit | 305 | master | 3,612 | require 'fileutils'
require 'castaway/range'
require 'castaway/size'
require 'castaway/timeline'
require 'ruby-progressbar'
require 'castaway/production/class_methods'
require 'castaway/production/audio'
require 'castaway/production/scenes'
module Castaway
class Production
extend Castaway::Production::ClassMeth... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/element/base.rb | Ruby | mit | 305 | master | 6,631 | require 'castaway/animation'
require 'castaway/delta'
require 'castaway/effect'
require 'castaway/embedded_audio'
require 'castaway/point'
module Castaway
module Element
class Base
def self.declarative_accessor(*names)
options = names.last.is_a?(Hash) ? names.pop : {}
convert = if options[... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/element/still.rb | Ruby | mit | 305 | master | 722 | require 'castaway/element/base'
require 'mini_magick'
module Castaway
module Element
class Still < Element::Base
attr_reader :filename, :info
def initialize(production, scene, filename, full: false)
super(production, scene)
@filename = production.resource(filename)
@info = ... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/element/pointer.rb | Ruby | mit | 305 | master | 989 | require 'castaway/element/still'
require 'castaway/box'
require 'castaway/point'
module Castaway
module Element
class Pointer < Element::Still
class HotspotDelta
def initialize(pointer)
@pointer = pointer
end
def [](t)
@pointer.raw_position[t] - @pointer.hotspo... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/element/matte.rb | Ruby | mit | 305 | master | 606 | require 'castaway/element/base'
require 'castaway/color'
module Castaway
module Element
class Matte < Element::Base
declarative_accessor :color, converter: :_convert_color
def initialize(production, scene, color = :black)
super(production, scene)
@color = Castaway::Delta[Castaway::C... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/element/text.rb | Ruby | mit | 305 | master | 1,552 | require 'castaway/element/base'
require 'castaway/color'
module Castaway
module Element
class Text < Element::Base
declarative_accessor :font_size, :kerning
declarative_accessor :background, :fill, :stroke,
converter: :_convert_color
def initialize(production, scene... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/production/scenes.rb | Ruby | mit | 305 | master | 850 | require 'castaway/scene'
module Castaway
class Production
module Scenes
# Returns the duration of the production, in seconds.
def duration
@scenes.any? ? @scenes.last.finish : 0
end
# Returns the first scene with the given title.
def scene(title)
@scenes.find { |s|... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/production/class_methods.rb | Ruby | mit | 305 | master | 4,911 | require 'castaway/times'
module Castaway
class Production
module ClassMethods
include Castaway::Times
# Returns an Array of Castaway::Scene objects corresponding to the
# scenes that have been defined.
def scenes
@scenes ||= []
end
# Returns a Hash, mapping ids to ei... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/production/audio.rb | Ruby | mit | 305 | master | 6,097 | require 'chaussettes'
module Castaway
class Production
module Audio
attr_reader :embedded_clips
def initialize
@embedded_clips = []
super
end
# Returns the filename associated with the soundclip with the given id.
# If the soundclip was declared with a block, the ... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/cli/main.rb | Ruby | mit | 305 | master | 811 | require 'gli'
require 'castaway'
require 'castaway/cli/build'
require 'castaway/cli/script'
require 'castaway/cli/version'
module Castaway
module CLI
class Main
extend GLI::App
program_desc 'Build screencasts from a script'
desc Castaway::CLI::Script.description
command(:build) { |c| Ca... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/cli/script.rb | Ruby | mit | 305 | master | 687 | require 'castaway/production'
module Castaway
module CLI
class Script
extend GLI::App
def self.description
'Display the given program as a script'
end
def self.define(command)
command.action do |_globals, _options, args|
exit_now!('you have to supply a castaway... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/cli/version.rb | Ruby | mit | 305 | master | 337 | require 'castaway/version'
module Castaway
module CLI
class Version
def self.description
"Report the current version (#{Castaway::VERSION})"
end
def self.define(command)
command.action do |_globals, _options, _args|
puts "v#{Castaway::VERSION}"
end
end
... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/cli/build.rb | Ruby | mit | 305 | master | 2,588 | require 'castaway/production'
require 'castaway/range'
module Castaway
module CLI
class Build
extend GLI::App
def self.description
'Builds the given castaway production'
end
def self.define(command)
command.desc 'The resolution at which to generate the frames'
co... |
github | jamis/castaway | https://github.com/jamis/castaway | lib/castaway/interpolation/linear.rb | Ruby | mit | 305 | master | 439 | module Castaway
module Interpolation
# A linear interpolation between two values
class Linear
attr_reader :start, :finish
def initialize(start, finish)
@start = start
@finish = finish
@delta = finish - start
end
def [](t)
if t < 0
@start
... |
github | jamis/castaway | https://github.com/jamis/castaway | examples/slide-maker.rb | Ruby | mit | 305 | master | 1,114 | # Converts the code snippets in the `snippets` directory, into PDF's that
# can then be converted into images, for the `images` directory.
#
# You only need to run this if you change any of the snippets in the `snippets`
# directory.
require 'fileutils'
require 'code_slide'
font_path = File.expand_path(
File.join('... |
github | jamis/castaway | https://github.com/jamis/castaway | examples/tutorial.rb | Ruby | mit | 305 | master | 15,358 | # A practical tutorial screencast, introducing Castaway and demonstrating
# what it can do.
voice_in = 3 # narration track starts 3 seconds in
pointer 'arrow.png', hotspot: [152, 12], scale: 0.1
soundclip :narration, resource('narration.mp3')
soundclip :theme do |clip|
intro_duration = scene('Title Screen').durat... |
github | jamis/castaway | https://github.com/jamis/castaway | examples/snippets/castaway-script.rb | Ruby | mit | 305 | master | 330 | # castaway-script.rb
soundclip :theme, resource('theme-music.mp3')
soundclip :narration, resource('narration.aiff')
soundtrack do |clip|
result = duck(
soundclip(:theme),
clip: soundclip(:narration), at: 3, adjust: 0.25)
clip.in result
end
scene 'Title' do
start '0:00'
plan do
still 'title.png'
... |
github | jamis/castaway | https://github.com/jamis/castaway | examples/snippets/sound-modify.rb | Ruby | mit | 305 | master | 207 | soundclip :theme do |clip|
clip.in resource('theme.mp3')
clip.chain.
trim(0, 15).
fade(0.5, 0, 5, type: :linear)
clip.chain.
trim(0, 30).
fade(5, 0, 5, type: :linear).
pad(120)
end |
github | jamis/castaway | https://github.com/jamis/castaway | examples/snippets/path-command.rb | Ruby | mit | 305 | master | 239 | pointer.
rotate(150).
at(0.0 => relative_position(0.25, 0.25),
0.5 => relative_position(0.75, 0.25),
1.0 => relative_position(0.75, 0.75),
1.5 => relative_position(0.25, 0.75),
2.0 => relative_position(0.25, 0.25)) |
github | cxn03651/write_xlsx | https://github.com/cxn03651/write_xlsx | Rakefile | Ruby | mit | 305 | main | 309 | # frozen_string_literal: true
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"]
t.warning = false
end
require "rubocop/rake_task"
RuboCop::RakeTask.new
task default: %i[test rubocop] |
github | cxn03651/write_xlsx | https://github.com/cxn03651/write_xlsx | write_xlsx.gemspec | Ruby | mit | 305 | main | 1,419 | # frozen_string_literal: true
require_relative 'lib/write_xlsx/version'
Gem::Specification.new do |gem|
gem.name = 'write_xlsx'
gem.version = WriteXLSX_VERSION
gem.authors = ['Hideo NAKAMURA']
gem.email = ['nakamura.hideo@gmail.com']
gem.description = 'write_xlsx is a gem to c... |
github | cxn03651/write_xlsx | https://github.com/cxn03651/write_xlsx | lib/write_xlsx.rb | Ruby | mit | 305 | main | 2,649 | # -*- coding: utf-8 -*-
# frozen_string_literal: true
require 'write_xlsx/workbook'
#
# write is gem to create a new file in the Excel 2007+ XLSX format,
# and you can use the same interface as writeexcel gem.
# write_xlsx is converted from Perl’s module github.com/jmcnamara/excel-writer-xlsx .
#
# == Description
# T... |
github | cxn03651/write_xlsx | https://github.com/cxn03651/write_xlsx | lib/write_xlsx/object_positioning.rb | Ruby | mit | 305 | main | 7,133 | # -*- coding: utf-8 -*-
# frozen_string_literal: true
require 'write_xlsx/utility/cell_reference'
require 'write_xlsx/utility/chart_formatting'
require 'write_xlsx/utility/dimensions'
require 'write_xlsx/utility/date_time'
require 'write_xlsx/utility/url'
require 'write_xlsx/utility/xml_primitives'
require 'write_xlsx... |
github | cxn03651/write_xlsx | https://github.com/cxn03651/write_xlsx | lib/write_xlsx/sparkline.rb | Ruby | mit | 305 | main | 24,113 | # -*- coding: utf-8 -*-
# frozen_string_literal: true
require 'write_xlsx/utility/common'
module Writexlsx
###############################################################################
#
# Sparkline - A class for handle Excel sparkline
#
# Used in conjunction with WriteXLSX.
#
# Copyright 2000-2012, J... |
github | cxn03651/write_xlsx | https://github.com/cxn03651/write_xlsx | lib/write_xlsx/formats.rb | Ruby | mit | 305 | main | 668 | # -*- encoding: utf-8 -*-
# frozen_string_literal: true
require 'write_xlsx/package/xml_writer_simple'
module Writexlsx
class Formats
attr_reader :formats, :xf_format_indices, :dxf_format_indices
def initialize
@formats = []
@xf_format_indices = {}
@dxf_format_indices = {}
end
de... |
github | cxn03651/write_xlsx | https://github.com/cxn03651/write_xlsx | lib/write_xlsx/chartsheet.rb | Ruby | mit | 305 | main | 5,074 | # -*- coding: utf-8 -*-
# frozen_string_literal: true
###############################################################################
#
# Chartsheet - A class for writing the Excel XLSX Chartsheet files.
#
# Used in conjunction with WriteXLSX
#
# Copyright 2000-2011, John McNamara, jmcnamara@cpan.org
# Convert to ruby... |
github | cxn03651/write_xlsx | https://github.com/cxn03651/write_xlsx | lib/write_xlsx/constants.rb | Ruby | mit | 305 | main | 257 | # -*- coding: utf-8 -*-
# frozen_string_literal: true
module Writexlsx
module Constants
ROW_MAX = 1048576 # :nodoc:
COL_MAX = 16384 # :nodoc:
STR_MAX = 32767 # :nodoc:
SHEETNAME_MAX = 31 # :nodoc:
end
end |
github | cxn03651/write_xlsx | https://github.com/cxn03651/write_xlsx | lib/write_xlsx/col_name.rb | Ruby | mit | 305 | main | 854 | # -*- coding: utf-8 -*-
# frozen_string_literal: true
require 'singleton'
class ColName
include Singleton
def initialize
@col_str_table = []
@row_str_table = []
end
def col_str(col)
@col_str_table[col] ||= col_str_build(col)
end
def row_str(row)
@row_str_table[row] ||= row.to_s
end
... |
github | cxn03651/write_xlsx | https://github.com/cxn03651/write_xlsx | lib/write_xlsx/page_setup.rb | Ruby | mit | 305 | main | 5,736 | # -*- encoding: utf-8 -*-
# frozen_string_literal: true
require 'write_xlsx/utility/common'
module Writexlsx
class PageSetup # :nodoc:
include Writexlsx::Utility::Common
attr_accessor :margin_left, :margin_right, :margin_top, :margin_bottom # :nodoc:
attr_accessor :margin_header, :margin_footer ... |
github | cxn03651/write_xlsx | https://github.com/cxn03651/write_xlsx | lib/write_xlsx/sheets.rb | Ruby | mit | 305 | main | 7,489 | # -*- encoding: utf-8 -*-
# frozen_string_literal: true
require 'delegate'
require 'write_xlsx/constants'
require 'write_xlsx/utility/common'
require 'write_xlsx/utility/xml_primitives'
require 'write_xlsx/package/xml_writer_simple'
module Writexlsx
class Sheets < DelegateClass(Array)
include Constants
incl... |
github | cxn03651/write_xlsx | https://github.com/cxn03651/write_xlsx | lib/write_xlsx/image_property.rb | Ruby | mit | 305 | main | 5,099 | # -*- coding: utf-8 -*-
# frozen_string_literal: true
require 'digest/md5'
require 'write_xlsx/utility/common'
module Writexlsx
class ImageProperty
include Utility::Common
attr_reader :type, :width, :height, :name, :x_dpi, :y_dpi, :md5
attr_reader :filename, :description, :decorative
attr_accessor ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.