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
erwinjunker/regressor
https://github.com/erwinjunker/regressor
lib/model/active_record/enum.rb
Ruby
mit
205
master
416
module Regressor module Model module Enum def enums enum_specs = [] @model.constantize.defined_enums.each do |enum_k, enum_v| enum_values = enum_v.map do |key, value| key end enum_specs << "it { is_expected.to define_enum_for(:#{enum_k}).with(#{enum_...
github
erwinjunker/regressor
https://github.com/erwinjunker/regressor
lib/model/active_record/util.rb
Ruby
mit
205
master
247
module Regressor module Model module Util def extract_validators(validator_type) @model.constantize.validators.select do |validator| validator.class.to_s == validator_type.to_s end end end end end
github
erwinjunker/regressor
https://github.com/erwinjunker/regressor
lib/model/active_record/validation/length.rb
Ruby
mit
205
master
1,119
module Regressor module Model module Validation module Length def length_validators extract_validators(::ActiveModel::Validations::LengthValidator).flatten.map do |validator| specs = [] specs.concat generate_length_examples(validator, validator.options[:minimum]-1, ...
github
erwinjunker/regressor
https://github.com/erwinjunker/regressor
lib/model/active_record/validation/presence.rb
Ruby
mit
205
master
490
module Regressor module Model module Validation module Presence def presence_validators extract_validators(::ActiveRecord::Validations::PresenceValidator).flatten.map do |validator| specs = validator.attributes.map do |attribute| "it { is_expected.to validate_pres...
github
erwinjunker/regressor
https://github.com/erwinjunker/regressor
lib/model/active_record/validation/numericality.rb
Ruby
mit
205
master
2,863
module Regressor module Model module Validation module Numericality def numericality_validators extract_validators(::ActiveModel::Validations::NumericalityValidator).flatten.map do |validator| specs = [] if validator.options.blank? specs.concat validat...
github
erwinjunker/regressor
https://github.com/erwinjunker/regressor
lib/model/active_record/nested/attribute.rb
Ruby
mit
205
master
403
module Regressor module Model module Nested module Attribute def nested_attributes if @model.constantize.nested_attributes_options.present? @model.constantize.nested_attributes_options.keys.map do |key| "it { is_expected.to accept_nested_attributes_for :#{key} }" ...
github
erwinjunker/regressor
https://github.com/erwinjunker/regressor
lib/model/active_record/relation/has_one.rb
Ruby
mit
205
master
334
module Regressor module Model module Relation module HasOne def has_one_relations @model.constantize.reflect_on_all_associations(:has_one).map(&:name).map do |relation| "it { is_expected.to have_one :#{relation} }" end.join("\n ") rescue nil end end ...
github
erwinjunker/regressor
https://github.com/erwinjunker/regressor
lib/model/active_record/relation/has_many.rb
Ruby
mit
205
master
338
module Regressor module Model module Relation module HasMany def has_many_relations @model.constantize.reflect_on_all_associations(:has_many).map(&:name).map do |relation| "it { is_expected.to have_many :#{relation} }" end.join("\n ") rescue nil end end...
github
erwinjunker/regressor
https://github.com/erwinjunker/regressor
lib/model/active_record/relation/belong_to.rb
Ruby
mit
205
master
331
module Regressor module Model module Relation module BelongTo def belong_to_relations @model.constantize.reflect_on_all_associations(:belongs_to).map(&:name).map do |relation| "it { is_expected.to belong_to :#{relation} }" end.join("\n ") end end en...
github
erwinjunker/regressor
https://github.com/erwinjunker/regressor
lib/model/active_record/relation/has_and_belongs_to_many.rb
Ruby
mit
205
master
385
module Regressor module Model module Relation module HasAndBelongsToMany def has_and_belongs_to_many_relations @model.constantize.reflect_on_all_associations(:has_and_belongs_to_many).map(&:name).map do |relation| "it { is_expected.to have_and_belong_to_many :#{relation} }" ...
github
erwinjunker/regressor
https://github.com/erwinjunker/regressor
lib/model/active_record/database/column.rb
Ruby
mit
205
master
285
module Regressor module Model module Database module Column def columns @model.constantize.columns.map(&:name).map do |column| "it { is_expected.to have_db_column :#{column} }" end.join("\n ") end end end end end
github
erwinjunker/regressor
https://github.com/erwinjunker/regressor
lib/model/active_record/database/index.rb
Ruby
mit
205
master
332
module Regressor module Model module Database module Index def indices ::ActiveRecord::Base.connection.indexes(@model.constantize.table_name).map do |indexes| "it { is_expected.to have_db_index #{indexes.columns} }" end.flatten.join("\n ") end end e...
github
0x7466/LeSSL
https://github.com/0x7466/LeSSL
le_ssl.gemspec
Ruby
mit
205
master
907
$:.push File.expand_path('../lib', __FILE__) # Maintain your gem's version: require 'le_ssl/version' # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = 'le_ssl' s.version = LeSSL::VERSION s.required_ruby_version = '>= 2.1.0' s.authors ...
github
0x7466/LeSSL
https://github.com/0x7466/LeSSL
Rakefile
Ruby
mit
205
master
573
begin require 'bundler/setup' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end require 'rdoc/task' RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'LeSSL' rdoc.options << '--line-numbers' rdoc.rdoc_files.include('README.rdoc') rdoc....
github
0x7466/LeSSL
https://github.com/0x7466/LeSSL
Gemfile
Ruby
mit
205
master
609
source 'https://rubygems.org' # Declare your gem's dependencies in le_ssl.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec # Declare any dependencies that are still in development here instead of in # ...
github
0x7466/LeSSL
https://github.com/0x7466/LeSSL
test/test_helper.rb
Ruby
mit
205
master
708
# Configure Rails Environment ENV["RAILS_ENV"] = "test" require File.expand_path("../../test/dummy/config/environment.rb", __FILE__) require "rails/test_help" # Filter out Minitest backtrace while allowing backtrace from other libraries # to be shown. Minitest.backtrace_filter = Minitest::BacktraceFilter.new # Load...
github
0x7466/LeSSL
https://github.com/0x7466/LeSSL
test/dummy/config/application.rb
Ruby
mit
205
master
1,086
require File.expand_path('../boot', __FILE__) # Pick the frameworks you want: # require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" require "sprockets/railtie" require "rails/test_unit/railtie" Bundler.require(*Rails.groups) require "le_ssl...
github
0x7466/LeSSL
https://github.com/0x7466/LeSSL
test/dummy/config/environments/test.rb
Ruby
mit
205
master
1,769
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suit...
github
0x7466/LeSSL
https://github.com/0x7466/LeSSL
test/dummy/config/environments/production.rb
Ruby
mit
205
master
3,203
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web serve...
github
0x7466/LeSSL
https://github.com/0x7466/LeSSL
test/le_ssl/manager_test.rb
Ruby
mit
205
master
3,987
require 'test_helper' class LeSSL::ManagerTest < ActiveSupport::TestCase def private_key; @private_key ||= OpenSSL::PKey::RSA.new(2048); end def manager(skip_register=true); @manager ||= LeSSL::Manager.new(skip_register: skip_register, email: FFaker::Internet.free_email, private_key: private_key, agree_terms: true...
github
0x7466/LeSSL
https://github.com/0x7466/LeSSL
lib/le_ssl/errors.rb
Ruby
mit
205
master
300
module LeSSL class GenericError < StandardError; end class NoContactEmailError < GenericError; end class TermsNotAcceptedError < GenericError; end class NoPrivateKeyError < GenericError; end class PrivateKeyInvalidFormat < GenericError; end class UnauthorizedError < GenericError; end end
github
0x7466/LeSSL
https://github.com/0x7466/LeSSL
lib/le_ssl/dns.rb
Ruby
mit
205
master
810
module LeSSL class DNS def initialize(nameservers=['8.8.8.8', '8.8.4.4']) @dns = Resolv::DNS.new(nameserver: nameservers) end # Checks if the TXT record # for a domain is valid. def challenge_record_valid?(domain, key) record = challenge_record(domain) return record && record.da...
github
0x7466/LeSSL
https://github.com/0x7466/LeSSL
lib/le_ssl/manager.rb
Ruby
mit
205
master
5,273
module LeSSL class Manager PRODUCTION_ENDPOINT = 'https://acme-v01.api.letsencrypt.org/' DEVELOPMENT_ENDPOINT = 'https://acme-staging.api.letsencrypt.org/' def initialize(options={}) email = options[:email] || email_from_env raise LeSSL::NoContactEmailError if email.nil? raise LeSSL::T...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
has_friendship.gemspec
Ruby
mit
205
master
1,518
RAILS_VERSIONS = ['>= 4.2.0'].freeze $:.push File.expand_path("../lib", __FILE__) # Maintain your gem's version: require "has_friendship/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = "has_friendship" s.version = HasFriendship::VERSION s.authors ...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
Guardfile
Ruby
mit
205
master
1,886
# A sample Guardfile # More info at https://github.com/guard/guard#readme ## Uncomment and set this to only include directories you want to watch # directories %(app lib config test spec feature) ## Uncomment to clear the screen before every task # clearing :on # Note: The cmd option is now required due to the incre...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
Gemfile
Ruby
mit
205
master
539
source "https://rubygems.org" # Declare your gem's dependencies in has_friendship.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec # Declare any dependencies that are still in development here instead ...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
Appraisals
Ruby
mit
205
master
1,324
appraise "rails-6-0" do version = "~> 6.0.0" gem "activesupport", version gem "activemodel", version gem "activerecord", version gem "logger" gem "concurrent-ruby", "< 1.3" gem "pg" gem "sqlite3", "~> 1.4" gem "mysql2", "~> 0.5" gem "irb" gem "psych", "< 4" end appraise "rails-6-1" do version =...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
Rakefile
Ruby
mit
205
master
528
begin require 'bundler/setup' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end require 'rspec/core/rake_task' require 'rdoc/task' RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'HasFriendship' rdoc.options << '--line-numbers' rdoc.rd...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
lib/has_friendship.rb
Ruby
mit
205
master
337
require 'stateful_enum' require 'active_support' require 'active_record' require 'rails/engine' require 'has_friendship/engine' module HasFriendship extend ActiveSupport::Autoload autoload :Friendable autoload :Friendship autoload :Extender end ActiveSupport.on_load(:active_record) do extend HasFriendship...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
lib/has_friendship/friendship.rb
Ruby
mit
205
master
2,414
module HasFriendship FRIENDSHIP_ENUM_VALUES = { pending: 0, requested: 1, accepted: 2, blocked: 3 } class Friendship < ActiveRecord::Base validate :satisfy_custom_conditions after_create do |record| friend.try(:on_friendship_created, record) end after_destroy do |record| friendable.tr...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
lib/has_friendship/engine.rb
Ruby
mit
205
master
975
module HasFriendship class Engine < ::Rails::Engine # Don't bother with isolate_namespace; we're only working with # one table here. # # isolate_namespace HasFriendship # # NOTE ABOUT DATABASE MIGRATIONS # # This Gem uses the `has_friendship:install:migrations` Rake task, # which ...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
lib/has_friendship/extender.rb
Ruby
mit
205
master
367
module HasFriendship module Extender def self.included(base) # Dynamically define the Friendship's association based on where the module is included. HasFriendship::Friendship.class_eval do belongs_to :friendable, polymorphic: true belongs_to :friend, class_name: "#{base.to_s}", forei...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
lib/has_friendship/friendable.rb
Ruby
mit
205
master
3,300
module HasFriendship module Friendable def friendable? false end def has_friendship class_eval do has_many :friendships, as: :friendable, class_name: "HasFriendship::Friendship", dependent: :destroy has_many :blocked_friends, -> { where frie...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
spec/rails_helper.rb
Ruby
mit
205
master
2,623
# This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' require 'spec_helper' require File.expand_path("../internal/config/environment", __FILE__) require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! require 'shoulda' requ...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
spec/spec_helper.rb
Ruby
mit
205
master
4,668
# Use coveralls to measure test coverage require 'coveralls' Coveralls.wear! # spec/spec_helper.rb require "active_record" adapter = ENV['DB_ADAPTER'] || 'sqlite3' config = case adapter when 'postgresql' { adapter: 'postgresql', database: 'rails_tester', host: 'localhost', user: 'postgres', password: 'password' } ...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
spec/support/friendship_macro.rb
Ruby
mit
205
master
1,032
module FriendshipMacros def create_request(friendable, friend) HasFriendship::Friendship.create(friendable_id: friendable.id, friendable_type: friendable.class.base_class.name, friend_id: friend.id, status: 'pending') HasFriendship::Friendship.create(friendable_id: friend.id, friendable_type: friend.class.bas...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
spec/internal/db/schema.rb
Ruby
mit
205
master
1,404
# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # This file is the source Rails uses to define your schema when running `bin/rai...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
spec/internal/config/application.rb
Ruby
mit
205
master
1,148
require File.expand_path('../boot', __FILE__) # Pick the frameworks you want: require "active_record/railtie" # require "action_controller/railtie" # require "action_mailer/railtie" # require "action_view/railtie" # require "sprockets/railtie" # require "rails/test_unit/railtie" Bundler.require(*Rails.groups) require...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
spec/internal/config/environments/development.rb
Ruby
mit
205
master
1,425
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web serv...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
spec/internal/config/environments/test.rb
Ruby
mit
205
master
1,662
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suit...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
spec/has_friendship/feature_spec.rb
Ruby
mit
205
master
1,809
require 'rails_helper' # Might not be needed describe "HasFriendship API" do let(:user){ User.create(name: "Jessie", id: 100) } let(:friend){ User.create(name: "Heisenberg", id: 101) } describe "Friend request" do context "when sent" do before { user.friend_request(friend) } it "should create ...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
spec/has_friendship/has_friendship_spec.rb
Ruby
mit
205
master
543
require 'rails_helper' describe HasFriendship do it { should be_a(Module) } describe ".friendable?" do it "should be provided for models" do expect(User).to respond_to(:friendable?) expect(Unfriendable).to respond_to(:friendable?) end context "for friendable models" do it "should re...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
spec/has_friendship/friendable_spec.rb
Ruby
mit
205
master
10,211
require 'rails_helper' describe User, type: :model do let(:user) { User.create(name: 'Jessie') } let(:friend) { User.create(name: 'Heisenberg') } describe "association" do # TODO: find a way to test condition it { should have_many(:friendships).class_name('HasFriendship::Friendship').dependent(:destroy)...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
spec/has_friendship/friendship_spec.rb
Ruby
mit
205
master
2,096
require 'rails_helper' describe HasFriendship::Friendship, type: :model do let(:user){ User.create(name: "Jessie") } let(:friend){ User.create(name: "Heisenberg") } describe "associations" do it { should belong_to(:friendable) } it { should belong_to(:friend).with_foreign_key(:friend_id) } # Why can't ...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
db/migrate/2_add_blocker_id_to_friendships.rb
Ruby
mit
205
master
396
if ActiveRecord.gem_version >= Gem::Version.new('5.0') class AddBlockerIdToFriendships < ActiveRecord::Migration[4.2]; end else class AddBlockerIdToFriendships < ActiveRecord::Migration; end end AddBlockerIdToFriendships.class_eval do def self.up add_column :friendships, :blocker_id, :integer, default: nil ...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
db/migrate/1_create_friendships.rb
Ruby
mit
205
master
459
if ActiveRecord.gem_version >= Gem::Version.new('5.0') class CreateFriendships < ActiveRecord::Migration[4.2]; end else class CreateFriendships < ActiveRecord::Migration; end end CreateFriendships.class_eval do def self.up create_table :friendships do |t| t.references :friendable, polymorphic: true ...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
db/migrate/5_add_unique_index_to_friendable_type.rb
Ruby
mit
205
master
1,515
if ActiveRecord.gem_version >= Gem::Version.new('5.0') class AddUniqueIndexToFriendableType < ActiveRecord::Migration[4.2]; end else class AddUniqueIndexToFriendableType < ActiveRecord::Migration; end end AddUniqueIndexToFriendableType.class_eval do disable_ddl_transaction! def self.up return if index_exi...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
db/migrate/4_add_unique_index_to_friendships.rb
Ruby
mit
205
master
922
if ActiveRecord.gem_version >= Gem::Version.new('5.0') class AddUniqueIndexToFriendships < ActiveRecord::Migration[4.2]; end else class AddUniqueIndexToFriendships < ActiveRecord::Migration; end end AddUniqueIndexToFriendships.class_eval do disable_ddl_transaction! def self.up return if index_exists?(:fri...
github
has-friendship/has_friendship
https://github.com/has-friendship/has_friendship
db/migrate/3_update_friendships.rb
Ruby
mit
205
master
1,229
if ActiveRecord.gem_version >= Gem::Version.new('5.0') class UpdateFriendships < ActiveRecord::Migration[4.2]; end else class UpdateFriendships < ActiveRecord::Migration; end end UpdateFriendships.class_eval do def self.up add_column :friendships, :status_temp, :integer, index: true HasFriendship::Friend...
github
tnm/redweb
https://github.com/tnm/redweb
redweb.rb
Ruby
mit
205
master
4,897
require 'ostruct' require 'yaml' require 'redis' require 'sinatra' require 'sinatra/base' class RedWeb < Sinatra::Base @config_file = ARGV[0] @@config ||= YAML.load_file(@config_file) get '/' do erb :index, :locals => { :servers => servers } end class RedisServerInfo attr_reader :name attr_read...
github
lautis/piperator
https://github.com/lautis/piperator
piperator.gemspec
Ruby
mit
205
master
996
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'piperator/version' Gem::Specification.new do |spec| spec.name = 'piperator' spec.version = Piperator::VERSION spec.authors = ['Ville Lautanala'] spec.email = ['lautis@gmail.com'] spec...
github
lautis/piperator
https://github.com/lautis/piperator
Gemfile
Ruby
mit
205
master
241
source 'https://rubygems.org' # Specify your gem's dependencies in piperator.gemspec gemspec if RUBY_VERSION >= '2.5' gem 'simplecov', '~> 0.22.0', group: [:development] gem 'simplecov-cobertura', '~> 3.1.0', group: [:development] end
github
lautis/piperator
https://github.com/lautis/piperator
spec/spec_helper.rb
Ruby
mit
205
master
488
require 'bundler/setup' if RUBY_VERSION >= '2.5' require 'simplecov' require 'simplecov-cobertura' SimpleCov.start do add_filter '/spec/' end if ENV['CI'] SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter end end require 'piperator' RSpec.configure do |config| # Enable flags like ...
github
lautis/piperator
https://github.com/lautis/piperator
spec/piperator_spec.rb
Ruby
mit
205
master
1,611
require 'spec_helper' # rubocop:disable Metrics/BlockLength RSpec.describe Piperator do it 'has a version number' do expect(Piperator::VERSION).not_to be nil end it 'can start piping from Piperator' do expect(Piperator.pipe(->(i) { i }).call([1, 2, 3]).to_a).to eq([1, 2, 3]) end it 'can start wrap ...
github
lautis/piperator
https://github.com/lautis/piperator
spec/piperator/pipeline_spec.rb
Ruby
mit
205
master
3,120
require 'spec_helper' RSpec.describe Piperator::Pipeline do let(:add1) { ->(input) { input.lazy.map { |i| i + 1 } } } let(:square) { ->(input) { input.lazy.map { |i| i * i } } } let(:sum) { ->(input) { input.reduce(0, &:+) } } describe 'calling' do it 'calls through all chain pipes in order' do chai...
github
lautis/piperator
https://github.com/lautis/piperator
spec/piperator/io_spec.rb
Ruby
mit
205
master
4,097
require 'spec_helper' require 'piperator/io' RSpec.describe Piperator::IO do KILOBYTE = 1024 describe '#read' do subject { Piperator::IO.new(["foo", "bar"].each) } it 'reads specific number of bytes' do expect(subject.read(4)).to eq('foob') end it 'buffers rest and returns on next read' do...
github
lautis/piperator
https://github.com/lautis/piperator
lib/piperator.rb
Ruby
mit
205
master
1,609
require 'piperator/version' require 'piperator/pipeline' require 'piperator/io' require 'piperator/builder' # Top-level shortcuts module Piperator # Build a new pipeline using DSL. This enables easy control of the pipeline # stucture. # # Piperator.build do # wrap [1, 2, 3] # pipe(-> (enumerable)...
github
lautis/piperator
https://github.com/lautis/piperator
lib/piperator/pipeline.rb
Ruby
mit
205
master
3,251
module Piperator # Pipeline is responsible of composition of a lazy enumerable from callables. # It contains a collection of pipes that respond to #call and return a # enumerable. # # For streaming purposes, it usually is desirable to have pipes that takes # a lazy Enumerator as an argument a return a (modi...
github
lautis/piperator
https://github.com/lautis/piperator
lib/piperator/builder.rb
Ruby
mit
205
master
1,470
module Piperator # Builder is used to provide DSL-based Pipeline building. Using Builder, # Pipelines can be built without pipe chaining, which might be easier if # some steps need to be included only on specific conditions. # # @see Piperator.build class Builder # Expose a chained method in Pipeline in...
github
lautis/piperator
https://github.com/lautis/piperator
lib/piperator/io.rb
Ruby
mit
205
master
3,182
require 'English' module Piperator # Pseudo I/O on Enumerators class IO FLUSH_THRESHOLD = 128 * 1028 # 128KiB attr_reader :eof attr_reader :pos def initialize(enumerator, flush_threshold: FLUSH_THRESHOLD) @enumerator = enumerator @flush_threshold = flush_threshold @buffer = Stri...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
tty-table.gemspec
Ruby
mit
204
master
1,395
# frozen_string_literal: true require_relative "lib/tty/table/version" Gem::Specification.new do |spec| spec.name = "tty-table" spec.version = TTY::Table::VERSION spec.authors = ["Piotr Murach"] spec.email = ["piotr@piotrmurach.com"] spec.summary = %q{A flexible and intuit...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
Gemfile
Ruby
mit
204
master
511
source "https://rubygems.org" gemspec if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.1.0") gem "rspec-benchmark" end if RUBY_VERSION == "2.0.0" gem "json", "2.4.1" gem "rake", "12.3.3" end group :tools do gem "yard", "~> 0.9.12" end group :metrics do if Gem::Version.new(RUBY_VERSION) >= Gem::Ver...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/spec_helper.rb
Ruby
mit
204
master
1,136
# frozen_string_literal: true if ENV["COVERAGE"] == "true" require "simplecov" require "coveralls" SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([ SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter ]) SimpleCov.start do command_name "spec" add_filter "spec...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/render_spec.rb
Ruby
mit
204
master
1,859
# frozen_string_literal: true RSpec.describe TTY::Table, '#render' do let(:object) { described_class } let(:header) { ['h1', 'h2'] } let(:rows) { [['a1', 'a2'], ['b1', 'b2']] } let(:color) { Pastel.new(enabled: true) } let(:basic_renderer) { TTY::Table::Renderer::Basic } let(:ascii_renderer) { TTY::...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/to_s_spec.rb
Ruby
mit
204
master
1,245
# frozen_string_literal: true require 'spec_helper' RSpec.describe TTY::Table, '#to_s' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } subject(:table) { described_class.new(header, rows) } context 'without renderer' do it 'displayes basic table' do ...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/rotate_spec.rb
Ruby
mit
204
master
2,097
# frozen_string_literal: true RSpec.describe TTY::Table, '#rotate' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } subject(:table) { described_class.new(header, rows) } before { table.orientation = :horizontal } context 'with default' do context 'without ...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/each_with_index_spec.rb
Ruby
mit
204
master
1,357
# frozen_string_literal: true RSpec.describe TTY::Table, '.each_with_index' do context 'with no block' do it 'returns enumerable' do table = TTY::Table.new ['h1','h2'], [['a1','a2'],['b1','b2']] expect(table.each_with_index).to be_instance_of(to_enum.class) end it 'yields the expected value...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/new_spec.rb
Ruby
mit
204
master
2,108
# frozen_string_literal: true RSpec.describe TTY::Table, '#new' do it { is_expected.to be_kind_of(Enumerable) } it { is_expected.to be_kind_of(Comparable) } context 'with rows only' do it 'allows hash like syntax for rows' do table = TTY::Table[['a1','a2'], ['b1', 'b2']] expect(table.to_a).to e...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/header_spec.rb
Ruby
mit
204
master
314
# frozen_string_literal: true RSpec.describe TTY::Table, '#header' do let(:header) { [:header1, :header2] } let(:rows) { [['a1', 'a2'], ['b1', 'b2']] } let(:object) { described_class } subject(:table) { object.new header, rows } it { expect(table.header).to be_instance_of(TTY::Table::Header) } end
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/data_spec.rb
Ruby
mit
204
master
285
# frozen_string_literal: true RSpec.describe TTY::Table, '.data' do it 'gets all table data' do header = ['h1', 'h2', 'h3'] rows = [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] table = described_class.new header, rows expect(table.data).to eql([header] + rows) end end
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/access_spec.rb
Ruby
mit
204
master
2,043
# frozen_string_literal: true RSpec.describe TTY::Table, 'access' do let(:header) { [:head1, :head2] } let(:rows) { [['a1', 'a2'], ['b1', 'b2']] } subject(:table) { TTY::Table.new rows: rows, header: header } it { is_expected.to respond_to(:element) } it { is_expected.to respond_to(:component) } it {...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/render_with_spec.rb
Ruby
mit
204
master
2,539
# frozen_string_literal: true RSpec.describe TTY::Table, '#render_with' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } let(:table) { described_class.new header, rows } let(:color) { Pastel.new(enabled: true) } before { allow(Pastel).to receive(:new).and_re...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/validatable_spec.rb
Ruby
mit
204
master
906
# frozen_string_literal: true RSpec.describe TTY::Table::Validatable do let(:described_class) { Class.new { include TTY::Table::Validatable } } let(:rows) { [['a1', 'a2'], ['b1']] } subject { described_class.new } it 'raises no exception' do rows[1] << ['b2'] expect { subject.assert_row_sizes(rows) }...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/eql_spec.rb
Ruby
mit
204
master
1,738
# frozen_string_literal: true RSpec.describe TTY::Table, "#eql?" do let(:header) { %w[h1 h2] } let(:rows) { [%w[a1 a2], %w[b1 b2]] } describe "#==" do it "is equivalent with the same table" do object = described_class.new(rows) expect(object).to eq(object) end it "is equivalent with a t...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/renderer_spec.rb
Ruby
mit
204
master
449
# frozen_string_literal: true RSpec.describe TTY::Table, '#renderer' do let(:object) { described_class } let(:header) { ['h1', 'h2'] } let(:rows) { [['a1', 'a2'], ['b1', 'b2']] } subject(:table) { object.new(header, rows).renderer } it 'creates new renderer' do expect(subject).to be_kind_of(TTY::Tabl...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/empty_spec.rb
Ruby
mit
204
master
428
# frozen_string_literal: true RSpec.describe TTY::Table, '#empty?' do let(:header) { ['Header1', 'Header2'] } let(:object) { described_class.new header, rows } subject { object.empty? } context 'with rows containing no entries' do let(:rows) { [] } it { is_expected.to eq(true) } end context 'wi...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/options_spec.rb
Ruby
mit
204
master
534
# frozen_string_literal: true RSpec.describe TTY::Table, 'options' do let(:rows) { [['a1', 'a2'], ['b1', 'b2']] } let(:widths) { nil } let(:aligns) { [] } let(:object) { described_class } let(:options) { { column_widths: widths, column_aligns: aligns, renderer: :basic } } sub...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/utf_spec.rb
Ruby
mit
204
master
992
# frozen_string_literal: true RSpec.describe TTY::Table, 'unicode support' do it "measures utf characters correctly for :basic" do table = TTY::Table[['こんにちは', 'a2'], ['b1','選択']] expect(table.render(:basic)).to eq unindent(<<-EOS) こんにちは a2 b1 選択 EOS end it "measure utf charact...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/orientation_spec.rb
Ruby
mit
204
master
3,303
# frozen_string_literal: true RSpec.describe TTY::Table, 'orientation' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } let(:options) { { :orientation => orientation } } subject { described_class.new(header, rows, options) } context 'when illegal option' do ...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/add_row_spec.rb
Ruby
mit
204
master
548
# frozen_string_literal: true RSpec.describe TTY::Table, '#<<' do let(:rows) { ['a', 'b', 'c'] } let(:object) { described_class } subject(:table) { object[rows] } context 'with primitive values' do let(:row) { [1, 2, 3] } it 'extracts values correctly' do table << row expect(table.to_a.l...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/filter_spec.rb
Ruby
mit
204
master
497
# frozen_string_literal: true RSpec.describe TTY::Table, '#filter' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } subject(:table) { described_class.new(header, rows) } it 'filters fields' do expect(table.render do |renderer| renderer.filter = proc ...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/each_spec.rb
Ruby
mit
204
master
561
# frozen_string_literal: true RSpec.describe TTY::Table, '#each' do let(:header) { ['Header1'] } let(:rows) { [['a1'], ['b1']] } subject(:table) { described_class.new(header, rows) } context 'with no block' do it { expect(table.each).to be_instance_of(to_enum.class) } it 'yields the expected value...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/properties_spec.rb
Ruby
mit
204
master
499
# frozen_string_literal: true RSpec.describe TTY::Table, 'properties' do let(:rows) {[['a1', 'a2', 'a3'], ['b1', 'b2', 'c3']] } subject(:table) { described_class.new rows } it { expect(table.width).to eq(6) } it { expect(table.rows_size).to eq(2) } it { expect(table.columns_size).to eq(3) } it { expec...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/render_repeat_spec.rb
Ruby
mit
204
master
1,113
# frozen_string_literal: true RSpec.describe TTY::Table, 'render repeat' do it "renders consistently" do table = TTY::Table.new header: ['header1', 'header2'] table << ['a1', 'a2'] table << ['b1', 'b2'] options = {padding: [1,1,1,1], alignments: [:right, :center]} expect(table.render(:ascii, opti...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/alignment_spec.rb
Ruby
mit
204
master
2,199
# frozen_string_literal: true RSpec.describe TTY::Table, 'alignment' do it "aligns table columns when rendering" do table = TTY::Table.new ['header1', 'header2'], [['a1','a2'],['b1','b2']] expect(table.render(alignments: [:right, :center])).to eql([ "header1 header2", " a1 a2 ", " ...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/padding_spec.rb
Ruby
mit
204
master
3,426
# frozen_string_literal: true RSpec.describe TTY::Table, 'padding' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } let(:table) { described_class.new(header, rows) } it 'sets specific padding' do expect(table.render(:ascii) { |renderer| renderer.paddi...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/renderer/select_spec.rb
Ruby
mit
204
master
446
# frozen_string_literal: true RSpec.describe TTY::Table::Renderer, '#select' do let(:klass) { ::Class.new } let(:instance) { described_class } subject { instance.select(renderer) } context 'with basic' do let(:renderer) { :basic } it { is_expected.to be(TTY::Table::Renderer::Basic) } end con...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/renderer/border_spec.rb
Ruby
mit
204
master
2,341
# frozen_string_literal: true RSpec.describe TTY::Table::Renderer, '#border' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } let(:border) { nil } let(:table) { TTY::Table.new(header, rows) } subject(:renderer) { described_class.select(type).new(table) } c...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/renderer/render_spec.rb
Ruby
mit
204
master
1,092
# frozen_string_literal: true RSpec.describe TTY::Table::Renderer, '#render' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } let(:table) { TTY::Table.new(header, rows) } subject { described_class.render(table, {}, &block) } context 'when default' do let...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/renderer/ascii/padding_spec.rb
Ruby
mit
204
master
4,296
# frozen_string_literal: true RSpec.describe TTY::Table::Renderer::ASCII, 'padding' do let(:header) { ['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'] } let(:rows) { [['id', 'int(11)', 'YES', 'nil', 'NULL', '']] } let(:table) { TTY::Table.new(header, rows) } subject(:renderer) { described_class.new(tab...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/renderer/ascii/coloring_spec.rb
Ruby
mit
204
master
2,810
# frozen_string_literal: true RSpec.describe TTY::Table::Renderer::ASCII, 'coloring' do let(:color) { Pastel.new(enabled: true) } before { allow(Pastel).to receive(:new).and_return(color) } context 'when border' do it "colors border" do table = TTY::Table.new header: ['header1', 'header2'] ta...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/renderer/ascii/render_spec.rb
Ruby
mit
204
master
1,556
# frozen_string_literal: true RSpec.describe TTY::Table::Renderer::ASCII, '#render' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } let(:table) { TTY::Table.new header, rows } subject(:renderer) { described_class.new(table) } context 'only rows' do let(:ta...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/renderer/ascii/multiline_spec.rb
Ruby
mit
204
master
3,092
# frozen_string_literal: true RSpec.describe TTY::Table::Renderer::ASCII, 'multiline content' do context 'with escaping' do it "renders multiline as single line" do rows = [["First", '1'], ["Multiline\nContent", '2'], ["Third", '3']] table = TTY::Table.new rows renderer = described_class.new(ta...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/renderer/ascii/indentation_spec.rb
Ruby
mit
204
master
844
# frozen_string_literal: true RSpec.describe TTY::Table::Renderer::ASCII, 'indentation' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } let(:table) { TTY::Table.new(header, rows) } let(:indent) { 2 } let(:options) { {indent: indent } } subject(:rendere...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/renderer/ascii/resizing_spec.rb
Ruby
mit
204
master
3,090
# frozen_string_literal: true RSpec.describe TTY::Table::Renderer::ASCII, 'resizing' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } let(:table) { TTY::Table.new(header, rows) } subject(:renderer) { described_class.new(table, options) } context 'when exp...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/renderer/ascii/separator_spec.rb
Ruby
mit
204
master
944
# frozen_string_literal: true RSpec.describe TTY::Table::Renderer::ASCII, 'with separator' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } let(:table) { TTY::Table.new(header, rows) } let(:object) { described_class.new table } subject(:renderer) { object } ...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/renderer/unicode/render_spec.rb
Ruby
mit
204
master
1,967
# frozen_string_literal: true RSpec.describe TTY::Table::Renderer::Unicode, '#render' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } let(:table) { TTY::Table.new header, rows } subject(:renderer) { described_class.new(table) } context 'with rows only' do ...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/renderer/unicode/coloring_spec.rb
Ruby
mit
204
master
2,794
# frozen_string_literal: true RSpec.describe TTY::Table::Renderer::Unicode, 'coloring' do let(:color) { Pastel.new(enabled: true) } before { allow(Pastel).to receive(:new).and_return(color) } context 'when border' do it "colors border" do table = TTY::Table.new header: ['header1', 'header2'] ...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/renderer/unicode/separator_spec.rb
Ruby
mit
204
master
1,051
# frozen_string_literal: true RSpec.describe TTY::Table::Renderer::Unicode, 'with separator' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } let(:table) { TTY::Table.new(header, rows) } let(:object) { described_class.new table } subject(:renderer) { object ...
github
piotrmurach/tty-table
https://github.com/piotrmurach/tty-table
spec/unit/renderer/unicode/indentation_spec.rb
Ruby
mit
204
master
1,033
# frozen_string_literal: true RSpec.describe TTY::Table::Renderer::Unicode, 'indentation' do let(:header) { ['h1', 'h2', 'h3'] } let(:rows) { [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']] } let(:table) { TTY::Table.new(header, rows) } let(:indent) { 2 } let(:options) { {indent: indent } } subject(:rende...