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
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/gzip/reader.rb
Ruby
apache-2.0
98
master
329
module IOStreams module Gzip class Reader < IOStreams::Reader # Read from a gzip stream, decompressing the contents as it is read def self.stream(input_stream, original_file_name: nil) io = ::Zlib::GzipReader.new(input_stream) yield io ensure io&.close end end ...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/zip/writer.rb
Ruby
apache-2.0
98
master
1,291
module IOStreams module Zip class Writer < IOStreams::Writer # Write a single file in Zip format to the supplied output stream # # Parameters # output_stream [IO] # Output stream to write to # # original_file_name [String] # Since this is a stream the or...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/zip/reader.rb
Ruby
apache-2.0
98
master
2,285
module IOStreams module Zip class Reader < IOStreams::Reader # Read from a zip file or stream, decompressing the contents as it is read # The input stream from the first file found in the zip file is passed # to the supplied block. # # Parameters: # entry_file_name: [String] ...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/tabular/header.rb
Ruby
apache-2.0
98
master
5,700
module IOStreams class Tabular # Process files / streams that start with a header. class Header # Column names that begin with this prefix have been rejected and should be ignored. IGNORE_PREFIX = "__rejected__".freeze attr_accessor :columns, :allowed_columns, :required_columns, :skip_unkno...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/tabular/utility/csv_row.rb
Ruby
apache-2.0
98
master
3,937
require "csv" module IOStreams class Tabular module Utility # For parsing a single line of CSV at a time # 2 to 3 times better performance than CSV.parse_line and considerably less # garbage collection required. # # Note: Only used prior to Ruby 2.6 class CSVRow < ::CSV ...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/tabular/parser/csv.rb
Ruby
apache-2.0
98
master
1,744
require "csv" module IOStreams class Tabular module Parser class Csv < Base attr_reader :csv_parser unless RUBY_VERSION.to_f >= 2.6 def initialize @csv_parser = Utility::CSVRow.new end end # Returns [Array<String>] the header row. # R...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/tabular/parser/hash.rb
Ruby
apache-2.0
98
master
428
require "json" module IOStreams class Tabular module Parser class Hash < Base def parse(row) raise(IOStreams::Errors::TypeMismatch, "Format is :hash. Invalid input: #{row.class.name}") unless row.is_a?(::Hash) row end def render(row, header) header.to_...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/tabular/parser/fixed.rb
Ruby
apache-2.0
98
master
7,110
module IOStreams class Tabular module Parser # Parsing and rendering fixed length data class Fixed < Base attr_reader :layout, :truncate # Returns [IOStreams::Tabular::Parser] # # Parameters: # layout: [Array<Hash>] # [ # {size: 23, ...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/tabular/parser/base.rb
Ruby
apache-2.0
98
master
233
module IOStreams class Tabular module Parser class Base # Returns [true|false] whether a header row is required for this format. def requires_header? true end end end end end
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/tabular/parser/array.rb
Ruby
apache-2.0
98
master
712
require "json" module IOStreams class Tabular module Parser class Array < Base # Returns [Array<String>] the header row. # Returns nil if the row is blank. def parse_header(row) unless row.is_a?(::Array) raise(IOStreams::Errors::InvalidHeader, "Format is :array....
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/tabular/parser/json.rb
Ruby
apache-2.0
98
master
631
require "json" module IOStreams class Tabular module Parser # For parsing a single line of JSON at a time class Json < Base def parse(row) return row if row.is_a?(::Hash) raise(IOStreams::Errors::TypeMismatch, "Format is :json. Invalid input: #{row.class.name}") unless row...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/tabular/parser/psv.rb
Ruby
apache-2.0
98
master
1,109
module IOStreams class Tabular module Parser # For parsing a single line of Pipe-separated values class Psv < Base # Returns [Array<String>] the header row. # Returns nil if the row is blank. def parse_header(row) return row if row.is_a?(::Array) unless row...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/row/writer.rb
Ruby
apache-2.0
98
master
2,408
require "csv" module IOStreams module Row # Example: # IOStreams.path("file.csv").writer(:array) do |stream| # stream << ['name', 'address', 'zipcode'] # stream << ['Jack', 'Somewhere', 12345] # stream << ['Joe', 'Lost', 32443] # end class Writer < IOStreams::Writer #...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/row/reader.rb
Ruby
apache-2.0
98
master
1,996
module IOStreams module Row # Converts each line of an input stream into an array for every line class Reader < IOStreams::Reader # Read a line as an Array at a time from a stream. # Note: # - The supplied stream _must_ already be a line stream, or a stream that responds to :each def s...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/xlsx/reader.rb
Ruby
apache-2.0
98
master
1,020
require "csv" module IOStreams module Xlsx class Reader < IOStreams::Reader # Convert a xlsx, or xlsm file into CSV format. def self.file(file_name, original_file_name: file_name, &block) # Stream into a temp file as csv Utils.temp_file_name("iostreams_csv") do |temp_file_name| ...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/line/reader.rb
Ruby
apache-2.0
98
master
7,212
module IOStreams module Line class Reader < IOStreams::Reader attr_reader :delimiter, :buffer_size, :line_number # Prevent denial of service when a delimiter is not found before this number * `buffer_size` characters are read. MAX_BLOCKS_MULTIPLIER = 100 LINEFEED_REGEXP = Regexp.compile(...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/line/writer.rb
Ruby
apache-2.0
98
master
1,744
module IOStreams module Line class Writer < IOStreams::Writer attr_reader :delimiter # Write a line at a time to a stream. def self.stream(output_stream, **args) # Pass-through if already a line writer return yield(output_stream) if output_stream.is_a?(self.class) yield...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/record/writer.rb
Ruby
apache-2.0
98
master
3,662
module IOStreams module Record # Example, implied header from first record: # IOStreams.path('file.csv').writer(:hash) do |stream| # stream << {name: 'Jack', address: 'Somewhere', zipcode: 12345} # stream << {name: 'Joe', address: 'Lost', zipcode: 32443, age: 23} # end class Writer...
github
reidmorrison/iostreams
https://github.com/reidmorrison/iostreams
lib/io_streams/record/reader.rb
Ruby
apache-2.0
98
master
3,290
module IOStreams module Record # Converts each line of an input stream into hash for every row class Reader < IOStreams::Reader include Enumerable # Read a record at a time from a line stream # Note: # - The supplied stream _must_ already be a line stream, or a stream that responds to...
github
Nakilon/dhash-vips
https://github.com/Nakilon/dhash-vips
dhash-vips.gemspec
Ruby
mit
98
master
789
Gem::Specification.new do |spec| spec.name = "dhash-vips" spec.version = "0.2.4.0" spec.summary = "dHash and IDHash perceptual image hashing/fingerprinting" spec.author = "Victor Maslov aka Nakilon" spec.email = "nakilon@gmail.com" spec.license = "MIT" spec.metad...
github
Nakilon/dhash-vips
https://github.com/Nakilon/dhash-vips
common.rb
Ruby
mit
98
master
446
def download_if_needed path require "open-uri" require "digest" FileUtils.mkdir_p File.dirname path URI("http://gems.nakilon.pro.storage.yandexcloud.net/dhash-vips/#{File.basename path}".tap do |url| puts "downloading #{path} from #{url}" end).open do |link| File.open(path, "wb"){ |file| IO.copy_strea...
github
Nakilon/dhash-vips
https://github.com/Nakilon/dhash-vips
Rakefile
Ruby
mit
98
master
16,283
require "bundler/gem_tasks" require "pp" visualize_hash = lambda do |hash| puts hash.to_s(2).rjust(64, ?0).gsub(/(?<=.)/, '\0 ').scan(/.{16}/) end desc "Compare how Vips and ImageMagick resize images to 9x8" task :compare_pixelation do |_| require_relative "lib/dhash-vips" require "dhash" ARGV.drop(1).each ...
github
Nakilon/dhash-vips
https://github.com/Nakilon/dhash-vips
test.rb
Ruby
mit
98
master
5,653
require "minitest/autorun" require_relative "lib/dhash-vips" # TODO tests about `fingerprint(4)` [ [DHashVips::DHash, :hamming, :calculate, 2, 23, 16, 50, 7, 0x7919395919191919], # v0.2.3.0 # [[0, 18, 26, 28, 28, 24, 35, 31, 42, 42, 32, 34, 33, 29, 35, 40], # [18, 0, 30, 24, 38, 34, 33, 33, 44, 42, 3...
github
Nakilon/dhash-vips
https://github.com/Nakilon/dhash-vips
Gemfile
Ruby
mit
98
master
327
source "https://rubygems.org" gem "rake" gem "rmagick" gem "dhash", github: "nakilon/dhash" gem "phamilie" gem "mini_magick" gem "dhashy" gem "phash-rb", github: "nakilon/phash-rb" gem "get_process_mem" gem "mll" gem "minitest" gem "byebug", *("<11.1.0" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.4")) g...
github
Nakilon/dhash-vips
https://github.com/Nakilon/dhash-vips
extconf.rb
Ruby
mit
98
master
1,188
require "mkmf" File.write "Makefile", dummy_makefile(?.).join unless Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.3.8") append_cppflags "-DRUBY_EXPORT" unless Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.4") create_makefile "idhash" # Why this hack? # 1. Because I want to use Ruby and ./idhash...
github
Nakilon/dhash-vips
https://github.com/Nakilon/dhash-vips
test_LoadError.rb
Ruby
mit
98
master
308
require "minitest/autorun" describe :test do it do FileUtils.move "idhash.bundle", "temp" begin require_relative "lib/dhash-vips" assert_equal :distance3_ruby, DHashVips::IDHash.method(:distance3).original_name ensure FileUtils.move "temp", "idhash.bundle" end end end
github
Nakilon/dhash-vips
https://github.com/Nakilon/dhash-vips
test_rbenv.rb
Ruby
mit
98
master
686
require "open3" assert_exitstatus = lambda do |_| (string, status) = Open3.capture2e _.tap &method(:puts) unless status.exitstatus.zero? puts string abort "exitstatus = #{status.exitstatus}" end end Dir.entries("#{ENV["RBENV_ROOT"]}/sources").grep(/\A(2\.[3-9]|3\.\d)\.\d\z/).sort.reverse.uniq{ |_| _[0,3] ...
github
Nakilon/dhash-vips
https://github.com/Nakilon/dhash-vips
example_ocr/main.rb
Ruby
mit
98
master
1,260
require "dhash-vips" # Courier Menlo Monaco Tahoma chars = %w{ Arial Verdana }.flat_map do |font| FileUtils.mkdir_p "chars/#{font}" (?A..?Z).map do |char| filename = "chars/#{font}/#{char.ord}.png" Vips::Image.text(char, font: font, width: 100, height: 100).invert.write_to_file filename unless File.exist...
github
Nakilon/dhash-vips
https://github.com/Nakilon/dhash-vips
example_dups/main.rb
Ruby
mit
98
master
634
require "dhash-vips" Dir.chdir ENV["TEST"] || "/images" pattern = %w{ *.jp*g *.png } pairs = Dir.glob(pattern).tap do |_| puts "\n#{pattern} images found: #{_.size}\n\n" end.sort.map{ |f| [DHashVips::IDHash.fingerprint(f), f] }. combination(2).map{ |(h1, f1), (h2, f2)| [DHashVips::IDHash.distance(h1, h2), f1, f2] ...
github
Nakilon/dhash-vips
https://github.com/Nakilon/dhash-vips
lib/dhash-vips-post-install-test.rb
Ruby
mit
98
master
2,052
puts "Testing native extension..." a, b = 27362028616592833077810614538336061650596602259623245623188871925927275101952, 57097733966917585112089915289446881218887831888508524872740133297073405558528 f = ->(a,b){ DHashVips::IDHash.distance3_ruby a, b } p as = [a.to_s(16).rjust(64,?0)].pack("H*").unpack("N*") p bs = [b...
github
Nakilon/dhash-vips
https://github.com/Nakilon/dhash-vips
lib/dhash-vips.rb
Ruby
mit
98
master
3,932
require "vips" Vips.vector_set false module DHashVips def self.bw image (image.has_alpha? ? image.flatten(background: 255) : image).colourspace("b-w")[0] end module DHash extend self def hamming a, b (a ^ b).to_s(2).count "1" end def pixelate input, hash_size DHashVips.bw( if ...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
Gemfile
Ruby
mit
98
main
263
# frozen_string_literal: true source "https://rubygems.org" ruby ">= 3.0" gemspec gem "pg" gem "sqlite3" gem "activesupport", ">= 8" gem "rake", "~> 13.0" gem "minitest", "~> 5.0" gem "redis", "~> 5", "< 6" gem "yard" gem "standard" gem "sord" gem "redcarpet"
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
Rakefile
Ruby
mit
98
main
675
# frozen_string_literal: true require "bundler/gem_tasks" require "rake/testtask" require "standard/rake" require "yard" YARD::Rake::YardocTask.new(:doc) Rake::TestTask.new(:test) do |t| t.libs << "test" t.libs << "lib" t.test_files = FileList["test/**/*_test.rb"] end task :format do `bundle exec standardrb...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
pecorino.gemspec
Ruby
mit
98
main
1,294
# frozen_string_literal: true require_relative "lib/pecorino/version" Gem::Specification.new do |spec| spec.name = "pecorino" spec.version = Pecorino::VERSION spec.authors = ["Julik Tarkhanov"] spec.email = ["me@julik.nl"] spec.summary = "Database-based rate limiter using leaky buckets" spec.description ...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
lib/pecorino.rb
Ruby
mit
98
main
2,854
# frozen_string_literal: true require "active_support/concern" require "active_record/sanitization" require_relative "pecorino/version" require_relative "pecorino/railtie" if defined?(Rails::Railtie) module Pecorino autoload :LeakyBucket, "pecorino/leaky_bucket" autoload :Block, "pecorino/block" autoload :Thro...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
lib/pecorino/throttle.rb
Ruby
mit
98
main
8,367
# frozen_string_literal: true # Provides a throttle with a block based on the `LeakyBucket`. Once a bucket fills up, # a block will be installed and an exception will be raised. Once a block is set, no # checks will be done on the leaky bucket - any further requests will be refused until # the block is lifted. The blo...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
lib/pecorino/leaky_bucket.rb
Ruby
mit
98
main
7,600
# frozen_string_literal: true # 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 the database. # # Leak rate is specified directly in tokens per second, instead of specifying the block perio...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
lib/pecorino/install_generator.rb
Ruby
mit
98
main
957
# frozen_string_literal: true require "rails/generators" require "rails/generators/active_record" module Pecorino # # Rails generator used for setting up Pecorino in a Rails application. # Run it with +bin/rails g pecorino:install+ in your console. # class InstallGenerator < Rails::Generators::Base incl...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
lib/pecorino/cached_throttle.rb
Ruby
mit
98
main
3,694
# The cached throttles can be used when you want to lift your throttle blocks into # a higher-level cache. If you are dealing with clients which are hammering on your # throttles a lot, it is useful to have a process-local cache of the timestamp when # the blocks that are set are going to expire. If you are running, sa...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
lib/pecorino/block.rb
Ruby
mit
98
main
1,306
# frozen_string_literal: true # Provides access to Pecorino blocks - same blocks which get set when a throttle triggers. The blocks # are just keys in the data store which have an expiry value. This can be useful if you want to restrict # access to a resource for an arbitrary timespan. class Pecorino::Block # Sets a...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
lib/pecorino/adapters/redis_adapter.rb
Ruby
mit
98
main
3,692
# frozen_string_literal: true require_relative "base_adapter" require "digest" require "redis" # An adapter for storing Pecorino leaky buckets and blocks in Redis. It uses Lua # to enforce atomicity for leaky bucket operations class Pecorino::Adapters::RedisAdapter < Pecorino::Adapters::BaseAdapter class RedisScrip...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
lib/pecorino/adapters/memory_adapter.rb
Ruby
mit
98
main
4,375
# frozen_string_literal: true # A memory store for leaky buckets and blocks class Pecorino::Adapters::MemoryAdapter class KeyedLock def initialize @locked_keys = Set.new @lock_mutex = Mutex.new end def lock(key) loop do @lock_mutex.synchronize do next if @locked_keys....
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
lib/pecorino/adapters/postgres_adapter.rb
Ruby
mit
98
main
8,007
# frozen_string_literal: true class Pecorino::Adapters::PostgresAdapter def initialize(model_class) @model_class = model_class end def state(key:, capacity:, leak_rate:) query_params = { key: key.to_s, capacity: capacity.to_f, leak_rate: leak_rate.to_f } # The `level` of the bu...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
lib/pecorino/adapters/base_adapter.rb
Ruby
mit
98
main
2,786
# frozen_string_literal: true # An adapter allows Pecorino throttles, leaky buckets and other # resources to interface with a data storage backend - a database, usually. class Pecorino::Adapters::BaseAdapter # Returns the state of a leaky bucket. The state should be a tuple of two # values: the current level (Floa...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
lib/pecorino/adapters/sqlite_adapter.rb
Ruby
mit
98
main
9,691
# frozen_string_literal: true class Pecorino::Adapters::SqliteAdapter def initialize(model_class) @model_class = model_class end def state(key:, capacity:, leak_rate:) # With a server database, it is really important to use the clock of the database itself so # that concurrent requests will see cons...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
test/test_helper.rb
Ruby
mit
98
main
252
# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "pecorino" require "minitest/autorun" require "active_support" require "active_support/test_case" require "active_record" class ActiveSupport::TestCase end
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
test/cached_throttle_test.rb
Ruby
mit
98
main
3,779
# frozen_string_literal: true require "test_helper" class CachedThrottleTest < ActiveSupport::TestCase def adapter @adapter ||= Pecorino::Adapters::MemoryAdapter.new end test "caches results of request! and correctly raises Throttled until the block is lifted" do store = ActiveSupport::Cache::MemorySto...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
test/block_test.rb
Ruby
mit
98
main
923
# frozen_string_literal: true require "test_helper" require "base64" class BlockTest < ActiveSupport::TestCase def setup @adapter = Pecorino::Adapters::MemoryAdapter.new end test "sets a block" do k = Base64.strict_encode64(Random.bytes(4)) assert_nil Pecorino::Block.blocked_until(key: k, adapter: ...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
test/leaky_bucket_test.rb
Ruby
mit
98
main
6,876
# frozen_string_literal: true require "test_helper" class LeakyBucketTest < ActiveSupport::TestCase def memory_adapter @adapter ||= Pecorino::Adapters::MemoryAdapter.new end # This test is performed multiple times since time is involved, and there can be fluctuations # between the iterations 8.times do...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
test/throttle_test.rb
Ruby
mit
98
main
3,656
# frozen_string_literal: true require "test_helper" class ThrottleTest < ActiveSupport::TestCase def memory_adapter @adapter ||= Pecorino::Adapters::MemoryAdapter.new end test "request! installs a block and then removes it and communicates the block using exceptions" do throttle = Pecorino::Throttle.ne...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
test/adapters/redis_adapter_test.rb
Ruby
mit
98
main
531
require_relative "../test_helper" require_relative "adapter_test_methods" class RedisAdapterTest < ActiveSupport::TestCase include AdapterTestMethods teardown { delete_created_keys } def create_adapter Pecorino::Adapters::RedisAdapter.new(new_redis, key_prefix: key_prefix) end def key_prefix "peco...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
test/adapters/sqlite_adapter_test.rb
Ruby
mit
98
main
1,505
require_relative "../test_helper" require_relative "adapter_test_methods" class SqliteAdapterTest < ActiveSupport::TestCase include AdapterTestMethods setup { create_sqlite_db } teardown { drop_sqlite_db } def create_sqlite_db ActiveRecord::Migration.verbose = false ActiveRecord::Base.establish_conne...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
test/adapters/adapter_test_methods.rb
Ruby
mit
98
main
9,236
# The module contains the conformance tests for a storage adapter for Pecorino. A well-behaved adapter # should pass all of these tests. When creating a new adapter include this module in your test case # and overload the `create_adapter` method module AdapterTestMethods LEVEL_DELTA = 0.1 def adapter @adapter ...
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
test/adapters/memory_adapter_test.rb
Ruby
mit
98
main
257
require_relative "../test_helper" require_relative "adapter_test_methods" class MemoryAdapterTest < ActiveSupport::TestCase include AdapterTestMethods def create_adapter Pecorino::Adapters::MemoryAdapter.new end undef :test_create_tables end
github
cheddar-me/pecorino
https://github.com/cheddar-me/pecorino
test/adapters/postgres_adapter_test.rb
Ruby
mit
98
main
2,768
require_relative "../test_helper" require_relative "adapter_test_methods" class PostgresAdapterTest < ActiveSupport::TestCase include AdapterTestMethods setup { create_postgres_database_if_none } teardown { truncate_test_tables } def self.establish_connection(**options) ActiveRecord::Base.establish_conne...
github
khelben/rails-boilerplate
https://github.com/khelben/rails-boilerplate
Guardfile
Ruby
mit
98
master
463
# A sample Guardfile # More info at https://github.com/guard/guard#readme guard 'minitest' do # with Minitest::Unit watch(%r|^test/(.*)_test\.rb|) watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}#{m[2]}_test.rb" } watch(%r|^test/test_helper\.rb|) { "test" } # with Minitest::Spec # watch(%r|^spec...
github
khelben/rails-boilerplate
https://github.com/khelben/rails-boilerplate
Gemfile
Ruby
mit
98
master
231
source "http://rubygems.org" # Specify your gem's dependencies in rails_boilerplate.gemspec gemspec gem 'rdoc' gem 'rake' gem 'rails', '~> 3.1.0' gem 'sqlite3' gem 'guard-minitest' gem 'awesome_print', :require => "ap" gem 'turn'
github
khelben/rails-boilerplate
https://github.com/khelben/rails-boilerplate
Rakefile
Ruby
mit
98
master
2,576
begin require 'bundler/setup' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end require "bundler/gem_tasks" require 'rdoc/task' require 'fileutils' include FileUtils RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'BackboneRails' rdoc.op...
github
khelben/rails-boilerplate
https://github.com/khelben/rails-boilerplate
rails-boilerplate.gemspec
Ruby
mit
98
master
917
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "rails_boilerplate/version" Gem::Specification.new do |s| s.name = "rails-boilerplate" s.version = RailsBoilerplate::VERSION s.authors = ["Christiaan Van den Poel"] s.email = ["christiaan.vandenpoel@gmail.com"] ...
github
khelben/rails-boilerplate
https://github.com/khelben/rails-boilerplate
test/rails_boilerplate_test.rb
Ruby
mit
98
master
371
require 'test_helper' class RailsBoilerplateTest < ActiveSupport::TestCase def setup @app = Dummy::Application end test 'modernizr is an asset' do assert_not_nil @app.assets["modernizr"] end test 'reset is an asset' do assert_not_nil @app.assets["reset"] end test 'plugins is an js asset' do ...
github
khelben/rails-boilerplate
https://github.com/khelben/rails-boilerplate
test/test_helper.rb
Ruby
mit
98
master
294
ENV["RAILS_ENV"] = 'test' require File.expand_path("../dummy/config/environment.rb", __FILE__) require 'rails/test_help' Rails.backtrace_cleaner.remove_silencers! Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } # For Generators require 'rails/generators/test_case'
github
khelben/rails-boilerplate
https://github.com/khelben/rails-boilerplate
test/generators/install_generator_test.rb
Ruby
mit
98
master
2,023
require 'test_helper' require 'generators/generators_test_helper' require 'generators/boilerplate/install/install_generator' class InstallGeneratorTest < Rails::Generators::TestCase include GeneratorsTestHelper tests Boilerplate::Generators::InstallGenerator def setup mkdir_p "#{destination_root}/app/assets...
github
khelben/rails-boilerplate
https://github.com/khelben/rails-boilerplate
test/dummy/config/application.rb
Ruby
mit
98
master
1,811
require File.expand_path('../boot', __FILE__) require "rails/all" Bundler.require require 'rails-boilerplate' module Dummy class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initial...
github
khelben/rails-boilerplate
https://github.com/khelben/rails-boilerplate
test/dummy/config/initializers/secret_token.rb
Ruby
mit
98
master
496
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attac...
github
khelben/rails-boilerplate
https://github.com/khelben/rails-boilerplate
lib/generators/boilerplate/resource_helpers.rb
Ruby
mit
98
master
275
module Boilerplate module Generators module ResourceHelpers def application_name if defined?(Rails) && Rails.application Rails.application.class.name.split('::').first else "application" end end end end end
github
khelben/rails-boilerplate
https://github.com/khelben/rails-boilerplate
lib/generators/boilerplate/install/install_generator.rb
Ruby
mit
98
master
1,594
require 'generators/boilerplate/resource_helpers' module Boilerplate module Generators class InstallGenerator < Rails::Generators::Base include ResourceHelpers source_root File.expand_path("../templates", __FILE__) desc 'This generator installs an application.html.erb file conforming to the h...
github
apjanke/ronn-ng
https://github.com/apjanke/ronn-ng
Rakefile
Ruby
mit
98
main
4,352
require 'rake/clean' require 'date' task default: :test ROOTDIR = File.expand_path(__dir__).sub(/#{Dir.pwd}(?=\/)/, '.') LIBDIR = "#{ROOTDIR}/lib".freeze BINDIR = "#{ROOTDIR}/bin".freeze desc 'Set up environment' task :environment do $LOAD_PATH.unshift ROOTDIR unless $LOAD_PATH.include?(ROOTDIR) $LOAD_PATH.unshi...
github
apjanke/ronn-ng
https://github.com/apjanke/ronn-ng
config.ru
Ruby
mit
98
main
278
#\ -p 1207 $LOAD_PATH << File.expand_path('lib', __dir__) require 'ronn' require 'ronn/server' # use Rack::Lint options = { styles: %w[man toc], organization: "Ronn v#{Ronn::VERSION}" } files = Dir['man/*.ronn'] + Dir['test/*.ronn'] run Ronn::Server.new(files, options)
github
apjanke/ronn-ng
https://github.com/apjanke/ronn-ng
ronn-ng.gemspec
Ruby
mit
98
main
2,654
Gem::Specification.new do |s| s.name = 'ronn-ng' s.version = '0.10.2.wip' # We target Ruby 2.7+ for test & deploy, plus nokogiri 1.14.3+ need Ruby 2.7 s.required_ruby_version = '>= 2.7' s.summary = 'Builds man pages from Markdown' s.description = 'Ronn-NG builds manuals in Unix man page and HTML format...
github
apjanke/ronn-ng
https://github.com/apjanke/ronn-ng
lib/ronn.rb
Ruby
mit
98
main
1,576
# Ronn is a humane text format and toolchain for authoring manpages (and # things that appear as manpages from a distance). Use it to build / # install standard Unix roff(7) formatted manpages or to generate # beautiful HTML manpages. module Ronn autoload :Document, 'ronn/document' autoload :Index, 'ronn/index' ...
github
apjanke/ronn-ng
https://github.com/apjanke/ronn-ng
lib/ronn/server.rb
Ruby
mit
98
main
2,106
require 'ronn' require 'rack' require 'sinatra/base' module Ronn # Ronn HTTP server. Serves a list of .ronn files as HTML. The options Hash is # passed to Ronn::Document.new on each invocation. # # Use Ronn::Server.new to create a Rack app. See the config.ru file in the # root of the Ronn distribution for ex...
github
apjanke/ronn-ng
https://github.com/apjanke/ronn-ng
lib/ronn/index.rb
Ruby
mit
98
main
3,722
require 'ronn' module Ronn # Maintains a list of links / references to manuals and other resources. class Index include Enumerable attr_reader :path, :references # Retrieve an Index for <path>, where <path> is a directory or normal # file. The index is loaded from the corresponding index.txt file...
github
apjanke/ronn-ng
https://github.com/apjanke/ronn-ng
lib/ronn/document.rb
Ruby
mit
98
main
17,651
require 'time' require 'cgi' require 'nokogiri' require 'kramdown' require 'ronn/index' require 'ronn/roff' require 'ronn/template' require 'ronn/utils' module Ronn # The Document class can be used to load and inspect a ronn document # and to convert a ronn document into other formats, like roff or # HTML. # ...
github
apjanke/ronn-ng
https://github.com/apjanke/ronn-ng
lib/ronn/utils.rb
Ruby
mit
98
main
1,667
require 'set' require 'cgi' module Ronn # Miscellaneous utilities. module Utils # All HTML 4 elements and some that are in common use. HTML = %w[ a abbr acronym address applet area b base basefont bdo big blockquote body br button caption center cite code col colgroup dd del dfn dir div dl dt ...
github
apjanke/ronn-ng
https://github.com/apjanke/ronn-ng
lib/ronn/template.rb
Ruby
mit
98
main
4,061
require 'mustache' module Ronn # A Mustache Template for HTML formatting. class Template < Mustache self.template_path = File.dirname(__FILE__) + '/template' self.template_extension = 'html' def initialize(document, style_path = ENV['RONN_STYLE'].to_s.split(':')) super() @document = docume...
github
apjanke/ronn-ng
https://github.com/apjanke/ronn-ng
lib/ronn/roff.rb
Ruby
mit
98
main
11,338
require 'nokogiri' require 'ronn/utils' module Ronn # Filter for converting HTML to ROFF class RoffFilter include Ronn::Utils # Convert Ronn HTML to roff. # The html input is an HTML fragment, not a complete document def initialize(html_fragment, name, section, tagline, manual = nil, ...
github
apjanke/ronn-ng
https://github.com/apjanke/ronn-ng
test/test_ronn.rb
Ruby
mit
98
main
3,992
require 'fileutils' require 'contest' class RonnTest < Test::Unit::TestCase testdir = File.dirname(__FILE__) # setup PATH so that we execute the right ronn command bindir = File.dirname(testdir) + '/bin' ENV['PATH'] = "#{bindir}:#{ENV.fetch('PATH', nil)}" # make sure the load path is setup correctly libd...
github
apjanke/ronn-ng
https://github.com/apjanke/ronn-ng
test/contest.rb
Ruby
mit
98
main
1,946
require 'test/unit' module Test module Unit # TestSuite loads a default test if the suite is empty, whose purpose is to # fail. Since having empty contexts is a common practice, we decided to # overwrite TestSuite#empty? in order to allow them. Having a failure when no # tests have been defined seems...
github
apjanke/ronn-ng
https://github.com/apjanke/ronn-ng
test/test_ronn_document.rb
Ruby
mit
98
main
6,548
require 'contest' require 'ronn/document' class DocumentTest < Test::Unit::TestCase SIMPLE_FILE = "#{File.dirname(__FILE__)}/basic_document.ronn".freeze def canonicalize(text) text .gsub(/^ +/, '') .gsub(/\n/m, '') .gsub(/ +/, ' ') .tr('"', "'") end test 'new with path' do doc...
github
apjanke/ronn-ng
https://github.com/apjanke/ronn-ng
test/test_ronn_index.rb
Ruby
mit
98
main
2,319
require 'contest' require 'ronn' class IndexTest < Test::Unit::TestCase setup do @index_path = File.expand_path('index.txt', __dir__) @missing_path = File.expand_path('missing-index.txt', __dir__) end def expand_path(path, rel = File.dirname(__FILE__)) File.expand_path(path, rel) end test 'cr...
github
gushmazuko/WinBypass
https://github.com/gushmazuko/WinBypass
bypassuac_sluihijack.rb
Ruby
mit
98
master
8,105
## # This module requires Metasploit: https://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ## require 'msf/core/exploit/exe' require 'msf/core/exploit/powershell' class MetasploitModule < Msf::Exploit::Local Rank = ExcellentRanking include Exploit::Powershell include...
github
sunlightlabs/rack-honeypot
https://github.com/sunlightlabs/rack-honeypot
rack-honeypot.gemspec
Ruby
bsd-3-clause
98
master
959
Gem::Specification.new do |s| s.name = %q{rack-honeypot} s.version = "0.1.3" s.summary = %q{Middleware that functions as a spambot trap.} s.authors = ["Luigi Montanez", "Luc Castera", "Daniel Schierbeck"] s.date = %q{2016-01-26} s.description = %q{This middleware acts as a spam trap. It inserts, into every ...
github
sunlightlabs/rack-honeypot
https://github.com/sunlightlabs/rack-honeypot
lib/rack/honeypot.rb
Ruby
bsd-3-clause
98
master
2,461
require 'unindentable' module Rack class Honeypot include Unindentable HONEYPOT_HEADER = "X-Honeypot" def initialize(app, options={}) @app = app @class_name = options[:class_name] || "phonetoy" @label = options[:label] || "Don't fill in this field" @input_name ...
github
sunlightlabs/rack-honeypot
https://github.com/sunlightlabs/rack-honeypot
test/test_honeypot.rb
Ruby
bsd-3-clause
98
master
2,883
require 'rack/test' require 'test/unit' require 'mocha/setup' require 'unindentable' require File.expand_path(File.dirname(__FILE__) + '/../lib/rack/honeypot') # To run this test, you need to have rack-test gem installed: sudo gem install rack-test class HoneypotTest < Test::Unit::TestCase include Rack::Test::Meth...
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
dry-inflector.gemspec
Ruby
mit
98
main
1,455
# frozen_string_literal: true # This file is synced from hanakai-rb/repo-sync. To update it, edit repo-sync.yml. lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "dry/inflector/version" Gem::Specification.new do |spec| spec.name = "dry-inflector" spe...
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
Rakefile
Ruby
mit
98
main
200
# frozen_string_literal: true require "rake" require "bundler/gem_tasks" require "rspec/core/rake_task" task default: :spec desc "Run all specs in spec directory" RSpec::Core::RakeTask.new(:spec)
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
Gemfile
Ruby
mit
98
main
216
# frozen_string_literal: true source "https://rubygems.org" eval_gemfile "Gemfile.devtools" gemspec group :benchmarks do gem "benchmark-ips" end group :tools do gem "byebug", platform: :mri gem "yard" end
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
lib/dry/inflector.rb
Ruby
mit
98
main
9,053
# frozen_string_literal: true module Dry # dry-inflector # # @since 0.1.0 class Inflector require "dry/inflector/version" require "dry/inflector/inflections" # Instantiate the inflector # # @param blk [Proc] an optional block to specify custom inflection rules # @yieldparam [Dry::Infle...
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
lib/dry/inflector/acronyms.rb
Ruby
mit
98
main
871
# frozen_string_literal: true module Dry class Inflector # A set of acronyms # # @since 0.1.2 # @api private class Acronyms attr_reader :regex # @since 0.1.2 # @api private def initialize @rules = {} define_regex_patterns end # @since 0.1.2 ...
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
lib/dry/inflector/inflections.rb
Ruby
mit
98
main
7,025
# frozen_string_literal: true require "dry/inflector/rules" require "dry/inflector/acronyms" module Dry class Inflector # Inflections # # @since 0.1.0 class Inflections require "dry/inflector/inflections/defaults" # Instantiate a set of inflection rules. # It adds the default rule...
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
lib/dry/inflector/rules.rb
Ruby
mit
98
main
664
# frozen_string_literal: true module Dry class Inflector # A set of inflection rules # # @since 0.1.0 # @api private class Rules # @since 0.1.0 # @api private def initialize @rules = [] end # @since 0.1.0 # @api private def apply_to(word) ...
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
lib/dry/inflector/inflections/defaults.rb
Ruby
mit
98
main
4,766
# frozen_string_literal: true module Dry class Inflector class Inflections # Default inflections # # @since 0.1.0 # @api private # # rubocop:disable Metrics/AbcSize module Defaults # @since 0.1.0 # @api private def self.call(inflect) plu...
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
spec/spec_helper.rb
Ruby
mit
98
main
666
# frozen_string_literal: true require "bundler/setup" require_relative "support/coverage" require "pathname" SPEC_ROOT = Pathname(__dir__) require "dry/inflector" Dir.glob(Pathname.new(__dir__).join("support", "**", "*.rb")).each do |file| require_relative file end RSpec.configure do |config| config.expect_w...
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
spec/support/immutable.rb
Ruby
mit
98
main
243
# frozen_string_literal: true module RSpec module Support module Immutable private def i(string) string.freeze end end end end RSpec.configure do |config| config.include RSpec::Support::Immutable end
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
spec/unit/dry/inflector_spec.rb
Ruby
mit
98
main
351
# frozen_string_literal: true RSpec.describe Dry::Inflector do subject(:inflector) { described_class.new } describe "#to_s" do specify do expect(inflector.to_s).to eql("#<Dry::Inflector>") end end describe "#inspect" do specify do expect(inflector.method(:inspect)).to eql(inflector.me...
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
spec/unit/dry/inflector/acronym_spec.rb
Ruby
mit
98
main
2,269
# frozen_string_literal: true RSpec.describe Dry::Inflector do subject do Dry::Inflector.new do |inflect| inflect.acronym("RESTful", "RoR", "PhD", "W3C", "SSL", "HTML") end end describe "acronyms" do it "uses acronyms" do aggregate_failures do # These examples were taken from Act...
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
spec/unit/dry/inflector/demodulize_spec.rb
Ruby
mit
98
main
500
# frozen_string_literal: true RSpec.describe Dry::Inflector do describe "#demodulize" do it "demodulizes module name: DataMapper::Inflecto => Inflecto" do expect(subject.demodulize(i("DataMapper::Inflecto"))).to eq("Inflecto") end it "demodulizes module name: A::B::C::D::E => E" do expect(su...
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
spec/unit/dry/inflector/dasherize_spec.rb
Ruby
mit
98
main
370
# frozen_string_literal: true RSpec.describe Dry::Inflector do describe "#dasherize" do it "dasherizes data_mapper_rspec as data-mapper-rspec" do expect(subject.dasherize(i("data_mapper_rspec"))).to eq("data-mapper-rspec") end it "accepts symbols" do expect(subject.dasherize(:data_mapper_rsp...
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
spec/unit/dry/inflector/foreign_key_spec.rb
Ruby
mit
98
main
483
# frozen_string_literal: true RSpec.describe Dry::Inflector do describe "#foreign_key" do it "adds _id to downcased string: Message => message_id" do expect(subject.foreign_key(i("Message"))).to eq "message_id" end it "demodulizes string first: Admin::Post => post_id" do expect(subject.forei...
github
dry-rb/dry-inflector
https://github.com/dry-rb/dry-inflector
spec/unit/dry/inflector/underscore_spec.rb
Ruby
mit
98
main
3,173
# frozen_string_literal: true RSpec.describe Dry::Inflector do describe "#underscore" do it "underscores DataMapper as data_mapper" do expect(subject.underscore(i("DataMapper"))).to eq("data_mapper") end it "underscores Merb as merb" do expect(subject.underscore(i("Merb"))).to eq("merb") ...