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 | citizensadvice/capybara_accessible_selectors | https://github.com/citizensadvice/capybara_accessible_selectors | lib/capybara_accessible_selectors/node/accessible_description.rb | Ruby | isc | 86 | main | 723 | # frozen_string_literal: true
require "capybara_accessible_selectors/nokogiri/accessible_description"
require "capybara_accessible_selectors/selenium/accessible_description"
module CapybaraAccessibleSelectors
module DriverNodeExtensions
def accessible_description
raise NotImplementedError
end
end
... |
github | fxposter/carrierwave-processing | https://github.com/fxposter/carrierwave-processing | carrierwave-processing.gemspec | Ruby | mit | 86 | master | 1,038 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/carrierwave-processing/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Pavel Forkert"]
gem.email = ["fxposter@gmail.com"]
gem.description = %q{Additional processing support for MiniMagick and RMagick}
gem.summary ... |
github | fxposter/carrierwave-processing | https://github.com/fxposter/carrierwave-processing | lib/carrierwave-processing.rb | Ruby | mit | 86 | master | 210 | require 'carrierwave-processing/version'
module CarrierWave
module Processing
autoload :RMagick, 'carrierwave-processing/rmagick'
autoload :MiniMagick, 'carrierwave-processing/mini_magick'
end
end |
github | fxposter/carrierwave-processing | https://github.com/fxposter/carrierwave-processing | lib/carrierwave-processing/rmagick.rb | Ruby | mit | 86 | master | 1,665 | module CarrierWave
module Processing
module RMagick
# Strips out all embedded information from the image
#
# process :strip
#
def strip
manipulate! do |img|
img.strip!
img = yield(img) if block_given?
img
end
end
# Reduces ... |
github | fxposter/carrierwave-processing | https://github.com/fxposter/carrierwave-processing | lib/carrierwave-processing/mini_magick.rb | Ruby | mit | 86 | master | 1,662 | module CarrierWave
module Processing
module MiniMagick
# Strips out all embedded information from the image
#
# process :strip
#
def strip
manipulate! do |img|
img.strip
img = yield(img) if block_given?
img
end
end
# Reduce... |
github | fxposter/carrierwave-processing | https://github.com/fxposter/carrierwave-processing | spec/spec_helper.rb | Ruby | mit | 86 | master | 982 | require 'fileutils'
module Helpers
def fixture_path(filename)
File.expand_path(File.join('..', 'fixtures', filename), __FILE__)
end
def open_fixture(filename, &block)
File.open(fixture_path(filename), &block)
end
def exif(path, field)
`identify -format %[exif:#{field}] #{path}`.chomp
end
d... |
github | fxposter/carrierwave-processing | https://github.com/fxposter/carrierwave-processing | spec/integration/carrierwave_processing_spec.rb | Ruby | mit | 86 | master | 3,362 | require 'carrierwave'
require 'carrierwave-processing'
require 'spec_helper'
working_module_names = (RUBY_PLATFORM == 'java' ? %w[MiniMagick] : %w[RMagick MiniMagick])
working_module_names.each do |module_name|
describe CarrierWave::Processing.const_get(module_name) do
before do
FileUtils.rm_rf(fixture_p... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | config.ru | Ruby | mit | 86 | main | 425 | # This file is used by Rack-based servers to start the application.
require_relative 'config/environment'
if Rails.env.production? && Rails.configuration.x.app_host
# Redirect to a canonical host (except for health check)
use Rack::CanonicalHost,
Rails.configuration.x.app_host,
cache_control: 'no-cach... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | Gemfile | Ruby | mit | 86 | main | 3,730 | source 'https://rubygems.org'
ruby file: '.ruby-version'
# Full-stack web application framework. (https://rubyonrails.org)
gem 'rails', '~> 8.1.2'
# Use Vite in Rails and bring joy to your JavaScript experience (https://github.com/ElMassimo/vite_ruby)
gem 'vite_rails'
# Pg is the Ruby interface to the PostgreSQL RD... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | spec/spec_helper.rb | Ruby | mit | 86 | main | 4,765 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to explicitly require ... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | spec/rails_helper.rb | Ruby | mit | 86 | main | 3,164 | require 'simplecov'
SimpleCov.start 'rails' do
add_filter 'app/jobs/application_job.rb'
add_filter 'app/mailers/application_mailer.rb'
add_filter 'app/channels/application_cable/connection.rb'
add_filter 'app/channels/application_cable/channel.rb'
add_filter 'app/models/application_record.rb'
end
# This file... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | spec/system/basic_spec.rb | Ruby | mit | 86 | main | 769 | describe 'Basic navigation and interaction' do
it 'can navigate between pages' do
visit '/'
expect(page).to have_content('Hello')
click_on 'About'
expect(page).to have_selector('main h1', text: 'About')
click_on 'Home'
expect(page).to have_selector('main h1', text: 'Hello')
end
it 'can ... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | spec/models/click_spec.rb | Ruby | mit | 86 | main | 447 | # == Schema Information
#
# Table name: clicks
#
# id :bigint not null, primary key
# ip :inet not null
# user_agent :string not null
# created_at :datetime not null
#
describe Click do
it 'saves payload' do
click = described_class.create! ip: '1.2.3.4',... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | spec/support/capybara.rb | Ruby | mit | 86 | main | 379 | require 'capybara/rspec'
Capybara.register_driver :my_playwright do |app|
Capybara::Playwright::Driver.new(
app,
browser_type: ENV.fetch('PLAYWRIGHT_BROWSER', 'chromium').to_sym,
headless: ENV['CI'].present? || ENV['PLAYWRIGHT_HEADLESS'].present?
)
end
RSpec.configure do |config|
config.before(:each... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | spec/requests/clicks_spec.rb | Ruby | mit | 86 | main | 2,155 | describe 'Clicks' do
include ActiveSupport::Testing::TimeHelpers
let(:user_agent) { 'Netscape Navigator' }
let(:ip) { '1.2.3.4' }
describe 'POST /clicks' do
let(:user_agent) { 'Netscape Navigator' }
def call(ip)
post clicks_path,
headers: {
HTTP_USER_AGENT: user_agent,
... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | app/models/click.rb | Ruby | mit | 86 | main | 420 | # == Schema Information
#
# Table name: clicks
#
# id :bigint not null, primary key
# ip :inet not null
# user_agent :string not null
# created_at :datetime not null
#
class Click < ApplicationRecord
validates :ip, presence: true
validates :user_agent, pre... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | app/helpers/application_helper.rb | Ruby | mit | 86 | main | 758 | module ApplicationHelper
def versions
{
alpine: alpine_version,
ruby: ruby_version,
rails: rails_version,
puma: puma_version,
postgres: postgres_version,
redis: redis_version,
sidekiq: sidekiq_version,
}
end
private
def alpine_version
return if RUBY_PLATFO... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | app/controllers/clicks_controller.rb | Ruby | mit | 86 | main | 1,005 | class ClicksController < ApplicationController
def index
clicks = Click.order(created_at: :desc).limit(5).to_a
return unless stale?(clicks, template: false, public: true)
expires_in 0, must_revalidate: true
respond_to do |format|
format.json { render json: { total: Click.count, items: clicks }... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | config/routes.rb | Ruby | mit | 86 | main | 6,169 | # == Route Map
#
# Prefix Verb URI Pattern Controller#Action
# rails_health_check GET /up(.:format) ... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | config/application.rb | Ruby | mit | 86 | main | 1,863 | require_relative 'boot'
require 'rails'
# Pick the frameworks you want:
require 'active_record/railtie'
# require 'active_storage/engine'
require 'action_controller/railtie'
require 'action_view/railtie'
require 'action_mailer/railtie'
require 'active_job/railtie'
require 'action_cable/engine'
require 'action_mailbox/... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | config/ci.rb | Ruby | mit | 86 | main | 956 | # Run using bin/ci
CI.run do
step 'Setup', 'bin/setup --skip-server'
step 'Style: Ruby', 'bin/rubocop'
step 'Style: JavaScript', 'bin/yarn lint'
step 'Style: TypeScript', 'bin/yarn tsc'
step 'Security: Brakeman code analysis',
'bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error'
step '... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | config/environments/test.rb | Ruby | mit | 86 | main | 2,209 | # The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.application.configure do
# Settings... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | config/environments/development.rb | Ruby | mit | 86 | main | 3,332 | require 'active_support/core_ext/integer/time'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Make code changes take effect immediately without server restart.
config.enable_reloading = true
# Do not eager load code on boot.
config.eager... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | config/environments/production.rb | Ruby | mit | 86 | main | 3,917 | require 'active_support/core_ext/integer/time'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.enable_reloading = false
# Eager load code on boot for better performance and memory savings (ignor... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | config/initializers/content_security_policy.rb | Ruby | mit | 86 | main | 3,062 | # Be sure to restart your server when you modify this file.
# Define an application-wide content security policy.
# See the Securing Rails Applications Guide for more information:
# https://guides.rubyonrails.org/security.html#content-security-policy-header
Rails.application.configure do
config.content_security_pol... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | config/initializers/rack.rb | Ruby | mit | 86 | main | 1,032 | # Remove 'x-runtime' header
Rails.application.config.middleware.delete(Rack::Runtime)
# Add content_type for some file extension not included in the
# list of defaults: https://github.com/rack/rack/blob/master/lib/rack/mime.rb
Rack::Mime::MIME_TYPES['.webmanifest'] = 'application/manifest+json'
unless Rails.env.devel... |
github | templatus/templatus-vue | https://github.com/templatus/templatus-vue | config/initializers/rorvswild.rb | Ruby | mit | 86 | main | 267 | if Rails.configuration.x.rorvswild.api_key
RorVsWild.start(
api_key: Rails.configuration.x.rorvswild.api_key,
ignored_exceptions: %w[ActionController::RoutingError],
deployment: {
revision: Rails.configuration.x.git.commit_version,
},
)
end |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | Rakefile | Ruby | mit | 86 | master | 426 | # frozen_string_literal: true
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "github_changelog_generator/task"
require "ams_lazy_relationships/version"
RSpec::Core::RakeTask.new(:spec)
task default: :spec
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
config.user = "Bajena"
co... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | ams_lazy_relationships.gemspec | Ruby | mit | 86 | master | 2,932 | # frozen_string_literal: true
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "ams_lazy_relationships/version"
Gem::Specification.new do |spec|
spec.name = "ams_lazy_relationships"
spec.version = AmsLazyRelationships::VERSION
spec.authors... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | Appraisals | Ruby | mit | 86 | master | 685 | appraise "ams-0.10.0.rc4" do
gem "active_model_serializers", "0.10.0.rc4"
end
appraise "ams-0.10.0" do
gem "active_model_serializers", "0.10.0"
end
appraise "ams-0.10.2" do
gem "active_model_serializers", "0.10.2"
end
appraise "ams-0.10.3" do
gem "active_model_serializers", "0.10.3"
end
appraise "ams-0.10.8... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | spec/core_spec.rb | Ruby | mit | 86 | master | 31,317 | # frozen_string_literal: true
require "spec_helper"
AMS_VERSION = Gem::Version.new(ActiveModel::Serializer::VERSION)
RSpec.describe AmsLazyRelationships::Core do
extend WithArModels
with_ar_models
class BaseTestSerializer < ActiveModel::Serializer
include AmsLazyRelationships::Core
attributes :id
... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | spec/spec_helper.rb | Ruby | mit | 86 | master | 1,410 | require "simplecov"
require "simplecov-lcov"
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
SimpleCov.start do
add_filter(/^\/spec\//)
end
require "bundler/setup"
# That is a missing dependency of AMS v0.10.0.rc4 in fact (
require... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | spec/benchmark_spec.rb | Ruby | mit | 86 | master | 6,877 | # frozen_string_literal: true
require "spec_helper"
require "benchmark"
require "benchmark/memory"
RSpec.describe AmsLazyRelationships::Core do
extend WithArModels
with_ar_models
class NonLazyUserSerializer < ActiveModel::Serializer
end
class NonLazyCommentSerializer < ActiveModel::Serializer
belongs... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | spec/loaders/association_spec.rb | Ruby | mit | 86 | master | 7,788 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe AmsLazyRelationships::Loaders::Association do
extend WithArModels
with_ar_models
context "belongs_to associations" do
let(:blog_post) { BlogPost.create! }
let!(:record) { Comment.create!(blog_post_id: blog_post.id) }
let(:loader) {... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | spec/loaders/simple_belongs_to_spec.rb | Ruby | mit | 86 | master | 3,238 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe AmsLazyRelationships::Loaders::SimpleBelongsTo do
extend WithArModels
with_ar_models
describe "load" do
let(:blog_post) { BlogPost.create! }
let!(:record) { Comment.create!(blog_post_id: blog_post.id) }
let(:loader) { described_cla... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | spec/loaders/direct_spec.rb | Ruby | mit | 86 | master | 2,153 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe AmsLazyRelationships::Loaders::Direct do
class ModelA
attr_reader :id, :model_b
def initialize(id:, model_b:)
@id = id
@model_b = model_b
end
end
class ModelB
def initialize(id:)
@id = id
end
end
let(... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | spec/loaders/simple_has_many_spec.rb | Ruby | mit | 86 | master | 3,072 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe AmsLazyRelationships::Loaders::SimpleHasMany do
extend WithArModels
with_ar_models
describe "load" do
let(:record) { BlogPost.create! }
let!(:comments) do
2.times.map do
Comment.create!(blog_post_id: record.id)
end
... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | spec/support/with_ar_models.rb | Ruby | mit | 86 | master | 1,773 | module WithArModels
def with_ar_models
with_model :User do
table(id: :uuid) do |t|
t.string :name
t.timestamps
end
model do
before_create { self.id = SecureRandom.uuid }
has_many :comments
has_many :blog_posts
accepts_nested_attributes_for :blog_p... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | lib/ams_lazy_relationships.rb | Ruby | mit | 86 | master | 287 | # frozen_string_literal: true
require "batch-loader"
require "active_model_serializers"
require "ams_lazy_relationships/version"
require "ams_lazy_relationships/extensions"
require "ams_lazy_relationships/loaders"
require "ams_lazy_relationships/core"
module AmsLazyRelationships
end |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | lib/ams_lazy_relationships/core.rb | Ruby | mit | 86 | master | 1,660 | # frozen_string_literal: true
require "ams_lazy_relationships/core/lazy_relationship_method"
require "ams_lazy_relationships/core/lazy_dig_method"
require "ams_lazy_relationships/core/relationship_wrapper_methods"
require "ams_lazy_relationships/core/evaluation"
# This module defines a set of methods useful for elimi... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | lib/ams_lazy_relationships/loaders.rb | Ruby | mit | 86 | master | 304 | # frozen_string_literal: true
require "ams_lazy_relationships/loaders/association"
require "ams_lazy_relationships/loaders/direct"
require "ams_lazy_relationships/loaders/simple_belongs_to"
require "ams_lazy_relationships/loaders/simple_has_many"
module AmsLazyRelationships
module Loaders
end
end |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | lib/ams_lazy_relationships/extensions/reflection.rb | Ruby | mit | 86 | master | 2,532 | # frozen_string_literal: true
# There is a general problem inside AMS related to custom association finder
# combined with `include_data` setting:
#
# class BlogPostSerializer < BaseSerializer
# belongs_to :category do
# include_data :if_sideloaded
# object.categories.last
# end
# end
#
# The p... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | lib/ams_lazy_relationships/loaders/association.rb | Ruby | mit | 86 | master | 2,713 | # frozen_string_literal: true
require "ams_lazy_relationships/loaders/base"
module AmsLazyRelationships
module Loaders
# Lazy loads (has_one/has_many/has_many_through/belongs_to) ActiveRecord
# associations for ActiveRecord models
class Association < Base
# @param model_class_name [String] The nam... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | lib/ams_lazy_relationships/loaders/direct.rb | Ruby | mit | 86 | master | 1,262 | # frozen_string_literal: true
require "ams_lazy_relationships/loaders/base"
module AmsLazyRelationships
module Loaders
# Lazy loads data in a "dumb" way - just executes the provided block when needed
class Direct < Base
# @param relationship_name [Symbol] used for building cache key. Also if the
... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | lib/ams_lazy_relationships/loaders/base.rb | Ruby | mit | 86 | master | 1,749 | # frozen_string_literal: true
module AmsLazyRelationships
module Loaders
# A base class for all the loaders. A correctly defined loader requires
# the `load_data` and `batch_key` methods.
class Base
# Lazy loads and yields the data when evaluating
# @param record [Object] an object for which ... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | lib/ams_lazy_relationships/loaders/simple_belongs_to.rb | Ruby | mit | 86 | master | 1,665 | # frozen_string_literal: true
require "ams_lazy_relationships/loaders/base"
module AmsLazyRelationships
module Loaders
# Batch loads parent ActiveRecord records for given record by foreign key.
# Useful when the relationship is not a standard ActiveRecord relationship.
class SimpleBelongsTo < Base
... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | lib/ams_lazy_relationships/loaders/simple_has_many.rb | Ruby | mit | 86 | master | 1,508 | # frozen_string_literal: true
require "ams_lazy_relationships/loaders/base"
module AmsLazyRelationships
module Loaders
# Batch loads ActiveRecord records belonging to given record by foreign key.
# Useful when the relationship is not a standard ActiveRecord relationship.
class SimpleHasMany < Base
... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | lib/ams_lazy_relationships/core/relationship_wrapper_methods.rb | Ruby | mit | 86 | master | 1,918 | # frozen_string_literal: true
module AmsLazyRelationships::Core
# Defines convenience methods - wraps `has_many/belongs_to/has_one` and defines a
# lazy_has_many, lazy_has_one and lazy_belongs_to.
#
# Calling lazy_has_one in your serializer class will:
# - define a lazy_relationship
# - define a has_one re... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | lib/ams_lazy_relationships/core/evaluation.rb | Ruby | mit | 86 | master | 3,137 | # frozen_string_literal: true
module AmsLazyRelationships::Core
# Module responsible for lazy loading the relationships during the runtime
module Evaluation
private
LAZY_NESTING_LEVELS = 3
NESTING_START_LEVEL = 1
# Loads the lazy relationship
#
# @param relation_name [Symbol] relation nam... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | lib/ams_lazy_relationships/core/lazy_relationship_meta.rb | Ruby | mit | 86 | master | 1,046 | # frozen_string_literal: true
module AmsLazyRelationships::Core
# Internal helper class for keeping relationship details
class LazyRelationshipMeta
# @param name [String/Symbol] lazy relationship name. Can be different than the relationship name
# @param loader [Object] lazy loader for the relationship. Ha... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | lib/ams_lazy_relationships/core/lazy_relationship_method.rb | Ruby | mit | 86 | master | 2,044 | # frozen_string_literal: true
require "ams_lazy_relationships/core/lazy_relationship_meta"
module AmsLazyRelationships::Core
module LazyRelationshipMethod
# This method defines a new lazy relationship on the serializer and a method
# with `lazy_` prefix.
#
# @param name [Symbol] The name of the lazy... |
github | Bajena/ams_lazy_relationships | https://github.com/Bajena/ams_lazy_relationships | lib/ams_lazy_relationships/core/lazy_dig_method.rb | Ruby | mit | 86 | master | 2,789 | # frozen_string_literal: true
module AmsLazyRelationships::Core
# Provides `lazy_dig` as an instance method for serializers, in order to make
# possible to dig relationships in depth just like `Hash#dig` do, keeping the
# laziness and N+1-free evaluation.
module LazyDigMethod
# @param relation_names [Array... |
github | kenn/enum_accessor | https://github.com/kenn/enum_accessor | enum_accessor.gemspec | Ruby | mit | 86 | master | 968 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'enum_accessor/version'
Gem::Specification.new do |gem|
gem.name = 'enum_accessor'
gem.version = EnumAccessor::VERSION
gem.authors = ['Kenn Ejima']
gem.email... |
github | kenn/enum_accessor | https://github.com/kenn/enum_accessor | spec/enum_accessor_spec.rb | Ruby | mit | 86 | master | 4,157 | # encoding: UTF-8
require 'spec_helper'
ActiveRecord::Base.connection.create_table :users, force: true do |t|
t.column :gender, :integer, default: 0
end
class User < ActiveRecord::Base
enum_accessor :gender, [:female, :male]
end
describe EnumAccessor do
before do
@user = User.new
end
after do
Use... |
github | kenn/enum_accessor | https://github.com/kenn/enum_accessor | spec/spec_helper.rb | Ruby | mit | 86 | master | 437 | require 'rubygems'
require 'bundler/setup'
require 'enum_accessor'
RSpec.configure do |config|
require 'active_record'
ActiveRecord::Base.send(:include, EnumAccessor)
# Establish in-memory database connection
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
# Load translat... |
github | kenn/enum_accessor | https://github.com/kenn/enum_accessor | lib/enum_accessor.rb | Ruby | mit | 86 | master | 3,675 | require 'enum_accessor/version'
require 'enum_accessor/railtie'
require 'active_support'
module EnumAccessor
extend ActiveSupport::Concern
module ClassMethods
def enum_accessor(column, keys, options={})
# Normalize keys
dict = case keys
when Array
Hash[keys.map.with_index{|i,index| [... |
github | kenn/enum_accessor | https://github.com/kenn/enum_accessor | lib/enum_accessor/railtie.rb | Ruby | mit | 86 | master | 272 | module EnumAccessor
if defined? Rails::Railtie
class Railtie < Rails::Railtie
initializer 'enum_accessor.insert_into_active_record' do |app|
ActiveSupport.on_load :active_record do
include EnumAccessor
end
end
end
end
end |
github | vlad-shatskyi/uberscore | https://github.com/vlad-shatskyi/uberscore | uberscore.gemspec | Ruby | mit | 86 | master | 950 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'uberscore/version'
Gem::Specification.new do |spec|
spec.name = "uberscore"
spec.version = Uberscore::VERSION
spec.authors = %w(Ox0dea shock_one)
spec.summary =... |
github | vlad-shatskyi/uberscore | https://github.com/vlad-shatskyi/uberscore | lib/uberscore.rb | Ruby | mit | 86 | master | 831 | require "uberscore/version"
UBERSCORE_METHOD_NAME = :_ unless defined? UBERSCORE_METHOD_NAME
module Uberscore
class Context < BasicObject
class << self
alias_method :__new_uberscore_context__, :new
undef_method :new
end
undef_method :!
undef_method :!=
undef_method :==
undef_met... |
github | vlad-shatskyi/uberscore | https://github.com/vlad-shatskyi/uberscore | spec/uberscore_spec.rb | Ruby | mit | 86 | master | 746 | require_relative "../lib/uberscore"
require "pry"
describe Uberscore do
it "works" do
expect(%w[A B C].map(&_.downcase)).to eq(%w[a b c])
end
it "chains method calls" do
expect(%w[0x 0d ea].map(&_.hex.divmod(13)[1] == 0)).to eq(%w[0x 0d ea].map { |element| element.hex.divmod(13)[1] == 0 })
end
it "... |
github | railsware/rspec-example_steps | https://github.com/railsware/rspec-example_steps | rspec-example_steps.gemspec | Ruby | mit | 86 | master | 740 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
Gem::Specification.new do |s|
s.name = 'rspec-example_steps'
s.version = '3.1.1'
s.authors = ['Andriy Yanko']
s.email = ['andriy.yanko@gmail.com']
s.homepage = 'https://github.com/railsware/rspec-example_steps'
s... |
github | railsware/rspec-example_steps | https://github.com/railsware/rspec-example_steps | lib/rspec/example_steps.rb | Ruby | mit | 86 | master | 1,027 | require 'rspec/core'
require 'rspec/core/formatters'
require 'rspec/core/formatters/console_codes'
require 'rspec/core/formatters/documentation_formatter'
require 'rspec/core/example_group'
require 'rspec/core/reporter'
require 'rspec/example_steps/documentation_formatter'
require 'rspec/example_steps/example_group'
r... |
github | railsware/rspec-example_steps | https://github.com/railsware/rspec-example_steps | lib/rspec/example_steps/example_group.rb | Ruby | mit | 86 | master | 804 | module RSpec
module ExampleSteps
module ExampleGroup
def Given(message, options = {}, &block)
RSpec.world.reporter.process_example_step(self, :given, message, options, &block)
end
def When(message, options = {}, &block)
RSpec.world.reporter.process_example_step(self, :when, mess... |
github | railsware/rspec-example_steps | https://github.com/railsware/rspec-example_steps | lib/rspec/example_steps/documentation_formatter.rb | Ruby | mit | 86 | master | 2,075 | module RSpec
module ExampleSteps
module DocumentationFormatter
def self.included(base)
base.class_eval do
include InstanceMethods
alias :example_started_without_steps :example_started
alias :example_started :example_started_with_steps
alias :example_passed_w... |
github | railsware/rspec-example_steps | https://github.com/railsware/rspec-example_steps | lib/rspec/example_steps/reporter.rb | Ruby | mit | 86 | master | 1,435 | module RSpec
module ExampleSteps
module Reporter
def process_example_step(example, type, message, options)
example_step_started(self, type, message, options)
if block_given? && !options[:pending]
begin
yield
rescue Exception => e
example_step_fail... |
github | railsware/rspec-example_steps | https://github.com/railsware/rspec-example_steps | spec/example_steps_spec.rb | Ruby | mit | 86 | master | 2,815 | require 'spec_helper'
describe "example steps" do
describe "Given/When/Then" do
Steps "should execute blocks" do
Given "thing" do
@thing = "Given value"
end
When "action" do
@action = "When value"
end
Then "result" do
@result = "Then value"
end
... |
github | railsware/rspec-example_steps | https://github.com/railsware/rspec-example_steps | spec/regression_spec.rb | Ruby | mit | 86 | master | 273 | require 'spec_helper'
describe 'Usual example' do
subject { 2 + 2 }
context 'success' do
specify { expect(subject).to eq(4) }
end
context 'failed' do
specify { expect(subject).to eq(5) }
end
context 'pending' do
it 'should be pending'
end
end |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | ruby-box.gemspec | Ruby | mit | 86 | master | 3,249 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: ruby-box 1.15.0 ruby lib
Gem::Specification.new do |s|
s.name = "ruby-box"
s.version = "1.15.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") ... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | Rakefile | Ruby | mit | 86 | master | 880 | # encoding: utf-8
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | lib/ruby-box.rb | Ruby | mit | 86 | master | 557 | require 'ruby-box/client'
require 'ruby-box/session'
require 'ruby-box/item'
require 'ruby-box/file'
require 'ruby-box/folder'
require 'ruby-box/user'
require 'ruby-box/comment'
require 'ruby-box/collaboration'
require 'ruby-box/discussion'
require 'ruby-box/exceptions'
require 'ruby-box/event_response'
require 'ruby-... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | lib/ruby-box/exceptions.rb | Ruby | mit | 86 | master | 526 | module RubyBox
class RubyBoxError < StandardError
attr_accessor :body, :status
def initialize(error_json, status, body)
@status = status
@body = body
@error_json = error_json
end
def [](key)
@error_json[key]
end
end
class ObjectNotFound < StandardError; end
class ... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | lib/ruby-box/file.rb | Ruby | mit | 86 | master | 2,163 | module RubyBox
class File < Item
has_many :comments
def download
resp = stream.read
end
def download_url
@session.get( file_content_url )["location"]
end
def copy_to( folder_id, name=nil )
# Allow either a folder_id or a folder object
# to be passed in.
folde... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | lib/ruby-box/client.rb | Ruby | mit | 86 | master | 4,635 | require 'uri'
require 'net/https'
require 'json'
require 'net/http/post/multipart'
require 'open-uri'
module RubyBox
class Client
def initialize(session)
@session = session
end
def root_folder
folder_by_id('0')
end
def folder_by_id(id)
folder = Folder.new(@session, {'id' => i... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | lib/ruby-box/event_response.rb | Ruby | mit | 86 | master | 231 | module RubyBox
class EventResponse < Item
def events
@events ||= entries.collect {|ev|
RubyBox::Event.new(@session, ev)
}
end
private
def resource_name
'events'
end
end
end |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | lib/ruby-box/user.rb | Ruby | mit | 86 | master | 249 | module RubyBox
class User < Item
def enterprise
resp = @session.get( "#{RubyBox::API_URL}/users/#{id}?fields=enterprise" )
resp["enterprise"]
end
private
def resource_name
'users'
end
end
end |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | lib/ruby-box/session.rb | Ruby | mit | 86 | master | 4,137 | require 'oauth2'
module RubyBox
class Session
OAUTH2_URLS = {
:site => 'https://www.box.com',
:authorize_url => "/api/oauth2/authorize",
:token_url => "/api/oauth2/token"
}
def initialize(opts={}, backoff=0.1)
@backoff = backoff # try not to excessively hammer API.
if op... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | lib/ruby-box/folder.rb | Ruby | mit | 86 | master | 3,466 | module RubyBox
class Folder < Item
has_many :discussions
has_many :collaborations
has_many_paginated :items
def files(name=nil, item_limit=100, offset=0, fields=nil)
items_by_type(RubyBox::File, name, item_limit, offset, fields)
end
def folders(name=nil, item_limit=100, offset=0, fiel... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | lib/ruby-box/item.rb | Ruby | mit | 86 | master | 4,915 | require 'time'
require 'addressable/uri'
module RubyBox
class Item
@@has_many = []
@@has_many_paginated = []
def initialize( session, raw_item )
@session = session
@raw_item = raw_item
end
def self.has_many(*keys)
keys.each {|key| @@has_many << key.to_s}
end
def self... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | lib/ruby-box/collaboration.rb | Ruby | mit | 86 | master | 223 | module RubyBox
class Collaboration < Item
private
def resource_name
'collaborations'
end
def update_fields
['role', 'status']
end
def has_mini_format?
true
end
end
end |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | spec/folder_spec.rb | Ruby | mit | 86 | master | 12,301 | #encoding: UTF-8
require 'spec_helper'
require 'helper/account'
require 'ruby-box'
require 'webmock/rspec'
describe RubyBox::Folder do
before do
@session = RubyBox::Session.new
@full_folder = JSON.parse('{ "type": "folder", "id": "11446498", "sequence_id": "1", "etag": "1", "name": "Pictures"... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | spec/session_spec.rb | Ruby | mit | 86 | master | 889 | #encoding: UTF-8
require 'spec_helper'
require 'ruby-box'
describe RubyBox::Session do
before do
@auth_code = double("OAuth2::Strategy::AuthCode")
@client = double("OAuth2::Client")
@client.stub(:auth_code) { @auth_code }
OAuth2::Client.stub(:new) { @client }
@session = RubyBox::Session.new({
... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | spec/users_spec.rb | Ruby | mit | 86 | master | 687 | #encoding: UTF-8
require 'ruby-box'
require 'webmock/rspec'
describe '/users' do
before do
@session = RubyBox::Session.new
@client = RubyBox::Client.new(@session)
@users_json = File.read 'spec/fixtures/users.json'
@users = JSON.load(@users_json)
stub_request(:get, /#{RubyBox::API_URL}\/users/).... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | spec/me_spec.rb | Ruby | mit | 86 | master | 498 | #encoding: UTF-8
require 'ruby-box'
require 'webmock/rspec'
describe '/users/me' do
before do
@session = RubyBox::Session.new
@client = RubyBox::Client.new(@session)
@me_json = File.read 'spec/fixtures/me.json'
@me = JSON.load @me_json
stub_request(:get, /#{RubyBox::API_URL}\/users\/me/).to_re... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | spec/integration_spec.rb | Ruby | mit | 86 | master | 13,575 | #encoding: UTF-8
require 'spec_helper'
require 'helper/account'
require 'ruby-box'
require 'webmock/rspec'
describe RubyBox, :skip => true do
before do
WebMock.allow_net_connect!
@session = RubyBox::Session.new({
api_key: ACCOUNT['api_key'],
auth_token: ACCOUNT['auth_token']
})
@c... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | spec/file_spec.rb | Ruby | mit | 86 | master | 6,336 | #encoding: UTF-8
require 'spec_helper'
require 'helper/account'
require 'ruby-box'
require 'webmock/rspec'
describe RubyBox::File do
before do
@session = RubyBox::Session.new
@full_file = JSON.parse('{ "type": "file", "id": "5000948880", "sequence_id": "3", "etag": "3", "sha1": "134b65991ed52... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | spec/item_spec.rb | Ruby | mit | 86 | master | 718 | #encoding: UTF-8
require 'ruby-box'
require 'webmock/rspec'
describe RubyBox::Item do
before do
@session = RubyBox::Session.new
@client = RubyBox::Client.new(@session)
end
describe '#factory' do
it 'creates an object from a web_link hash' do
web_link = RubyBox::Item.factory(@session, {... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | spec/client_spec.rb | Ruby | mit | 86 | master | 2,043 | #encoding: UTF-8
require 'spec_helper'
require 'helper/account'
require 'ruby-box'
require 'webmock/rspec'
describe RubyBox::Client do
before do
@session = RubyBox::Session.new
end
describe '#folder' do
it "should return root folder as default behavior for paths such as ./" do
RubyBox::Client.any... |
github | attachmentsme/ruby-box | https://github.com/attachmentsme/ruby-box | spec/event_spec.rb | Ruby | mit | 86 | master | 2,300 | #encoding: UTF-8
require 'ruby-box'
require 'webmock/rspec'
describe RubyBox::EventResponse do
before do
@session = RubyBox::Session.new
@client = RubyBox::Client.new(@session)
@events_json = File.read 'spec/fixtures/events.json'
@events = JSON.load @events_json
stub_request(:get, /#{RubyBox::... |
github | redbooth/departure | https://github.com/redbooth/departure | test_database.rb | Ruby | mit | 86 | master | 1,932 | # Setups the test database with the schema_migrations table that ActiveRecord
# requires for the migrations, plus a table for the Comment model used throught
# the tests.
#
class TestDatabase
# Constructor
#
# @param config [Hash]
def initialize(config)
@config = config
@database = config['database']
... |
github | redbooth/departure | https://github.com/redbooth/departure | Rakefile | Ruby | mit | 86 | master | 327 | require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require './configuration'
require './test_database'
RSpec::Core::RakeTask.new(:spec)
task default: :spec
namespace :db do
desc 'Create the test database'
task :create do
config = Configuration.new
TestDatabase.new(config).setup_test_database
e... |
github | redbooth/departure | https://github.com/redbooth/departure | departure.gemspec | Ruby | mit | 86 | master | 1,448 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'departure/version'
Gem::Specification.new do |spec|
spec.name = 'departure'
spec.version = Departure::VERSION
spec.authors = ['Ilya Zayats', 'Pau Pérez', 'Fran Casas'... |
github | redbooth/departure | https://github.com/redbooth/departure | configuration.rb | Ruby | mit | 86 | master | 202 | require 'yaml'
class Configuration
CONFIG_PATH = 'config.yml'.freeze
attr_reader :config
def initialize
@config = YAML.load_file(CONFIG_PATH)
end
def [](key)
config[key]
end
end |
github | redbooth/departure | https://github.com/redbooth/departure | lib/departure.rb | Ruby | mit | 86 | master | 2,454 | require 'active_record'
require 'active_support/all'
require 'departure/version'
require 'departure/log_sanitizers/password_sanitizer'
require 'departure/runner'
require 'departure/cli_generator'
require 'departure/logger'
require 'departure/null_logger'
require 'departure/logger_factory'
require 'departure/configurat... |
github | redbooth/departure | https://github.com/redbooth/departure | lib/lhm.rb | Ruby | mit | 86 | master | 785 | require 'lhm/adapter'
# Defines the same global namespace as LHM's gem does to mimic its API
# while providing a different behaviour. We delegate all LHM's methods to
# ActiveRecord so that you don't need to modify your old LHM migrations
module Lhm
# Yields an adapter instance so that Lhm migration Dsl methods get
... |
github | redbooth/departure | https://github.com/redbooth/departure | lib/departure/errors.rb | Ruby | mit | 86 | master | 957 | module Departure
class Error < StandardError; end
# Used when for whatever reason we couldn't get the spawned process'
# status.
class NoStatusError < Error
def message
'Status could not be retrieved'.freeze
end
end
# Used when the spawned process failed by receiving a signal.
# pt-online-... |
github | redbooth/departure | https://github.com/redbooth/departure | lib/departure/null_logger.rb | Ruby | mit | 86 | master | 204 | module Departure
class NullLogger
def say(_message, _subitem = false)
# noop
end
def write(_text)
# noop
end
def write_no_newline(_text)
# noop
end
end
end |
github | redbooth/departure | https://github.com/redbooth/departure | lib/departure/cli_generator.rb | Ruby | mit | 86 | master | 2,986 | require 'departure/dsn'
require 'departure/option'
require 'departure/alter_argument'
require 'departure/connection_details'
require 'departure/user_options'
module Departure
# Generates the equivalent Percona's pt-online-schema-change command to the
# given SQL statement
#
# --no-check-alter is used to allow ... |
github | redbooth/departure | https://github.com/redbooth/departure | lib/departure/alter_argument.rb | Ruby | mit | 86 | master | 1,165 | module Departure
class InvalidAlterStatement < StandardError; end
# Represents the '--alter' argument of Percona's pt-online-schema-change
# See https://www.percona.com/doc/percona-toolkit/2.0/pt-online-schema-change.html
class AlterArgument
ALTER_TABLE_REGEX = /\AALTER TABLE `(\w+)` /
attr_reader :ta... |
github | redbooth/departure | https://github.com/redbooth/departure | lib/departure/runner.rb | Ruby | mit | 86 | master | 1,741 | require 'open3'
module Departure
# It executes pt-online-schema-change commands in a new process and gets its
# output and status
class Runner
# Constructor
#
# @param logger [#say, #write]
# @param cli_generator [CliGenerator]
# @param mysql_adapter [ActiveRecord::ConnectionAdapter] it must ... |
github | redbooth/departure | https://github.com/redbooth/departure | lib/departure/railtie.rb | Ruby | mit | 86 | master | 895 | require 'departure'
require 'lhm' # It's our own Lhm adapter, not the gem
require 'rails'
module Departure
class Railtie < Rails::Railtie
railtie_name :departure
# It drops all previous database connections and reconnects using this
# PerconaAdapter. By doing this, all later ActiveRecord methods called ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.