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 | mhutter/string-similarity | https://github.com/mhutter/string-similarity | Guardfile | Ruby | mit | 92 | master | 218 | guard :rspec, cmd: 'bundle exec rspec' do
watch(%r{^spec/(.*)\/?(.*)_spec\.rb$})
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
end |
github | mhutter/string-similarity | https://github.com/mhutter/string-similarity | Gemfile | Ruby | mit | 92 | master | 207 | source 'https://rubygems.org'
# Specify your gem's dependencies in string-similarity.gemspec
gemspec
group :test do
gem 'guard'
gem 'guard-rspec'
gem 'growl'
gem 'simplecov', :require => false
end |
github | mhutter/string-similarity | https://github.com/mhutter/string-similarity | lib/string/similarity.rb | Ruby | mit | 92 | master | 4,193 | require 'string/similarity/version'
require 'string/similarity_refinements'
# +String::Similarity+ provides various methods for
# calculating string distances.
module String::Similarity
# Calcuate the {https://en.wikipedia.org/wiki/Cosine_similarity
# Cosine similarity} of two strings.
#
# For an explanation o... |
github | mhutter/string-similarity | https://github.com/mhutter/string-similarity | lib/string/similarity_refinements.rb | Ruby | mit | 92 | master | 684 | # provide refinements for the String class
module String::SimilarityRefinements
refine String do
# Returns the cosine similarity to +other+
# @see String::Similarity#cosine
def cosine_similarity_to(other)
String::Similarity.cosine(self, other)
end
# Returns the Levenshtein distance to +othe... |
github | mhutter/string-similarity | https://github.com/mhutter/string-similarity | spec/usage_spec.rb | Ruby | mit | 92 | master | 311 | require 'spec_helper'
RSpec.describe 'loading' do
it 'can be required with string/similarity' do
expect {
require 'string/similarity'
}.to_not raise_error
end
it 'can be required with string-similarity' do
expect {
require 'string-similarity'
}.to_not raise_error
end
end |
github | mhutter/string-similarity | https://github.com/mhutter/string-similarity | spec/spec_helper.rb | Ruby | mit | 92 | master | 731 | require "simplecov"
SimpleCov.add_filter '.bundle'
SimpleCov.add_filter 'spec'
SimpleCov.start
require 'string/similarity'
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
... |
github | mhutter/string-similarity | https://github.com/mhutter/string-similarity | spec/string/similarity_refinements_spec.rb | Ruby | mit | 92 | master | 652 | require 'spec_helper'
RSpec.describe String::SimilarityRefinements do
using String::SimilarityRefinements
it '#cosine_similarity_to calls the appropriate method' do
expect(String::Similarity).to receive(:cosine).with('a', 'b')
'a'.cosine_similarity_to('b')
end
it '#levenshtein_distance_to calls the a... |
github | mhutter/string-similarity | https://github.com/mhutter/string-similarity | spec/string/similarity_spec.rb | Ruby | mit | 92 | master | 4,012 | require 'spec_helper'
RSpec.describe String::Similarity do
let(:klass) { ::String::Similarity }
it 'has a version' do
expect(klass::VERSION).to_not be_nil
end
context '#cosine' do
it 'returns 1.0 for identical strings' do
expect(klass.cosine('foo', 'foo')).to eq 1.0
expect(klass.cosine(''... |
github | arkadiyt/ssrf_filter | https://github.com/arkadiyt/ssrf_filter | ssrf_filter.gemspec | Ruby | mit | 92 | main | 1,372 | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
require 'ssrf_filter/version'
Gem::Specification.new do |gem|
gem.name = 'ssrf_filter'
gem.platform = Gem::Platform::RUBY
gem.version = SsrfFilter::VERSION
gem.authors = ['Arkadiy Tetelman']
gem.required_ruby... |
github | arkadiyt/ssrf_filter | https://github.com/arkadiyt/ssrf_filter | lib/ssrf_filter/ssrf_filter.rb | Ruby | mit | 92 | main | 9,652 | # frozen_string_literal: true
require 'ipaddr'
require 'net/http'
require 'resolv'
require 'uri'
class SsrfFilter
private_class_method def self.prefixlen_from_ipaddr(ipaddr)
mask_addr = ipaddr.instance_variable_get('@mask_addr')
raise ArgumentError, 'Invalid mask' if mask_addr.zero?
while mask_addr.nob... |
github | arkadiyt/ssrf_filter | https://github.com/arkadiyt/ssrf_filter | spec/spec_helper.rb | Ruby | mit | 92 | main | 808 | # frozen_string_literal: true
require 'simplecov'
require 'simplecov-lcov'
SimpleCov.start do
SimpleCov::Formatter::LcovFormatter.config do |c|
c.report_with_single_file = true
c.single_report_path = 'coverage/lcov.info'
end
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov... |
github | arkadiyt/ssrf_filter | https://github.com/arkadiyt/ssrf_filter | spec/lib/ssrf_filter_spec.rb | Ruby | mit | 92 | main | 23,948 | # frozen_string_literal: true
require 'timeout'
require 'webrick/https'
require 'webrick/httpproxy'
describe SsrfFilter do
before :all do
described_class.make_all_class_methods_public!
end
let(:public_ipv4) { IPAddr.new('172.217.6.78') }
let(:private_ipv4) { IPAddr.new('127.0.0.1') }
let(:public_ipv6) ... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | u-attributes.gemspec | Ruby | mit | 92 | main | 1,442 | lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'micro/attributes/version'
Gem::Specification.new do |spec|
spec.name = 'u-attributes'
spec.version = Micro::Attributes::VERSION
spec.authors = ['Rodrigo Serradura']
spec.email ... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | Gemfile | Ruby | mit | 92 | main | 1,057 | source 'https://rubygems.org'
gem 'u-case', '~> 4.5', '>= 4.5.1'
activemodel_version = ENV['ACTIVEMODEL_VERSION']
activemodel = case activemodel_version
when '3.2' then '3.2.22'
when '4.0' then '4.0.13'
when '4.1' then '4.1.16'
when '4.2' then '4.2.11'
... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | lib/micro/attributes.rb | Ruby | mit | 92 | main | 5,216 | # frozen_string_literal: true
require 'kind'
module Micro
module Attributes
require 'micro/attributes/version'
require 'micro/attributes/utils'
require 'micro/attributes/diff'
require 'micro/attributes/macros'
require 'micro/attributes/features'
def self.included(base)
base.extend(::M... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | lib/micro/attributes/macros.rb | Ruby | mit | 92 | main | 6,664 | # frozen_string_literal: true
module Micro
module Attributes
module Macros
module Options
PERMITTED = [
:default, :required, :freeze, :protected, :private, # for all
:validate, :validates, # for ext: activemodel_validations
:accept, :reject... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | lib/micro/attributes/diff.rb | Ruby | mit | 92 | main | 1,764 | # frozen_string_literal: true
module Micro::Attributes
module Diff
class Changes
FROM_TO_SYM = [:from, :to].freeze
FROM_TO_STR = ['from'.freeze, 'to'.freeze].freeze
FROM_TO_ERROR = 'pass the attribute name with the :from and :to values'.freeze
attr_reader :from, :to, :differences
... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | lib/micro/attributes/features.rb | Ruby | mit | 92 | main | 5,383 | # frozen_string_literal: true
module Micro
module Attributes
module With
end
module Features
require 'micro/attributes/features/diff'
require 'micro/attributes/features/accept'
require 'micro/attributes/features/accept/strict'
require 'micro/attributes/features/initialize'
... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | lib/micro/attributes/utils.rb | Ruby | mit | 92 | main | 1,411 | # frozen_string_literal: true
module Micro::Attributes::Utils
module Hashes
extend self
def stringify_keys(arg)
hash = Kind::Hash[arg]
return hash if hash.empty?
return hash.transform_keys(&:to_s) if hash.respond_to?(:transform_keys)
hash.each_with_object({}) { |(key, val), memo| ... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | lib/micro/attributes/features/diff.rb | Ruby | mit | 92 | main | 332 | # frozen_string_literal: true
module Micro::Attributes
module Features
module Diff
def diff_attributes(to)
return Micro::Attributes::Diff::Changes.new(from: self, to: to) if to.is_a?(::Micro::Attributes)
raise ArgumentError, "#{to.inspect} must implement Micro::Attributes"
end
en... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | lib/micro/attributes/features/keys_as_symbol.rb | Ruby | mit | 92 | main | 546 | # frozen_string_literal: true
module Micro::Attributes
module Features
module KeysAsSymbol
module ClassMethods
def attributes_access
:symbol
end
def __attribute_key_check__(value)
Kind::Symbol[value]
end
def __attribute_key_transform__(value)
... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | lib/micro/attributes/features/activemodel_validations.rb | Ruby | mit | 92 | main | 2,056 | # frozen_string_literal: true
module Micro::Attributes
module Features
module ActiveModelValidations
module Standard
private def __call_after_attributes_assign
run_validations!
end
end
module CheckActivemodelValidationErrors
private def __check_activemodel_val... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | lib/micro/attributes/features/accept.rb | Ruby | mit | 92 | main | 4,047 | # frozen_string_literal: true
module Micro::Attributes
module Features
module Accept
def attributes_errors
@__attributes_errors
end
def attributes_errors?
!@__attributes_errors.empty?
end
def rejected_attributes
@__rejected_attributes ||= attributes_errors.... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | lib/micro/attributes/features/initialize.rb | Ruby | mit | 92 | main | 448 | # frozen_string_literal: true
module Micro::Attributes
module Features
module Initialize
def self.included(base)
base.class_eval(<<-RUBY)
def initialize(arg)
self.attributes = arg
end
RUBY
end
def with_attributes(arg)
self.class.new(attri... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | lib/micro/attributes/features/initialize/strict.rb | Ruby | mit | 92 | main | 346 | # frozen_string_literal: true
module Micro::Attributes
module Features
module Initialize
module Strict
module ClassMethods
def attributes_are_all_required?
true
end
end
def self.included(base)
base.send(:extend, ClassMethods)
end
... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | lib/micro/attributes/features/accept/strict.rb | Ruby | mit | 92 | main | 615 | # frozen_string_literal: true
module Micro::Attributes
module Features
module Accept
module Strict
ATTRIBUTES_REJECTED = "One or more attributes were rejected. Errors:\n".freeze
def __call_after_attributes_assign
return unless attributes_errors?
__raise_error_if_found... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | test/test_helper.rb | Ruby | mit | 92 | main | 599 | if RUBY_VERSION >= '2.4.0'
require 'simplecov'
SimpleCov.start do
add_filter '/test/'
enable_coverage :branch if RUBY_VERSION >= '2.5.0'
end
end
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'u-case'
if activemodel_version = ENV['ACTIVEMODEL_VERSION']
if activemodel_version < '... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | test/micro/case_test.rb | Ruby | mit | 92 | main | 3,882 | require 'test_helper'
class Micro::AttributesTest < Minitest::Test
class Add < Micro::Case
attributes 'a', :b
def call!
Success result: { number: a + b }
end
end
def test_add
result = Add.call(a: 1, 'b' => 2)
assert_predicate result, :success?
assert_equal 3, result[:number]
en... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | test/micro/attributes_test.rb | Ruby | mit | 92 | main | 20,567 | require 'digest'
require 'test_helper'
class Micro::AttributesTest < Minitest::Test
class Biz
include Micro::Attributes
attribute :a
attributes :b, :c
def initialize(a, b, c='_c')
@a, @b = a, b
@c = c
end
end
def test_custom_constructor
object = Biz.new('a', nil)
asser... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | test/micro/attributes/private_members_test.rb | Ruby | mit | 92 | main | 1,189 | require 'test_helper'
class Micro::Attributes::PrivateMembersTest < Minitest::Test
class A
include Micro::Attributes
end
class AA < A; end
class AAA < AA; end
class B
include Micro::Attributes.with(:initialize)
end
class BB < B; end
class BBB < BB; end
class C
include Micro::Attribute... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | test/micro/attributes/features_test.rb | Ruby | mit | 92 | main | 11,961 | require 'test_helper'
class Micro::Attributes::FeaturesTest < Minitest::Test
# == Helpers ==
#
With = Micro::Attributes::With
Features = Micro::Attributes::Features
def check_micro_attributes_features(assert:, refute:)
klass = Class.new { include yield }
([::Micro::Attributes] + Array(assert)).each... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | test/micro/attributes/utils_test.rb | Ruby | mit | 92 | main | 3,554 | require 'test_helper'
class Micro::Attributes::UtilsTest < Minitest::Test
def test_stringify_hash_keys
err = assert_raises(Kind::Error) { Micro::Attributes::Utils::Hashes.stringify_keys([]) }
assert_equal('[] expected to be a kind of Hash', err.message)
# --
hash = { :a => 1 }
new_hash = Micr... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | test/micro/attributes/inheritance_test.rb | Ruby | mit | 92 | main | 8,207 | require 'test_helper'
class Micro::Attributes::InheritanceTest < Minitest::Test
class Base
include Micro::Attributes.with(:initialize)
attribute :e
attribute :f, default: 'ƒ'
end
class AnotherClassWithAttributes
include Micro::Attributes
end
def test_base_classes_cant_access_the_methods_to... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | test/micro/attributes/defaults_test.rb | Ruby | mit | 92 | main | 2,791 | require 'test_helper'
class Micro::Attributes::DefaultsTest < Minitest::Test
class Add
include Micro::Attributes.with(:initialize)
attribute :a, default: 1
attribute :b, default: 1
def call
a + b
end
end
def test_defaults_defined_via_the_attribute_methods
assert_equal(2, Add.new(... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | test/micro/attributes/features/keys_as_symbol_test.rb | Ruby | mit | 92 | main | 7,696 | require 'test_helper'
class Micro::Attributes::Features::KeysAsSymbolTest < Minitest::Test
class Bar
include Micro::Attributes.with(:keys_as_symbol)
attribute :a
attribute :b
attributes :c, :d
def initialize(data)
self.attributes = data
end
def a_plus_b
a + b
end
end
... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | test/micro/attributes/features/diff_test.rb | Ruby | mit | 92 | main | 3,529 | require 'test_helper'
class Micro::Attributes::Features::DiffTest < Minitest::Test
class Foo
include Micro::Attributes.with(:initialize, :diff)
attribute :a
attribute 'b'
end
class Bar
include Micro::Attributes.with(:initialize, :diff)
attributes :a, 'b'
end
def setup
@foo_1 = Foo... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | test/micro/attributes/features/accept_test.rb | Ruby | mit | 92 | main | 19,180 | require 'digest'
require 'test_helper'
class Micro::Attributes::Features::AcceptTest < Minitest::Test
class CalcWithIndifferentAccess
include Micro::Attributes.with(:accept)
attribute :a, accept: Numeric
attribute :b, accept: Numeric
attribute :operator, reject: Numeric
def initialize(data)
... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | test/micro/attributes/features/initialize_test.rb | Ruby | mit | 92 | main | 2,807 | require 'test_helper'
class Micro::Attributes::Features::InitializeTest < Minitest::Test
class Foo
include Micro::Attributes::With::Initialize
attribute :a
attribute 'b'
end
class Bar
include Micro::Attributes.with(:initialize, :activemodel_validations)
attribute :a
attribute :b, defau... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | test/micro/attributes/features/activemodel_validations_test.rb | Ruby | mit | 92 | main | 10,831 | require 'test_helper'
class Micro::Attributes::Features::ActiveModelValidationsTest < MiniTest::Test
def test_load_error
Class.new do
include Micro::Attributes::With::ActiveModelValidations
end
assert(true)
end
if ENV.fetch('ACTIVEMODEL_VERSION', '7') < '7'
require 'active_model'
requ... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | test/micro/attributes/features/initialize/strict_test.rb | Ruby | mit | 92 | main | 3,202 | require 'test_helper'
class Micro::Attributes::Features::InitializeStrictTest < Minitest::Test
class Foo
include Micro::Attributes::With::InitializeStrict
attribute :a
attribute 'b'
end
class Bar
include Micro::Attributes.with(initialize: :strict)
attribute :a
attribute :b, default: 'B... |
github | serradura/u-attributes | https://github.com/serradura/u-attributes | test/micro/attributes/features/accept/strict_test.rb | Ruby | mit | 92 | main | 2,460 | require 'test_helper'
class Micro::Attributes::Features::AcceptStrictTest < Minitest::Test
class CalcWithIndifferentAccess
include Micro::Attributes.with(accept: :strict)
attribute :a, accept: Numeric
attribute :b, accept: Numeric
attribute :operator, reject: Numeric
def initialize(data)
... |
github | vasile/GTFS-viz | https://github.com/vasile/GTFS-viz | Rakefile | Ruby | mit | 93 | master | 18,068 | Encoding.default_external = "UTF-8"
require 'json'
require 'csv'
require 'yaml'
require 'sqlite3'
import 'inc/helpers.rb'
import 'inc/gtfs.rb'
import 'inc/ft.rb'
# Allowed characters: letters, digits, -, _
PROJECT_NAME = 'sfmta'
# Path of the repo cloned/downloaded from https://github.com/vasile/transit-map
PATH_TO_... |
github | vasile/GTFS-viz | https://github.com/vasile/GTFS-viz | inc/helpers.rb | Ruby | mit | 93 | master | 263 | class Profiler
@t0 = nil
def self.init(msg = 'START')
@t0 = Time.now
self.save(msg)
end
def self.save(msg)
if @t0.nil?
self.init
end
t = Time.now
print "#{t.strftime('%H:%M:%S')} +#{(t - @t0).to_i} : #{msg}\n"
end
end |
github | vasile/GTFS-viz | https://github.com/vasile/GTFS-viz | inc/ft.rb | Ruby | mit | 93 | master | 7,230 | require 'csv'
require 'json'
require 'google/api_client'
class FT_Export
@debug = false
@debug_client = false
@client_issuer = API_CONSOLE_EMAIL_ADDRESS
@client = nil
@api_drive = nil
@api_ft = nil
def self.init
if @client
return
end
@client = Google::APIClient.new(:application_na... |
github | vasile/GTFS-viz | https://github.com/vasile/GTFS-viz | inc/gtfs.rb | Ruby | mit | 93 | master | 9,690 | class GTFS
@db = nil
def self.db_init
if @db
return
end
if File.file? GTFS_DB_PATH
@db = SQLite3::Database.open(GTFS_DB_PATH)
else
@db = SQLite3::Database.new(GTFS_DB_PATH)
sql = File.open("#{APP_INC_PATH}/sql/gtfs_init.sql", "r").read
@db.execute_batch(sql)
end... |
github | chrismytton/fancybox-rails | https://github.com/chrismytton/fancybox-rails | Rakefile | Ruby | mit | 92 | master | 1,468 | # encoding: UTF-8
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
# For checking remote fancybox version.
require 'nokogiri'
require 'open-uri'
# Path to atom feed with fancybox updates.
$fancybox_feed = "http://code.google.com/feeds/... |
github | chrismytton/fancybox-rails | https://github.com/chrismytton/fancybox-rails | Gemfile | Ruby | mit | 92 | master | 415 | source 'http://rubygems.org'
gem 'rails', '>= 3.1.0'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', ">= 3.1.0"
gem 'coffee-rails', ">= 3.1.0"
gem 'uglifier'
end
gem 'jquery-rails'
group :test do
# Pretty printed test ou... |
github | chrismytton/fancybox-rails | https://github.com/chrismytton/fancybox-rails | fancybox-rails.gemspec | Ruby | mit | 92 | master | 623 | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "fancybox-rails"
s.authors = ["Chris Mytton", "Les Hill", "Dennis Reimann", "Mattias Svedhem", "Greg Reinacker"]
s.email = ["chrismytton@gmail.com"]
s.homepage = "https://github.com/chrismytton/fancybox-rails"
s.summary ... |
github | chrismytton/fancybox-rails | https://github.com/chrismytton/fancybox-rails | lib/generators/fancybox_rails_generator.rb | Ruby | mit | 92 | master | 452 | class FancyboxRailsGenerator < Rails::Generators::Base
source_root File.expand_path("../../../vendor/assets", __FILE__)
desc "Copy FancyBox into lib/ for customization"
def copy_assets
dir = Pathname.new(self.class.source_root)
Dir[self.class.source_root + '/**/*'].each do |entry|
next if File.dire... |
github | chrismytton/fancybox-rails | https://github.com/chrismytton/fancybox-rails | test/test_helper.rb | Ruby | mit | 92 | master | 1,156 | # Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
require "rails/test_help"
# Filter out Minitest backtrace while allowing backtrace... |
github | chrismytton/fancybox-rails | https://github.com/chrismytton/fancybox-rails | test/fancybox_rails_test.rb | Ruby | mit | 92 | master | 901 | require 'test_helper'
class FancyboxRailsTest < ActiveSupport::TestCase
include Rack::Test::Methods
def app
Dummy::Application
end
test "jquery.fancybox.js is found as an asset" do
assert_not_nil app.assets['jquery.fancybox.js']
assert_not_nil app.assets['fancybox.js']
end
test "jquery.fancy... |
github | chrismytton/fancybox-rails | https://github.com/chrismytton/fancybox-rails | test/dummy/config/application.rb | Ruby | mit | 92 | master | 1,024 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(*Rails.groups)
require "fancybox-rails"
module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in co... |
github | chrismytton/fancybox-rails | https://github.com/chrismytton/fancybox-rails | test/dummy/config/routes.rb | Ruby | mit | 92 | master | 1,629 | Rails.application.routes.draw do
root to: 'fancybox#index'
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
#... |
github | chrismytton/fancybox-rails | https://github.com/chrismytton/fancybox-rails | test/integration/fancybox_test.rb | Ruby | mit | 92 | master | 296 | require 'test_helper'
class FancyboxTest < ActionDispatch::IntegrationTest
test "fancybox is loaded and works" do
visit root_path
fancybox = find('#fancybox-content', visible: false)
assert !fancybox.visible?
click_link 'Check it out'
assert fancybox.visible?
end
end |
github | honeybadger-io/pg_partition_manager | https://github.com/honeybadger-io/pg_partition_manager | pg_partition_manager.gemspec | Ruby | mit | 92 | master | 1,516 | lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "pg_partition_manager/version"
Gem::Specification.new do |spec|
spec.name = "pg_partition_manager"
spec.version = PgPartitionManager::VERSION
spec.authors = ["Benjamin Curtis"]
spec.email = ["ben@honeybadger.... |
github | honeybadger-io/pg_partition_manager | https://github.com/honeybadger-io/pg_partition_manager | Rakefile | Ruby | mit | 92 | master | 232 | require "bundler/gem_tasks"
require "rake/testtask"
require "standard/rake"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
end
task default: [:standard, :test] |
github | honeybadger-io/pg_partition_manager | https://github.com/honeybadger-io/pg_partition_manager | test/pg_partition_manager_test.rb | Ruby | mit | 92 | master | 4,173 | require "test_helper"
class PgPartitionManagerTest < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::PgPartitionManager::VERSION
end
def test_it_bails_when_passed_an_invalid_period
assert_raises ArgumentError do
PgPartitionManager::Time.new({parent_table: "public.events", period:... |
github | honeybadger-io/pg_partition_manager | https://github.com/honeybadger-io/pg_partition_manager | lib/pg_partition_manager.rb | Ruby | mit | 92 | master | 4,685 | require "pg_partition_manager/version"
require "date"
require "pg"
require "ulid"
module PgPartitionManager
class Error < StandardError; end
class Time
def initialize(partition, start: Date.today, db: nil)
raise ArgumentError, "Period must be 'month', 'week', or 'day'" unless ["month", "week", "day"].in... |
github | WeTransfer/prorate | https://github.com/WeTransfer/prorate | prorate.gemspec | Ruby | mit | 92 | master | 1,592 | lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'prorate/version'
Gem::Specification.new do |spec|
spec.name = "prorate"
spec.version = Prorate::VERSION
spec.authors = ["Julik Tarkhanov"]
spec.email = ["me@julik.nl"]
spe... |
github | WeTransfer/prorate | https://github.com/WeTransfer/prorate | Rakefile | Ruby | mit | 92 | master | 545 | require "bundler/gem_tasks"
require "rspec/core/rake_task"
require 'rubocop/rake_task'
require 'yard'
YARD::Rake::YardocTask.new(:doc) do |t|
# The dash has to be between the two to "divide" the source files and
# miscellaneous documentation files that contain no code
t.files = ['lib/**/*.rb', '-', 'LICENSE.txt'... |
github | WeTransfer/prorate | https://github.com/WeTransfer/prorate | spec/null_logger_spec.rb | Ruby | mit | 92 | master | 703 | require 'spec_helper'
describe Prorate::NullLogger do
it 'accepts calls that a Logger would' do
subject = described_class
subject.debug("foo")
subject.debug { "foo" }
subject.debug("progname") { "foo" }
subject.info("foo")
subject.info { "foo" }
subject.info("progname") { "foo" }
s... |
github | WeTransfer/prorate | https://github.com/WeTransfer/prorate | spec/leaky_bucket_spec.rb | Ruby | mit | 92 | master | 3,616 | require 'spec_helper'
require 'securerandom'
require 'connection_pool'
describe Prorate::LeakyBucket do
describe 'in a happy path' do
# There is timing involved in Prorate, and some issues can be intermittent.
# To make sure _both_ code and tests are resilient, we should run multiple iterations
# of the ... |
github | WeTransfer/prorate | https://github.com/WeTransfer/prorate | spec/throttle_spec.rb | Ruby | mit | 92 | master | 10,537 | require 'spec_helper'
require 'securerandom'
require 'connection_pool'
describe Prorate::Throttle do
describe 'the Throttled exception' do
it 'carries the remaining block time and the name of the throttle' do
e = Prorate::Throttled.new("trigger-warnings", 10)
expect(e.retry_in_seconds).to eq(10)
... |
github | WeTransfer/prorate | https://github.com/WeTransfer/prorate | lib/prorate/throttled.rb | Ruby | mit | 92 | master | 810 | # The Throttled exception gets raised when a throttle is triggered.
#
# The exception carries additional attributes which can be used for
# error tracking and for creating a correct Retry-After HTTP header for
# a 429 response
class Prorate::Throttled < StandardError
# @attr [String] the name of the throttle (like "s... |
github | WeTransfer/prorate | https://github.com/WeTransfer/prorate | lib/prorate/leaky_bucket.rb | Ruby | mit | 92 | master | 5,496 | module Prorate
# This offers just the leaky bucket implementation with fill control, but without the timed lock.
# It does not raise any exceptions, it just tracks the state of a leaky bucket in Redis.
#
# Important differences from the more full-featured Throttle class are:
#
# * No logging (as most meani... |
github | WeTransfer/prorate | https://github.com/WeTransfer/prorate | lib/prorate/throttle.rb | Ruby | mit | 92 | master | 6,604 | require 'digest'
module Prorate
class MisconfiguredThrottle < StandardError
end
class Throttle
LUA_SCRIPT_CODE = File.read(File.join(__dir__, "rate_limit.lua"))
LUA_SCRIPT_HASH = Digest::SHA1.hexdigest(LUA_SCRIPT_CODE)
attr_reader :name, :limit, :period, :block_for, :redis, :logger
def initial... |
github | WeTransfer/prorate | https://github.com/WeTransfer/prorate | lib/prorate/null_logger.rb | Ruby | mit | 92 | master | 212 | module Prorate
module NullLogger
def self.debug(*); end
def self.info(*); end
def self.warn(*); end
def self.error(*); end
def self.fatal(*); end
def self.unknown(*); end
end
end |
github | WeTransfer/prorate | https://github.com/WeTransfer/prorate | scripts/bm.rb | Ruby | mit | 92 | master | 1,047 | # Runs a mild benchmark and prints out the average time a call to 'throttle!' takes.
require 'prorate'
require 'benchmark'
require 'redis'
require 'securerandom'
def average_ms(ary)
ary.map { |x| x * 1000 }.inject(0, &:+) / ary.length
end
r = Redis.new
logz = Logger.new(STDERR)
logz.level = Logger::FATAL # block ... |
github | WeTransfer/prorate | https://github.com/WeTransfer/prorate | scripts/bm_latency_lb_vs_mget.rb | Ruby | mit | 92 | master | 1,556 | # Runs a mild benchmark and prints out the average time a call to 'throttle!' takes.
require 'prorate'
require 'benchmark'
require 'redis'
require 'securerandom'
def average_ms(ary)
ary.map { |x| x * 1000 }.inject(0, &:+) / ary.length
end
r = Redis.new
# 4000000.times do
# random1 = SecureRandom.hex(10)
# ran... |
github | featurist/interfaceable | https://github.com/featurist/interfaceable | interfaceable.gemspec | Ruby | mit | 92 | master | 1,154 | # frozen_string_literal: true
require_relative 'lib/interfaceable/version'
Gem::Specification.new do |spec|
spec.name = 'interfaceable'
spec.version = Interfaceable::VERSION
spec.authors = ['artemave']
spec.email = ['artemave@gmail.com']
spec.summary = 'Strict interfaces ... |
github | featurist/interfaceable | https://github.com/featurist/interfaceable | Gemfile | Ruby | mit | 92 | master | 202 | # frozen_string_literal: true
source 'https://rubygems.org'
# Specify your gem's dependencies in interfacable.gemspec
gemspec
gem 'awesome_print'
gem 'rake'
gem 'rspec'
gem 'rubocop'
gem 'simplecov' |
github | featurist/interfaceable | https://github.com/featurist/interfaceable | spec/interfaceable_spec.rb | Ruby | mit | 92 | master | 1,448 | # frozen_string_literal: true
# rubocop:disable Metrics/BlockLength
RSpec.describe Interfaceable do
it 'has a version number' do
expect(Interfaceable::VERSION).not_to be nil
end
module Barable
def bar; end
end
module Fooable
def foo; end
end
it 'raises if class does not implement a method'... |
github | featurist/interfaceable | https://github.com/featurist/interfaceable | spec/spec_helper.rb | Ruby | mit | 92 | master | 605 | # frozen_string_literal: true
if ENV.fetch('COVERAGE', false)
require 'simplecov'
SimpleCov.start do
enable_coverage :branch
add_filter '/spec/'
minimum_coverage line: 100, branch: 100
end
end
require 'bundler/setup'
require 'awesome_print'
require 'interfaceable'
RSpec.configure do |config|
# Ena... |
github | featurist/interfaceable | https://github.com/featurist/interfaceable | spec/error_formatter_spec.rb | Ruby | mit | 92 | master | 1,594 | # frozen_string_literal: true
require_relative '../lib/interfaceable/error_formatter'
# rubocop:disable Metrics/BlockLength
RSpec.describe Interfaceable::ErrorFormatter do
it 'checks instance methods' do
expected_error = <<~ERROR.chomp
Stuff must implement:
- Barable#bar
- Fooable.foo
... |
github | featurist/interfaceable | https://github.com/featurist/interfaceable | spec/implementation_check_spec.rb | Ruby | mit | 92 | master | 4,297 | # frozen_string_literal: true
require_relative '../lib/interfaceable/implementation_check'
# rubocop:disable Metrics/BlockLength
RSpec.describe Interfaceable::ImplementationCheck do
it 'checks instance methods' do
interface = Module.new do
def foo; end
end
klass = Class.new
errors = Interfacea... |
github | featurist/interfaceable | https://github.com/featurist/interfaceable | lib/interfaceable.rb | Ruby | mit | 92 | master | 1,212 | # frozen_string_literal: true
require_relative 'interfaceable/implementation_check'
require_relative 'interfaceable/error_formatter'
# Ruby interfaces yeah
module Interfaceable
# Subclassing exceptions because other errors don't raise from within `TracePoint.trace`.
# rubocop:disable Lint/InheritException
class... |
github | featurist/interfaceable | https://github.com/featurist/interfaceable | lib/interfaceable/implementation_check.rb | Ruby | mit | 92 | master | 4,584 | # frozen_string_literal: true
module Interfaceable
# Checks if class implements interfaces correctly
class ImplementationCheck
def initialize(klass)
@klass = klass
end
def perform(interfaces)
results = validate(interfaces)
results.reject do |_, checks|
checks.values.all?(&:e... |
github | featurist/interfaceable | https://github.com/featurist/interfaceable | lib/interfaceable/error_formatter.rb | Ruby | mit | 92 | master | 1,795 | # frozen_string_literal: true
module Interfaceable
# Formats errors
class ErrorFormatter
def initialize(class_name)
@class_name = class_name
end
def format_errors(errors)
error_lines = []
if (missing_method_errors = all_missing_methods_errors(errors)).any?
error_lines << "#{... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | Gemfile | Ruby | bsd-3-clause | 92 | master | 3,488 | source 'https://rubygems.org'
ruby '2.2.4'
gem 'rails', '4.2.0'
# Use mysql/postgres as the database for Active Record
gem 'pg'
# gem 'mysql2'
# Active Record composite primary keys support
gem 'composite_primary_keys'
# Use SCSS for stylesheets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and v... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/spec_helper.rb | Ruby | bsd-3-clause | 92 | master | 3,967 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# ... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/rails_helper.rb | Ruby | bsd-3-clause | 92 | master | 3,184 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||=... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/extensions/extensions_spec.rb | Ruby | bsd-3-clause | 92 | master | 2,407 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
RSpec.describe BeaconControl::EXTENSIONS, type: :async do
let(:extens... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/integration/event_processor_spec.rb | Ruby | bsd-3-clause | 92 | master | 1,449 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
RSpec.describe 'EventProcessor event processing', type: :async do
let... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/integration/s2s_api/v1/passwords_spec.rb | Ruby | bsd-3-clause | 92 | master | 2,754 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
require 'support/s2s_api_shared_context'
describe 'S2sApi::V1::Password... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/integration/s2s_api/v1/beacons_spec.rb | Ruby | bsd-3-clause | 92 | master | 11,775 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
require 'support/s2s_api_shared_context'
RSpec.describe 'S2sApi::V1::Be... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/integration/s2s_api/v1/zone_colors_spec.rb | Ruby | bsd-3-clause | 92 | master | 740 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
require 'support/s2s_api_shared_context'
RSpec.describe 'S2sApi::V1::Zo... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/integration/s2s_api/v1/registrations_spec.rb | Ruby | bsd-3-clause | 92 | master | 3,252 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
require 'support/s2s_api_shared_context'
RSpec.describe 'S2sApi::V1::Re... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/integration/s2s_api/v1/zones_spec.rb | Ruby | bsd-3-clause | 92 | master | 8,814 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
require 'support/s2s_api_shared_context'
RSpec.describe 'S2sApi::V1::Zo... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/integration/s2s_api/v1/admins_spec.rb | Ruby | bsd-3-clause | 92 | master | 5,717 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
require 'support/s2s_api_shared_context'
RSpec.describe 'S2sApi::V1::Ad... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/integration/s2s_api/v1/extensions_spec.rb | Ruby | bsd-3-clause | 92 | master | 2,145 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
require 'support/s2s_api_shared_context'
RSpec.describe 'S2sApi::V1::Ex... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/integration/s2s_api/v1/application_settings_spec.rb | Ruby | bsd-3-clause | 92 | master | 5,134 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
require 'support/s2s_api_shared_context'
RSpec.describe 'S2sApi::V1::Ap... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/integration/s2s_api/v1/authorization_spec.rb | Ruby | bsd-3-clause | 92 | master | 3,200 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
require 'support/s2s_api_shared_context'
RSpec.describe 's2s_api/v1 aut... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/integration/s2s_api/v1/activities_spec.rb | Ruby | bsd-3-clause | 92 | master | 11,542 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
require 'support/s2s_api_shared_context'
RSpec.describe 'S2sApi::V1::Ac... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/integration/s2s_api/v1/applications_spec.rb | Ruby | bsd-3-clause | 92 | master | 4,949 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
require 'support/s2s_api_shared_context'
RSpec.describe 'S2sApi::V1::Ap... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/integration/api/v1/authorization_spec.rb | Ruby | bsd-3-clause | 92 | master | 4,796 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
RSpec.describe 'api/v1 authorization', type: :request do
let(:doorkee... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/integration/api/v1/events_spec.rb | Ruby | bsd-3-clause | 92 | master | 2,404 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
RSpec.describe 'Api::V1::Events', type: :request do
describe 'events ... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/integration/api/v1/configurations_spec.rb | Ruby | bsd-3-clause | 92 | master | 1,630 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
require 'rails_helper'
RSpec.describe 'Api::V1::Configurations', type: :request do
describe ... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/factories/activities.rb | Ruby | bsd-3-clause | 92 | master | 624 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
FactoryGirl.define do
factory :activity do |activity|
sequence(:name) { |n| "Activity #{n... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/factories/coupons.rb | Ruby | bsd-3-clause | 92 | master | 449 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
FactoryGirl.define do
factory :coupon do
template "template_1"
sequence(:name) { |n| ... |
github | upnext/BeaconControl | https://github.com/upnext/BeaconControl | spec/factories/application_extensions.rb | Ruby | bsd-3-clause | 92 | master | 331 | ###
# Copyright (c) 2015, Upnext Technologies Sp. z o.o.
# All rights reserved.
#
# This source code is licensed under the BSD 3-Clause License found in the
# LICENSE.txt file in the root directory of this source tree.
###
FactoryGirl.define do
factory :application_extension do
application
extension_name ""... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.