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 | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/argument/block.rb | Ruby | mit | 234 | master | 623 | # frozen_string_literal: true
module RuboCop
module GraphQL
class Argument
class Block
extend RuboCop::NodePattern::Macros
include DescriptionMethod
# @!method argument_block(node)
def_node_matcher :argument_block, <<~PATTERN
(block
(send nil? :argumen... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/field/block.rb | Ruby | mit | 234 | master | 602 | # frozen_string_literal: true
module RuboCop
module GraphQL
class Field
class Block
extend RuboCop::NodePattern::Macros
include DescriptionMethod
# @!method field_block(node)
def_node_matcher :field_block, <<~PATTERN
(block
(send nil? :field ...)
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/field/kwargs.rb | Ruby | mit | 234 | master | 2,281 | # frozen_string_literal: true
module RuboCop
module GraphQL
class Field
class Kwargs
extend RuboCop::NodePattern::Macros
# @!method field_kwargs(node)
def_node_matcher :field_kwargs, <<~PATTERN
(send nil? :field
...
(hash
$...
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/ext/snake_case.rb | Ruby | mit | 234 | master | 279 | # frozen_string_literal: true
module RuboCop
module GraphQL
module Ext
module SnakeCase
SNAKE_CASE = /^[\da-z_]+[!?=]?$/
refine Symbol do
def snake_case?
match?(SNAKE_CASE)
end
end
end
end
end
end |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql_cops.rb | Ruby | mit | 234 | master | 1,263 | # frozen_string_literal: true
require_relative "graphql/argument_description"
require_relative "graphql/argument_name"
require_relative "graphql/argument_uniqueness"
require_relative "graphql/context_write_in_type"
require_relative "graphql/extract_input_type"
require_relative "graphql/extract_type"
require_relative "... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/ordered_arguments.rb | Ruby | mit | 234 | master | 3,438 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# Arguments should be alphabetically sorted within groups.
#
# @example
# # good
#
# class UpdateProfile < BaseMutation
# argument :email, String, required: false
# argument :name, S... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/object_description.rb | Ruby | mit | 234 | master | 1,612 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# This cop checks if a type (object, input, interface, scalar, union,
# mutation, subscription, and resolver) has a description.
#
# @example
# # good
#
# class Types::UserType < Types::BaseObje... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/field_definitions.rb | Ruby | mit | 234 | master | 8,666 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# Checks consistency of field definitions
#
# EnforcedStyle supports two modes:
#
# `group_definitions` : all field definitions should be grouped together.
#
# `define_resolver_after_definition` : if ... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/extract_input_type.rb | Ruby | mit | 234 | master | 1,294 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
class ExtractInputType < Base
# Checks fields on common prefix groups
#
# # @example
# # good
#
# class UpdateUser < BaseMutation
# argument :uuid, ID, required: true
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/unnecessary_field_alias.rb | Ruby | mit | 234 | master | 2,156 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# This cop prevents defining an unnecessary alias, method, or resolver_method.
#
# @example
# # good
#
# field :name, String, "Name of the user", null: true, alias: :real_name
# field :name, St... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/not_authorized_node_type.rb | Ruby | mit | 234 | master | 3,943 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# Detects types that implement Node interface and not have `.authorized?` check.
# Such types can be fetched by ID and therefore should have type level check to
# avoid accidental information exposure.
#
# If `.a... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/ordered_fields.rb | Ruby | mit | 234 | master | 2,609 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# Fields should be alphabetically sorted within groups.
#
# @example
# # good
#
# class UserType < BaseType
# field :name, String, null: true
# field :phone, String, null: true do
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/argument_uniqueness.rb | Ruby | mit | 234 | master | 3,103 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# This cop detects duplicate argument definitions
#
# @example
# # good
#
# class BanUser < BaseMutation
# argument :user_id, ID, required: true
# end
#
# # bad
#
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/extract_type.rb | Ruby | mit | 234 | master | 2,819 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
class ExtractType < Base
# Checks fields on common prefix groups
#
# # @example
# # good
#
# class Types::UserType < Types::BaseObject
# field :registered_at, String, null:... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/field_uniqueness.rb | Ruby | mit | 234 | master | 2,279 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# Detects duplicate field definitions within
# the same type
#
# @example
# # good
#
# class UserType < BaseType
# field :name, String, null: true
# field :phone, String, null:... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/max_complexity_schema.rb | Ruby | mit | 234 | master | 729 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# Detects missing max_complexity configuration in schema files
#
# @example
# # good
#
# class AppSchema < BaseSchema
# max_complexity 42
# end
#
class MaxComplexitySchema ... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/context_write_in_type.rb | Ruby | mit | 234 | master | 1,652 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# Detects writes to the `context` object within GraphQL types.
# Writing to `context` mutates shared state across the query execution,
# which can lead to unexpected behavior and makes code harder to reason about.
#
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/max_depth_schema.rb | Ruby | mit | 234 | master | 689 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# Detects missing max_depth configuration in schema files
#
# @example
# # good
#
# class AppSchema < BaseSchema
# max_depth 42
# end
#
class MaxDepthSchema < Base
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/argument_description.rb | Ruby | mit | 234 | master | 867 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# This cop checks if each field has a description.
#
# @example
# # good
#
# class BanUser < BaseMutation
# argument :uuid, ID, required: true, description: "UUID of the user to ban"
# ... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/field_hash_key.rb | Ruby | mit | 234 | master | 2,628 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# This cop prevents defining unnecessary resolver methods in cases
# when :hash_key option can be used
#
# @example
# # good
#
# class Types::UserType < Types::BaseObject
# field :phon... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/field_name.rb | Ruby | mit | 234 | master | 1,360 | # frozen_string_literal: true
require_relative "../../../refinements/underscore_string"
using UnderscoreString unless String.method_defined?(:underscore)
module RuboCop
module Cop
module GraphQL
# This cop checks whether field names are snake_case.
#
# @example
# # good
#
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/field_method.rb | Ruby | mit | 234 | master | 2,547 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# This cop prevents defining unnecessary resolver methods in cases
# when :method option can be used
#
# @example
# # good
#
# class Types::UserType < Types::BaseObject
# field :phone,... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/unnecessary_field_camelize.rb | Ruby | mit | 234 | master | 927 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# This cop checks if each field has an unnecessary camelize.
#
# @example
# # good
#
# class UserType < BaseType
# field :name, String, "Name of the user", null: true
# end
#
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/legacy_dsl.rb | Ruby | mit | 234 | master | 988 | # frozen_string_literal: true
module RuboCop
module Cop
# This cop checks whether type definitions are class-based or legacy.
#
# @example
# # good
#
# class Example < BaseType
# ....
# end
#
# # bad
#
# Example = GraphQL::ObjectType.define do
# .... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/argument_name.rb | Ruby | mit | 234 | master | 899 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# This cop checks whether field names are snake_case.
#
# @example
# # good
#
# class BanUser < BaseMutation
# argument :user_id, ID, required: true
# end
#
# # bad
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/field_description.rb | Ruby | mit | 234 | master | 825 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# This cop checks if each field has a description.
#
# @example
# # good
#
# class UserType < BaseType
# field :name, String, "Name of the user", null: true
# end
#
# # ... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/multiple_field_definitions.rb | Ruby | mit | 234 | master | 3,293 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# Checks whether fields with multiple definitions are grouped together.
# @example
# # good
#
# class UserType < BaseType
# field :first_name, String, null: true
# field :first_name, Name,... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/unused_argument.rb | Ruby | mit | 234 | master | 6,226 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# Arguments should either be listed explicitly or **rest should be in the resolve signature
# (and similar methods, such as #authorized?).
#
# @example
# # good
#
# class SomeResolver < Resolvers:... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/unnecessary_argument_camelize.rb | Ruby | mit | 234 | master | 1,567 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# This cop checks if each argument has an unnecessary camelize.
#
# @example
# # good
#
# class UserType < BaseType
# field :name, String, "Name of the user", null: true do
# argu... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/prepare_method.rb | Ruby | mit | 234 | master | 3,622 | # frozen_string_literal: true
require "rubocop"
module RuboCop
module Cop
module GraphQL
# Checks that GraphQL Argument definitions prepare arguments use String or constants
# instead of `prepare: CONST_REF`
# This allows better Sorbet typing.
#
# Preference is given to an input ob... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/graphql_name.rb | Ruby | mit | 234 | master | 1,905 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# Checks consistency of graphql_name usage
#
# EnforcedStyle supports two modes:
#
# `only_override` : types and mutations should have graphql_name configured only if it's
# different from the default name... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/cop/graphql/resolver_method_length.rb | Ruby | mit | 234 | master | 1,439 | # frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# Checks if the length of a resolver method exceeds some maximum value.
# Comment lines can optionally be ignored.
#
# The maximum allowed length is configurable using the Max option.
class ResolverMethodLength <... |
github | vidarh/rubywm | https://github.com/vidarh/rubywm | desktop.rb | Ruby | mit | 234 | master | 525 | class Desktop
attr_accessor :name, :id, :wm, :layout, :window
def initialize(wm, id, name) = (@wm, @id, @name = wm, id, name)
def active? = (@wm.current_desktop_id == self.id)
def children = @wm.windows.values.find_all{_1.desktop==self}
def mapped_regular_children = children.find_all{_1.mapped && !_1.specia... |
github | vidarh/rubywm | https://github.com/vidarh/rubywm | wm.rb | Ruby | mit | 234 | master | 13,601 | require_relative 'floating'
class WindowManager
attr_reader :dpy, :desktops, :windows, :focus
def inspect = "<WindowManager>"
def initialize dpy, config
@dpy = dpy
@windows = {}
@border_normal = 0x88666666
@border_focus = 0xffff66ff
@floating = FloatingLayout.new(rootgeom)
process_c... |
github | vidarh/rubywm | https://github.com/vidarh/rubywm | tiled.rb | Ruby | mit | 234 | master | 1,143 | GAP = 64
require_relative 'geom.rb'
require_relative 'leaf.rb'
require_relative 'node.rb'
require_relative 'layout'
class TiledLayout < Layout
attr_reader :root
def initialize(desktop, geom)
@desktop = desktop
@geom = geom.dup
# FIXME: This is to account for a bar, but we shouldn't just assume
... |
github | vidarh/rubywm | https://github.com/vidarh/rubywm | leaf.rb | Ruby | mit | 234 | master | 964 | class Leaf
attr_accessor :window, :parent
attr_accessor :iclass
def inspect = "<Leaf @window=#{@window.inspect}, @iclass=#{@iclass} @parent=#{@parent.object_id}>"
def initialize(window=nil, parent: nil, iclass: nil)
@window, @parent, @iclass = window, parent, iclass
end
def children = @window
def... |
github | vidarh/rubywm | https://github.com/vidarh/rubywm | type_dispatcher.rb | Ruby | mit | 234 | master | 829 | # # Dispatcher
#
# Dispatch `call(method, *args)` to `@target.on_<name>(*args)` or `@on[method].call(*args)`
# where <name> is a cleaned up string representation of method, so that:
#
# dispatch.(X11::Form::MotionNotify, arg1, arg2)
#
# Becomes:
#
# @target.on_motion_notify(arg1, arg2)
#
class Dispatcher
def init... |
github | vidarh/rubywm | https://github.com/vidarh/rubywm | rubywm.rb | Ruby | mit | 234 | master | 1,335 | # (C) 2024 Vidar Hokstad <vidar@hokstad.com>
# Licensed under the MIT license.
#
# Based on TinyWM by Nick Welch
# Lots of inspiration from Katriawm
# https://www.uninformativ.de/git/katriawm/files.html
#
require 'bundler/setup'
require 'X11'
require 'set'
require 'yaml'
require_relative 'window.rb'
require_relative ... |
github | vidarh/rubywm | https://github.com/vidarh/rubywm | geom.rb | Ruby | mit | 234 | master | 1,808 | module X11
module Form
class Geometry
def inspect = "<Geometry x=#{x.to_i} y=#{y.to_i} width=#{width.to_i} height=#{height.to_i}>"
end
end
end
def gap(geom,g)
geom = geom.dup
geom.x += g
geom.width -= g*2
geom.y += g
geom.height -= g*2
geom
end
def split_geom(geom, dir, node, gap, rati... |
github | vidarh/rubywm | https://github.com/vidarh/rubywm | node.rb | Ruby | mit | 234 | master | 2,206 | class Node
attr_accessor :ratio, :nodes, :dir, :parent
attr_reader :geom
def inspect = "<Node #{object_id} @nodes=#{@nodes.inspect}, @dir=#{@dir.inspect} @ratio=#{@ratio.inspect} @parent=#{@parent.object_id}>"
def initialize(nodes=[], parent: nil, dir: nil)
@nodes = Array(nodes.dup)
@nodes.each{... |
github | vidarh/rubywm | https://github.com/vidarh/rubywm | floating.rb | Ruby | mit | 234 | master | 671 | #
# Apart from the very limited "place" the main purpose of this
# class is to ensure there *always* is a layout
require_relative 'layout'
class FloatingLayout < Layout
def initialize(rootgeom)
@rootgeom = rootgeom
end
def find(w) = nil
def place(w, focus)
attr = w.get_geometry
return if at... |
github | vidarh/rubywm | https://github.com/vidarh/rubywm | window.rb | Ruby | mit | 234 | master | 4,197 | # FIXME: 10000 pixels should be enough for anyone ...
# Until it isn't.
HIDDEN_OFFSET=10000
# FIXME: Extract this from the real root width
MAX_WIDTH=1920
class Window < X11::Window
attr_reader :desktop, :hidden, :mapped
attr_writer :floating
def eql?(other) = (wid == other&.wid)
def ==(other) = eql?(other)
... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | Gemfile | Ruby | mit | 234 | main | 2,996 | source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby File.read('.ruby-version')
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem 'rails', '~> 7.0.8'
# Use postgresql as the database for Active Record
gem 'pg'
# Use the Puma web server ... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | app/serializers/user_serializer.rb | Ruby | mit | 234 | main | 904 | # frozen_string_literal: true
# == Schema Information
#
# Table name: users
#
# id :bigint not null, primary key
# email :string default(""), not null
# encrypted_password :string default(""), not null
# reset_password_token :string
# reset_... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | app/controllers/registrations_controller.rb | Ruby | mit | 234 | main | 425 | # frozen_string_literal: true
class RegistrationsController < Devise::RegistrationsController
private
def respond_with(resource, _opts = {})
register_success(resource) && return if resource.persisted?
register_failed(resource)
end
def register_success(resource)
render jsonapi: resource
end
... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | app/controllers/application_controller.rb | Ruby | mit | 234 | main | 360 | class ApplicationController < ActionController::Base
skip_before_action :verify_authenticity_token
include Pagy::Backend
after_action { pagy_headers_merge(@pagy) if @pagy }
def website
render template: 'layouts/website'
end
def panel
return redirect_to website_path unless user_signed_in?
ren... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | app/controllers/sessions_controller.rb | Ruby | mit | 234 | main | 232 | # frozen_string_literal: true
class SessionsController < Devise::SessionsController
private
def respond_with(resource, _opts = {})
render jsonapi: resource
end
def respond_to_on_destroy
head :no_content
end
end |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | app/models/allowlisted_jwt.rb | Ruby | mit | 234 | main | 531 | # frozen_string_literal: true
# == Schema Information
#
# Table name: allowlisted_jwts
#
# id :bigint not null, primary key
# jti :string not null
# aud :string
# exp :datetime not null
# user_id :bigint not null
# created_at :datetime ... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | app/models/user.rb | Ruby | mit | 234 | main | 1,051 | # frozen_string_literal: true
# == Schema Information
#
# Table name: users
#
# id :bigint not null, primary key
# email :string default(""), not null
# encrypted_password :string default(""), not null
# reset_password_token :string
# reset_... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | config/puma.rb | Ruby | mit | 234 | main | 2,498 | # frozen_string_literal: true
# Specify the bind host and environment.
bind "tcp://0.0.0.0:#{ENV.fetch('PORT', '3000')}"
environment ENV.fetch('RAILS_ENV', 'development')
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# ... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | config/application.rb | Ruby | mit | 234 | main | 2,158 | require_relative 'boot'
require 'rails/all'
require 'sidekiq/web'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module BaseApp
class Application < Rails::Application
# Initialize configuration defaults for origin... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | config/routes.rb | Ruby | mit | 234 | main | 703 | Rails.application.routes.draw do
mount Sidekiq::Web => '/sidekiq'
root to: 'application#website'
devise_for :users, defaults: { format: :json }, skip: :all
devise_scope :user do
# If you change these urls and helpers, you must change these files too:
# - config/initializers/devise.rb#JWT Devise
# -... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | config/environments/development.rb | Ruby | mit | 234 | main | 2,627 | require 'active_support/core_ext/integer/time'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for developme... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | config/environments/production.rb | Ruby | mit | 234 | main | 3,860 | 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.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your applica... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | config/initializers/content_security_policy.rb | Ruby | mit | 234 | main | 2,134 | # Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
# Rails.application.configure do
# config.content_security_po... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | config/initializers/devise.rb | Ruby | mit | 234 | main | 15,456 | # frozen_string_literal: true
# Assuming you have not yet modified this file, each configuration option below
# is set to its default value. Note that some are commented out while others
# are not: uncommented lines are intended to protect your configuration from
# breaking changes in upgrades (i.e., in the event that... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | config/initializers/cors.rb | Ruby | mit | 234 | main | 286 | # frozen_string_literal: true
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
resource '*',
headers: :any,
expose: ['Authorization'],
methods: %i[get post put patch delete options head]
end
end |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | lib/tasks/auto_annotate_models.rake | Ruby | mit | 234 | main | 1,345 | # NOTE: only doing this in development as some production environments (Heroku)
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
# NOTE: to have a dev-mode tool do its thing in production.
if Rails.env.development?
task :set_annotation_options do
# You can override any of these by set... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | db/schema.rb | Ruby | mit | 234 | main | 2,033 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rai... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | db/migrate/20220417152356_create_allowlisted_jwts.rb | Ruby | mit | 234 | main | 400 | # frozen_string_literal: true
class CreateAllowlistedJwts < ActiveRecord::Migration[7.0]
def change
create_table :allowlisted_jwts do |t|
t.string :jti, null: false
t.string :aud
t.datetime :exp, null: false
t.references :user, foreign_key: { on_delete: :cascade }, null: false
t.ti... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | db/migrate/20220417135124_devise_create_users.rb | Ruby | mit | 234 | main | 1,392 | # frozen_string_literal: true
class DeviseCreateUsers < ActiveRecord::Migration[7.0]
def change
create_table :users do |t|
## Database authenticatable
t.string :email, null: false, default: ''
t.string :encrypted_password, null: false, default: ''
## Recoverable
t.stri... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | spec/spec_helper.rb | Ruby | mit | 234 | main | 5,088 | # frozen_string_literal: true
# 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, withou... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | spec/rails_helper.rb | Ruby | mit | 234 | main | 2,901 | # frozen_string_literal: true
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)
# Prevent database truncation if the environment is production
abort('The Rails environment is running in... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | spec/support/database_cleaner.rb | Ruby | mit | 234 | main | 481 | # frozen_string_literal: true
require 'database_cleaner/active_record'
RSpec.configure do |config|
# start by truncating all the tables but then use the faster transaction strategy the rest of the time.
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
DatabaseCleaner.strategy = :transactio... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | spec/support/authentication_helper.rb | Ruby | mit | 234 | main | 481 | # frozen_string_literal: true
module AuthenticationHelper
def login(user)
post user_session_path, params: {
user: {
email: user.email,
password: user.password
}
}
@loggedin_user_token = response.headers['Authorization']
end
def loggedin_user_token
@loggedin_user_toke... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | spec/controllers/registrations_controller_spec.rb | Ruby | mit | 234 | main | 1,686 | # frozen_string_literal: true
require 'rails_helper'
describe RegistrationsController, type: :request do
let(:signup_url) { '/users/signup' }
let!(:existing_user) { create(:user) }
let(:email) { Faker::Internet.email }
let(:password) { Faker::Internet.password(min_length: 10, max_length: 20, special_characte... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | spec/controllers/sessions_controller_spec.rb | Ruby | mit | 234 | main | 1,457 | # frozen_string_literal: true
require 'rails_helper'
describe SessionsController, type: :request do
let(:user) { create(:user) }
let(:login_url) { '/users/login' }
let(:logout_url) { '/users/logout' }
context 'when logging in' do
before do
login(user)
end
it 'returns a token' do
expe... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | spec/controllers/application_controller_spec.rb | Ruby | mit | 234 | main | 889 | # frozen_string_literal: true
require 'rails_helper'
describe ApplicationController, type: :request do
shared_examples 'visiting website url' do
context 'when visiting website url' do
it 'stays at website' do
get '/'
expect(response.request.fullpath).to eq('/')
end
end
end
... |
github | zakariaf/rails-base-app | https://github.com/zakariaf/rails-base-app | spec/factories/users.rb | Ruby | mit | 234 | main | 1,010 | # frozen_string_literal: true
# == Schema Information
#
# Table name: users
#
# id :bigint not null, primary key
# email :string default(""), not null
# encrypted_password :string default(""), not null
# reset_password_token :string
# reset_... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | chroma.gemspec | Ruby | isc | 234 | master | 977 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'chroma/version'
Gem::Specification.new do |spec|
spec.name = 'chroma'
spec.version = Chroma::VERSION
spec.authors = ['Jeremy Fairbank']
spec.email = ['elpapap... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma.rb | Ruby | isc | 234 | master | 3,953 | # General
require 'chroma/version'
require 'chroma/errors'
require 'yaml'
# Modules
require 'chroma/helpers/bounders'
# Color
require 'chroma/color/attributes'
require 'chroma/color/serializers'
require 'chroma/color/modifiers'
require 'chroma/color'
require 'chroma/color_modes'
# Palettes
require 'chroma/harmonies'... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/color.rb | Ruby | isc | 234 | master | 2,730 | module Chroma
# The main class to represent colors.
class Color
include Attributes
include Serializers
include Modifiers
include Helpers::Bounders
# @param input [String, ColorModes::Rgb, ColorModes::Hsl, ColorModes::Hsv]
# @param format [Symbol] the color mode format
def initialize(in... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/color_modes.rb | Ruby | isc | 234 | master | 1,441 | module Chroma
module ColorModes
class << self
private
# Builds a new color mode class.
#
# @param name [String] the class name
# @param attrs [Array<Symbol>] the instance attribute names
# @!macro [attach] build
# @!parse class $1
# attr_accessor :$2,... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/rgb_generator.rb | Ruby | isc | 234 | master | 1,003 | module Chroma
# Main module to generate an instance of {ColorModes::Rgb} from several
# possible inputs.
module RgbGenerator
class << self
# Generates an instance of {ColorModes::Rgb} as well as color format
# symbol.
#
# @param input [String, ColorModes::Rgb, ColorModes::Hsl, ColorM... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/harmonies.rb | Ruby | isc | 234 | master | 5,141 | module Chroma
# Class to hold all palette methods.
class Harmonies
# @param color [Color]
def initialize(color)
@color = color
end
# Generate a complement palette.
#
# @example
# 'red'.paint.palette.complement #=> [red, cyan]
# 'red'.paint.palette.complement(as:... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/palette_builder.rb | Ruby | isc | 234 | master | 2,038 | module Chroma
# Class internally used to build custom palettes from {Chroma.define_palette}.
class PaletteBuilder
# Wrapper to instantiate a new instance of {PaletteBuilder} and call its
# {PaletteBuilder#build} method.
#
# @param block [Proc] the palette definition blo... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/helpers/bounders.rb | Ruby | isc | 234 | master | 1,160 | module Chroma
module Helpers
module Bounders
# Bounds a value `n` that is from `0` to `max` to `0` to `1`.
#
# @param n [Numeric, String]
# @param max [Fixnum]
# @return [Float]
def bound01(n, max)
is_percent = n.to_s.include? '%'
n = [max, [0, n.to_f].max]... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/rgb_generator/from_rgb.rb | Ruby | isc | 234 | master | 430 | module Chroma
module RgbGenerator
class FromRgb < Base
# @param format [Symbol] color format
# @param rgb [ColorModes::Rgb]
def initialize(format, rgb)
@format = format
@rgb = rgb
end
# Generates a {ColorModes::Rgb}.
# @return [ColorModes::Rgb]
def gen... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/rgb_generator/from_hsl_values.rb | Ruby | isc | 234 | master | 712 | module Chroma
module RgbGenerator
class FromHslValues < Base
# @param format [Symbol] color format
# @param h [String, Numeric] hue value
# @param s [String, Numeric] saturation value
# @param l [String, Numeric] lightness value
# @param a [String, Numeri... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/rgb_generator/from_hsl.rb | Ruby | isc | 234 | master | 410 | module Chroma
module RgbGenerator
class FromHsl < Base
# @param format [Symbol] color format
# @param hsl [ColorModes::Hsl]
def initialize(format, hsl)
@format = format
@hsl = hsl
end
# Generates a {ColorModes::Rgb}.
# @return [ColorModes::Rgb]
def gen... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/rgb_generator/from_rgb_values.rb | Ruby | isc | 234 | master | 714 | module Chroma
module RgbGenerator
class FromRgbValues < Base
# @param format [Symbol] color format
# @param r [String, Numeric] red value
# @param g [String, Numeric] green value
# @param b [String, Numeric] blue value
# @param a [String, Numeric] alpha v... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/rgb_generator/from_hex_string_values.rb | Ruby | isc | 234 | master | 1,913 | module Chroma
module RgbGenerator
class FromHexStringValues < Base
# @param format [Symbol] color format
# @param r [String] red value
# @param g [String] green value
# @param b [String] blue value
# @param a [String] alpha value
def initialize(format, r, g,... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/rgb_generator/from_hsv.rb | Ruby | isc | 234 | master | 410 | module Chroma
module RgbGenerator
class FromHsv < Base
# @param format [Symbol] color format
# @param hsv [ColorModes::Hsv]
def initialize(format, hsv)
@format = format
@hsv = hsv
end
# Generates a {ColorModes::Rgb}.
# @return [ColorModes::Rgb]
def gen... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/rgb_generator/from_hsv_values.rb | Ruby | isc | 234 | master | 708 | module Chroma
module RgbGenerator
class FromHsvValues < Base
# @param format [Symbol] color format
# @param h [String, Numeric] hue value
# @param s [String, Numeric] saturation value
# @param v [String, Numeric] value value
# @param a [String, Numeric] a... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/rgb_generator/from_string.rb | Ruby | isc | 234 | master | 3,107 | module Chroma
module RgbGenerator
class FromString < Base
# Returns the regex matchers and rgb generation classes for various
# string color formats.
#
# @api private
# @return [Hash<Symbol, Hash>]
def self.matchers
@matchers ||= begin
# TinyColor.js matchers
... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/converters/hsv_converter.rb | Ruby | isc | 234 | master | 1,128 | module Chroma
module Converters
# Class to convert a color mode to {ColorModes::Hsl}.
class HsvConverter < Base
# Convert rgb to hsv.
# @return [ColorModes::Hsv]
def convert_rgb
r = bound01(@input.r, 255)
g = bound01(@input.g, 255)
b = bound01(@input.b, 255)
... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/converters/rgb_converter.rb | Ruby | isc | 234 | master | 1,688 | module Chroma
module Converters
# Class to convert a color mode to {ColorModes::Rgb}.
class RgbConverter < Base
# Returns @input because it's the same color mode.
# @return [ColorModes::Rgb]
def convert_rgb
@input
end
# Convert hsl to rgb.
# @return [ColorModes::Rg... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/converters/base.rb | Ruby | isc | 234 | master | 863 | module Chroma
module Converters
# Base class for converting one color mode to another.
# @abstract
class Base
include Helpers::Bounders
# @param input [ColorModes::Rgb, ColorModes::Hsl, ColorModes::Hsv]
# @return [Base]
def initialize(input)
@input = input
end
... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/converters/hsl_converter.rb | Ruby | isc | 234 | master | 1,244 | module Chroma
module Converters
# Class to convert a color mode to {ColorModes::Hsl}.
class HslConverter < Base
# Convert rgb to hsl.
# @return [ColorModes::Hsl]
def convert_rgb
r = bound01(@input.r, 255)
g = bound01(@input.g, 255)
b = bound01(@input.b, 255)
... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/color/modifiers.rb | Ruby | isc | 234 | master | 3,315 | module Chroma
class Color
# Methods that return a new modified {Color}.
module Modifiers
# Lightens the color by the given `amount`.
#
# @example
# 'red'.paint.lighten #=> #ff3333
# 'red'.paint.lighten(20) #=> #ff6666
#
# @param amount [Fixnum]
# @return... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/color/attributes.rb | Ruby | isc | 234 | master | 1,226 | module Chroma
class Color
# Attribute methods for {Color}.
module Attributes
attr_reader :format
# Determines if the color is dark.
#
# @example
# 'red'.paint.dark? #=> true
# 'yellow'.paint.dark? #=> false
#
# @return [true, false]
def dark?
... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/color/serializers.rb | Ruby | isc | 234 | master | 5,124 | module Chroma
class Color
# Methods for serializing {Color} to different color mode string formats.
module Serializers
# Convert to hsv string.
#
# @example
# 'red'.paint.to_hsv #=> 'hsv(0, 100%, 100%)'
# 'rgba(255, 0, 0, 0.5)'.paint.to_hsv #=> 'hsva(0, 100%,... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | lib/chroma/extensions/string.rb | Ruby | isc | 234 | master | 333 | class String
# Creates {Chroma::Color} directly from a string representing a color.
#
# @example
# 'red'.paint
# '#f00'.paint
# '#ff0000'.paint
# 'rgb(255, 0, 0)'.paint
# 'hsl(0, 100%, 50%)'.paint
# 'hsv(0, 100%, 100%)'.paint
#
# @return [Chroma::Color]
def paint
Chroma.paint(sel... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | spec/spec_helper.rb | Ruby | isc | 234 | master | 4,279 | require 'chroma'
# This file was generated by the `rspec --init` 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 requir... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | spec/custom_matchers.rb | Ruby | isc | 234 | master | 391 | RSpec::Matchers.define :generate_palette do |expected|
expected.map!(&:paint)
match do |actual|
actual == expected
end
end
RSpec::Matchers.define :have_format do |expected|
match do |actual|
actual.format == expected
end
end
RSpec::Matchers.define :be_dark do
match { |value| value.dark? }
end
RS... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | spec/chroma_spec.rb | Ruby | isc | 234 | master | 716 | describe Chroma do
describe '.hex_from_name' do
it 'returns the hex representation for a color name' do
Chroma.send(:named_colors_map).each do |name, hex|
expect(Chroma.hex_from_name(name)).to eq hex
end
end
it 'returns nil for unknown colors names' do
expect(Chroma.hex_from_nam... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | spec/color_spec.rb | Ruby | isc | 234 | master | 666 | require 'spec_helper'
describe Chroma::Color do
let(:red) { 'red'.paint }
let(:other_red) { '#f00'.paint }
let(:blue) { 'blue'.paint }
context 'with equality' do
it 'equals itself' do
expect(red).to eql(red)
expect(red).to eq(red)
end
it 'equals another instance of the same... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | spec/color/serializers_spec.rb | Ruby | isc | 234 | master | 4,651 | describe Chroma::Color do
context 'with serializers' do
let(:green) { 'green'.paint }
let(:blue) { 'rgba(0, 0, 255, 0.5)'.paint }
let(:transparent) { 'rgba(0, 0, 0, 0)'.paint }
describe '#to_hsv' do
it 'returns the hsv string' do
expect(green.to_hsv).to eq('hsv(120, 100%, 5... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | spec/color/attributes_spec.rb | Ruby | isc | 234 | master | 1,348 | describe Chroma::Color do
let(:red) { 'red'.paint }
let(:black) { 'black'.paint }
let(:white) { 'white'.paint }
let(:yellow) { 'yellow'.paint }
describe '#dark?' do
it 'returns true for dark colors' do
expect(red).to be_dark
expect(black).to be_dark
end
it 'returns false for l... |
github | jfairbank/chroma | https://github.com/jfairbank/chroma | spec/color/modifiers_spec.rb | Ruby | isc | 234 | master | 2,451 | describe Chroma::Color do
let(:red) { 'red'.paint }
let(:yellow) { 'yellow'.paint }
describe '#lighten' do
context 'with default amount' do
it 'generates the correct color' do
expect(red.lighten).to eq '#ff3333'.paint
end
end
context 'with supplied amount' do
it 'generat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.