repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
voxpupuli/onceover | https://github.com/voxpupuli/onceover/blob/2a9776b3caf6cca8bf5b710cfe783cbd01110707/lib/onceover/runner.rb | lib/onceover/runner.rb | require 'backticks'
require 'io/console'
class Onceover
class Runner
attr_reader :repo
attr_reader :config
def initialize(repo, config, mode = [:spec, :acceptance])
@repo = repo
@config = config
@mode = [mode].flatten
@command_prefix = ENV['BUNDLE_GEMFILE'] ? 'bundle exec ' :... | ruby | Apache-2.0 | 2a9776b3caf6cca8bf5b710cfe783cbd01110707 | 2026-01-04T17:33:43.713297Z | false |
voxpupuli/onceover | https://github.com/voxpupuli/onceover/blob/2a9776b3caf6cca8bf5b710cfe783cbd01110707/lib/onceover/cli.rb | lib/onceover/cli.rb | require 'cri'
class Onceover
class CLI
def self.command
@command ||= Cri::Command.define do
name 'onceover'
usage 'onceover <subcommand> [options]'
summary 'Tool for testing Puppet controlrepos'
flag :h, :help, 'Show help for this command' do |value, cmd|
puts cmd... | ruby | Apache-2.0 | 2a9776b3caf6cca8bf5b710cfe783cbd01110707 | 2026-01-04T17:33:43.713297Z | false |
voxpupuli/onceover | https://github.com/voxpupuli/onceover/blob/2a9776b3caf6cca8bf5b710cfe783cbd01110707/lib/onceover/deploy.rb | lib/onceover/deploy.rb | # handle local deployments (run r10k in .onceover dir)
class Onceover
class Deploy
def deploy_local(repo = Onceover::Controlrepo.new, opts = {})
require 'onceover/controlrepo'
require 'pathname'
require 'fileutils'
require 'multi_json'
logger.debug 'Deploying locally (R10K)...'
... | ruby | Apache-2.0 | 2a9776b3caf6cca8bf5b710cfe783cbd01110707 | 2026-01-04T17:33:43.713297Z | false |
voxpupuli/onceover | https://github.com/voxpupuli/onceover/blob/2a9776b3caf6cca8bf5b710cfe783cbd01110707/lib/onceover/vendored_modules.rb | lib/onceover/vendored_modules.rb | require 'puppet/version'
require 'net/http'
require 'uri'
require 'multi_json'
require 'r10k/module_loader/puppetfile'
require 'onceover/logger'
### operations
#
# 1. resolve all the component json files in the puppet-agent repo for vendored modules
# 2. parse each json file and determine vendored modules repo + ref
#... | ruby | Apache-2.0 | 2a9776b3caf6cca8bf5b710cfe783cbd01110707 | 2026-01-04T17:33:43.713297Z | false |
voxpupuli/onceover | https://github.com/voxpupuli/onceover/blob/2a9776b3caf6cca8bf5b710cfe783cbd01110707/lib/onceover/rspec/formatters.rb | lib/onceover/rspec/formatters.rb | require 'rspec'
require 'rspec-puppet'
require 'pathname'
require 'English'
class OnceoverFormatter
RSpec::Core::Formatters.register(
self,
:example_group_started,
:example_passed,
:example_failed,
:example_pending,
:dump_failures,
)
COMPILATION_ERROR = %r{error during compilation: ... | ruby | Apache-2.0 | 2a9776b3caf6cca8bf5b710cfe783cbd01110707 | 2026-01-04T17:33:43.713297Z | false |
voxpupuli/onceover | https://github.com/voxpupuli/onceover/blob/2a9776b3caf6cca8bf5b710cfe783cbd01110707/lib/onceover/cli/plugins.rb | lib/onceover/cli/plugins.rb | require 'rubygems'
# Get all of the gems that start with onceover-
plugins = Gem::Specification.group_by{ |g| g.name }.keep_if do |name, details|
name =~ /^onceover-.*$/
end.keys
plugins.each do |plugin|
require plugin.gsub('-', '/')
end
| ruby | Apache-2.0 | 2a9776b3caf6cca8bf5b710cfe783cbd01110707 | 2026-01-04T17:33:43.713297Z | false |
voxpupuli/onceover | https://github.com/voxpupuli/onceover/blob/2a9776b3caf6cca8bf5b710cfe783cbd01110707/lib/onceover/cli/update.rb | lib/onceover/cli/update.rb | require 'cri'
require 'onceover/controlrepo'
require 'onceover/cli'
require 'onceover/logger'
class Onceover
class CLI
class Update
def self.command
@command ||= Cri::Command.define do
name 'update'
usage 'update puppetfile'
summary 'Updates stuff, currently only the P... | ruby | Apache-2.0 | 2a9776b3caf6cca8bf5b710cfe783cbd01110707 | 2026-01-04T17:33:43.713297Z | false |
voxpupuli/onceover | https://github.com/voxpupuli/onceover/blob/2a9776b3caf6cca8bf5b710cfe783cbd01110707/lib/onceover/cli/run.rb | lib/onceover/cli/run.rb | require 'cri'
require 'onceover/controlrepo'
require 'onceover/cli'
require 'onceover/runner'
require 'onceover/testconfig'
require 'onceover/logger'
require 'onceover/deploy'
class Onceover
class CLI
class Run
def self.command
@command ||= Cri::Command.define do
name 'run'
usag... | ruby | Apache-2.0 | 2a9776b3caf6cca8bf5b710cfe783cbd01110707 | 2026-01-04T17:33:43.713297Z | false |
voxpupuli/onceover | https://github.com/voxpupuli/onceover/blob/2a9776b3caf6cca8bf5b710cfe783cbd01110707/lib/onceover/cli/init.rb | lib/onceover/cli/init.rb | require 'cri'
require 'onceover/controlrepo'
require 'onceover/cli'
require 'onceover/runner'
require 'onceover/testconfig'
require 'onceover/logger'
class Onceover
class CLI
class Init
def self.command
@command ||= Cri::Command.define do
name 'init'
usage 'init'
summa... | ruby | Apache-2.0 | 2a9776b3caf6cca8bf5b710cfe783cbd01110707 | 2026-01-04T17:33:43.713297Z | false |
voxpupuli/onceover | https://github.com/voxpupuli/onceover/blob/2a9776b3caf6cca8bf5b710cfe783cbd01110707/lib/onceover/cli/show.rb | lib/onceover/cli/show.rb | require 'cri'
require 'onceover/controlrepo'
require 'onceover/cli'
require 'onceover/logger'
class Onceover
class CLI
class Show
def self.command
@command ||= Cri::Command.define do
name 'show'
usage 'show [controlrepo|puppetfile]'
summary 'Shows the current state of ... | ruby | Apache-2.0 | 2a9776b3caf6cca8bf5b710cfe783cbd01110707 | 2026-01-04T17:33:43.713297Z | false |
voxpupuli/onceover | https://github.com/voxpupuli/onceover/blob/2a9776b3caf6cca8bf5b710cfe783cbd01110707/lib/onceover/beaker/spec_helper.rb | lib/onceover/beaker/spec_helper.rb | # This has all been hacked out of the beaker-rspec gem. The reason I have
# hacked it out instead of just using it the way it was intended is that
# it is very stuck in its ways around how it spins up all the servers
# first, then goes ahead and runs the tests. Because I don't want to do this
# I have had to replicate ... | ruby | Apache-2.0 | 2a9776b3caf6cca8bf5b710cfe783cbd01110707 | 2026-01-04T17:33:43.713297Z | false |
palkan/action_policy-graphql | https://github.com/palkan/action_policy-graphql/blob/9338cefef3abbb7d3f04569e501c90be0bd3ba28/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
# This turns off per-thread caching in action_policy
ENV["RACK_ENV"] = "test"
require "i18n"
require "action_policy-graphql"
begin
require "debug" unless ENV["CI"]
rescue LoadError
end
require "action_policy/rspec"
ActionPolicy:... | ruby | MIT | 9338cefef3abbb7d3f04569e501c90be0bd3ba28 | 2026-01-04T17:33:48.592174Z | false |
palkan/action_policy-graphql | https://github.com/palkan/action_policy-graphql/blob/9338cefef3abbb7d3f04569e501c90be0bd3ba28/spec/support/graphql_context.rb | spec/support/graphql_context.rb | # frozen_string_literal: true
shared_context "common:graphql" do
let(:context) { {} }
let(:variables) { {} }
let(:field) { result.fetch("data").keys.first }
let(:schema) { raise NotImplementedError.new("Specify schema under test, e.g. `let(:schema) { MySchema }`") }
let(:data) do
raise "API Query failed... | ruby | MIT | 9338cefef3abbb7d3f04569e501c90be0bd3ba28 | 2026-01-04T17:33:48.592174Z | false |
palkan/action_policy-graphql | https://github.com/palkan/action_policy-graphql/blob/9338cefef3abbb7d3f04569e501c90be0bd3ba28/spec/support/schema.rb | spec/support/schema.rb | # frozen_string_literal: true
class Post < Struct.new(:title); end
class PostList < Array
def policy_name
"#{first.class}Policy"
end
end
class PostPolicy < ActionPolicy::Base
scope_matcher :data, PostList
scope_for :data do |data|
next data if admin?
data.select { |post| post.title.start_with? ... | ruby | MIT | 9338cefef3abbb7d3f04569e501c90be0bd3ba28 | 2026-01-04T17:33:48.592174Z | false |
palkan/action_policy-graphql | https://github.com/palkan/action_policy-graphql/blob/9338cefef3abbb7d3f04569e501c90be0bd3ba28/spec/action_policy/graphql/behaviour_spec.rb | spec/action_policy/graphql/behaviour_spec.rb | # frozen_string_literal: true
require "spec_helper"
describe ActionPolicy::GraphQL::Behaviour do
include_context "common:graphql"
let(:user) { :user }
let(:post) { Post.new("private") }
let(:schema) { Schema }
let(:context) { {current_user: user} }
describe ".authorized? + allowed_to?" do
let(:quer... | ruby | MIT | 9338cefef3abbb7d3f04569e501c90be0bd3ba28 | 2026-01-04T17:33:48.592174Z | false |
palkan/action_policy-graphql | https://github.com/palkan/action_policy-graphql/blob/9338cefef3abbb7d3f04569e501c90be0bd3ba28/spec/action_policy/graphql/expose_authorization_rules_spec.rb | spec/action_policy/graphql/expose_authorization_rules_spec.rb | # frozen_string_literal: true
require "spec_helper"
describe "#expose_authorization_rules", :aggregate_failures do
include_context "common:graphql"
let(:post) { Post.new("private") }
let(:schema) { Schema }
let(:query) do
%({
post {
title
canShow {
value
... | ruby | MIT | 9338cefef3abbb7d3f04569e501c90be0bd3ba28 | 2026-01-04T17:33:48.592174Z | false |
palkan/action_policy-graphql | https://github.com/palkan/action_policy-graphql/blob/9338cefef3abbb7d3f04569e501c90be0bd3ba28/spec/action_policy/graphql/authorized_spec.rb | spec/action_policy/graphql/authorized_spec.rb | # frozen_string_literal: true
require "spec_helper"
describe "field extensions", :aggregate_failures do
include_context "common:graphql"
let(:user) { :user }
let(:schema) { Schema }
let(:context) { {user: user} }
context "authorized_scope: *" do
let(:posts) { [Post.new("private-a"), Post.new("public-... | ruby | MIT | 9338cefef3abbb7d3f04569e501c90be0bd3ba28 | 2026-01-04T17:33:48.592174Z | false |
palkan/action_policy-graphql | https://github.com/palkan/action_policy-graphql/blob/9338cefef3abbb7d3f04569e501c90be0bd3ba28/lib/action_policy-graphql.rb | lib/action_policy-graphql.rb | # frozen_string_literal: true
require "ruby-next"
require "action_policy/graphql"
| ruby | MIT | 9338cefef3abbb7d3f04569e501c90be0bd3ba28 | 2026-01-04T17:33:48.592174Z | false |
palkan/action_policy-graphql | https://github.com/palkan/action_policy-graphql/blob/9338cefef3abbb7d3f04569e501c90be0bd3ba28/lib/action_policy/graphql.rb | lib/action_policy/graphql.rb | # frozen_string_literal: true
require "graphql"
require "action_policy"
require "action_policy/graphql/behaviour"
module ActionPolicy
module GraphQL
class << self
# Which rule to use when no specified (e.g. `authorize: true`)
# Defaults to `:show?`
attr_accessor :default_authorize_rule
... | ruby | MIT | 9338cefef3abbb7d3f04569e501c90be0bd3ba28 | 2026-01-04T17:33:48.592174Z | false |
palkan/action_policy-graphql | https://github.com/palkan/action_policy-graphql/blob/9338cefef3abbb7d3f04569e501c90be0bd3ba28/lib/action_policy/graphql/version.rb | lib/action_policy/graphql/version.rb | # frozen_string_literal: true
module ActionPolicy
module GraphQL
VERSION = "0.6.0"
end
end
| ruby | MIT | 9338cefef3abbb7d3f04569e501c90be0bd3ba28 | 2026-01-04T17:33:48.592174Z | false |
palkan/action_policy-graphql | https://github.com/palkan/action_policy-graphql/blob/9338cefef3abbb7d3f04569e501c90be0bd3ba28/lib/action_policy/graphql/authorized_field.rb | lib/action_policy/graphql/authorized_field.rb | # frozen_string_literal: true
module ActionPolicy
module GraphQL
# Add `authorized` option to the field
#
# Example:
#
# class PostType < ::GraphQL::Schema::Object
# field :comments, null: false, authorized: true
#
# # or with options
# field :comments, null: false, ... | ruby | MIT | 9338cefef3abbb7d3f04569e501c90be0bd3ba28 | 2026-01-04T17:33:48.592174Z | false |
palkan/action_policy-graphql | https://github.com/palkan/action_policy-graphql/blob/9338cefef3abbb7d3f04569e501c90be0bd3ba28/lib/action_policy/graphql/fields.rb | lib/action_policy/graphql/fields.rb | # frozen_string_literal: true
require "action_policy/graphql/types/authorization_result"
module ActionPolicy
using RubyNext
module GraphQL
# Add DSL to add policy rules as fields
#
# Example:
#
# class PostType < ::GraphQL::Schema::Object
# # Adds can_edit, can_destroy fields with
... | ruby | MIT | 9338cefef3abbb7d3f04569e501c90be0bd3ba28 | 2026-01-04T17:33:48.592174Z | false |
palkan/action_policy-graphql | https://github.com/palkan/action_policy-graphql/blob/9338cefef3abbb7d3f04569e501c90be0bd3ba28/lib/action_policy/graphql/behaviour.rb | lib/action_policy/graphql/behaviour.rb | # frozen_string_literal: true
require "action_policy/graphql/fields"
require "action_policy/graphql/authorized_field"
module ActionPolicy
module GraphQL
module Behaviour
require "action_policy/ext/module_namespace"
using ActionPolicy::Ext::ModuleNamespace
# When used with self.authorized?
... | ruby | MIT | 9338cefef3abbb7d3f04569e501c90be0bd3ba28 | 2026-01-04T17:33:48.592174Z | false |
palkan/action_policy-graphql | https://github.com/palkan/action_policy-graphql/blob/9338cefef3abbb7d3f04569e501c90be0bd3ba28/lib/action_policy/graphql/types/failure_reasons.rb | lib/action_policy/graphql/types/failure_reasons.rb | # frozen_string_literal: true
module ActionPolicy
module GraphQL
module Types
class FailureReasons < ::GraphQL::Schema::Object
field :details, String, null: false, description: "JSON-encoded map of reasons"
field :full_messages, [String], null: false, description: "Human-readable errors"
... | ruby | MIT | 9338cefef3abbb7d3f04569e501c90be0bd3ba28 | 2026-01-04T17:33:48.592174Z | false |
palkan/action_policy-graphql | https://github.com/palkan/action_policy-graphql/blob/9338cefef3abbb7d3f04569e501c90be0bd3ba28/lib/action_policy/graphql/types/authorization_result.rb | lib/action_policy/graphql/types/authorization_result.rb | # frozen_string_literal: true
require "action_policy/graphql/types/failure_reasons"
module ActionPolicy
module GraphQL
module Types
class AuthorizationResult < ::GraphQL::Schema::Object
field :value, Boolean, null: false, description: "Result of applying a policy rule"
field :message, Stri... | ruby | MIT | 9338cefef3abbb7d3f04569e501c90be0bd3ba28 | 2026-01-04T17:33:48.592174Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/spec/spec_helper.rb | spec/spec_helper.rb | $:.unshift '.'
require 'lib/grape_logging'
RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# This option will default to ... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/spec/lib/grape_logging/middleware/request_logger_spec.rb | spec/lib/grape_logging/middleware/request_logger_spec.rb | require 'spec_helper'
require 'rack'
describe GrapeLogging::Middleware::RequestLogger do
let(:env) { { 'action_dispatch.request_id' => 'request-abc123' } }
let(:subject) { request.send(request_method, path, env) }
let(:app) { proc { [status, {}, ['response body']] } }
let(:stack) { described_class.new app, **o... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/spec/lib/grape_logging/formatters/rails_spec.rb | spec/lib/grape_logging/formatters/rails_spec.rb | require 'spec_helper'
describe GrapeLogging::Formatters::Rails do
let(:formatter) { described_class.new }
let(:severity) { 'INFO' }
let(:datetime) { Time.new('2018', '03', '02', '10', '35', '04', '+13:00') }
let(:exception_data) { ArgumentError.new('Message') }
let(:hash_data) do
{
status: 200,
... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/spec/lib/grape_logging/loggers/response_spec.rb | spec/lib/grape_logging/loggers/response_spec.rb | require 'spec_helper'
describe GrapeLogging::Loggers::Response do
context 'with a parseable JSON body' do
let(:response) do
instance_double(Rack::Request, body: [{ one: 'two', three: { four: 5 } }])
end
it 'returns an array of parsed JSON objects' do
expect(subject.parameters(nil, response))... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/spec/lib/grape_logging/loggers/request_headers_spec.rb | spec/lib/grape_logging/loggers/request_headers_spec.rb | require 'spec_helper'
describe GrapeLogging::Loggers::RequestHeaders do
let(:mock_request) do
instance_double(Rack::Request, env: { HTTP_REFERER: 'http://example.com', HTTP_ACCEPT: 'text/plain' })
end
let(:mock_request_with_unhandled_headers) do
instance_double(Rack::Request, env: {
... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/spec/lib/grape_logging/loggers/filter_parameters_spec.rb | spec/lib/grape_logging/loggers/filter_parameters_spec.rb | require 'spec_helper'
describe GrapeLogging::Loggers::FilterParameters do
let(:filtered_parameters) { %w[one four] }
let(:mock_request) do
instance_double(Rack::Request, params: {
'this_one' => 'this one',
'that_one' => 'one',
'two' => 'two',
... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/spec/lib/grape_logging/loggers/client_env_spec.rb | spec/lib/grape_logging/loggers/client_env_spec.rb | require 'spec_helper'
describe GrapeLogging::Loggers::ClientEnv do
let(:ip) { '10.0.0.1' }
let(:user_agent) { 'user agent' }
let(:forwarded_for) { 'forwarded for' }
let(:remote_addr) { 'remote address' }
context 'forwarded for' do
let(:mock_request) do
instance_double(Rack::Request, env: {
... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging.rb | lib/grape_logging.rb | require 'grape_logging/multi_io'
require 'grape_logging/version'
require 'grape_logging/formatters/default'
require 'grape_logging/formatters/json'
require 'grape_logging/formatters/lograge'
require 'grape_logging/formatters/logstash'
require 'grape_logging/formatters/rails'
require 'grape_logging/loggers/base'
require... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/version.rb | lib/grape_logging/version.rb | module GrapeLogging
VERSION = '3.0.1'
end
| ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/timings.rb | lib/grape_logging/timings.rb | module GrapeLogging
module Timings
def self.db_runtime=(value)
Thread.current[:grape_db_runtime] = value
end
def self.db_runtime
Thread.current[:grape_db_runtime] ||= 0
end
def self.reset_db_runtime
self.db_runtime = 0
end
def self.append_db_runtime(event)
self.d... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/multi_io.rb | lib/grape_logging/multi_io.rb | module GrapeLogging
class MultiIO
def initialize(*targets)
@targets = targets
end
def write(*args)
@targets.each { |t| t.write(*args) }
end
def close
@targets.each(&:close)
end
end
end
| ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/util/parameter_filter.rb | lib/grape_logging/util/parameter_filter.rb | if defined?(Rails.application)
if Gem::Version.new(Rails.version) < Gem::Version.new('6.0.0')
class ParameterFilter < ActionDispatch::Http::ParameterFilter
def initialize(_replacement, filter_parameters)
super(filter_parameters)
end
end
else
require 'active_support/parameter_filter'
... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/middleware/request_logger.rb | lib/grape_logging/middleware/request_logger.rb | require 'grape'
module GrapeLogging
module Middleware
class RequestLogger < Grape::Middleware::Base
if defined?(ActiveRecord)
ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
GrapeLogging::Timings.appen... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/reporters/active_support_reporter.rb | lib/grape_logging/reporters/active_support_reporter.rb | module Reporters
class ActiveSupportReporter
def initialize(instrumentation_key)
@instrumentation_key = instrumentation_key
end
def perform(params)
ActiveSupport::Notifications.instrument @instrumentation_key, params
end
end
end
| ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/reporters/logger_reporter.rb | lib/grape_logging/reporters/logger_reporter.rb | module Reporters
class LoggerReporter
def initialize(logger, formatter, log_level)
@logger = logger.clone || Logger.new(STDOUT)
@log_level = log_level || :info
@logger.formatter = formatter || @logger.formatter || GrapeLogging::Formatters::Default.new if @logger.respond_to?(:formatter=)
end
... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/formatters/logstash.rb | lib/grape_logging/formatters/logstash.rb | module GrapeLogging
module Formatters
class Logstash
def call(severity, datetime, _, data)
{
'@timestamp': datetime.iso8601,
'@version': '1',
severity: severity
}.merge!(format(data)).to_json + "\n"
end
private
def format(data)
if dat... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/formatters/rails.rb | lib/grape_logging/formatters/rails.rb | require 'rack/utils'
module GrapeLogging
module Formatters
class Rails
def call(severity, datetime, _, data)
if data.is_a?(String)
"#{severity[0..0]} [#{datetime}] #{severity} -- : #{data}\n"
elsif data.is_a?(Exception)
"#{severity[0..0]} [#{datetime}] #{severity} -- : #... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/formatters/default.rb | lib/grape_logging/formatters/default.rb | module GrapeLogging
module Formatters
class Default
def call(severity, datetime, _, data)
"[#{datetime}] #{severity} -- #{format(data)}\n"
end
def format(data)
if data.is_a?(String)
data
elsif data.is_a?(Exception)
format_exception(data)
elsif... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/formatters/lograge.rb | lib/grape_logging/formatters/lograge.rb | module GrapeLogging
module Formatters
class Lograge
def call(severity, datetime, _, data)
time = data.delete :time
attributes = {
severity: severity,
duration: time[:total],
db: time[:db],
view: time[:view],
datetime: datetime.iso8601
... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/formatters/json.rb | lib/grape_logging/formatters/json.rb | module GrapeLogging
module Formatters
class Json
def call(severity, datetime, _, data)
{
date: datetime,
severity: severity,
data: format(data)
}.to_json + "\n"
end
private
def format(data)
if data.is_a?(String) || data.is_a?(Hash)
... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/loggers/response.rb | lib/grape_logging/loggers/response.rb | module GrapeLogging
module Loggers
class Response < GrapeLogging::Loggers::Base
def parameters(_, response)
response ? { response: serialized_response_body(response) } : {}
end
private
# In some cases, response.body is not parseable by JSON.
# For example, if you POST on a ... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/loggers/request_headers.rb | lib/grape_logging/loggers/request_headers.rb | module GrapeLogging
module Loggers
class RequestHeaders < GrapeLogging::Loggers::Base
HTTP_PREFIX = 'HTTP_'.freeze
def parameters(request, _)
headers = {}
request.env.each_pair do |k, v|
next unless k.to_s.start_with? HTTP_PREFIX
k = k[5..-1].split('_').each(&:ca... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/loggers/base.rb | lib/grape_logging/loggers/base.rb | module GrapeLogging
module Loggers
class Base
def parameters(_request, _response)
{}
end
end
end
end
| ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/loggers/client_env.rb | lib/grape_logging/loggers/client_env.rb | module GrapeLogging
module Loggers
class ClientEnv < GrapeLogging::Loggers::Base
def parameters(request, _)
{ ip: request.env['HTTP_X_FORWARDED_FOR'] || request.env['REMOTE_ADDR'], ua: request.env['HTTP_USER_AGENT'] }
end
end
end
end
| ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
aserafin/grape_logging | https://github.com/aserafin/grape_logging/blob/f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc/lib/grape_logging/loggers/filter_parameters.rb | lib/grape_logging/loggers/filter_parameters.rb | module GrapeLogging
module Loggers
class FilterParameters < GrapeLogging::Loggers::Base
AD_PARAMS = 'action_dispatch.request.parameters'.freeze
def initialize(filter_parameters = nil, replacement = nil, exceptions = %w[controller action format])
@filter_parameters = filter_parameters || (defi... | ruby | MIT | f9d417f2d6e5dfff7310e4b9c8f54c5821b2b6cc | 2026-01-04T17:33:53.651145Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/spec/spec_helper.rb | spec/spec_helper.rb | require 'sir_trevor_rails'
require 'bundler'
Bundler.require :default, :development
require 'combustion'
Combustion.initialize! :active_record, :action_view do
config.active_support.test_order = :random
end
require 'capybara/rails'
require 'minitest/autorun'
require 'minitest/spec'
require 'minitest/pride'
requi... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/spec/integration/editing_spec.rb | spec/integration/editing_spec.rb | require 'spec_helper'
class EditingSpec < ActionDispatch::IntegrationTest
describe 'Edit form' do
let(:post) { Post.create(body: blocks_json(:text_html)) }
it 'serializes BlockArray to correct json' do
visit edit_post_path(post)
expect { find_field('Body').value == {data: post.body.as_json}.to_j... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/spec/integration/rendering_spec.rb | spec/integration/rendering_spec.rb | require 'spec_helper'
class RenderingSpec < ActionDispatch::IntegrationTest
describe 'SirTrevorContent rendering' do
it 'renders all blocks as separate divs' do
post = Post.create(body: blocks_json(:list_html, :text_html))
visit post_path(post)
expect { all('.st__content-block').length == 2 }
... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/spec/internal/app/controllers/posts_controller.rb | spec/internal/app/controllers/posts_controller.rb | class PostsController < ActionController::Base
def new
@post = Post.new
end
def edit
@post = Post.find(params[:id])
end
def create
@post = Post.new(post_attributes)
if @post.save
redirect_to post_show_path(@post)
else
render :new
end
end
def update
@post = Post.... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/spec/internal/app/models/post.rb | spec/internal/app/models/post.rb | class Post < ActiveRecord::Base
include SirTrevorRails::HasSirTrevorContent
sir_trevor_content :body
end
| ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/spec/internal/app/models/custom_block.rb | spec/internal/app/models/custom_block.rb | class CustomBlock < SirTrevorRails::Block
def upcase_title
title.upcase
end
end
| ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/spec/internal/db/schema.rb | spec/internal/db/schema.rb | ActiveRecord::Schema.define do
create_table(:posts, force: true) do |t|
t.string :title
t.text :body
t.timestamps null: false
end
end
| ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/spec/internal/config/routes.rb | spec/internal/config/routes.rb | Rails.application.routes.draw do
resources :posts
end
| ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/spec/unit/has_sir_trevor_content_spec.rb | spec/unit/has_sir_trevor_content_spec.rb | require 'spec_helper'
class HasSirTrevorContentSpec < ActiveSupport::TestCase
describe 'HasSirTrevorContent' do
describe 'initialized for body field' do
let(:post) { Post.new }
it 'returns BlockArray for initialised field' do
assert { post.body.is_a? BlockArray }
end
it 'returns... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/spec/unit/helpers_spec.rb | spec/unit/helpers_spec.rb | require 'spec_helper'
module SirTrevorRails
describe Helpers do
let(:subject) { Class.new.send(:include, Helpers::ViewHelper).new }
describe 'sir_trevor_format' do
it 'is callable' do
expect { subject.respond_to? :sir_trevor_format }
end
it 'calls sir_trevor_markdown if format is ... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/spec/unit/block_array_spec.rb | spec/unit/block_array_spec.rb | require 'spec_helper'
class BlockArraySpec < ActiveSupport::TestCase
describe BlockArray do
describe 'initialization' do
subject { BlockArray }
it 'can be initialized with an empty JSON array' do
array = subject.from_json('[]')
expect { array.is_a? BlockArray }
end
it 'c... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/spec/unit/block_spec.rb | spec/unit/block_spec.rb | require 'spec_helper'
class BlockSpec < ActiveSupport::TestCase
describe Block do
describe '.block_class' do
subject { Block }
describe 'for known type' do
let(:klass) { subject.block_class('tweet') }
it 'returns class' do
expect { klass == Blocks::TweetBlock }
end... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/spec/unit/custom_block_spec.rb | spec/unit/custom_block_spec.rb | require 'spec_helper'
# The block that is being tested here is defined in
# `spec/internal/app/models/custom_block.rb`, just like it would in real
# Rails app.
class CustomBlockTest < ActiveSupport::TestCase
describe CustomBlock do
describe "SirTrevorRails::Block" do
let(:custom_block_hash) { {type: 'cus... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/lib/sir_trevor_rails.rb | lib/sir_trevor_rails.rb | # Require things from Rails
require 'rails/engine'
require 'action_view'
require 'action_view/template/resolver'
require 'multi_json'
require 'sir_trevor_rails/version'
require 'sir_trevor_rails/engine'
require 'sir_trevor_rails/has_sir_trevor_content'
require 'sir_trevor_rails/view_resolver'
module SirTrevorRails
... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/lib/sir_trevor_rails/block_array.rb | lib/sir_trevor_rails/block_array.rb | module SirTrevorRails
class BlockArray < Array
def self.from_json(blocks, parent = nil)
if blocks.is_a?(String)
blocks = MultiJson.load(blocks, symbolize_keys: true)
end
if blocks.is_a?(Hash)
blocks = blocks[:data] || blocks['data'] or
raise IndexError, "No block data... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/lib/sir_trevor_rails/version.rb | lib/sir_trevor_rails/version.rb | module SirTrevorRails
VERSION = "0.6.3"
end
| ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/lib/sir_trevor_rails/view_resolver.rb | lib/sir_trevor_rails/view_resolver.rb | module SirTrevorRails
class ViewResolver < ::ActionView::FileSystemResolver
def initialize
super("app/views")
end
def find_templates(name, prefix, *args)
super(name, prefix.gsub(/^(.)+(sir_trevor)/, '\2'), *args)
end
end
end
| ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/lib/sir_trevor_rails/engine.rb | lib/sir_trevor_rails/engine.rb | module SirTrevorRails
class Engine < Rails::Engine
require 'redcarpet'
config.after_initialize do |app|
app.config.paths.add 'app/sir_trevor_blocks', eager_load: true
end
initializer "sir_trevor_rails.load_app_instance_data" do |app|
SirTrevorRails.setup do |config|
config.app_r... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/lib/sir_trevor_rails/has_sir_trevor_content.rb | lib/sir_trevor_rails/has_sir_trevor_content.rb | require 'sir_trevor_rails/block_array'
require 'sir_trevor_rails/block'
module SirTrevorRails
module HasSirTrevorContent
extend ActiveSupport::Concern
module ClassMethods
def sir_trevor_content(*attributes)
attributes.each do |attribute|
#next unless name.constantize.column_names.inc... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/lib/sir_trevor_rails/block.rb | lib/sir_trevor_rails/block.rb | require 'ostruct'
module SirTrevorRails
class Block < OpenStruct
DEFAULT_FORMAT = :markdown
def self.from_hash(hash, parent)
hash = hash.deep_dup.with_indifferent_access
self.type_klass(hash).new(hash, parent)
end
def format
send(:[], :format).present? ? send(:[], :format).to_sym ... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/lib/sir_trevor_rails/helpers/view_helper.rb | lib/sir_trevor_rails/helpers/view_helper.rb | module SirTrevorRails
module Helpers
module ViewHelper
extend ActiveSupport::Concern
included do
include ActionView::Helpers::SanitizeHelper
end
def sir_trevor_format(text, format: :markdown)
if format.to_s.to_sym == :html
sir_trevor_html(text)
else
... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/lib/sir_trevor_rails/blocks/tweet_block.rb | lib/sir_trevor_rails/blocks/tweet_block.rb | require 'twitter-text'
module SirTrevorRails
module Blocks
class TweetBlock < SirTrevorRails::Block
include ActionView::Helpers::SanitizeHelper
def render_tweet_body
sanitize Twitter::TwitterText::Autolink.auto_link(
self.text,
url_entities: (self.entities.values... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/lib/sir_trevor_rails/blocks/video_block.rb | lib/sir_trevor_rails/blocks/video_block.rb | module SirTrevorRails
module Blocks
class VideoBlock < SirTrevorRails::Block
def to_partial_path
"sir_trevor/blocks/videos/" << self.source
end
end
end
end | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/lib/generators/sir_trevor_rails/block/block_generator.rb | lib/generators/sir_trevor_rails/block/block_generator.rb | require 'rails/generators'
module SirTrevorRails
module Generators
class BlockGenerator < Rails::Generators::NamedBase
def self.source_root
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
end
def create_block
# Copy the JS
template "_block.js.erb", "ap... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/lib/generators/sir_trevor_rails/views/views_generator.rb | lib/generators/sir_trevor_rails/views/views_generator.rb | require 'rails/generators'
module SirTrevorRails
module Generators
class ViewsGenerator < Rails::Generators::Base
def self.source_root
@source_root ||= SirTrevorRails::Engine.root
end
def views
directory "app/views/sir_trevor"
end
end
end
end | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
madebymany/sir-trevor-rails | https://github.com/madebymany/sir-trevor-rails/blob/a26c4f5ec364c9a37044e21e01e833a756b99a10/config/initializers/validators.rb | config/initializers/validators.rb | require 'active_model/validator'
class IsJsonValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
@json = MultiJson.load(value, symbolize_keys: true)
record.errors.add(attribute, "is empty") if @json.empty?
rescue TypeError => e
record.errors.add(attribute, "is not valid J... | ruby | MIT | a26c4f5ec364c9a37044e21e01e833a756b99a10 | 2026-01-04T17:33:55.015623Z | false |
ASCIIwwdc/wwdc | https://github.com/ASCIIwwdc/wwdc/blob/3a9f837499051f000639e3c2a7a22ea9181e925b/lib/wwdc.rb | lib/wwdc.rb | require 'wwdc/version'
require 'wwdc/helpers'
require 'wwdc/commands'
| ruby | MIT | 3a9f837499051f000639e3c2a7a22ea9181e925b | 2026-01-04T17:33:59.905975Z | false |
ASCIIwwdc/wwdc | https://github.com/ASCIIwwdc/wwdc/blob/3a9f837499051f000639e3c2a7a22ea9181e925b/lib/wwdc/version.rb | lib/wwdc/version.rb | module WWDC
VERSION = '1.1.1'
end
| ruby | MIT | 3a9f837499051f000639e3c2a7a22ea9181e925b | 2026-01-04T17:33:59.905975Z | false |
ASCIIwwdc/wwdc | https://github.com/ASCIIwwdc/wwdc/blob/3a9f837499051f000639e3c2a7a22ea9181e925b/lib/wwdc/helpers.rb | lib/wwdc/helpers.rb | require 'excon'
require 'json'
require 'rubygems/text'
module WWDC
YEARS = (2010..2018)
module Helpers
include Gem::Text
def get(options = {}, &block)
response = client.get(options)
say_error "Error #{response.status}" and abort unless response.status == 200
yield response if block_giv... | ruby | MIT | 3a9f837499051f000639e3c2a7a22ea9181e925b | 2026-01-04T17:33:59.905975Z | false |
ASCIIwwdc/wwdc | https://github.com/ASCIIwwdc/wwdc/blob/3a9f837499051f000639e3c2a7a22ea9181e925b/lib/wwdc/commands.rb | lib/wwdc/commands.rb | include WWDC::Helpers
require 'wwdc/commands/info'
require 'wwdc/commands/open'
require 'wwdc/commands/search'
| ruby | MIT | 3a9f837499051f000639e3c2a7a22ea9181e925b | 2026-01-04T17:33:59.905975Z | false |
ASCIIwwdc/wwdc | https://github.com/ASCIIwwdc/wwdc/blob/3a9f837499051f000639e3c2a7a22ea9181e925b/lib/wwdc/commands/search.rb | lib/wwdc/commands/search.rb | command :search do |c|
c.syntax = 'wwdc search [QUERY]'
c.summary = 'Find sessions containing the specified search terms'
c.option '-y', '--year YEAR', 'WWDC Year'
c.action do |args, options|
determine_query!(args, options)
determine_year!(args, options) if options.year
@results = get(path: "searc... | ruby | MIT | 3a9f837499051f000639e3c2a7a22ea9181e925b | 2026-01-04T17:33:59.905975Z | false |
ASCIIwwdc/wwdc | https://github.com/ASCIIwwdc/wwdc/blob/3a9f837499051f000639e3c2a7a22ea9181e925b/lib/wwdc/commands/info.rb | lib/wwdc/commands/info.rb | command :info do |c|
c.syntax = 'wwdc info SESSION'
c.summary = 'Get information about a session by its number and year'
c.option '-y', '--year YEAR', 'WWDC Year'
c.action do |args, options|
determine_session!(args, options)
determine_year!(args, options)
@session = get(path: "/#{@year}/sessions/#... | ruby | MIT | 3a9f837499051f000639e3c2a7a22ea9181e925b | 2026-01-04T17:33:59.905975Z | false |
ASCIIwwdc/wwdc | https://github.com/ASCIIwwdc/wwdc/blob/3a9f837499051f000639e3c2a7a22ea9181e925b/lib/wwdc/commands/open.rb | lib/wwdc/commands/open.rb | command :open do |c|
c.syntax = 'wwdc open [SESSION]'
c.summary = 'Open your browser to the Apple Developer Center to view session slides and video'
c.option '-y', '--year YEAR', 'WWDC Year'
c.action do |args, options|
determine_session!(args, options)
determine_year!(args, options)
@session = get... | ruby | MIT | 3a9f837499051f000639e3c2a7a22ea9181e925b | 2026-01-04T17:33:59.905975Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/support/coverage_setup.rb | support/coverage_setup.rb | # frozen_string_literal: true
def setup_simplecov
return unless ENV.fetch('SKIP_COVERAGE_VALIDATION', 'false') == 'true'
require 'simplecov'
SimpleCov.command_name "#{ENV['SIMPLECOV_COMMAND_NAME']}:#{Process.pid}"
SimpleCov.root File.expand_path('..', __dir__)
SimpleCov.start do
enable_coverage :branc... | ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/updated_files/ruby_app/spec/student_spec.rb | sample_projects/updated_files/ruby_app/spec/student_spec.rb | # frozen_string_literal: true
require 'securerandom'
require_relative '../app/student'
RSpec.describe Student do
let(:registration_id) { SecureRandom.uuid }
subject { Student.new(registration_id) }
describe '#name=' do
context 'without name' do
it 'does not set name' do
expect { subject.name... | ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/calculator_app/app/calculator.rb | sample_projects/calculator_app/app/calculator.rb | # frozen_string_literal: true
module Calculator
module_function
def add(a, b) a + b; end
def sub(a, b) a - b; end
end
| ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/calculator_app/spec/calculator_spec.rb | sample_projects/calculator_app/spec/calculator_spec.rb | # frozen_string_literal: true
require_relative '../app/calculator'
RSpec.describe Calculator do
describe '#add' do
[
[1, 2, 3],
[0, 0, 0],
[5, 32, 37],
[-1, -8, -9],
[10, -10, 0]
].each do |a, b, r|
it "adds #{a} and #{b} to #{r}" do
expect(described_class.add(a, ... | ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/calculator_app/spec/spec_helper.rb | sample_projects/calculator_app/spec/spec_helper.rb | # frozen_string_literal: true
require 'simplecov'
SimpleCov.start do
if Gem::Version.new(SimpleCov::VERSION) >= Gem::Version.new('0.15.0')
add_filter %r{^/spec/}
else
add_filter '/spec/'
end
end
require 'rspec_tracer'
RSpecTracer.start
# This file was generated by the `rspec --init` command. Convention... | ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/parallel_tests_ruby_app/app/student.rb | sample_projects/parallel_tests_ruby_app/app/student.rb | # frozen_string_literal: true
require 'set'
class Student
attr_reader :registration_id, :details
def initialize(registration_id)
@registration_id = registration_id
@details = {}
@courses = Set.new
end
def name=(name)
@details[:name] = name if name
end
def email=(email)
@details[:ema... | ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/parallel_tests_ruby_app/app/foo.rb | sample_projects/parallel_tests_ruby_app/app/foo.rb | # frozen_string_literal: true
module Foo
module_function
def foo
'foo'
end
def bar
'bar'
end
def baz
'baz'
end
end
| ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/parallel_tests_ruby_app/app/course.rb | sample_projects/parallel_tests_ruby_app/app/course.rb | # frozen_string_literal: true
require 'set'
class Course
attr_reader :id, :name
def initialize(id, name)
@id = id
@name = name
@students = Set.new
end
def enrolled(student)
return unless student
@students << student
end
def enrolled_students
@students
end
def enrolled_stud... | ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/parallel_tests_ruby_app/spec/student_spec.rb | sample_projects/parallel_tests_ruby_app/spec/student_spec.rb | # frozen_string_literal: true
require 'securerandom'
require_relative '../app/student'
RSpec.describe Student do
let(:registration_id) { SecureRandom.uuid }
subject { Student.new(registration_id) }
describe '#name=' do
context 'without name' do
it 'does not set name' do
expect { subject.name... | ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/parallel_tests_ruby_app/spec/course_spec.rb | sample_projects/parallel_tests_ruby_app/spec/course_spec.rb | # frozen_string_literal: true
require_relative '../app/course'
require_relative '../app/student'
RSpec.describe Course do
subject { Course.new(:rspec_tracer, 'RSpec Tracer') }
describe 'enrolled' do
context 'without student' do
it 'does not enroll' do
expect { subject.enrolled(nil) }.not_to cha... | ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/ruby_app/app/student.rb | sample_projects/ruby_app/app/student.rb | # frozen_string_literal: true
require 'set'
class Student
attr_reader :registration_id, :details
def initialize(registration_id)
@registration_id = registration_id
@details = {}
@courses = Set.new
end
def name=(name)
@details[:name] = name if name
end
def email=(email)
@details[:ema... | ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/ruby_app/app/foo.rb | sample_projects/ruby_app/app/foo.rb | # frozen_string_literal: true
module Foo
module_function
def foo
'foo'
end
def bar
'bar'
end
def baz
'baz'
end
end
| ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/ruby_app/app/course.rb | sample_projects/ruby_app/app/course.rb | # frozen_string_literal: true
require 'set'
class Course
attr_reader :id, :name
def initialize(id, name)
@id = id
@name = name
@students = Set.new
end
def enrolled(student)
return unless student
@students << student
end
def enrolled_students
@students
end
def enrolled_stud... | ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/ruby_app/spec/student_spec.rb | sample_projects/ruby_app/spec/student_spec.rb | # frozen_string_literal: true
require 'securerandom'
require_relative '../app/student'
RSpec.describe Student do
let(:registration_id) { SecureRandom.uuid }
subject { Student.new(registration_id) }
describe '#name=' do
context 'without name' do
it 'does not set name' do
expect { subject.name... | ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/ruby_app/spec/course_spec.rb | sample_projects/ruby_app/spec/course_spec.rb | # frozen_string_literal: true
require_relative '../app/course'
require_relative '../app/student'
RSpec.describe Course do
subject { Course.new(:rspec_tracer, 'RSpec Tracer') }
describe 'enrolled' do
context 'without student' do
it 'does not enroll' do
expect { subject.enrolled(nil) }.not_to cha... | ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/spec_helpers/parallel_tests_ruby_app/with_simplecov_updated.rb | sample_projects/spec_helpers/parallel_tests_ruby_app/with_simplecov_updated.rb | # frozen_string_literal: true
# Dummy comment to change the md5 of the file
require 'simplecov'
SimpleCov.start do
if Gem::Version.new(SimpleCov::VERSION) >= Gem::Version.new('0.15.0')
add_filter %r{^/spec/}
else
add_filter '/spec/'
end
end
require 'rspec_tracer'
RSpecTracer.start do
# Track these fi... | ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
avmnu-sng/rspec-tracer | https://github.com/avmnu-sng/rspec-tracer/blob/568c5e763385187d50b16ff1a95a859f9f288d20/sample_projects/spec_helpers/parallel_tests_ruby_app/with_simplecov.rb | sample_projects/spec_helpers/parallel_tests_ruby_app/with_simplecov.rb | # frozen_string_literal: true
require 'simplecov'
SimpleCov.start do
if Gem::Version.new(SimpleCov::VERSION) >= Gem::Version.new('0.15.0')
add_filter %r{^/spec/}
else
add_filter '/spec/'
end
end
require 'rspec_tracer'
RSpecTracer.start do
# Track these files in the coverage report
coverage_track_fil... | ruby | MIT | 568c5e763385187d50b16ff1a95a859f9f288d20 | 2026-01-04T17:33:26.748049Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.