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 | paper-trail-gem/paper_trail | https://github.com/paper-trail-gem/paper_trail | lib/paper_trail/frameworks/cucumber.rb | Ruby | mit | 6,998 | master | 726 | # frozen_string_literal: true
# before hook for Cucumber
Before do
PaperTrail.enabled = false
PaperTrail.request.enabled = true
PaperTrail.request.whodunnit = nil
PaperTrail.request.controller_info = {} if defined?(Rails)
end
module PaperTrail
module Cucumber
# Helper method for enabling PT in Cucumber ... |
github | paper-trail-gem/paper_trail | https://github.com/paper-trail-gem/paper_trail | lib/paper_trail/frameworks/rspec/helpers.rb | Ruby | mit | 6,998 | master | 798 | # frozen_string_literal: true
module PaperTrail
module RSpec
module Helpers
# Included in the RSpec configuration in `frameworks/rspec.rb`
module InstanceMethods
# enable versioning for specific blocks (at instance-level)
def with_versioning
was_enabled = ::PaperTrail.enable... |
github | paper-trail-gem/paper_trail | https://github.com/paper-trail-gem/paper_trail | lib/paper_trail/frameworks/rails/railtie.rb | Ruby | mit | 6,998 | master | 1,291 | # frozen_string_literal: true
module PaperTrail
# Represents code to load within Rails framework. See documentation in
# `railties/lib/rails/railtie.rb`.
# @api private
class Railtie < ::Rails::Railtie
# PaperTrail only has one initializer.
#
# We specify `before: "load_config_initializers"` to ens... |
github | paper-trail-gem/paper_trail | https://github.com/paper-trail-gem/paper_trail | lib/paper_trail/frameworks/rails/controller.rb | Ruby | mit | 6,998 | master | 3,271 | # frozen_string_literal: true
module PaperTrail
module Rails
# Extensions to rails controllers. Provides convenient ways to pass certain
# information to the model layer, with `controller_info` and `whodunnit`.
# Also includes a convenient on/off switch,
# `paper_trail_enabled_for_controller`.
mo... |
github | paper-trail-gem/paper_trail | https://github.com/paper-trail-gem/paper_trail | lib/paper_trail/frameworks/active_record/models/paper_trail/version.rb | Ruby | mit | 6,998 | master | 544 | # frozen_string_literal: true
require "paper_trail/version_concern"
module PaperTrail
# This is the default ActiveRecord model provided by PaperTrail. Most simple
# applications will use this model as-is, but it is possible to sub-class,
# extend, or even do without this model entirely. See documentation sectio... |
github | paper-trail-gem/paper_trail | https://github.com/paper-trail-gem/paper_trail | lib/paper_trail/attribute_serializers/cast_attribute_serializer.rb | Ruby | mit | 6,998 | master | 1,756 | # frozen_string_literal: true
require "paper_trail/attribute_serializers/attribute_serializer_factory"
module PaperTrail
# :nodoc:
module AttributeSerializers
# The `CastAttributeSerializer` (de)serializes model attribute values. For
# example, the string "1.99" serializes into the integer `1` when assign... |
github | paper-trail-gem/paper_trail | https://github.com/paper-trail-gem/paper_trail | lib/paper_trail/attribute_serializers/object_changes_attribute.rb | Ruby | mit | 6,998 | master | 1,592 | # frozen_string_literal: true
require "paper_trail/attribute_serializers/cast_attribute_serializer"
module PaperTrail
module AttributeSerializers
# Serialize or deserialize the `version.object_changes` column.
class ObjectChangesAttribute
def initialize(item_class)
@item_class = item_class
... |
github | paper-trail-gem/paper_trail | https://github.com/paper-trail-gem/paper_trail | lib/paper_trail/attribute_serializers/object_attribute.rb | Ruby | mit | 6,998 | master | 1,456 | # frozen_string_literal: true
require "paper_trail/attribute_serializers/cast_attribute_serializer"
module PaperTrail
module AttributeSerializers
# Serialize or deserialize the `version.object` column.
class ObjectAttribute
def initialize(model_class)
@model_class = model_class
# Acti... |
github | paper-trail-gem/paper_trail | https://github.com/paper-trail-gem/paper_trail | lib/paper_trail/attribute_serializers/attribute_serializer_factory.rb | Ruby | mit | 6,998 | master | 1,193 | # frozen_string_literal: true
require "paper_trail/type_serializers/postgres_array_serializer"
module PaperTrail
module AttributeSerializers
# Values returned by some Active Record serializers are
# not suited for writing JSON to a text column. This factory
# replaces certain default Active Record seria... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | Rakefile | Ruby | bsd-2-clause | 6,973 | master | 12,745 | require 'rake'
require 'fileutils'
require File.join(File.dirname(__FILE__), 'bin', 'yadr', 'vundle')
desc "Hook our dotfiles into system-standard positions."
task :install => [:submodule_init, :submodules] do
puts
puts "======================================================"
puts "Welcome to YADR Installation."... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/marky.rb | Ruby | bsd-2-clause | 6,973 | master | 8,588 | #!/usr/bin/env ruby
# source http://brettterpstra.com/marky-the-markdownifier-reintroductions/
require 'open-uri'
require 'net/http'
require 'iconv'
require 'optparse'
require 'fileutils'
require 'cgi'
$options = {}
# $fymdhost = "http://fym.dev"
$fymdhost = "http://heckyesmarkdown.com"
optparse = OptionParser.new ... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/vundle.rb | Ruby | bsd-2-clause | 6,973 | master | 1,580 | require 'fileutils'
module Vundle
@vundles_path = File.expand_path File.join(ENV['HOME'], '.vim', '.vundles.local')
def self.add_plugin_to_vundle(plugin_repo)
return if contains_vundle? plugin_repo
vundles = vundles_from_file
last_bundle_dir = vundles.rindex{ |line| line =~ /^Bundle / }
last_bundl... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/git-style-binaries-0.1.11/Rakefile | Ruby | bsd-2-clause | 6,973 | master | 1,877 | require 'rubygems'
require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "git-style-binaries"
gem.description = %Q{Ridiculously easy git-style binaries}
gem.summary =<<-EOF
Add git-style binaries to your project easily.
EOF
gem.email = "nate@natemurray.com"
gem.... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary.rb | Ruby | bsd-2-clause | 6,973 | master | 2,016 | $:.unshift(File.dirname(__FILE__))
require 'rubygems'
# Load the vendor gems
$:.unshift(File.dirname(__FILE__) + "/../vendor/gems")
%w(trollop).each do |library|
begin
require "#{library}/lib/#{library}"
rescue LoadError
begin
require 'trollop'
rescue LoadError
puts "There was an error load... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/git-style-binaries-0.1.11/lib/ext/colorize.rb | Ruby | bsd-2-clause | 6,973 | master | 4,810 | #
# Colorize String class extension.
#
class String
#
# Version string
#
COLORIZE_VERSION = '0.5.6'
#
# Colors Hash
#
COLORS = {
:black => 0,
:red => 1,
:green => 2,
:yellow => 3,
:blue => 4,
:magenta => 5,
:cyan ... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/git-style-binaries-0.1.11/lib/ext/core.rb | Ruby | bsd-2-clause | 6,973 | master | 248 | class Object
def returning(value)
yield(value)
value
end unless Object.respond_to?(:returning)
end
class Symbol
def to_proc
Proc.new { |*args| args.shift.__send__(self, *args) }
end
end
class IO
attr_accessor :use_color
end |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/command.rb | Ruby | bsd-2-clause | 6,973 | master | 5,621 | require 'git-style-binary'
module GitStyleBinary
def self.command(&block)
returning Command.new(:constraints => [block]) do |c|
c.name ||= (GitStyleBinary.name_of_command_being_loaded || GitStyleBinary.current_command_name)
GitStyleBinary.known_commands[c.name] = c
if !GitStyleBinary.current_c... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/autorunner.rb | Ruby | bsd-2-clause | 6,973 | master | 323 | require 'git-style-binary/parser'
module GitStyleBinary
class AutoRunner
def self.run(argv=ARGV)
r = new
r.run
end
def run
unless GitStyleBinary.run?
if !GitStyleBinary.current_command
GitStyleBinary.load_primary
end
GitStyleBinary.current_command.run
end
end
end
e... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/parser.rb | Ruby | bsd-2-clause | 6,973 | master | 5,986 | module GitStyleBinary
class Parser < Trollop::Parser
attr_reader :runs, :callbacks
attr_reader :short_desc
attr_accessor :command
def initialize *a, &b
super
@runs = []
setup_callbacks
end
def setup_callbacks
@callbacks = {}
%w(run).each do |event|
%w(before after).each do... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/commands/help.rb | Ruby | bsd-2-clause | 6,973 | master | 998 | module GitStyleBinary
module Commands
class Help
# not loving this syntax, but works for now
GitStyleBinary.command do
short_desc "get help for a specific command"
run do |command|
# this is slightly ugly b/c it has to muck around in the internals to
# get informat... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/helpers/name_resolver.rb | Ruby | bsd-2-clause | 6,973 | master | 2,475 | module GitStyleBinary
module Helpers
module NameResolver
def basename(filename=zero)
File.basename(filename).match(/(.*?)(\-|$)/).captures.first
end
alias_method :primary_name, :basename
# checks the bin directory for all files starting with +basename+ and
# returns an array of strings spe... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/git-style-binaries-0.1.11/lib/git-style-binary/helpers/pager.rb | Ruby | bsd-2-clause | 6,973 | master | 926 | module GitStyleBinary
module Helpers
module Pager
# by Nathan Weizenbaum - http://nex-3.com/posts/73-git-style-automatic-paging-in-ruby
def run_pager
return if RUBY_PLATFORM =~ /win32/
return unless STDOUT.tty?
STDOUT.use_color = true
read, write = IO.pipe
un... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/git-style-binaries-0.1.11/test/running_binaries_test.rb | Ruby | bsd-2-clause | 6,973 | master | 6,615 | require File.dirname(__FILE__) + "/test_helper.rb"
THIS_YEAR=Time.now.year # todo
class RunningBinariesTest < Test::Unit::TestCase
include RunsBinaryFixtures
context "when running primary" do
["wordpress -h", "wordpress help"].each do |format|
context "and getting help as a '#{format}'" do
setu... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/git-style-binaries-0.1.11/test/test_helper.rb | Ruby | bsd-2-clause | 6,973 | master | 728 | require 'rubygems'
require 'test/unit'
require 'shoulda'
begin require 'redgreen'; rescue LoadError; end
require 'open3'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
Dir[File.join(File.dirname(__FILE__), "shoulda_macros", "*.rb")].each {|f| require f}
EN... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/git-style-binaries-0.1.11/test/git_style_binary_test.rb | Ruby | bsd-2-clause | 6,973 | master | 1,006 | require File.dirname(__FILE__) + "/test_helper.rb"
class GitStyleBinariesTest < Test::Unit::TestCase
context "parsing basenames" do
should "accurately parse basenames" do
assert_equal "wordpress", GitStyleBinary.basename("bin/wordpress")
assert_equal "wordpress", GitStyleBinary.basename("bin/wordpres... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/git-style-binaries-0.1.11/test/git-style-binary/command_test.rb | Ruby | bsd-2-clause | 6,973 | master | 401 | require File.dirname(__FILE__) + "/../test_helper.rb"
require 'git-style-binary/command'
class CommandTest < Test::Unit::TestCase
context "cmd" do
setup do
@c = GitStyleBinary::Command.new
end
should "be able to easily work with constraints" do
assert_equal @c.constraints, []
@c.constr... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/git-style-binaries-0.1.11/test/shoulda_macros/matching_stdio.rb | Ruby | bsd-2-clause | 6,973 | master | 316 | class Test::Unit::TestCase
def output_should_match(regexp)
assert_match regexp, @stdout + @stderr
end
alias_method :output_matches, :output_should_match
def stdout_should_match(regexp)
assert_match regexp, @stdout
end
def stderr_should_match(regexp)
assert_match regexp, @stderr
end
end |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/trollop-1.16.2/lib/trollop.rb | Ruby | bsd-2-clause | 6,973 | master | 27,225 | ## lib/trollop.rb -- trollop command-line processing library
## Author:: William Morgan (mailto: wmorgan-trollop@masanjin.net)
## Copyright:: Copyright 2007 William Morgan
## License:: the same terms as ruby itself
require 'date'
module Trollop
VERSION = "1.16.2"
## Thrown by Parser in the event of a commandli... |
github | skwp/dotfiles | https://github.com/skwp/dotfiles | bin/yadr/lib/trollop-1.16.2/test/test_trollop.rb | Ruby | bsd-2-clause | 6,973 | master | 37,325 | ## test/test_trollop.rb -- unit tests for trollop
## Author:: William Morgan (mailto: wmorgan-trollop@masanjin.net)
## Copyright:: Copyright 2007 William Morgan
## License:: GNU GPL version 2
require 'test/unit'
require 'stringio'
require 'trollop'
module Trollop
module Test
class Trollop < ::Test::Unit::TestCa... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | Rakefile | Ruby | mit | 6,872 | master | 1,392 | require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "better_errors/error_page_style"
RSpec::Core::RakeTask.new(:test)
task :default => :test
def gemfiles
@gemfiles ||= Dir[File.dirname(__FILE__) + '/gemfiles/*.gemfile']
end
def with_each_gemfile
gemfiles.each do |gemfile|
Bundler.with_clean_en... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | better_errors.gemspec | Ruby | mit | 6,872 | master | 2,040 | lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'better_errors/version'
Gem::Specification.new do |s|
s.name = "better_errors"
s.version = BetterErrors::VERSION
s.authors = ["Hailey Somerville"]
s.email = ["hailey@hailey.lo... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors.rb | Ruby | mit | 6,872 | master | 4,603 | require "pp"
require "erubi"
require "uri"
require "better_errors/version"
require "better_errors/code_formatter"
require "better_errors/inspectable_value"
require "better_errors/error_page"
require "better_errors/middleware"
require "better_errors/raised_exception"
require "better_errors/repl"
require "better_errors/... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/rails.rb | Ruby | mit | 6,872 | master | 718 | module BetterErrors
# @private
class Railtie < Rails::Railtie
initializer "better_errors.configure_rails_initialization" do
if use_better_errors?
insert_middleware
BetterErrors.logger = Rails.logger
BetterErrors.application_root = Rails.root.to_s
end
end
def insert_m... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/editor.rb | Ruby | mit | 6,872 | master | 3,499 | require "uri"
module BetterErrors
class Editor
KNOWN_EDITORS = [
{ symbols: [:atom], sniff: /atom/i, url: "atom://core/open/file?filename=%{file}&line=%{line}" },
{ symbols: [:emacs, :emacsclient], sniff: /emacs/i, url: "emacs://open?url=file://%{file}&line=%{line}" },
{ symbols: [:idea], sniff... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/stack_frame.rb | Ruby | mit | 6,872 | master | 3,367 | require "set"
module BetterErrors
# @private
class StackFrame
def self.from_exception(exception)
RaisedException.new(exception).backtrace
end
attr_reader :filename, :line, :name, :frame_binding
def initialize(filename, line, name, frame_binding = nil)
@filename = filename
... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/error_page.rb | Ruby | mit | 6,872 | master | 4,728 | require "cgi"
require "json"
require "securerandom"
require "rouge"
require "better_errors/error_page_style"
module BetterErrors
# @private
class ErrorPage
VariableInfo = Struct.new(:frame, :editor_url, :rails_params, :rack_session, :start_time)
def self.template_path(template_name)
File.expand_path... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/exception_hint.rb | Ruby | mit | 6,872 | master | 900 | module BetterErrors
class ExceptionHint
def initialize(exception)
@exception = exception
end
def hint
case exception
when NoMethodError
/\Aundefined method `(?<method>[^']+)' for (?<val>[^:]+):(?<klass>\w+)/.match(exception.message) do |match|
if match[:val] == "nil"
... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/raised_exception.rb | Ruby | mit | 6,872 | master | 2,970 | require 'better_errors/exception_hint'
# @private
module BetterErrors
class RaisedException
attr_reader :exception, :message, :backtrace, :hint
def initialize(exception)
if exception.class.name == "ActionView::Template::Error" && exception.respond_to?(:cause)
# Rails 6+ exceptions of this type... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/error_page_style.rb | Ruby | mit | 6,872 | master | 1,662 | module BetterErrors
# @private
module ErrorPageStyle
def self.compiled_css(for_deployment = false)
begin
require "sassc"
rescue LoadError
raise LoadError, "The `sassc` gem is required when developing the `better_errors` gem. "\
"If you're using a release of `better_errors`,... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/inspectable_value.rb | Ruby | mit | 6,872 | master | 1,063 | require "cgi"
require "objspace" rescue nil
module BetterErrors
class ValueLargerThanConfiguredMaximum < StandardError; end
class InspectableValue
def initialize(value)
@original_value = value
end
def to_html
raise ValueLargerThanConfiguredMaximum unless value_small_enough_to_inspect?
... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/code_formatter.rb | Ruby | mit | 6,872 | master | 1,076 | module BetterErrors
# @private
class CodeFormatter
require "better_errors/code_formatter/html"
require "better_errors/code_formatter/text"
attr_reader :filename, :line, :context
def initialize(filename, line, context = 5)
@filename = filename
@line = line
@context = context
... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/exception_extension.rb | Ruby | mit | 6,872 | master | 376 | module BetterErrors
module ExceptionExtension
prepend_features Exception
def set_backtrace(*)
if caller_locations.none? { |loc| loc.path == __FILE__ }
@__better_errors_bindings_stack = ::Kernel.binding.callers.drop(1)
end
super
end
def __better_errors_bindings_stack
... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/middleware.rb | Ruby | mit | 6,872 | master | 8,133 | require "json"
require "ipaddr"
require "securerandom"
require "set"
require "rack"
module BetterErrors
# Better Errors' error handling middleware. Including this in your middleware
# stack will show a Better Errors error page for exceptions raised below this
# middleware.
#
# If you are using Ruby on Rails,... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/repl.rb | Ruby | mit | 6,872 | master | 711 | module BetterErrors
# @private
module REPL
PROVIDERS = [
{ impl: "better_errors/repl/basic",
const: :Basic },
]
def self.provider
@provider ||= const_get detect[:const]
end
def self.provider=(prov)
@provider = prov
end
def self.detect
PROVIDERS... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/repl/pry.rb | Ruby | mit | 6,872 | master | 1,913 | require "fiber"
require "pry"
module BetterErrors
module REPL
class Pry
class Input
def readline
Fiber.yield
end
end
class Output
def initialize
@buffer = ""
end
def puts(*args)
args.each do |arg|
@buffer << "#{... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/repl/basic.rb | Ruby | mit | 6,872 | master | 403 | module BetterErrors
module REPL
class Basic
def initialize(binding, _exception)
@binding = binding
end
def send_input(str)
[execute(str), ">>", ""]
end
private
def execute(str)
"=> #{@binding.eval(str).inspect}\n"
rescue Exception => e
"!! ... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/code_formatter/text.rb | Ruby | mit | 6,872 | master | 338 | module BetterErrors
# @private
class CodeFormatter::Text < CodeFormatter
def source_unavailable
"# Source is not available"
end
def formatted_lines
each_line_of(context_lines) { |highlight, current_line, str|
sprintf '%s %3d %s', (highlight ? '>' : ' '), current_line, str
}
... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | lib/better_errors/code_formatter/html.rb | Ruby | mit | 6,872 | master | 1,073 | require "rouge"
module BetterErrors
# @private
class CodeFormatter::HTML < CodeFormatter
def source_unavailable
"<p class='unavailable'>Source is not available</p>"
end
def formatted_lines
each_line_of(highlighted_lines) { |highlight, current_line, str|
class_name = highlight ? "hi... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | spec/better_errors_spec.rb | Ruby | mit | 6,872 | master | 2,152 | require "spec_helper"
RSpec.describe BetterErrors do
describe ".editor" do
context "when set to a specific value" do
before do
allow(BetterErrors::Editor).to receive(:editor_from_symbol).and_return(:editor_from_symbol)
allow(BetterErrors::Editor).to receive(:for_formatting_string).and_retur... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | spec/without_binding_of_caller.rb | Ruby | mit | 6,872 | master | 204 | module Kernel
alias_method :require_with_binding_of_caller, :require
def require(feature)
raise LoadError if feature == "binding_of_caller"
require_with_binding_of_caller(feature)
end
end |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | spec/spec_helper.rb | Ruby | mit | 6,872 | master | 922 | $: << File.expand_path("../../lib", __FILE__)
ENV["EDITOR"] = nil
ENV["BETTER_ERRORS"] = nil
require 'simplecov'
require 'simplecov-lcov'
# Fix incompatibility of simplecov-lcov with older versions of simplecov that are not expresses in its gemspec.
# https://github.com/fortissimo1997/simplecov-lcov/pull/25
if !Simp... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | spec/better_errors/raised_exception_spec.rb | Ruby | mit | 6,872 | master | 4,633 | require "spec_helper"
require "rspec/its"
module BetterErrors
describe RaisedException do
let(:exception) { RuntimeError.new("whoops") }
subject(:described_instance) { RaisedException.new(exception) }
before do
allow(BetterErrors::ExceptionHint).to receive(:new).and_return(exception_hint)
end
... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | spec/better_errors/error_page_spec.rb | Ruby | mit | 6,872 | master | 16,937 | require "spec_helper"
class ErrorPageTestIgnoredClass; end
module BetterErrors
describe ErrorPage do
# It's necessary to use HTML matchers here that are specific as possible.
# This is because if there's an exception within this file, the lines of code will be reflected in the
# generated HTML, so any s... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | spec/better_errors/stack_frame_spec.rb | Ruby | mit | 6,872 | master | 6,588 | require "spec_helper"
module BetterErrors
describe StackFrame do
context "#application?" do
it "is true for application filenames" do
allow(BetterErrors).to receive(:application_root).and_return("/abc/xyz")
frame = StackFrame.new("/abc/xyz/app/controllers/crap_controller.rb", 123, "index")
... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | spec/better_errors/middleware_spec.rb | Ruby | mit | 6,872 | master | 18,888 | require "spec_helper"
module BetterErrors
describe Middleware do
let(:app) { Middleware.new(->env { ":)" }) }
let(:exception) { RuntimeError.new("oh no :(") }
let(:status) { response_env[0] }
let(:headers) { response_env[1] }
let(:body) { response_env[2].join }
context 'when the application ... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | spec/better_errors/exception_hint_spec.rb | Ruby | mit | 6,872 | master | 1,179 | require 'spec_helper'
RSpec.describe BetterErrors::ExceptionHint do
let(:described_instance) { described_class.new(exception) }
describe '#hint' do
subject(:hint) { described_instance.hint }
context "when the exception is a NameError" do
let(:exception) {
begin
foo
rescue ... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | spec/better_errors/editor_spec.rb | Ruby | mit | 6,872 | master | 8,032 | require "spec_helper"
RSpec.describe BetterErrors::Editor do
describe ".for_formatting_string" do
it "returns an object that reponds to #url" do
editor = described_class.for_formatting_string("custom://%{file}:%{file_unencoded}:%{line}")
expect(editor.url("/path&file", 42)).to eq("custom://%2Fpath%26... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | spec/better_errors/repl/basic_spec.rb | Ruby | mit | 6,872 | master | 452 | require "spec_helper"
require "better_errors/repl/basic"
require "better_errors/repl/shared_examples"
module BetterErrors
module REPL
describe Basic do
let(:fresh_binding) {
local_a = 123
binding
}
let!(:exception) { raise ZeroDivisionError, "you divided by zero you silly goose... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | spec/better_errors/repl/pry_spec.rb | Ruby | mit | 6,872 | master | 1,543 | require "spec_helper"
require "better_errors/repl/shared_examples"
if defined? ::Pry
RSpec.describe 'BetterErrors::REPL::Pry' do
before(:all) do
load "better_errors/repl/pry.rb"
end
after(:all) do
# Ensure the Pry REPL file has not been included. If this is not done,
# the constant leak... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | spec/better_errors/repl/shared_examples.rb | Ruby | mit | 6,872 | master | 566 | shared_examples_for "a REPL provider" do
it "evaluates ruby code in a given context" do
repl.send_input("local_a = 456")
expect(fresh_binding.eval("local_a")).to eq(456)
end
it "returns a tuple of output and the new prompt" do
output, prompt = repl.send_input("1 + 2")
expect(output).to eq("=> 3\n... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | spec/better_errors/code_formatter/text_spec.rb | Ruby | mit | 6,872 | master | 1,604 | require "spec_helper"
RSpec.describe BetterErrors::CodeFormatter::Text do
let(:filename) { File.expand_path("../../support/my_source.rb", __FILE__) }
let(:line) { 8 }
let(:formatter) { described_class.new(filename, line) }
it "shows 5 lines of context" do
expect(formatter.line_range).to eq(3..13)
exp... |
github | BetterErrors/better_errors | https://github.com/BetterErrors/better_errors | spec/better_errors/code_formatter/html_spec.rb | Ruby | mit | 6,872 | master | 1,474 | require "spec_helper"
RSpec.describe BetterErrors::CodeFormatter::HTML do
let(:filename) { File.expand_path("../../support/my_source.rb", __FILE__) }
let(:line) { 8 }
let(:formatter) { described_class.new(filename, line) }
it "shows 5 lines of context above and below the line" do
expect(formatter.line_ran... |
github | sj26/mailcatcher | https://github.com/sj26/mailcatcher | Rakefile | Ruby | mit | 6,771 | main | 2,362 | # frozen_string_literal: true
require "fileutils"
require "rubygems"
require "mail_catcher/version"
# XXX: Would prefer to use Rake::SprocketsTask but can't populate
# non-digest assets, and we don't want sprockets at runtime so
# can't use manifest directly. Perhaps index.html should be
# precompiled with digest as... |
github | sj26/mailcatcher | https://github.com/sj26/mailcatcher | mailcatcher.gemspec | Ruby | mit | 6,771 | main | 1,951 | # frozen_string_literal: true
require File.expand_path("../lib/mail_catcher/version", __FILE__)
Gem::Specification.new do |s|
s.name = "mailcatcher"
s.version = MailCatcher::VERSION
s.license = "MIT"
s.summary = "Runs an SMTP server, catches and displays email in a web interface."
s.description = <<-END
... |
github | sj26/mailcatcher | https://github.com/sj26/mailcatcher | spec/command_spec.rb | Ruby | mit | 6,771 | main | 626 | require "spec_helper"
RSpec.describe "mailcatcher command" do
context "--version" do
it "shows a version then exits" do
expect { system %(mailcatcher --version) }
.to output(a_string_including("MailCatcher v#{MailCatcher::VERSION}"))
.to_stdout_from_any_process
end
end
context "--h... |
github | sj26/mailcatcher | https://github.com/sj26/mailcatcher | spec/spec_helper.rb | Ruby | mit | 6,771 | main | 3,718 | # frozen_string_literal: true
ENV["MAILCATCHER_ENV"] ||= "test"
require "capybara/rspec"
require "capybara-screenshot/rspec"
require "selenium/webdriver"
require "net/smtp"
require "socket"
require "mail_catcher"
DEFAULT_FROM = "from@example.com"
DEFAULT_TO = "to@example.com"
LOCALHOST = "127.0.0.1"
SMTP_PORT = 2... |
github | sj26/mailcatcher | https://github.com/sj26/mailcatcher | spec/clear_spec.rb | Ruby | mit | 6,771 | main | 869 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe "Clear", type: :feature do
it "clears all messages" do
# Delivering three emails ..
deliver_example("plainmail")
deliver_example("plainmail")
deliver_example("plainmail")
# .. should display three emails
expect(page).to have... |
github | sj26/mailcatcher | https://github.com/sj26/mailcatcher | spec/delivery_spec.rb | Ruby | mit | 6,771 | main | 8,600 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MailCatcher, type: :feature do
def messages_element
page.find("#messages")
end
def message_row_element
messages_element.find(:xpath, ".//table/tbody/tr[1]")
end
def message_from_element
message_row_element.find(:xpath, ".//td[1... |
github | sj26/mailcatcher | https://github.com/sj26/mailcatcher | spec/quit_spec.rb | Ruby | mit | 6,771 | main | 1,104 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe "Quit", type: :feature do
it "quits cleanly via the Quit button" do
# Quitting and cancelling ..
dismiss_confirm do
click_on "Quit"
end
# .. should not exit the process
expect { Process.kill(0, @pid) }.not_to raise_error
... |
github | sj26/mailcatcher | https://github.com/sj26/mailcatcher | lib/mail_catcher.rb | Ruby | mit | 6,771 | main | 6,838 | # frozen_string_literal: true
require "open3"
require "optparse"
require "rbconfig"
require "eventmachine"
require "thin"
module EventMachine
# Monkey patch fix for 10deb4
# See https://github.com/eventmachine/eventmachine/issues/569
def self.reactor_running?
(@reactor_running || false)
end
end
require ... |
github | sj26/mailcatcher | https://github.com/sj26/mailcatcher | lib/mail_catcher/mail.rb | Ruby | mit | 6,771 | main | 6,699 | # frozen_string_literal: true
require "eventmachine"
require "json"
require "mail"
require "sqlite3"
module MailCatcher::Mail extend self
def db
@__db ||= begin
SQLite3::Database.new(":memory:", :type_translation => true).tap do |db|
db.execute(<<-SQL)
CREATE TABLE message (
... |
github | sj26/mailcatcher | https://github.com/sj26/mailcatcher | lib/mail_catcher/smtp.rb | Ruby | mit | 6,771 | main | 1,562 | # frozen_string_literal: true
require "eventmachine"
require "mail_catcher/mail"
class MailCatcher::Smtp < EventMachine::Protocols::SmtpServer
# We override EM's mail from processing to allow multiple mail-from commands
# per [RFC 2821](https://tools.ietf.org/html/rfc2821#section-4.1.1.2)
def process_mail_from... |
github | sj26/mailcatcher | https://github.com/sj26/mailcatcher | lib/mail_catcher/web.rb | Ruby | mit | 6,771 | main | 654 | # frozen_string_literal: true
require "rack/builder"
require "mail_catcher/web/application"
module MailCatcher
module Web extend self
def app
@@app ||= Rack::Builder.new do
map(MailCatcher.options[:http_path]) do
if MailCatcher.development?
require "mail_catcher/web/assets"
... |
github | sj26/mailcatcher | https://github.com/sj26/mailcatcher | lib/mail_catcher/web/assets.rb | Ruby | mit | 6,771 | main | 360 | # frozen_string_literal: true
require "sprockets"
require "sprockets-sass"
require "compass"
module MailCatcher
module Web
Assets = Sprockets::Environment.new(File.expand_path("#{__FILE__}/../../../..")).tap do |sprockets|
Dir["#{sprockets.root}/{,vendor}/assets/*"].each do |path|
sprockets.append... |
github | sj26/mailcatcher | https://github.com/sj26/mailcatcher | lib/mail_catcher/web/application.rb | Ruby | mit | 6,771 | main | 4,857 | # frozen_string_literal: true
require "pathname"
require "net/http"
require "uri"
require "faye/websocket"
require "sinatra"
require "mail_catcher/bus"
require "mail_catcher/mail"
Faye::WebSocket.load_adapter("thin")
# Faye's adapter isn't smart enough to close websockets when thin is stopped,
# so we teach it to ... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | Gemfile | Ruby | mit | 6,741 | main | 255 | source "https://rubygems.org"
gemspec name: "dotenv"
gemspec name: "dotenv-rails"
gem "railties", "~> #{ENV["RAILS_VERSION"] || "7.1"}"
gem "benchmark-ips"
gem "stackprof"
group :guard do
gem "guard-rspec"
gem "guard-bundler"
gem "rb-fsevent"
end |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | dotenv.gemspec | Ruby | mit | 6,741 | main | 858 | require File.expand_path("../lib/dotenv/version", __FILE__)
require "English"
Gem::Specification.new "dotenv", Dotenv::VERSION do |gem|
gem.authors = ["Brandon Keepers"]
gem.email = ["brandon@opensoul.org"]
gem.description = gem.summary = "Loads environment variables from `.env`."
gem.homepage = "https://githu... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | Rakefile | Ruby | mit | 6,741 | main | 825 | #!/usr/bin/env rake
require "bundler/gem_helper"
require "rspec/core/rake_task"
require "rake/testtask"
require "standard/rake"
namespace "dotenv" do
Bundler::GemHelper.install_tasks name: "dotenv"
end
class DotenvRailsGemHelper < Bundler::GemHelper
def guard_already_tagged
# noop
end
def tag_version
... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | Guardfile | Ruby | mit | 6,741 | main | 227 | guard "bundler" do
watch("Gemfile")
end
guard "rspec", cmd: "bundle exec rspec" do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^spec/spec_helper.rb$}) { "spec" }
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
end |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | dotenv-rails.gemspec | Ruby | mit | 6,741 | main | 742 | require File.expand_path("../lib/dotenv/version", __FILE__)
require "English"
Gem::Specification.new "dotenv-rails", Dotenv::VERSION do |gem|
gem.authors = ["Brandon Keepers"]
gem.email = ["brandon@opensoul.org"]
gem.description = gem.summary = "Autoload dotenv in Rails."
gem.homepage = "https://github.com/bke... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | test/autorestore_test.rb | Ruby | mit | 6,741 | main | 516 | require "active_support" # Rails 6.1 fails if this is not loaded
require "active_support/test_case"
require "minitest/autorun"
require "dotenv"
require "dotenv/autorestore"
class AutorestoreTest < ActiveSupport::TestCase
test "restores ENV between tests, part 1" do
assert_nil ENV["DOTENV"], "ENV was not restore... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | spec/spec_helper.rb | Ruby | mit | 6,741 | main | 404 | require "dotenv"
require "dotenv/autorestore"
require "tmpdir"
def fixture_path(*parts)
Pathname.new(__dir__).join("./fixtures", *parts)
end
# Capture output to $stdout and $stderr
def capture_output(&_block)
original_stderr = $stderr
original_stdout = $stdout
output = $stderr = $stdout = StringIO.new
yield... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | spec/dotenv_spec.rb | Ruby | mit | 6,741 | main | 11,423 | require "spec_helper"
describe Dotenv do
before do
Dir.chdir(File.expand_path("../fixtures", __FILE__))
end
shared_examples "load" do
context "with no args" do
let(:env_files) { [] }
it "defaults to .env" do
expect(Dotenv::Environment).to receive(:new).with(expand(".env"), anything)... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | spec/dotenv/rails_spec.rb | Ruby | mit | 6,741 | main | 6,324 | require "spec_helper"
require "rails"
require "dotenv/rails"
describe Dotenv::Rails do
let(:log_output) { StringIO.new }
let(:application) do
log_output = self.log_output
Class.new(Rails::Application) do
config.load_defaults Rails::VERSION::STRING.to_f
config.eager_load = false
config.log... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | spec/dotenv/parser_spec.rb | Ruby | mit | 6,741 | main | 9,531 | require "spec_helper"
describe Dotenv::Parser do
def env(...)
Dotenv::Parser.call(...)
end
it "parses unquoted values" do
expect(env("FOO=bar")).to eql("FOO" => "bar")
end
it "parses unquoted values with spaces after seperator" do
expect(env("FOO= bar")).to eql("FOO" => "bar")
end
it "pars... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | spec/dotenv/log_subscriber_spec.rb | Ruby | mit | 6,741 | main | 2,010 | require "spec_helper"
require "active_support/all"
require "rails"
require "dotenv/rails"
describe Dotenv::LogSubscriber do
let(:logs) { StringIO.new }
before do
Dotenv.instrumenter = ActiveSupport::Notifications
Dotenv::Rails.logger = Logger.new(logs)
end
describe "load" do
it "logs when a file ... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | spec/dotenv/environment_spec.rb | Ruby | mit | 6,741 | main | 612 | require "spec_helper"
describe Dotenv::Environment do
subject { env("OPTION_A=1\nOPTION_B=2") }
describe "initialize" do
it "reads the file" do
expect(subject["OPTION_A"]).to eq("1")
expect(subject["OPTION_B"]).to eq("2")
end
it "fails if file does not exist" do
expect do
Do... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | spec/dotenv/diff_spec.rb | Ruby | mit | 6,741 | main | 1,389 | require "spec_helper"
describe Dotenv::Diff do
let(:before) { {} }
let(:after) { {} }
subject { Dotenv::Diff.new(a: before, b: after) }
context "no changes" do
let(:before) { {"A" => 1} }
let(:after) { {"A" => 1} }
it { expect(subject.added).to eq({}) }
it { expect(subject.removed).to eq({}) ... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | spec/dotenv/cli_spec.rb | Ruby | mit | 6,741 | main | 4,989 | require "spec_helper"
require "dotenv/cli"
describe "dotenv binary" do
before do
Dir.chdir(File.expand_path("../../fixtures", __FILE__))
end
def run(*args)
Dotenv::CLI.new(args).run
end
it "loads from .env by default" do
expect(ENV).not_to have_key("DOTENV")
run
expect(ENV).to have_key(... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | lib/dotenv.rb | Ruby | mit | 6,741 | main | 4,854 | require "dotenv/version"
require "dotenv/parser"
require "dotenv/environment"
require "dotenv/missing_keys"
require "dotenv/diff"
# Shim to load environment variables from `.env files into `ENV`.
module Dotenv
extend self
# An internal monitor to synchronize access to ENV in multi-threaded environments.
SEMAPHO... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | lib/dotenv/replay_logger.rb | Ruby | mit | 6,741 | main | 553 | module Dotenv
# A logger that can be used before the apps real logger is initialized.
class ReplayLogger < Logger
def initialize
super(nil) # Doesn't matter what this is, it won't be used.
@logs = []
end
# Override the add method to store logs so we can replay them to a real logger later.
... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | lib/dotenv/parser.rb | Ruby | mit | 6,741 | main | 3,334 | require "dotenv/substitutions/variable"
require "dotenv/substitutions/command" if RUBY_VERSION > "1.8.7"
module Dotenv
# Error raised when encountering a syntax error while parsing a .env file.
class FormatError < SyntaxError; end
# Parses the `.env` file format into key/value pairs.
# It allows for variable ... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | lib/dotenv/log_subscriber.rb | Ruby | mit | 6,741 | main | 1,473 | require "active_support/log_subscriber"
module Dotenv
# Logs instrumented events
#
# Usage:
# require "active_support/notifications"
# require "dotenv/log_subscriber"
# Dotenv.instrumenter = ActiveSupport::Notifications
#
class LogSubscriber < ActiveSupport::LogSubscriber
attach_to :dotenv
... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | lib/dotenv/rails.rb | Ruby | mit | 6,741 | main | 3,971 | # Since rubygems doesn't support optional dependencies, we have to manually check
unless Gem::Requirement.new(">= 6.1").satisfied_by?(Gem::Version.new(Rails.version))
warn "dotenv 3.0 only supports Rails 6.1 or later. Use dotenv ~> 2.0."
return
end
require "dotenv/replay_logger"
require "dotenv/log_subscriber"
Do... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | lib/dotenv/missing_keys.rb | Ruby | mit | 6,741 | main | 252 | module Dotenv
class Error < StandardError; end
class MissingKeys < Error # :nodoc:
def initialize(keys)
key_word = "key#{"s" if keys.size > 1}"
super("Missing required configuration #{key_word}: #{keys.inspect}")
end
end
end |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | lib/dotenv/rails-now.rb | Ruby | mit | 6,741 | main | 414 | # If you use gems that require environment variables to be set before they are
# loaded, then list `dotenv` in the `Gemfile` before those other gems and
# require `dotenv/load`.
#
# gem "dotenv", require: "dotenv/load"
# gem "gem-that-requires-env-variables"
#
require "dotenv/load"
warn '[DEPRECATION] `require... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | lib/dotenv/cli.rb | Ruby | mit | 6,741 | main | 1,378 | require "dotenv"
require "dotenv/version"
require "dotenv/template"
require "optparse"
module Dotenv
# The `dotenv` command line interface. Run `$ dotenv --help` to see usage.
class CLI < OptionParser
attr_reader :argv, :filenames, :overwrite
def initialize(argv = [])
@argv = argv.dup
@filenam... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | lib/dotenv/autorestore.rb | Ruby | mit | 6,741 | main | 801 | # Automatically restore `ENV` to its original state after
if defined?(RSpec.configure)
RSpec.configure do |config|
# Save ENV before the suite starts
config.before(:suite) { Dotenv.save }
# Restore ENV after each example
config.after { Dotenv.restore }
end
end
if defined?(ActiveSupport)
ActiveS... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | lib/dotenv/environment.rb | Ruby | mit | 6,741 | main | 632 | module Dotenv
# A `.env` file that will be read and parsed into a Hash
class Environment < Hash
attr_reader :filename, :overwrite
# Create a new Environment
#
# @param filename [String] the path to the file to read
# @param overwrite [Boolean] whether the parser should assume existing values wi... |
github | bkeepers/dotenv | https://github.com/bkeepers/dotenv | lib/dotenv/template.rb | Ruby | mit | 6,741 | main | 1,053 | module Dotenv
EXPORT_COMMAND = "export ".freeze
# Class for creating a template from a env file
class EnvTemplate
def initialize(env_file)
@env_file = env_file
end
def create_template
File.open(@env_file, "r") do |env_file|
File.open("#{@env_file}.template", "w") do |env_template|... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.