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 | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | app/mailers/staff/proposal_mailer.rb | Ruby | mit | 234 | main | 1,881 | class Staff::ProposalMailer < ApplicationMailer
include FinalizationMessages
attr_accessor :test_mode
def send_email(proposal)
if proposal.accepted?
accept_email(proposal.event, proposal)
elsif proposal.rejected?
reject_email(proposal.event, proposal)
elsif proposal.waitlisted?
wai... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/application.rb | Ruby | mit | 234 | main | 1,739 | require_relative "boot"
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/engine'
# require 'action_text/engine'
require '... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/ci.rb | Ruby | mit | 234 | main | 657 | # Run using bin/ci
CI.run do
step "Setup", "bin/setup --skip-server"
step "Security: Importmap vulnerability audit", "bin/importmap audit"
step "Tests: Rails", "bin/rails test"
step "Tests: System", "bin/rails test:system"
step "Tests: Seeds", "env RAILS_ENV=test bin/rails db:seed:replant"
# Optional: s... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/routes.rb | Ruby | mit | 234 | main | 4,691 | Rails.application.routes.draw do
resources :passwords, param: :token
# OmniAuth
get '/users/auth/:provider/callback', to: 'users/omniauth_callbacks#callback', as: :omniauth_callback
post '/users/auth/:provider', to: 'users/omniauth_callbacks#passthru', as: :omniauth_authorize
get '/users/auth/failure', to: ... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/environments/development.rb | Ruby | mit | 234 | main | 2,937 | # frozen_string_literal: true
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 lo... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/environments/test.rb | Ruby | mit | 234 | main | 2,460 | # frozen_string_literal: true
# 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.applic... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/environments/production.rb | Ruby | mit | 234 | main | 4,342 | # frozen_string_literal: true
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 perfor... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/initializers/time_formats.rb | Ruby | mit | 234 | main | 341 | Time::DATE_FORMATS[:month_day_year] = "%b %d, %Y"
Time::DATE_FORMATS[:long_with_zone] = "%b %-d, %Y at %I:%M%P %Z"
Time::DATE_FORMATS[:day_at_time] = "%-d %b @ %H:%M"
Time::DATE_FORMATS[:month_day] = "%b %d"
Time::DATE_FORMATS[:db_just_date] = "%Y-%m-%d"
Time::DATE_FORMATS[:event_day] = "%A, %b %d"
Time::DATE_FORMATS[:... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/initializers/simple_form_bootstrap.rb | Ruby | mit | 234 | main | 4,095 | # Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
config.button_class = 'btn btn-default'
config.boolean_label_class = nil
config.wrappers :vertical_form, tag: 'div', class: 'form-group',
error_class: 'field_with_errors' do |b|
b.use :html5
b.use... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/initializers/devise.rb | Ruby | mit | 234 | main | 13,102 | # Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmat... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/initializers/filter_parameter_logging.rb | Ruby | mit | 234 | main | 382 | # Be sure to restart your server when you modify this file.
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
# Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for supported notations and behavio... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/initializers/omniauth.rb | Ruby | mit | 234 | main | 355 | Rails.application.config.middleware.use OmniAuth::Builder do
provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: 'user:email'
provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']
provider :developer unless Rails.env.production?
end
OmniAuth.config.path_prefix = '/users/auth'
OmniAuth.config... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/initializers/assets.rb | Ruby | mit | 234 | main | 542 | # Be sure to restart your server when you modify this file.
# Note: node_modules is NOT added to asset paths.
# JS is bundled by esbuild (jsbundling-rails) to app/assets/builds/
# CSS is bundled by postcss (cssbundling-rails) to app/assets/builds/
# Exclude rails-ujs from actionview since we use Turbo instead
# Exclu... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/initializers/fastly_service.rb | Ruby | mit | 234 | main | 319 | class FastlyService
include Singleton
attr_reader :service
def initialize
if ENV['FASTLY_API_KEY']
fastly = Fastly.new(api_key: ENV['FASTLY_API_KEY'])
@service = Fastly::Service.new({ id: ENV['FASTLY_SERVICE_ID'] }, fastly)
end
end
def self.service
self.instance.service
end
end |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/initializers/eager_load_routes.rb | Ruby | mit | 234 | main | 260 | require 'devise/version'
if Devise::VERSION < '5'
ActiveSupport.on_load :action_mailer do
Rails.application.reload_routes_unless_loaded
end
else
raise 'Perhaps this issue has been fixed upstream. Consider removing this monkey-patch for Devise.'
end |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/initializers/simple_form.rb | Ruby | mit | 234 | main | 6,704 | # Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a
# complete input. You can remove any component from the
# wrapper, change the order or even add your own to the
# stack. The options given below are used to... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/initializers/simple_form/popover_icon_component.rb | Ruby | mit | 234 | main | 2,352 | module SimpleForm
module Components
module PopoverIcons
def popover_icon(wrapper_options = nil)
return if popover_content.blank?
input_html_options[:rel] ||= 'popover'
input_html_options[:data] ||= {}
input_html_options[:data][:toggle] ||= 'popover'
input_html_option... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/initializers/simple_form/tooltip_component.rb | Ruby | mit | 234 | main | 856 | module SimpleForm
module Components
module Tooltips
def tooltip(wrapper_options = nil)
unless tooltip_text.nil?
input_html_options['data-bs-toggle'] ||= 'tooltip'
input_html_options['data-bs-placement'] ||= tooltip_position
input_html_options['data-bs-trigger'] ||= 'hov... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/routes/staff_website.rb | Ruby | mit | 234 | main | 409 | # Staff website management routes (beta feature)
# These routes are kept separate as the website feature is incomplete
resource :website, only: [:new, :create, :edit, :update] do
member do
post :purge
end
end
resources :pages do
member do
get :preview
post :show
patch :publish
patch :promote... |
github | rubycentral/cfp-app | https://github.com/rubycentral/cfp-app | config/routes/website.rb | Ruby | mit | 234 | main | 959 | # Website-related routes (beta feature)
# These routes are kept separate as the website feature is incomplete
unless ENV['DISABLE_WEBSITE']
constraints DomainConstraint.new do
get '/', to: 'pages#show'
get '/(:slug)/program', to: 'programs#show'
get '/(:slug)/schedule', to: 'schedule#show'
get '/(:sl... |
github | gevans/sidekiq-throttler | https://github.com/gevans/sidekiq-throttler | sidekiq-throttler.gemspec | Ruby | mit | 234 | master | 1,597 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'sidekiq/throttler/version'
Gem::Specification.new do |gem|
gem.name = 'sidekiq-throttler'
gem.version = Sidekiq::Throttler::VERSION
gem.authors = ['Gabe Evans... |
github | gevans/sidekiq-throttler | https://github.com/gevans/sidekiq-throttler | Rakefile | Ruby | mit | 234 | master | 428 | require 'bundler/gem_tasks'
require 'appraisal'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
task :default => :spec
require 'yard'
YARD::Rake::YardocTask.new
desc 'Start Pry with runtime dependencies loaded'
task :console, :script do |t... |
github | gevans/sidekiq-throttler | https://github.com/gevans/sidekiq-throttler | Guardfile | Ruby | mit | 234 | master | 356 | guard 'bundler' do
watch('Gemfile')
watch('sidekiq-throttler.gemspec')
end
guard 'rspec' do
watch(%r{^spec/app/.+_worker\.rb$}) { 'spec' }
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { 'spec' }
end
guard 'yard' do
watch(%r{app/... |
github | gevans/sidekiq-throttler | https://github.com/gevans/sidekiq-throttler | Appraisals | Ruby | mit | 234 | master | 239 | appraise 'sidekiq-head' do
gem 'sidekiq', github: 'mperham/sidekiq'
end
appraise 'sidekiq-4' do
gem 'sidekiq', '~> 4.0'
end
appraise 'sidekiq-3' do
gem 'sidekiq', '~> 3.0'
end
appraise 'sidekiq-2' do
gem 'sidekiq', '~> 2.0'
end |
github | gevans/sidekiq-throttler | https://github.com/gevans/sidekiq-throttler | spec/spec_helper.rb | Ruby | mit | 234 | master | 1,023 | $LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
WORKERS = File.join(File.dirname(__FILE__), 'app', 'workers')
$LOAD_PATH.unshift(WORKERS)
unless ENV['CI']
require 'simplecov'
SimpleCov.start do
add_filter '/spec/'
end
end
require 'rspec'
require... |
github | gevans/sidekiq-throttler | https://github.com/gevans/sidekiq-throttler | spec/sidekiq/throttler_spec.rb | Ruby | mit | 234 | master | 1,282 | require 'spec_helper'
describe Sidekiq::Throttler do
subject(:throttler) do
described_class.new(options)
end
let(:worker) do
LolzWorker.new
end
let(:options) do
{ storage: :memory }
end
let(:message) do
{
'args' => 'Clint Eastwood'
}
end
let(:queue) do
'default'
e... |
github | gevans/sidekiq-throttler | https://github.com/gevans/sidekiq-throttler | spec/sidekiq/throttler/rate_limit_spec.rb | Ruby | mit | 234 | master | 7,805 | require 'spec_helper'
shared_examples "incrementing" do
it 'increments #count by one' do
Timecop.freeze do
expect { rate_limit.increment }.to change{ rate_limit.count }.by(1)
end
end
context 'when #period has passed' do
it 'removes old increments' do
rate_limit.options['period'] = 5
... |
github | gevans/sidekiq-throttler | https://github.com/gevans/sidekiq-throttler | spec/app/workers/proc_worker.rb | Ruby | mit | 234 | master | 201 | class ProcWorker
include Sidekiq::Worker
sidekiq_options throttle: { threshold: 10, period: 1.minute, key: Proc.new { |*args| args.join(':') } }
def perform(*args)
puts args.first
end
end |
github | gevans/sidekiq-throttler | https://github.com/gevans/sidekiq-throttler | spec/app/workers/proc_threshold_worker.rb | Ruby | mit | 234 | master | 222 | class ProcThresholdWorker
include Sidekiq::Worker
sidekiq_options throttle: { threshold: Proc.new { |user_id, limit| limit }, period: 1.minute }
def perform(user_id, limit)
puts user_id
puts limit
end
end |
github | gevans/sidekiq-throttler | https://github.com/gevans/sidekiq-throttler | spec/app/workers/proc_period_worker.rb | Ruby | mit | 234 | master | 218 | class ProcPeriodWorker
include Sidekiq::Worker
sidekiq_options throttle: { threshold: 10, period: Proc.new { |user_id, period| period } }
def perform(user_id, period)
puts user_id
puts period
end
end |
github | gevans/sidekiq-throttler | https://github.com/gevans/sidekiq-throttler | spec/support/sidekiq.rb | Ruby | mit | 234 | master | 585 | require 'sidekiq/util'
Sidekiq.logger.level = Logger::ERROR
require 'rspec-redis_helper'
RSpec::RedisHelper::CONFIG = { :url => 'redis://localhost/15', :namespace => 'testy' }
require 'sidekiq/redis_connection'
REDIS = Sidekiq::RedisConnection.create(RSpec::RedisHelper::CONFIG)
RSpec.configure do |spec|
spec.inclu... |
github | gevans/sidekiq-throttler | https://github.com/gevans/sidekiq-throttler | lib/sidekiq/throttler.rb | Ruby | mit | 234 | master | 1,198 | require 'sidekiq'
require 'active_support/core_ext/numeric/time'
require 'singleton'
require 'sidekiq/throttler/version'
require 'sidekiq/throttler/rate_limit'
require 'sidekiq/throttler/storage/memory'
require 'sidekiq/throttler/storage/redis'
module Sidekiq
##
# Sidekiq server middleware. Throttles jobs when t... |
github | gevans/sidekiq-throttler | https://github.com/gevans/sidekiq-throttler | lib/sidekiq/throttler/rate_limit.rb | Ruby | mit | 234 | master | 5,803 | require 'thread'
module Sidekiq
class Throttler
##
# Handles the tracking of rate limits.
#
# TODO: Consider reducing `threshold` and `period` to smooth out job
# executions so that "24 jobs every 1 hour" becomes "1 job every 2 minutes
# and 30 seconds"
class RateLimit
LOCK = Mutex... |
github | davydovanton/kan | https://github.com/davydovanton/kan | Rakefile | Ruby | mit | 234 | master | 235 | require "bundler/gem_tasks"
require "rake/testtask"
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task default: :spec
rescue LoadError # rubocop:disable Lint/HandleExceptions
# no rspec available
end |
github | davydovanton/kan | https://github.com/davydovanton/kan | Gemfile | Ruby | mit | 234 | master | 200 | source "https://rubygems.org"
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
# Specify your gem's dependencies in kan.gemspec
gemspec
gem 'rubocop', '0.50.0', require: false |
github | davydovanton/kan | https://github.com/davydovanton/kan | kan.gemspec | Ruby | mit | 234 | master | 949 | lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "kan/version"
Gem::Specification.new do |spec|
spec.name = "kan"
spec.version = Kan::VERSION
spec.authors = ["Anton Davydov"]
spec.email = ["antondavydov.o@gmail.com"]
spec... |
github | davydovanton/kan | https://github.com/davydovanton/kan | spec/abilities/application_spec.rb | Ruby | mit | 234 | master | 2,090 | require 'spec_helper'
RSpec.describe Kan::Application, type: :ability do
module CustomMatcher
class PostAbilities
include Kan::Abilities
register(:read) { |_| true }
register(:edit) { |user, post| user.id == post.user_id }
register_alias(:alias_read, :read)
end
class UserAbilit... |
github | davydovanton/kan | https://github.com/davydovanton/kan | spec/unit/application_spec.rb | Ruby | mit | 234 | master | 1,745 | RSpec.describe Kan::Application do
class PostAbilities
include Kan::Abilities
register('read') { |_| true }
register('edit') { |_, _| false }
end
class UserAbilities
include Kan::Abilities
register('read') { false }
end
let(:app) do
Kan::Application.new(
user: UserAbilities.n... |
github | davydovanton/kan | https://github.com/davydovanton/kan | spec/unit/abilities_spec.rb | Ruby | mit | 234 | master | 3,830 | RSpec.describe Kan::Abilities do
class PostAbilities
include Kan::Abilities
role(:manager) { |_, _| true }
register('read') { |_| true }
register(:edit) { |_, _| false }
end
class EmptyAbilities
include Kan::Abilities
role(:anonymous) { false }
end
class ArrayAbilities
include... |
github | davydovanton/kan | https://github.com/davydovanton/kan | spec/unit/abilities_list_spec.rb | Ruby | mit | 234 | master | 1,301 | RSpec.describe Kan::AbilitiesList do
class PostAbilities
include Kan::Abilities
role(:manager) { |_, _| true }
register('read') { |_| true }
register(:edit) { |_, _| false }
end
class EmptyAbilities
include Kan::Abilities
role(:anonymous) { false }
end
class ArrayAbilities
inc... |
github | davydovanton/kan | https://github.com/davydovanton/kan | spec/integration/after_call_callback_spec.rb | Ruby | mit | 234 | master | 530 | RSpec.describe 'after_call_callback' do
let(:callback) { spy }
let(:app) do
Kan::Application.new(
ability_with_callback: UserAbilities.new(
after_call_callback: -> (ability_name, payload) { callback.call(ability_name, payload) }
)
)
end
class UserAbilities
include Kan::Abilities... |
github | davydovanton/kan | https://github.com/davydovanton/kan | spec/integration/role_class_spec.rb | Ruby | mit | 234 | master | 2,521 | RSpec.describe 'Rolle class' do
class AdminRole
def call(user, _)
user.admin?
end
end
let(:admin_post_abilities) do
Class.new do
include Kan::Abilities
role :admin, AdminRole
register('read') { |_| true }
end
end
describe 'when abilities set as array' do
let(:app)... |
github | davydovanton/kan | https://github.com/davydovanton/kan | spec/integration/logging_spec.rb | Ruby | mit | 234 | master | 416 | RSpec.describe 'logger support' do
let(:logger) { spy }
let(:app) do
Kan::Application.new(
logger: LoggerAbilities.new(logger: logger)
)
end
class LoggerAbilities
include Kan::Abilities
register('info') do
logger.info('Log read ability')
true
end
end
it do
app['l... |
github | davydovanton/kan | https://github.com/davydovanton/kan | spec/integration/inject_spec.rb | Ruby | mit | 234 | master | 652 | require 'dry/auto_inject'
RSpec.describe 'with dry inject' do
class PostAbilities
include Kan::Abilities
register('read') { |_| true }
register('edit') { |_, _| false }
end
class UserAbilities
include Kan::Abilities
register('read') { false }
end
App = Kan::Application.new(
user: ... |
github | davydovanton/kan | https://github.com/davydovanton/kan | lib/kan/rspec.rb | Ruby | mit | 234 | master | 1,656 | module Kan
module RSpec
module Matchers
extend ::RSpec::Matchers::DSL
matcher :permit do |ability, *targets|
match_proc = lambda do |app|
app[ability].call(*targets)
end
match_when_negated_proc = lambda do |app|
!app[ability].call(*targets)
end
... |
github | davydovanton/kan | https://github.com/davydovanton/kan | lib/kan/application.rb | Ruby | mit | 234 | master | 1,215 | module Kan
class Application
class InvalidScopeError < StandardError; end
class MissingScopeError < StandardError; end
class AbilityTypeError < StandardError; end
def initialize(scopes = {})
raise(InvalidScopeError) unless scopes.is_a?(Hash)
raise(InvalidScopeError) if scopes.empty?
... |
github | davydovanton/kan | https://github.com/davydovanton/kan | lib/kan/abilities_list.rb | Ruby | mit | 234 | master | 637 | module Kan
class AbilitiesList
ROLES_DETECT = 'roles'.freeze
def initialize(name, list)
@name = name
@list = list
end
def call(*payload)
@name == ROLES_DETECT ? mapped_roles(payload) : ability_check(payload)
end
private
def ability_check(payload)
@list
.... |
github | davydovanton/kan | https://github.com/davydovanton/kan | lib/kan/abilities.rb | Ruby | mit | 234 | master | 2,517 | require 'logger'
module Kan
module Abilities
def self.included(base)
base.extend(ClassMethods)
end
class InvalidRoleObjectError < StandardError; end
class InvalidAbilityNameError < StandardError; end
class InvalidAliasNameError < StandardError; end
module ClassMethods
RESERVED_N... |
github | ryan-allen/workflow | https://github.com/ryan-allen/workflow | rakefile.rb | Ruby | mit | 234 | master | 613 | task :default do
Rake::Task['run_specs'].invoke
end
task :spec => [:run_specs] do
end
task :run_specs do
puts `spec --require specs/bootstrap.rb --color specs/*_spec.rb`
raise "specs failed" if $?.exitstatus != 0
end
task :run_specs_without_specdoc do
puts `spec --require specs/bootstrap.rb --color specs/*_s... |
github | ryan-allen/workflow | https://github.com/ryan-allen/workflow | lib/workflow.rb | Ruby | mit | 234 | master | 11,431 | %w(rubygems active_support).each { |f| require f }
module Workflow
@@logger = nil
def self.logger=(obj) @@logger = obj; end
def logger=(obj) @@logger = obj; end
def self.logger() @@logger; end
def logger() @@logger; end
WORKFLOW_DEFAULT_LOGGER = Logger.new(STDERR)
WORKFLOW_DEFAULT_LOGGER.level = Logger:... |
github | ryan-allen/workflow | https://github.com/ryan-allen/workflow | specs/matta_spec.rb | Ruby | mit | 234 | master | 651 | require "#{File.dirname(__FILE__)}/bootstrap"
class Matta
include Workflow
end
class SuperMatta < Matta
end
describe "matta's inheritence problem" do
setup do
Matta.class_eval do
workflow do
state :sleeping do
event :wake_up, :transitions_to => :awake
end
state :awake... |
github | ryan-allen/workflow | https://github.com/ryan-allen/workflow | specs/documentation_validation_spec.rb | Ruby | mit | 234 | master | 10,813 | require "#{File.dirname(__FILE__)}/bootstrap"
describe 'As described in README,' do
before :each do
Workflow.specify 'Article Workflow', :meta => {:is_for => :articles_duh} do
state :new do
event :submit, :transitions_to => :awaiting_review
end
state :awaiting_review, :meta => {:one => ... |
github | ryan-allen/workflow | https://github.com/ryan-allen/workflow | specs/active_record_spec.rb | Ruby | mit | 234 | master | 6,157 | require "#{File.dirname(__FILE__)}/bootstrap"
require 'rubygems'
require 'activerecord'
# on initialize, we have to make sure we've either:
#
# a) reconsisited a instance if the state is set
# b) created a new instance if the state is not set
#
# before_save, we serialise the state to the state field
#
describe "... |
github | ryan-allen/workflow | https://github.com/ryan-allen/workflow | specs/recorder.rb | Ruby | mit | 234 | master | 1,472 | module Recorder
@@records = {}
def record(n)
initialize_records unless records_initialized?
@@records[self] << n
end
def records
initialize_records unless records_initialized?
@@records[self]
end
def self.records
@@records
end
private
def initialize_records
@@reco... |
github | ryan-allen/workflow | https://github.com/ryan-allen/workflow | specs/workflow_spec.rb | Ruby | mit | 234 | master | 9,959 | require "#{File.dirname(__FILE__)}/bootstrap"
describe 'Workflow:' do
after { Workflow.reset! }
describe 'a very simple workflow - two states, one event' do
before do
Workflow.specify do
state :new do
event :purchase, :transitions_to => :used
end
state :used
end... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | rubocop-graphql.gemspec | Ruby | mit | 234 | master | 1,424 | lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "rubocop/graphql/version"
Gem::Specification.new do |spec|
spec.name = "rubocop-graphql"
spec.version = RuboCop::GraphQL::VERSION
spec.authors = ["Dmitry Tsepelev"]
spec.email = ["dmitry.a.tsepelev@gmail.com"... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/spec_helper.rb | Ruby | mit | 234 | master | 466 | # frozen_string_literal: true
require "rubocop-graphql"
require "rubocop/rspec/support"
spec_helper_glob = File.expand_path("{support}/*.rb", __dir__)
Dir.glob(spec_helper_glob).map(&method(:require))
RSpec.configure do |config|
config.disable_monkey_patching!
config.raise_errors_for_deprecations!
config.raise... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/graphql_name_spec.rb | Ruby | mit | 234 | master | 4,340 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::GraphqlName, :config do
let(:config) do
RuboCop::Config.new(
"GraphQL/GraphqlName" => {
"EnforcedStyle" => enforced_style,
"SupportedStyles" => %w[required only_override]
}
)
end
context "when EnforcedStyle i... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/ordered_arguments_spec.rb | Ruby | mit | 234 | master | 11,026 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::OrderedArguments, :config do
context "when arguments are alphabetically sorted" do
it "not registers an offense" do
expect_no_offenses(<<~RUBY)
class UpdateProfile < BaseMutation
argument :email, String, required: false
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/prepare_method_spec.rb | Ruby | mit | 234 | master | 6,472 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::PrepareMethod, :config do
let(:config) do
RuboCop::Config.new(
"GraphQL/PrepareMethod" => {
"EnforcedStyle" => nil
}
)
end
context "when there is a block" do
it "registers an offense when the block is declared di... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/not_authorized_node_type_spec.rb | Ruby | mit | 234 | master | 5,196 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::NotAuthorizedNodeType, :config do
let(:config) do
RuboCop::Config.new(
"GraphQL/NotAuthorizedNodeType" => {
"SafeBaseClasses" => ["BaseUserType", "Types::OtherBaseUserType"]
}
)
end
context "when type not implements ... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/field_method_spec.rb | Ruby | mit | 234 | master | 2,870 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::FieldMethod, :config do
it "not registers an offense" do
expect_no_offenses(<<~RUBY)
class UserType < BaseType
field :phone, String, null: true, method: :home_phone
end
RUBY
end
context "when method is set on field" ... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/legacy_dsl_spec.rb | Ruby | mit | 234 | master | 683 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::LegacyDsl, :config do
context "when legacy DSL is defined" do
it "registers an offense" do
expect_offense(<<~RUBY)
User = GraphQL::Object.define do
^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid using legacy based type-based defini... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/field_uniqueness_spec.rb | Ruby | mit | 234 | master | 4,319 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::FieldUniqueness, :config do
context "when fields are not duplicated" do
it "does not register an offense" do
expect_no_offenses(<<~RUBY)
class UserType < BaseType
field :name, String, null: true
field :phone, St... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/max_depth_schema_spec.rb | Ruby | mit | 234 | master | 887 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::MaxDepthSchema, :config do
context "when schema has max_depth" do
specify do
expect_no_offenses(<<~RUBY, "./graphql/app_schema.rb")
class AppSchema < BaseSchema
max_depth 42
end
RUBY
end
context "wh... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/argument_description_spec.rb | Ruby | mit | 234 | master | 9,132 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::ArgumentDescription, :config do
context "when description is passed as argument" do
it "not registers an offense" do
expect_no_offenses(<<~RUBY)
class BanUser < BaseMutation
argument :uuid, ID, "UUID of the user to ban", ... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/argument_name_spec.rb | Ruby | mit | 234 | master | 653 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::ArgumentName, :config do
context "when field name is in snake case" do
it "not registers an offense" do
expect_no_offenses(<<~RUBY)
class BanUser < BaseMutation
argument :user_id, ID, required: true
end
RUBY... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/max_complexity_schema_spec.rb | Ruby | mit | 234 | master | 917 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::MaxComplexitySchema, :config do
context "when schema has max_complexity" do
specify do
expect_no_offenses(<<~RUBY, "./graphql/app_schema.rb")
class AppSchema < BaseSchema
max_complexity 42
end
RUBY
end
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/resolver_method_length_spec.rb | Ruby | mit | 234 | master | 2,365 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::ResolverMethodLength, :config do
let(:config) do
RuboCop::Config.new(
"GraphQL/ResolverMethodLength" => {
"Max" => 2,
"ExcludedMethods" => []
}
)
end
it "not registers an offense" do
expect_no_offenses(<<... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/field_hash_key_spec.rb | Ruby | mit | 234 | master | 3,712 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::FieldHashKey, :config do
it "does not register an offense" do
expect_no_offenses(<<~RUBY)
class UserType < BaseType
field :phone, String, null: true, hash_key: :home_phone
end
RUBY
end
context "when class has two fie... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/unused_argument_spec.rb | Ruby | mit | 234 | master | 7,574 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::UnusedArgument, :config do
context "when all args are used" do
it "not registers an offense" do
expect_no_offenses(<<~RUBY)
class SomeResolver < Resolvers::Base
class Input < GraphQL::Schema::InputObject
argum... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/multiple_field_definitions_spec.rb | Ruby | mit | 234 | master | 6,128 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::MultipleFieldDefinitions, :config do
context "when a field has multiple definitions" do
context "when the field type or nullability has changed" do
it "not register an offense when grouped" do
expect_no_offenses(<<~RUBY)
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/field_name_spec.rb | Ruby | mit | 234 | master | 1,308 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::FieldName, :config do
context "when field name is in snake case" do
it "not registers an offense" do
expect_no_offenses(<<~RUBY)
class UserType < BaseType
field :first_name, String, null: true
end
RUBY
e... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/extract_type_spec.rb | Ruby | mit | 234 | master | 6,239 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::ExtractType, :config do
let(:config) do
RuboCop::Config.new(
"GraphQL/ExtractType" => {
"MaxFields" => 2,
"Prefixes" => %w[is has avg min max]
}
)
end
it "not registers an offense" do
expect_no_offenses(<... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/field_description_spec.rb | Ruby | mit | 234 | master | 4,064 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::FieldDescription, :config do
context "when description is passed as argument" do
it "not registers an offense" do
expect_no_offenses(<<~RUBY)
class UserType < BaseType
field :first_name, String, "First name", null: true
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/field_definitions_spec.rb | Ruby | mit | 234 | master | 32,552 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::FieldDefinitions, :config do
let(:config) do
RuboCop::Config.new(
"GraphQL/FieldDefinitions" => {
"EnforcedStyle" => enforced_style,
"SupportedStyles" => %w[group_definitions define_resolver_after_definition]
}
)
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/extract_input_type_spec.rb | Ruby | mit | 234 | master | 1,958 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::ExtractInputType, :config do
let(:config) do
RuboCop::Config.new(
"GraphQL/ExtractInputType" => {
"MaxArguments" => 2
}
)
end
it "not registers an offense" do
expect_no_offenses(<<~RUBY)
class UpdateUser < ... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/unnecessary_field_alias_spec.rb | Ruby | mit | 234 | master | 3,520 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::UnnecessaryFieldAlias, :config do
describe ":alias" do
context "when proper field alias defined" do
it "not registers an offense" do
expect_no_offenses(<<~RUBY)
class UserType < BaseType
field :first_name, Str... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/ordered_fields_spec.rb | Ruby | mit | 234 | master | 12,034 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::OrderedFields, :config do
let(:config) do
RuboCop::Config.new(
"GraphQL/OrderedFields" => {
"Groups" => true
}
)
end
context "when there is a block" do
it "registers an offense" do
expect_offense(<<~RUBY)
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/unnecessary_argument_camelize_spec.rb | Ruby | mit | 234 | master | 1,687 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::UnnecessaryArgumentCamelize, :config do
context "when proper field camelize defined" do
it "not registers an offense" do
expect_no_offenses(<<~RUBY)
class User < BaseType
field :avatar_url, String do
argument ... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/context_write_in_type_spec.rb | Ruby | mit | 234 | master | 2,797 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::ContextWriteInType, :config do
context "when writing to context with bracket assignment" do
it "registers an offense" do
expect_offense(<<~RUBY, "graphql/types/user_type.rb")
class UserType < BaseType
field :name, String,... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/argument_uniqueness_spec.rb | Ruby | mit | 234 | master | 6,833 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::ArgumentUniqueness, :config do
context "when arguments are not duplicated" do
it "does not register an offense" do
expect_no_offenses(<<~RUBY)
class UpdateProfile < BaseMutation
argument :email, String, required: false
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/unnecessary_field_camelize_spec.rb | Ruby | mit | 234 | master | 903 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::UnnecessaryFieldCamelize, :config do
context "when proper field camelize defined" do
it "not registers an offense" do
expect_no_offenses(<<~RUBY)
class UserType < BaseType
field :first_name, String, null: true, camelize: ... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/rubocop/cop/graphql/object_description_spec.rb | Ruby | mit | 234 | master | 17,519 | # frozen_string_literal: true
RSpec.describe RuboCop::Cop::GraphQL::ObjectDescription, :config do
context "when object" do
context "when description is filled" do
it "does not register an offense" do
expect_no_offenses(<<~RUBY)
class Types::UserType < Types::BaseObject
descrip... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | spec/support/expect_offence.rb | Ruby | mit | 234 | master | 465 | # frozen_string_literal: true
# rubocop-graphql gem extension of RuboCop's ExpectOffense module.
#
# This mixin is the same as rubocop's ExpectOffense except the default
# filename contains 'graphql/'`
module ExpectOffense
include RuboCop::RSpec::ExpectOffense
DEFAULT_FILENAME = "graphql/example.rb"
def expect... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop-graphql.rb | Ruby | mit | 234 | master | 971 | # frozen_string_literal: true
require "rubocop"
require_relative "rubocop/graphql/ext/snake_case"
require_relative "rubocop/graphql"
require_relative "rubocop/graphql/version"
require_relative "rubocop/graphql/plugin"
require_relative "rubocop/graphql/compare_order"
require_relative "rubocop/graphql/description_meth... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/refinements/underscore_string.rb | Ruby | mit | 234 | master | 826 | # frozen_string_literal: true
module UnderscoreString
refine String do
# This method was extracted from activesupport in Rails:
# https://github.com/rails/rails/blob/8dab534ca81dd32c6a83ac03596a1feb7ddaaca7/activesupport/lib/active_support/inflector/methods.rb#L96
def underscore
camel_cased_word =... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/field.rb | Ruby | mit | 234 | master | 2,643 | # frozen_string_literal: true
module RuboCop
module GraphQL
class Field
extend Forwardable
extend RuboCop::NodePattern::Macros
# These constants were extracted from graphql-ruby in lib/graphql/schema/member/has_fields.rb
RUBY_KEYWORDS = %i[class module def undef begin rescue ensure end i... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/plugin.rb | Ruby | mit | 234 | master | 795 | # frozen_string_literal: true
require "lint_roller"
module RuboCop
module GraphQL
# A plugin that integrates rubocop-graphql with RuboCop's plugin system.
class Plugin < LintRoller::Plugin
def about
LintRoller::About.new(
name: "rubocop-graphql",
version: VERSION,
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/heredoc.rb | Ruby | mit | 234 | master | 718 | # frozen_string_literal: true
module RuboCop
module GraphQL
module Heredoc
def heredoc?(node)
node.type?(:str, :dstr) && node.heredoc?
end
def range_including_heredoc(node)
last_heredoc = find_last_heredoc(node)
range = node.source_range
range = range.join(last... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/schema_member.rb | Ruby | mit | 234 | master | 723 | # frozen_string_literal: true
module RuboCop
module GraphQL
class SchemaMember
extend RuboCop::NodePattern::Macros
# @!method class_contents(node)
def_node_matcher :class_contents, <<~PATTERN
{(class _ _ $_) | (module _ $_)}
PATTERN
attr_reader :node
def initialize(... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/description_method.rb | Ruby | mit | 234 | master | 1,053 | # frozen_string_literal: true
module RuboCop
module GraphQL
# Matches a variety of description formats commonly seen in Rails applications
#
# description 'blah'
#
# description "blah"
#
# description <<~EOT
# blah
# bloop
# EOT
#
# description <<-E... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/compare_order.rb | Ruby | mit | 234 | master | 1,587 | # frozen_string_literal: true
module RuboCop
module GraphQL
module CompareOrder
def correct_order?(previous, current)
# If Order config is provided, we should use it to determine the order
# Else, we should use alphabetical order
# e.g. "Order" => [
# "id",
# "/^... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/node_uniqueness.rb | Ruby | mit | 234 | master | 283 | # frozen_string_literal: true
module RuboCop
module GraphQL
# Shared methods to check duplicated definitions
module NodeUniqueness
def current_class_full_name(node)
node.each_ancestor(:class).map(&:defined_module_name).join("::")
end
end
end
end |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/node_pattern.rb | Ruby | mit | 234 | master | 747 | # frozen_string_literal: true
module RuboCop
module GraphQL
module NodePattern
extend RuboCop::NodePattern::Macros
# @!method field_definition?(node)
def_node_matcher :field_definition?, <<~PATTERN
(send nil? :field (:sym _) ...)
PATTERN
# @!method field_definition_with_bo... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/argument.rb | Ruby | mit | 234 | master | 1,081 | # frozen_string_literal: true
module RuboCop
module GraphQL
class Argument
extend RuboCop::NodePattern::Macros
# @!method argument_description(node)
def_node_matcher :argument_description, <<~PATTERN
(send nil? :argument _ _ (:str $_) ...)
PATTERN
# @!method argument_name(... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/class.rb | Ruby | mit | 234 | master | 249 | # frozen_string_literal: true
module RuboCop
module GraphQL
class Class
attr_reader :node
def initialize(node)
@node = node
end
def nested?
node.each_ancestor(:class).any?
end
end
end
end |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/swap_range.rb | Ruby | mit | 234 | master | 1,137 | # frozen_string_literal: true
module RuboCop
module GraphQL
module SwapRange
include RuboCop::Cop::RangeHelp
def swap_range(corrector, current, previous)
current_range = declaration(current)
previous_range = declaration(previous)
corrector.insert_before(previous_range, curre... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/sorbet.rb | Ruby | mit | 234 | master | 520 | # frozen_string_literal: true
module RuboCop
module GraphQL
module Sorbet
extend RuboCop::NodePattern::Macros
# @!method sorbet_signature(node)
def_node_matcher(:sorbet_signature, <<~PATTERN)
(block (send nil? :sig) (args) ...)
PATTERN
def has_sorbet_signature?(node)
... |
github | DmitryTsepelev/rubocop-graphql | https://github.com/DmitryTsepelev/rubocop-graphql | lib/rubocop/graphql/argument/kwargs.rb | Ruby | mit | 234 | master | 1,432 | # frozen_string_literal: true
module RuboCop
module GraphQL
class Argument
class Kwargs
extend RuboCop::NodePattern::Macros
# @!method argument_kwargs(node)
def_node_matcher :argument_kwargs, <<~PATTERN
(send nil? :argument
...
(hash
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.