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
tleish/ruby-prof-rails
https://github.com/tleish/ruby-prof-rails
lib/ruby-prof/rails/engine.rb
Ruby
mit
19
master
321
require 'rack/ruby-prof-rails' module RubyProf module Rails class Engine < ::Rails::Engine # isolate_namespace RubyProfRails engine_name 'ruby_prof_rails_engine' initializer :ruby_prof_rails_middleware do |app| app.config.middleware.use Rack::RubyProfRails end end end end
github
tleish/ruby-prof-rails
https://github.com/tleish/ruby-prof-rails
app/controllers/ruby_prof_rails/profile_controller.rb
Ruby
mit
19
master
1,518
module RubyProfRails class ProfileController < RubyProfRails::ApplicationController include ActionView::Helpers::TextHelper def show profile = RubyProf::Rails::Profiles.find(params[:id]) if profile time = profile.time.strftime('%Y-%m-%d_%I-%M-%S-%Z') send_file profile.filename, f...
github
tleish/ruby-prof-rails
https://github.com/tleish/ruby-prof-rails
app/controllers/ruby_prof_rails/home_controller.rb
Ruby
mit
19
master
1,891
module RubyProfRails class HomeController < RubyProfRails::ApplicationController before_action :init_ruby_prof_rails_session def index @config = session[:ruby_prof_rails].symbolize_keys @config[:printers] = Array(RubyProf::Rails::Printers.default.type.to_s) if @config[:printers].blank? @ses...
github
tleish/ruby-prof-rails
https://github.com/tleish/ruby-prof-rails
app/controllers/ruby_prof_rails/printer_controller.rb
Ruby
mit
19
master
696
module RubyProfRails class PrinterController < RubyProfRails::ApplicationController RUBY_PROF_GEM_DIR = Gem::Specification.find_by_name('ruby-prof').gem_dir def show printer = printers[params[:id].to_sym] || 'no-printer' printer_path = File.join(RUBY_PROF_GEM_DIR, 'examples', printer) if ...
github
tleish/ruby-prof-rails
https://github.com/tleish/ruby-prof-rails
app/controllers/ruby_prof_rails/application_controller.rb
Ruby
mit
19
master
884
require 'ruby-prof/rails/config_validation' module RubyProfRails class ApplicationController < ActionController::Base before_action :init_vars, :properly_configured?, :session_authenticate http_basic_authenticate_with RubyProf::Rails::Config.http_basic_authenticate private def init_vars @conf...
github
mul53/activestorage-ipfs
https://github.com/mul53/activestorage-ipfs
activestorage-ipfs.gemspec
Ruby
mit
19
master
1,295
require_relative 'lib/active_storage/service/version' Gem::Specification.new do |spec| spec.name = "activestorage-ipfs" spec.version = ActiveStorage::IpfsService::VERSION spec.authors = ["Mulenga Bowa"] spec.email = ["mulengabowa53@gmail.com"] spec.summary = "" spec.desc...
github
mul53/activestorage-ipfs
https://github.com/mul53/activestorage-ipfs
spec/spec_helper.rb
Ruby
mit
19
master
368
require "bundler/setup" require "test_helpers" RSpec.configure do |config| # Enable flags like --only-failures and --next-failure config.example_status_persistence_file_path = ".rspec_status" # Disable RSpec exposing methods globally on `Module` and `main` config.disable_monkey_patching! config.expect_with...
github
mul53/activestorage-ipfs
https://github.com/mul53/activestorage-ipfs
spec/test_helpers.rb
Ruby
mit
19
master
334
module ActiveStorage class Service def instrument(_operation, _option = {}) yield end end end class Model def update(params) end end class BlobStub class << self def find_by_key(key) Model.new end end end require 'active_storage/service/...
github
mul53/activestorage-ipfs
https://github.com/mul53/activestorage-ipfs
spec/ipfs_service_spec.rb
Ruby
mit
19
master
5,000
require 'spec_helper' RSpec.describe ActiveStorage::Service::IpfsService do let(:api_endpoint) { 'http://localhost:5001' } let(:gateway_endpoint) { 'http://localhost:8080' } let(:key) { 'some-key' } let(:file) { double } let(:filename) { 'text.txt' } let(:checksum) { 'ushagte' } let(:subject) { Activ...
github
mul53/activestorage-ipfs
https://github.com/mul53/activestorage-ipfs
lib/active_storage/service/ipfs_service.rb
Ruby
mit
19
master
2,493
require 'ipfs/client' class ActiveStorage::DirectUploadsController private def blob_args params.require(:blob).permit(:key, :filename, :byte_size, :checksum, :content_type, :metadata).to_h.symbolize_keys end end class ActiveStorage::Blob class << self def create_before_direct_upload!(key: nil, filen...
github
mul53/activestorage-ipfs
https://github.com/mul53/activestorage-ipfs
lib/ipfs/client.rb
Ruby
mit
19
master
1,568
# frozen_string_literal: true require 'http' require 'json' module Ipfs class Error < StandardError; end class NotFoundError < Error; end class Client attr_reader :api_endpoint, :gateway_endpoint, :http_client def initialize(api_endpoint, gateway_endpoint) @api_endpoint = api_endpoint @gat...
github
amcaplan/dynamic_class
https://github.com/amcaplan/dynamic_class
Rakefile
Ruby
mit
19
master
202
require "bundler/gem_tasks" require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) desc 'Run Benchmarking Examples' task :benchmark do require './bin/benchmark' end task :default => :spec
github
amcaplan/dynamic_class
https://github.com/amcaplan/dynamic_class
dynamic_class.gemspec
Ruby
mit
19
master
1,391
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'dynamic_class/version' Gem::Specification.new do |spec| spec.name = "dynamic_class" spec.version = DynamicClass::VERSION spec.authors = ["amcaplan"] spec.email ...
github
amcaplan/dynamic_class
https://github.com/amcaplan/dynamic_class
spec/dynamic_class_spec.rb
Ruby
mit
19
master
10,118
require 'spec_helper' require 'ostruct' describe DynamicClass do subject { klass.new(data) } let(:klass) { described_class.new } let(:data) {{}} # default, overridden in many tests def expect_subject_responds(attribute) expect(subject).to respond_to(attribute) expect(subject).to respond_to(:"#{attrib...
github
amcaplan/dynamic_class
https://github.com/amcaplan/dynamic_class
bin/benchmark.rb
Ruby
mit
19
master
2,442
require 'benchmark/ips' require 'dynamic_class' require 'ostruct' require 'persistent_open_struct' require 'ofstruct' class RegularClass attr_accessor :foo def initialize(args) @foo = args[:foo] end end MyDynamicClass = DynamicClass.new puts "Initialization benchmark\n\n" Benchmark.ips do |x| input_has...
github
amcaplan/dynamic_class
https://github.com/amcaplan/dynamic_class
lib/dynamic_class.rb
Ruby
mit
19
master
2,915
require 'dynamic_class/version' require 'set' module DynamicClass def self.new(&block) ::Class.new(::DynamicClass::Class).tap do |klass| klass.class_exec(&block) if block_given? end end class Class class << self def attributes @attributes ||= Set.new end # Always rev...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
Gemfile
Ruby
mit
19
main
310
# frozen_string_literal: true source "https://rubygems.org" # Specify your gem's dependencies in sidekiq_rescue.gemspec gemspec gem "appraisal" gem "logger" gem "ostruct" gem "rake", "~> 13.3" gem "rspec", "~> 3.0" gem "rubocop", "~> 1.85" gem "rubocop-performance" gem "rubocop-rake" gem "rubocop-rspec"
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
sidekiq-rescue.gemspec
Ruby
mit
19
main
1,108
# frozen_string_literal: true require_relative "lib/sidekiq/rescue/version" Gem::Specification.new do |spec| spec.name = "sidekiq-rescue" spec.version = Sidekiq::Rescue::VERSION spec.authors = ["Dmitrii Ivliev"] spec.email = ["mail@ivda.dev"] spec.license = "MIT" spec.summary = "Rescue Sidekiq jobs on ex...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
Appraisals
Ruby
mit
19
main
546
# frozen_string_literal: true appraise "sidekiq-7.0.x" do group :test do gem "sidekiq", "~> 7.0.0" end end appraise "sidekiq-7.1.x" do group :test do gem "sidekiq", "~> 7.1.0" end end appraise "sidekiq-7.2.x" do group :test do gem "sidekiq", "~> 7.2.0" end end appraise "sidekiq-7.3.x" do g...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
lib/sidekiq_rescue.rb
Ruby
mit
19
main
327
# frozen_string_literal: true require "sidekiq" require "forwardable" require_relative "sidekiq/rescue/config" require_relative "sidekiq/rescue" require_relative "sidekiq/rescue/version" require_relative "sidekiq/rescue/dsl" require_relative "sidekiq/rescue/server_middleware" require_relative "sidekiq/rescue/rspec/mat...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
lib/sidekiq/rescue.rb
Ruby
mit
19
main
1,631
# frozen_string_literal: true module Sidekiq # Sidekiq::Rescue is a Sidekiq plugin which allows you to easily handle # exceptions thrown by your jobs. # # To use Sidekiq::Rescue, you need to include Sidekiq::Rescue::Dsl module # in your job class and use the sidekiq_rescue class method to define # exceptio...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
lib/sidekiq/rescue/server_middleware.rb
Ruby
mit
19
main
2,943
# frozen_string_literal: true module Sidekiq module Rescue # Server middleware for sidekiq-rescue # It is responsible for catching the errors and rescheduling the job # according to the options provided # @api private class ServerMiddleware include Sidekiq::ServerMiddleware def call(...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
lib/sidekiq/rescue/config.rb
Ruby
mit
19
main
2,219
# frozen_string_literal: true module Sidekiq module Rescue # Config class is used to store the configuration of Sidekiq::Rescue # and to allow to configure it. class Config DEFAULTS = { delay: 60, limit: 10, jitter: 0.15 }.freeze def initialize @delay = ...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
lib/sidekiq/rescue/dsl.rb
Ruby
mit
19
main
4,237
# frozen_string_literal: true module Sidekiq module Rescue DELAY_STRATEGIES = %i[polynomially_longer exponentially_longer].freeze # This module is included into the job class to provide the Dsl for # configuring rescue options. module Dsl def self.included(base) base.extend(ClassMethod...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
lib/sidekiq/rescue/rspec/matchers.rb
Ruby
mit
19
main
2,723
# frozen_string_literal: true return unless defined?(RSpec) require "rspec/matchers" module Sidekiq module Rescue module RSpec # RSpec matchers for Sidekiq::Rescue module Matchers ::RSpec::Matchers.define :have_sidekiq_rescue do |expected| # rubocop:disable Metrics/BlockLength des...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
spec/spec_helper.rb
Ruby
mit
19
main
942
# frozen_string_literal: true require "sidekiq_rescue" require "sidekiq/testing" Dir[File.join(__dir__, "support/**/*.rb")].each { |f| require f } RSpec.configure do |config| config.include Sidekiq::Rescue::RSpec::Matchers # Enable flags like --only-failures and --next-failure config.example_status_persistenc...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
spec/support/jobs.rb
Ruby
mit
19
main
2,020
# frozen_string_literal: true class BaseJob include Sidekiq::Job include Sidekiq::Rescue::Dsl end class WithTestErrorJob < BaseJob sidekiq_rescue TestError def perform(*) raise TestError end end class WithTestErrorAndDelayProc < BaseJob sidekiq_rescue TestError, delay: ->(counter) { counter * 10 } ...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
spec/sidekiq/rescue_spec.rb
Ruby
mit
19
main
919
# frozen_string_literal: true RSpec.describe Sidekiq::Rescue do it "has a version number" do expect(described_class::VERSION).not_to be_nil end it "provides a default sidekiq logger" do expect(described_class.logger).to be_a(Sidekiq::Logger) end describe "#configure" do it "allows to configurat...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
spec/sidekiq/rescue/dsl_spec.rb
Ruby
mit
19
main
6,249
# frozen_string_literal: true RSpec.describe Sidekiq::Rescue::Dsl do let(:job_class) do Class.new do include Sidekiq::Job include Sidekiq::Rescue::Dsl end end def define_dsl(...) job_class.instance_eval(...) end describe "#sidekiq_rescue" do it "sets error and default options" d...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
spec/sidekiq/rescue/integration_spec.rb
Ruby
mit
19
main
5,977
# frozen_string_literal: true RSpec.describe "Sidekiq::Rescue", :integration do subject(:perform_async) do job_class.perform_async(*args) job_class.perform_one end let(:args) { [1, 2, 3] } let(:last_job) { job_class.jobs.last } context "with expected error" do let(:job_class) { WithTestErrorJob...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
spec/sidekiq/rescue/config_spec.rb
Ruby
mit
19
main
1,690
# frozen_string_literal: true RSpec.describe Sidekiq::Rescue::Config do describe "#delay=" do it "sets the delay value" do config = described_class.new config.delay = 30 expect(config.delay).to eq(30) end it "raises an ArgumentError if delay is not an Integer or Float" do config ...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
spec/sidekiq/rescue/server_middleware_spec.rb
Ruby
mit
19
main
9,480
# frozen_string_literal: true RSpec.describe Sidekiq::Rescue::ServerMiddleware do let(:middleware) { described_class.new } let(:job_instance) { WithTestErrorJob.new } let(:job_payload) do { "class" => "TestJob", "args" => [1], "retry" => true, "queue" => "default", "jid" => "123...
github
moofkit/sidekiq-rescue
https://github.com/moofkit/sidekiq-rescue
spec/sidekiq/rescue/rspec/matchers_spec.rb
Ruby
mit
19
main
3,807
# frozen_string_literal: true RSpec.describe Sidekiq::Rescue::RSpec::Matchers do let(:job_class) { WithTestErrorJob } it "matches" do expect(job_class).to have_sidekiq_rescue(TestError) end it "does not match" do expect(job_class).not_to have_sidekiq_rescue(StandardError) end context "with multi...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
Gemfile
Ruby
mit
19
main
437
# frozen_string_literal: true source "https://rubygems.org" # Specify your gem's dependencies in transmutation.gemspec gemspec gem "rake", "~> 13.0" gem "rails", ">= 7.2" gem "rspec", "~> 3.0" gem "rspec-rails", "~> 7.0" gem "rubocop", "~> 1.21" gem "rubocop-rspec", require: false gem "simplecov" gem "simplecov-...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
Rakefile
Ruby
mit
19
main
257
# frozen_string_literal: true require "bundler/gem_tasks" require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) require "rubocop/rake_task" RuboCop::RakeTask.new do |task| task.requires << "rubocop-rspec" end task default: %i[spec rubocop]
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
transmutation.gemspec
Ruby
mit
19
main
1,385
# frozen_string_literal: true require_relative "lib/transmutation/version" Gem::Specification.new do |spec| spec.name = "transmutation" spec.version = Transmutation::VERSION spec.authors = %w[nitemaeric borrabeer] spec.email = %w[daniel@spellbook.tech worapath.pakkavesa@spellbook.tech] spec.summary = "Ruby...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/spec_helper.rb
Ruby
mit
19
main
818
# frozen_string_literal: true require "pry" require "simplecov" require "simplecov-lcov" require "undercover" SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([SimpleCov::Formatter::HTMLFormatter, ...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/rails_helper.rb
Ruby
mit
19
main
706
# frozen_string_literal: true require "spec_helper" ENV["RAILS_ENV"] ||= "test" require_relative "dummy/config/environment" abort("The Rails environment is not running in test mode!") if Rails.env.production? require "rspec/rails" # Load the database schema into the in-memory SQLite database ActiveRecord::Schema.v...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/support/markdown_helper.rb
Ruby
mit
19
main
711
# frozen_string_literal: true module MarkdownHelper def parse_markdown_table(markdown, nil_value: "nil") header_row, _, *rows = markdown.split("\n") header_names = header_row.delete_prefix("|").split("|")&.map(&:strip) rows.map do |raw_row| parse_markdown_row(raw_row, nil_value:, header_names:) ...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/lib/transmutation/serialization_spec.rb
Ruby
mit
19
main
7,384
# frozen_string_literal: true RSpec.describe Transmutation::Serialization do extend MarkdownHelper serializer_lookup_table = parse_markdown_table(<<~TABLE, nil_value: "") | context | namespace | serializer | expected_namespace | expected_ser...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/lib/transmutation/serializer_spec.rb
Ruby
mit
19
main
981
# frozen_string_literal: true RSpec.describe Transmutation::Serializer do subject(:json) { example_serializer.new(example_object) } before do example_object_class = Class.new do attr_accessor :first_name, :last_name def initialize(first_name:, last_name:) @first_name = first_name ...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/requests/api/v1/posts_spec.rb
Ruby
mit
19
main
1,222
# frozen_string_literal: true require "rails_helper" RSpec.describe "Api::V1::Posts", type: :request do describe "GET /api/v1/posts" do it "returns a list of posts serialized with Api::V1::PostSerializer", :aggregate_failures do get api_v1_posts_path expect(response).to have_http_status(:ok) ...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/requests/api/v1/users_spec.rb
Ruby
mit
19
main
1,665
# frozen_string_literal: true require "rails_helper" RSpec.describe "Api::V1::Users", type: :request do describe "GET /api/v1/users" do it "returns a list of users serialized with Api::V1::UserSerializer", :aggregate_failures do get api_v1_users_path expect(response).to have_http_status(:ok) ...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/requests/api/v1/products_spec.rb
Ruby
mit
19
main
526
# frozen_string_literal: true require "rails_helper" RSpec.describe "Api::V1::Products", type: :request do describe "GET /api/v1/products/:id" do it "returns a product serialized with ProductSerializer", :aggregate_failures do get api_v1_product_path(1) expect(response).to have_http_status(:ok) ...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/requests/api/v1/health_spec.rb
Ruby
mit
19
main
913
# frozen_string_literal: true require "rails_helper" RSpec.describe "Api::V1::Health", type: :request do describe "GET /api/v1/health" do it "returns a JSON object without serialization", :aggregate_failures do get api_v1_health_index_path expect(response).to have_http_status(:ok) expect(JSON...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/dummy/db/schema.rb
Ruby
mit
19
main
702
# frozen_string_literal: true ActiveRecord::Schema.define(version: 0) do create_table :users, force: true do |t| t.string :first_name, null: false t.string :last_name, null: false end create_table :posts, force: true do |t| t.string :title, null: false t.text :body, null: false t.references ...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/dummy/app/serializers/api/v1/user_serializer.rb
Ruby
mit
19
main
242
# frozen_string_literal: true module Api module V1 class UserSerializer < Transmutation::Serializer attribute :id attribute :full_name do "#{object.first_name} #{object.last_name}".strip end end end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/dummy/app/serializers/api/v1/detailed/post_serializer.rb
Ruby
mit
19
main
203
# frozen_string_literal: true module Api module V1 module Detailed class PostSerializer < Api::V1::PostSerializer attributes :body has_one :user end end end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/dummy/app/serializers/api/v1/detailed/user_serializer.rb
Ruby
mit
19
main
396
# frozen_string_literal: true module Api module V1 module Detailed class UserSerializer < Api::V1::UserSerializer attributes :first_name, :last_name has_many :posts, :comments, namespace: "::Api::V1" has_many :published_posts, namespace: "::Api::V1" do object.posts.rejec...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/dummy/app/controllers/api/v1/posts_controller.rb
Ruby
mit
19
main
318
# frozen_string_literal: true module Api module V1 class PostsController < Api::ApplicationController def index posts = Post.all render json: posts end def show post = Post.find(params[:id]) render json: post, namespace: "Detailed" end end end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/dummy/app/controllers/api/v1/health_controller.rb
Ruby
mit
19
main
302
# frozen_string_literal: true module Api module V1 class HealthController < Api::ApplicationController def index render json: { ok: true } end def download send_data "binary data content", filename: "report.txt", type: "text/plain" end end end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/dummy/app/controllers/api/v1/products_controller.rb
Ruby
mit
19
main
228
# frozen_string_literal: true module Api module V1 class ProductsController < Api::ApplicationController def show product = Product.find(params[:id]) render json: product end end end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/dummy/app/controllers/api/v1/users_controller.rb
Ruby
mit
19
main
335
# frozen_string_literal: true module Api module V1 class UsersController < Api::ApplicationController def index users = User.all render json: users end def show user = User.find(params[:id]) render json: user, serializer: "Detailed::UserSerializer" end ...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/dummy/app/models/money.rb
Ruby
mit
19
main
326
# frozen_string_literal: true # Simulates the Money class from the Money gem class Money Currency = Struct.new(:iso_code) attr_reader :fractional def initialize(fractional, currency_code) @fractional = fractional @currency_code = currency_code end def currency Currency.new(@currency_code) en...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/dummy/config/routes.rb
Ruby
mit
19
main
365
# frozen_string_literal: true Rails.application.routes.draw do namespace :api do namespace :v1 do resources :users, only: %i[index show] resources :posts, only: %i[index show] resources :products, only: [:show] resources :health, only: [:index] do collection do get :down...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/dummy/config/application.rb
Ruby
mit
19
main
490
# frozen_string_literal: true require_relative "boot" require "rails" require "active_record/railtie" require "action_controller/railtie" Bundler.require(*Rails.groups) require "transmutation" module Dummy class Application < Rails::Application config.root = File.expand_path("..", __dir__) config.load_d...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/dummy/config/boot.rb
Ruby
mit
19
main
227
# frozen_string_literal: true ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__) require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) $LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
spec/dummy/config/environments/test.rb
Ruby
mit
19
main
295
# frozen_string_literal: true Rails.application.configure do config.eager_load = false config.consider_all_requests_local = true config.action_controller.perform_caching = false config.action_controller.allow_forgery_protection = false config.active_support.deprecation = :stderr end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/Gemfile
Ruby
mit
19
main
417
# frozen_string_literal: true source "https://rubygems.org" gem "pry" gem "rubocop" # Serializers gem "active_model_serializers" gem "alba" gem "jbuilder" gem "panko_serializer" gem "rabl" gem "representable" gem "transmutation", path: ".." # JSON generators gem "multi_json" gem "oj" # Benchmarking gem "benchmark-...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/benchmark.rb
Ruby
mit
19
main
5,248
# frozen_string_literal: true require "bundler/setup" require "active_support/core_ext/object/deep_dup" # Required for Active Model Serializers Bundler.require Oj.optimize_rails # Use OJ for benchmarks using #to_json MultiJson.use(:oj) # Use OJ by default from multi_json loader = Zeitwerk::Loader.new loader.push_di...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/lib/gem_benchmarks.rb
Ruby
mit
19
main
3,995
# frozen_string_literal: true class GemBenchmarks def self.report(**options, &block) new(**options, &block).groups.each_value(&:report) end def initialize(**options, &block) config[:output] = options.fetch(:output, true) config[:style] = options.fetch(:style, :markdown) instance_eval(&block) ...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/lib/models/post.rb
Ruby
mit
19
main
431
# frozen_string_literal: true class Post < Base attr_accessor :id, :title, :body, :user_id def self.all @all ||= [ Post.new(id: 1, title: "Post 1", body: "Sample body 1", user_id: 1), Post.new(id: 2, title: "Post 2", body: "Sample body 2", user_id: 2), Post.new(id: 3, title: "Post 3", body: ...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/lib/models/user.rb
Ruby
mit
19
main
441
# frozen_string_literal: true class User < Base attr_accessor :id, :first_name, :last_name, :organisation_id def self.all @all ||= [ User.new(id: 1, first_name: "John", last_name: "Doe", organisation_id: 1), ] end def organisation Organisation.all.find { |org| org.id == organisation_id } ...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/lib/models/base.rb
Ruby
mit
19
main
202
class Base def initialize(**attributes) attributes.each do |key, value| send("#{key}=", value) end end def read_attribute_for_serialization(attribute) send(attribute) end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/lib/serializers/representable/post_representer.rb
Ruby
mit
19
main
392
# frozen_string_literal: true module Representable class PostRepresenter < Representable::Decorator include Representable::JSON property :id property :title property :body property :user do property :id property :first_name property :full_name, getter: ->(represented:, **) { "...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/lib/serializers/representable/organisation_representer.rb
Ruby
mit
19
main
303
# frozen_string_literal: true module Representable class OrganisationRepresenter < Representable::Decorator include Representable::JSON property :id property :name property :logo_url, getter: ->(represented:, **) { "https://example.com/logos/companies/#{represented.id}" } end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/lib/serializers/representable/user_representer.rb
Ruby
mit
19
main
395
# frozen_string_literal: true module Representable class UserRepresenter < Representable::Decorator include Representable::JSON property :id property :first_name property :full_name, getter: ->(represented:, **) { "#{represented.first_name} #{represented.last_name}" } collection :posts do ...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/lib/serializers/panko_serializer/organisation_serializer.rb
Ruby
mit
19
main
235
# frozen_string_literal: true module PankoSerializer class OrganisationSerializer < Panko::Serializer attributes :id, :name, :logo_url def logo_url "https://example.com/logos/companies/#{object.id}" end end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/lib/serializers/panko_serializer/user_serializer.rb
Ruby
mit
19
main
248
# frozen_string_literal: true module PankoSerializer class UserSerializer < Panko::Serializer attributes :id, :first_name, :full_name def full_name "#{object.first_name} #{object.last_name}" end has_many :posts end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/lib/serializers/transmutation/organisation_serializer.rb
Ruby
mit
19
main
240
# frozen_string_literal: true module Transmutation class OrganisationSerializer < Transmutation::Serializer attributes :id, :name attribute :logo_url do "https://example.com/logos/companies/#{object.id}" end end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/lib/serializers/transmutation/user_serializer.rb
Ruby
mit
19
main
252
# frozen_string_literal: true module Transmutation class UserSerializer < Transmutation::Serializer attributes :id, :first_name attribute :full_name do "#{object.first_name} #{object.last_name}" end has_many :posts end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/lib/serializers/active_model_serializers/user_serializer.rb
Ruby
mit
19
main
259
# frozen_string_literal: true module ActiveModelSerializers class UserSerializer < ActiveModel::Serializer attributes :id, :first_name attribute :full_name do "#{object.first_name} #{object.last_name}" end has_many :posts end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/lib/serializers/active_model_serializers/organisation_serializer.rb
Ruby
mit
19
main
247
# frozen_string_literal: true module ActiveModelSerializers class OrganisationSerializer < ActiveModel::Serializer attributes :id, :name attribute :logo_url do "https://example.com/logos/companies/#{object.id}" end end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/lib/serializers/alba/user_resource.rb
Ruby
mit
19
main
276
# frozen_string_literal: true module Alba class UserResource include Alba::Resource attributes :id, :first_name attribute :full_name do |resource| "#{resource.first_name} #{resource.last_name}" end many :posts, resource: PostResource end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
benchmarks/lib/serializers/alba/organisation_resource.rb
Ruby
mit
19
main
242
# frozen_string_literal: true module Alba class OrganisationResource include Alba::Resource attributes :id, :name attribute :logo_url do |resource| "https://example.com/logos/companies/#{resource.id}" end end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
lib/transmutation.rb
Ruby
mit
19
main
1,415
# frozen_string_literal: true require "transmutation/class_attributes" # A performant and expressive solution for serializing Ruby objects into JSON, with a touch of opinionated "magic" ✨. # # @example Basic usage # # Define a data class. # class User # attr_reader :name, :email # # def initialize(name:, ...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
lib/transmutation/serializer.rb
Ruby
mit
19
main
4,517
# frozen_string_literal: true module Transmutation # Base class for your serializers. # # @example Basic usage # class UserSerializer < Transmutation::Serializer # attributes :first_name, :last_name # # attribute :full_name do # "#{object.first_name} #{object.last_name}".strip # e...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
lib/transmutation/object_serializer.rb
Ruby
mit
19
main
266
# frozen_string_literal: true module Transmutation # Default object serializer. # This is used when no serializer is found for the given object. class ObjectSerializer < Serializer def as_json(options = {}) object.as_json(options) end end end
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
lib/transmutation/class_attributes.rb
Ruby
mit
19
main
1,161
# frozen_string_literal: true module Transmutation # @api private module ClassAttributes def class_attribute( *names, instance_accessor: true, instance_reader: instance_accessor, instance_writer: instance_accessor, default: nil ) class_attribute_reader(*names, instance_r...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
lib/transmutation/serialization.rb
Ruby
mit
19
main
2,230
# frozen_string_literal: true module Transmutation module Serialization # Serialize a given object with the looked up serializer. # # @param object [Object] The object to serialize. # @param namespace [String, Symbol, Module] The namespace to lookup the serializer in. # @param serializer [String,...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
lib/transmutation/serialization/lookup.rb
Ruby
mit
19
main
2,647
# frozen_string_literal: true module Transmutation module Serialization # @api private class Lookup def initialize(caller, namespace: nil) @caller = caller @namespace = namespace end # Bubbles up the namespace until we find a matching serializer. # # @see Transm...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
lib/transmutation/serialization/rendering.rb
Ruby
mit
19
main
1,093
# frozen_string_literal: true module Transmutation module Serialization module Rendering # Serializes the value of the `json` parameter before calling the existing render method. # # Handles both Rails-style hash arguments (e.g., from send_data) and keyword arguments. def render(options =...
github
spellbook-technology/transmutation
https://github.com/spellbook-technology/transmutation
lib/transmutation/serialization/lookup/serializer_not_found.rb
Ruby
mit
19
main
1,069
# frozen_string_literal: true module Transmutation module Serialization class Lookup # @api public class SerializerNotFound < Transmutation::Error attr_reader :object, :namespace, :name def initialize(object, namespace: nil, name: nil) @object = object @namespace ...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
oxcelix.gemspec
Ruby
mit
19
master
1,053
# -*- encoding: utf-8 -*- require 'rake' Gem::Specification.new do |s| s.name = 'oxcelix' s.version = '0.4.2' s.date = '2018-11-01' s.summary = 'A fast Excel 2007/2010 file parser' s.description = 'A fast Excel 2007/2010 (.xlsx) file parser that returns a collection of Matrix objects' s.authors = 'Giovanni...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
lib/oxcelix.rb
Ruby
mit
19
master
1,129
require 'ox' require 'find' require 'matrix' require 'fileutils' require 'tmpdir' require 'zip' require 'oxcelix/cellhelper' require 'oxcelix/numformats' require 'oxcelix/nf' require 'oxcelix/cell' require 'oxcelix/sheet' require 'oxcelix/workbook' require 'oxcelix/sax/sharedstrings' require 'oxcelix/sax/comments' requ...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
lib/oxcelix/workbook.rb
Ruby
mit
19
master
14,481
# The namespace for all classes and modules included on Oxcelix. module Oxcelix # Helper methods for the Workbook class module Workbookhelper # returns a sheet based on its name # @example Select a sheet # w = Workbook.new('Example.xlsx') # sheet = w["Examplesheet"] def [] (sheetname=String...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
lib/oxcelix/cell.rb
Ruby
mit
19
master
687
module Oxcelix # Simple class representing an excel cell. # @!attribute [rw] xlcoords # @return [String] The Excel-style coordinates of the cell object # @!attribute [rw] type # @return [String] Cell content type # @!attribute [rw] value # @return [String] the type of the cell # @!attribute [rw] c...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
lib/oxcelix/cellhelper.rb
Ruby
mit
19
master
1,893
module Oxcelix # The Cellvalues module provides methods for setting cell values. They are named after the relevant XML entitiesd and # called directly by the Xlsheet SAX parser. module Cellvalues # Set the excel cell name (eg: 'A2') # @param [String] val Excel cell address name def r(val); @xlcoords...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
lib/oxcelix/numformats.rb
Ruby
mit
19
master
5,818
module Oxcelix # The Numformats module provides helper methods that either return the Cell object's raw @value as a ruby value # (e.g. Numeric, DateTime, String) or formats it according to the excel _numformat_ string (#Cell.numformat). module Numformats # Map containing the Excel formatting strings and their...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
lib/oxcelix/nf.rb
Ruby
mit
19
master
11,183
module Oxcelix module Numformats # Formatarray is the array of default format strings in Excel. Nil values should apparently contain CJK date format strings, #feel free to add/document those according to existing standards. Formatarray = [ {:id => '0', :xl => 'General', :ostring => nil, :cls => 'string'}, ...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
lib/oxcelix/sheet.rb
Ruby
mit
19
master
3,585
module Oxcelix # The Sheet class represents an excel sheet. class Sheet < Matrix include Cellhelper include Numberhelper # @!attribute [rw] name # @return [String] Sheet name # @!attribute [rw] sheetId # @return [String] returns the sheetId SheetML internal attribute # @!attribute [rw] relatio...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
lib/oxcelix/sax/comments.rb
Ruby
mit
19
master
729
module Oxcelix # The Comments class is a parser which builds an array of comments class Comments < ::Ox::Sax # @!attribute [rw] commarray # @return [Array] the array of all comments of a given sheet # @!attribute [rw] comment # @return [Hash] a hash representing a comment attr_accessor :commar...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
lib/oxcelix/sax/sharedstrings.rb
Ruby
mit
19
master
536
module Oxcelix # Ox based SAX parser which pushes shared strings (taken from the sharedString.xml file) to an array # These strings will replace the references in the cells (interpolation). class Sharedstrings < ::Ox::Sax # @!attribute [rw] stringarray # @return [Array] the array of all the strings foun...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
lib/oxcelix/sax/styles.rb
Ruby
mit
19
master
1,132
require 'ox' module Oxcelix # Ox based SAX parser which pushes the number formats (taken from the styles.xml file) to an array # The reference taken from the cell's 's' attribute points to an element of the # style array, which in turn points to a number format (numFmt) that can be # either built-in (@formats)...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
lib/oxcelix/sax/xlsheet.rb
Ruby
mit
19
master
4,745
module Oxcelix ## # The Xlsheet class is a SAX parser based on the Ox library. It parses a # SpreadsheetML (AKA Office Open XML) formatted XML file and returns an array # of Cell objects {#cellarray} and an array of merged cells {#mergedcells}. # # Xlsheet will omit the following: # * empty cells # * ce...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
spec/string_spec.rb
Ruby
mit
19
master
419
require './spec/spec_helper' describe "String object" do describe 'numeric?' do context "with numbers" do it "should return true" do (1..100).each do |x| x.to_s.numeric?.should == true end end end context "with strings" do it "should return false" do ('a...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
spec/sheet_spec.rb
Ruby
mit
19
master
354
require './spec/spec_helper.rb' describe "Oxcelix module" do describe 'Sheet' do context 'format' do it "should not raise a syntax error on a Text field with a ZIP code" do file = 'spec/fixtures/test.xlsx' w=Oxcelix::Workbook.new(file) lambda { w.sheets[0].to_fmt }.should_not raise_...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
spec/cell_spec.rb
Ruby
mit
19
master
263
require './spec/spec_helper' describe "Cell" do describe '#r' do it "sets the value of xlcoords" do c=Oxcelix::Cell.new c.r('H276') c.xlcoords.should == 'H276' c.x.should == 7 c.y.should == 275 end end end
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
spec/oxcelix_spec.rb
Ruby
mit
19
master
1,061
require './spec/spec_helper.rb' describe "Oxcelix module" do describe 'Workbook' do context 'normal' do it "should open the excel file and return a Workbook object" do file = 'spec/fixtures/test.xlsx' w=Oxcelix::Workbook.new(file) w.sheets.size.should == 2 w.sheets[0].nam...
github
gbiczo/oxcelix
https://github.com/gbiczo/oxcelix
spec/matrix_spec.rb
Ruby
mit
19
master
243
require './spec/spec_helper' describe "Matrix object" do describe '#[]=' do it "should set a cell to a new value" do m_obj = Matrix.build(4, 4){nil} m_obj[3,3] = 'foo' m_obj[3,3].should == 'foo' end end end