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 | MoskitoHero/barley | https://github.com/MoskitoHero/barley | Rakefile | Ruby | mit | 84 | main | 212 | require "bundler/setup"
require "bundler/gem_tasks"
require "rake/testtask"
Rake::TestTask.new do |t|
t.test_files = FileList["test/**/*_test.rb"]
t.libs << "test"
end
desc "Run tests"
task default: :test |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | Gemfile | Ruby | mit | 84 | main | 275 | source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Specify your gem's dependencies in barley.gemspec.
gemspec
gem "puma"
gem "sqlite3", "~> 2.1"
gem "debug", ">= 1.0.0", group: :development
gem "standard", group: :development |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | benchmarks/single_resource.rb | Ruby | mit | 84 | main | 6,797 | # Benchmark script to run varieties of JSON serializers
# Fetch Barley from local, otherwise fetch latest from RubyGems
require_relative "prep"
# --- Alba serializers ---
require "alba"
class AlbaCommentResource
include ::Alba::Resource
attributes :id, :body
end
class AlbaPostResource
include ::Alba::Resourc... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | benchmarks/prep.rb | Ruby | mit | 84 | main | 1,412 | # --- Test data model setup ---
RubyVM::YJIT.enable unless ENV["NO_YJIT"]
require "csv"
require "pg"
require "active_record"
require "active_record/connection_adapters/postgresql_adapter"
require "logger"
require "oj"
require "sqlite3"
Oj.optimize_rails unless ENV["NO_OJ_OPTIMIZE_RAILS"]
puts "Running benchmark with ... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | benchmarks/Gemfile | Ruby | mit | 84 | main | 553 | # frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "active_model_serializers"
gem "activerecord", "~> 7.1"
gem "alba"
gem "barley", path: "../"
gem "benchmark-ips"
gem "benchmark-memory"
gem "blueprinter"
gem "csv"
gem "debug"
gem "fast_seri... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | benchmarks/collection.rb | Ruby | mit | 84 | main | 7,866 | # Benchmark script to run varieties of JSON serializers
# Fetch Barley from local, otherwise fetch latest from RubyGems
require_relative "prep"
# --- Alba serializers ---
require "alba"
Alba.inflector = :active_support
class AlbaCommentResource
include ::Alba::Resource
attributes :id, :body
end
class AlbaPost... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | lib/barley.rb | Ruby | mit | 84 | main | 475 | require "barley/version"
require "barley/railtie"
require "barley/configuration"
require "dry-types"
module Barley
mattr_accessor :config
self.config = Configuration.new
def self.configure
self.config ||= Configuration.new
yield(config)
end
autoload :Cache, "barley/cache"
autoload :Error, "barle... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | lib/generators/serializer/serializer_generator.rb | Ruby | mit | 84 | main | 1,042 | # frozen_string_literal: true
class SerializerGenerator < Rails::Generators::NamedBase
source_root File.expand_path("templates", __dir__)
class_option :name, type: :string, desc: "Custom serializer name"
def create_serializer_file
@serializer_name = options[:name] || "#{class_name}Serializer"
file_name... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | lib/generators/serializable/serializable_generator.rb | Ruby | mit | 84 | main | 1,228 | # frozen_string_literal: true
class SerializableGenerator < Rails::Generators::NamedBase
source_root File.expand_path("templates", __dir__)
class_option :name, type: :string, desc: "Custom serializer name"
def modify_model_file
inject_into_class File.join("app/models", class_path, "#{class_name.underscore}... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | lib/barley/configuration.rb | Ruby | mit | 84 | main | 271 | # frozen_string_literal: true
module Barley
class Configuration
attr_accessor :cache_store
def initialize
@cache_store = default_cache_store
end
private
def default_cache_store
ActiveSupport::Cache::MemoryStore.new
end
end
end |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | lib/barley/serializer.rb | Ruby | mit | 84 | main | 13,029 | # frozen_string_literal: true
module Barley
class Serializer
EMPTY_ARRAY = [].freeze
EMPTY_HASH = {}.freeze
attr_accessor :object, :context
class << self
attr_accessor :defined_attributes
# Defines attributes for the serializer
#
# Accepts either a list of symbols or a hash... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | lib/barley/cache.rb | Ruby | mit | 84 | main | 368 | # frozen_string_literal: true
module Barley
class Cache
class << self
delegate :fetch, :delete, to: :new
end
def initialize
@cache_store = Barley.config.cache_store
end
def fetch(key, options = {}, &block)
@cache_store.fetch(key, options, &block)
end
def delete(key)
... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | lib/barley/serializable.rb | Ruby | mit | 84 | main | 2,751 | # frozen_string_literal: true
module Barley
# Makes a Model serializable
#
# * Allows setting a default model Serializer
#
# @example
# class Item < ApplicationRecord
# include Barley::Serializable
#
# # optionally define the default serializer, otherwise defaults to ItemSerializer
# se... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/benchmark_test.rb | Ruby | mit | 84 | main | 600 | # frozen_string_literal: true
require "test_helper"
require "minitest/benchmark"
class BenchmarkTest < Minitest::Benchmark
def setup
@user = Struct.new(:id, :email, :created_at, :updated_at, :groups, :profile).new(1, "john@doe.com", Time.now, Time.now, [], nil)
@serializer = Class.new(Barley::Serializer) do... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/test_helper.rb | Ruby | mit | 84 | main | 631 | # Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require_relative "../test/dummy/config/environment"
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
require "rails/test_help"
# Load fixtures from the engine
if ActiveSupport::TestCase.respond_to?(:fixture_paths=... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/barley_test.rb | Ruby | mit | 84 | main | 618 | # frozen_string_literal: true
require "test_helper"
class BarleyTest < ActiveSupport::TestCase
test "it has a version number" do
assert Barley::VERSION
end
test "it has a configuration" do
assert Barley.config
assert_instance_of Barley::Configuration, Barley.config, msg: "Barley.config should be a ... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/barley/serializer_test.rb | Ruby | mit | 84 | main | 10,420 | # frozen_string_literal: true
require "test_helper"
module Barley
class SerializerTest < ActiveSupport::TestCase
setup do
@user = users(:one)
Barley.configure do |config|
config.cache_store = ActiveSupport::Cache::MemoryStore.new
end
end
test "it serializes a model" do
s... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/barley/serializable_test.rb | Ruby | mit | 84 | main | 4,471 | # frozen_string_literal: true
require "test_helper"
require "minitest/mock"
class DummyModelSerializer < Barley::Serializer
end
class OtherDummyModelSerializer < Barley::Serializer
end
module Barley
class SerializableTest < ActiveSupport::TestCase
def setup
@model = DummyModel
end
test "it prov... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/lib/generators/serializable_generator_test.rb | Ruby | mit | 84 | main | 2,362 | # frozen_string_literal: true
require "test_helper"
require "generators/serializable/serializable_generator"
require "minitest/mock"
class SerializableGeneratorTest < Rails::Generators::TestCase
tests SerializableGenerator
destination Rails.root.join("tmp/generators")
setup :prepare_destination
setup do
... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/lib/generators/serializer_generator_test.rb | Ruby | mit | 84 | main | 1,985 | # frozen_string_literal: true
require "test_helper"
require "generators/serializer/serializer_generator"
require "minitest/mock"
class SerializerGeneratorTest < Rails::Generators::TestCase
tests SerializerGenerator
destination Rails.root.join("tmp/generators")
setup :prepare_destination
teardown do
FileU... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/dummy/app/models/group.rb | Ruby | mit | 84 | main | 221 | class Group < ApplicationRecord
include Barley::Serializable
serializer GroupSerializer, cache: true
has_many :memberships
has_many :users, through: :memberships
scope :active, -> { where(active: true) }
end |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/dummy/app/serializers/user_serializer.rb | Ruby | mit | 84 | main | 538 | # frozen_string_literal: true
class UserSerializer < Barley::Serializer
class ProfileSerializer < Barley::Serializer
attributes :name, :age
attribute :birthday do
object.birthdate.strftime("%m-%d")
end
attribute :list_name do
"#{object.name} (#{object.age})"
end
end
class GroupS... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/dummy/app/serializers/group_serializer.rb | Ruby | mit | 84 | main | 295 | # frozen_string_literal: true
class GroupSerializer < Barley::Serializer
class UserSerializer < Barley::Serializer
attributes :email
attribute :profile do
object.profile.age
end
end
attributes :id, :name
many :users, serializer: GroupSerializer::UserSerializer
end |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/dummy/config/routes.rb | Ruby | mit | 84 | main | 443 | Rails.application.routes.draw do
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
# Can be used by load balancers and uptime monitors to verify that the app is live.
get... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/dummy/config/application.rb | Ruby | mit | 84 | main | 1,564 | require_relative "boot"
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
# require "active_job/railtie"
require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
# require "action_mailer/railtie"
# require "action_mailbox/engine"
# require "acti... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/dummy/config/environments/development.rb | Ruby | mit | 84 | main | 1,958 | require "active_support/core_ext/integer/time"
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 any time
# it changes. This slows down response time but is perfect for developme... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/dummy/config/environments/production.rb | Ruby | mit | 84 | main | 3,202 | require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.enable_reloading = false
# Eager load code on boot. This eager loads most of Rails and
# your app... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/dummy/config/environments/test.rb | Ruby | mit | 84 | main | 2,239 | require "active_support/core_ext/integer/time"
# 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 suite and is wiped
# and recreated between test runs. Don't rely on the data the... |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/dummy/db/schema.rb | Ruby | mit | 84 | main | 1,898 | # 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 | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/dummy/db/migrate/20231009004108_create_profiles.rb | Ruby | mit | 84 | main | 203 | class CreateProfiles < ActiveRecord::Migration[7.1]
def change
create_table :profiles do |t|
t.string :name
t.integer :age
t.date :birthdate
t.timestamps
end
end
end |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/dummy/db/migrate/20231009012652_create_memberships.rb | Ruby | mit | 84 | main | 258 | class CreateMemberships < ActiveRecord::Migration[7.1]
def change
create_table :memberships do |t|
t.references :user, null: false, foreign_key: true
t.references :group, null: false, foreign_key: true
t.timestamps
end
end
end |
github | MoskitoHero/barley | https://github.com/MoskitoHero/barley | test/dummy/db/migrate/20231009004134_create_users.rb | Ruby | mit | 84 | main | 213 | class CreateUsers < ActiveRecord::Migration[7.1]
def change
create_table :users do |t|
t.string :email
t.references :profile, null: false, foreign_key: true
t.timestamps
end
end
end |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | Rakefile | Ruby | apache-2.0 | 84 | master | 1,106 | require 'rake/testtask'
namespace :test do
Rake::TestTask.new(:all) do |t|
t.ruby_opts << "-r./tests/fixtures.rb"
t.test_files = FileList['tests/*_test.rb']
t.verbose = false
t.options = "-v"
end
Rake::TestTask.new(:app) do |t|
t.ruby_opts << "-r./tests/fixtures.rb"
t.test_files = FileL... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | sinatra-rabbit.gemspec | Ruby | apache-2.0 | 84 | master | 1,651 | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not u... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | lib/sinatra/rabbit.rb | Ruby | apache-2.0 | 84 | master | 1,229 | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not u... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | lib/sinatra/rabbit/features.rb | Ruby | apache-2.0 | 84 | master | 2,666 | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not u... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | lib/sinatra/rabbit/base.rb | Ruby | apache-2.0 | 84 | master | 13,721 | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not u... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | lib/sinatra/rabbit/param.rb | Ruby | apache-2.0 | 84 | master | 1,756 | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not u... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | lib/sinatra/rabbit/base_collection.rb | Ruby | apache-2.0 | 84 | master | 2,833 | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not u... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | lib/sinatra/rabbit/dsl.rb | Ruby | apache-2.0 | 84 | master | 1,852 | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not u... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | lib/sinatra/rabbit/validator.rb | Ruby | apache-2.0 | 84 | master | 2,260 | #
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not u... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | examples/rabbit_modular.rb | Ruby | apache-2.0 | 84 | master | 1,858 | require 'rubygems'
require 'sinatra/base'
$:.unshift File.join(File::dirname(__FILE__), '..', 'lib')
require 'sinatra/rabbit'
API_ROOT_URL = '/'
############## EXAMPLE #################
Sinatra::Rabbit.configure do
enable :documentation
enable :head_routes
enable :options_routes
end
class Example < Sinatra::... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | examples/simple/rabbit_modular.rb | Ruby | apache-2.0 | 84 | master | 925 | require 'rubygems'
require 'sinatra/base'
$:.unshift File.join(File::dirname(__FILE__), '..', '..', 'lib')
require 'sinatra/rabbit'
############## EXAMPLE #################
class Example < Sinatra::Base
include Sinatra::Rabbit
configure do
enable :logging
end
collection :images do
description "Im... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | examples/rabbit_and_plain_sinatra/rabbit_modular.rb | Ruby | apache-2.0 | 84 | master | 893 | require 'rubygems'
require 'sinatra/base'
$:.unshift File.join(File::dirname(__FILE__), '..','..', 'lib')
require 'sinatra/rabbit'
############## EXAMPLE #################
class Example < Sinatra::Base
include Sinatra::Rabbit
configure do
enable :logging
end
collection :images do
description "Ima... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | tests/fixtures.rb | Ruby | apache-2.0 | 84 | master | 2,959 | require 'rubygems'
begin
require 'simplecov'
if ENV['COVERAGE']
SimpleCov.start
SimpleCov.command_name 'Minitest Tests'
end
rescue LoadError
end
require 'minitest/autorun'
require 'sinatra/base'
$:.unshift File.join(File::dirname(__FILE__), '..')
require 'lib/sinatra/rabbit'
class Sample < Sinatra::Bas... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | tests/docs_test.rb | Ruby | apache-2.0 | 84 | master | 1,722 | require 'rack/test'
require 'nokogiri'
include Rack::Test::Methods
def app
Sample
end
def status
last_response.status
end
def html
Nokogiri::HTML(last_response.body)
end
describe 'Documentation' do
it "should respond with status OK for root" do
get '/docs'
status.must_equal 200
end
it "should... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | tests/dsl_test.rb | Ruby | apache-2.0 | 84 | master | 9,748 | describe Sinatra::Rabbit::DSL do
it "should allow to set configuration" do
Sinatra::Rabbit.configure do
enable :documentation
enable :head_routes
enable :options_routes
disable :sample_setting
end
Sinatra::Rabbit.enabled?(:documentation).must_equal true
Sinatra::Rabbit.disable... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | tests/app_test.rb | Ruby | apache-2.0 | 84 | master | 2,302 | require 'rack/test'
include Rack::Test::Methods
def app
Sample
end
def status
last_response.status
end
describe Sample do
it "should respond with status OK for root" do
get '/'
status.must_equal 200
end
it "should respond 400 to index operation for sample collection without param" do
get '/s... |
github | mfojtik/sinatra-rabbit | https://github.com/mfojtik/sinatra-rabbit | tests/params_test.rb | Ruby | apache-2.0 | 84 | master | 4,749 | describe Sinatra::Rabbit::Param do
def index_operation
Sample.collection(:sample).operation(:rindex)
end
it "should return string representation of param" do
"#{index_operation.param(:r_string)}".must_equal 'r_string:string:required'
end
it "should allow define required string param with descriptio... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | pairwise.gemspec | Ruby | mit | 84 | master | 735 | require File.dirname(__FILE__) + '/lib/pairwise'
Gem::Specification.new do |s|
s.name = "pairwise"
s.summary = %Q{Turn large test data combinations into smaller ones}
s.description = %Q{A tool for selecting a smaller number of test combinations (using pairwise generation) rather than exhaustively testing a... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | spec/pairwise_spec.rb | Ruby | mit | 84 | master | 4,667 | require 'spec_helper'
describe Pairwise do
before(:each) do
Kernel.stub!(:rand).and_return(0)
end
context "with invalid inputs" do
it "should be invalid when running with no input" do
lambda{ Pairwise.combinations([]) }.should raise_error(Pairwise::InvalidInputData)
end
it "should be inva... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | spec/pairwise/pair_collection_spec.rb | Ruby | mit | 84 | master | 468 | require 'spec_helper'
module Pairwise
describe PairCollection do
describe '#input_combination_that_covers_most_pairs' do
it "should do find the combination that covers most pairs" do
pair_collection = PairCollection.new([:A2, :B2], [[:A2, :B2], [:B2, :A1]], 1)
combination = pair_collection... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | spec/pairwise/cli_spec.rb | Ruby | mit | 84 | master | 1,597 | require 'spec_helper'
module Pairwise
describe Cli do
before(:each) do
Kernel.stub!(:exit).and_return(nil)
end
def output_stream
@output_stream ||= StringIO.new
end
def options
#TODO: push options out to an object and avoid hacking at private instance vars
@cli.instance... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | spec/pairwise/ipo/horizontal_spec.rb | Ruby | mit | 84 | master | 1,349 | require 'spec_helper'
module Pairwise
class IPO
describe Horizontal do
describe ".growth" do
context "when the input_combinations size is smaller than the input values for growth size" do
it "should extenhd with C's inputs" do
input_combinations = [[:A1, :B1], [:A1, :B2]]
dat... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | features/step_definitions/pairwise_data_steps.rb | Ruby | mit | 84 | master | 762 | Given /^I have the (?:yaml |csv )?file "([^\"]*)" containing:$/ do |file_name, file_contents|
create_file(file_name, file_contents)
end
Given /^I have the file "([^\"]*)"$/ do |filename|
step %Q{I have the file "#{filename}" containing:}, ""
end
Given /^I have a folder "([^\"]*)"$/ do |folder_name|
create_folde... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | features/support/env.rb | Ruby | mit | 84 | master | 1,947 | require 'rubygems'
require 'simplecov'
SimpleCov.start
SimpleCov.command_name 'integration_tests'
require 'tempfile'
require 'rspec'
require "rspec/mocks/standalone"
require 'fileutils'
require 'forwardable'
SCRATCH_SPACE = 'tmp'
require 'limited_red/plugins/cucumber'
class PairwiseWorld
extend Forwardable
def... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | lib/pairwise.rb | Ruby | mit | 84 | master | 1,064 | $:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
require 'pairwise/test_pair'
require 'pairwise/pair_collection'
require 'pairwise/ipo'
require 'pairwise/ipo/horizontal'
require 'pairwise/ipo/vertical'
require 'pairwise/formatter'
... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | lib/pairwise/pair_collection.rb | Ruby | mit | 84 | master | 2,424 | module Pairwise
class PairCollection < Array
def initialize(input_parameter_values, input_value_lists, input_parameter_index)
pairs = generate_pairs_between(input_parameter_values, input_value_lists, input_parameter_index)
@combination_history = []
super(pairs)
end
def remove_pairs_cov... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | lib/pairwise/cli.rb | Ruby | mit | 84 | master | 2,573 | require 'optparse'
module Pairwise
class Cli
BUILTIN_FORMATS = {
'cucumber' => [Pairwise::Formatter::Cucumber,
'Tables for Cucumber'],
'csv' => [Pairwise::Formatter::Csv,
'Comma seperated values']}
max = BUILTIN_FORMATS.keys.map{|s| s.length}.max
... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | lib/pairwise/input_data.rb | Ruby | mit | 84 | master | 501 | module Pairwise
class InputData
def initialize(inputs)
@inputs = inputs.is_a?(Hash) ? hash_inputs_to_list(inputs) : inputs
end
def data
@data ||= @inputs.map {|input| input.values[0]}
end
def labels
@labels ||= @inputs.map{|input| input.keys}.flatten
end
private
... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | lib/pairwise/input_file.rb | Ruby | mit | 84 | master | 1,319 | module Pairwise
class InputFile
class << self
def load(filename)
inputs = self.new(filename).load_and_parse
InputData.new(inputs) if valid?(inputs)
end
def valid?(inputs)
inputs && (inputs.is_a?(Array) || inputs.is_a?(Hash))
end
end
def initialize(filenam... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | lib/pairwise/ipo.rb | Ruby | mit | 84 | master | 2,123 | # A pairwise implementation using the in-parameter-order (IPO) strategy.
# Based on: http://ranger.uta.edu/~ylei/paper/ipo-tse.pdf
module Pairwise
class IPO
WILD_CARD = 'wild_card'
def initialize(inputs, options = {})
@list_of_input_values = inputs
@options = options
end
def build
... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | lib/pairwise/test_pair.rb | Ruby | mit | 84 | master | 1,323 | require 'forwardable'
module Pairwise
class TestPair
extend Forwardable
def_delegators :@pair, :+, :inspect, :to_a, :==
def initialize(p1_position, p2_position, p1, p2)
@p1, @p2 = p1, p2
@p1_position, @p2_position = p1_position, p2_position
@pair = [@p1, @p2]
end
def covered_... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | lib/pairwise/ipo/vertical.rb | Ruby | mit | 84 | master | 397 | module Pairwise
class IPO
class Vertical
def self.growth(input_combinations, uncovered_pairs)
new_input_combinations = uncovered_pairs.reduce([]) do |new_input_combinations, uncovered_pair|
new_input_combinations = uncovered_pair.replace_wild_card(new_input_combinations)
end
... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | lib/pairwise/ipo/horizontal.rb | Ruby | mit | 84 | master | 1,159 | module Pairwise
class IPO
class Horizontal
class << self
def growth(input_combinations, input_values_for_growth, previously_grown_input_values)
uncovered_pairs = PairCollection.new(input_values_for_growth, previously_grown_input_values, previously_grown_input_values.size)
input... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | lib/pairwise/formatter/cucumber.rb | Ruby | mit | 84 | master | 1,285 | module Pairwise
module Formatter
class Cucumber
def initialize(out)
@out = out
@max = {}
end
def display(test_data, input_labels)
@test_data = label_wild_cards(test_data, input_labels)
@input_labels = input_labels
@out.print "|"
@input_labels.ea... |
github | josephwilk/pairwise | https://github.com/josephwilk/pairwise | lib/pairwise/formatter/csv.rb | Ruby | mit | 84 | master | 297 | module Pairwise
module Formatter
class Csv
def initialize(out)
@out = out
end
def display(test_data, input_labels)
@out.puts input_labels.join(',')
test_data.each do |data|
@out.puts data.join(',')
end
end
end
end
end |
github | salsify/offline-sort | https://github.com/salsify/offline-sort | offline-sort.gemspec | Ruby | mit | 84 | master | 1,458 | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'offline_sort/version'
Gem::Specification.new do |spec|
spec.name = 'offline-sort'
spec.version = OfflineSort::VERSION
spec.authors = ['Matthew Cross']
spec... |
github | salsify/offline-sort | https://github.com/salsify/offline-sort | spec/offline_sort/fixed_size_min_heap_spec.rb | Ruby | mit | 84 | master | 1,998 | # frozen_string_literal: true
require 'spec_helper'
describe OfflineSort::FixedSizeMinHeap do
let(:array) { (1..10).to_a.shuffle }
let(:heap) { OfflineSort::FixedSizeMinHeap.new(array.dup) }
describe "#initialize" do
it "is a a heap" do
expect { assert_min_heap(heap.array) }.not_to raise_error
en... |
github | salsify/offline-sort | https://github.com/salsify/offline-sort | spec/offline_sort/sorter_spec.rb | Ruby | mit | 84 | master | 2,524 | # frozen_string_literal: true
require 'spec_helper'
describe OfflineSort::Sorter do
shared_examples "a correct offline sort" do
let(:count) { 10000 }
let(:entries_per_chunk) { 900 }
let(:enumerable) {}
let(:sort) {}
before do
@unsorted = enumerable.dup
r = Benchmark.measure do
... |
github | salsify/offline-sort | https://github.com/salsify/offline-sort | spec/offline_sort/chunk/input_output/marshal_spec.rb | Ruby | mit | 84 | master | 234 | # frozen_string_literal: true
require 'spec_helper'
describe OfflineSort::Chunk::InputOutput::Marshal do
it_behaves_like "a valid chunk input output" do
let(:chunk_class) { OfflineSort::Chunk::InputOutput::Marshal }
end
end |
github | salsify/offline-sort | https://github.com/salsify/offline-sort | spec/offline_sort/chunk/input_output/base_spec.rb | Ruby | mit | 84 | master | 2,229 | # frozen_string_literal: true
require 'spec_helper'
shared_examples "a valid chunk input output" do
let(:count) { 1000 }
let(:arrays) do
Array.new(count) do |index|
[SecureRandom.hex, index, SecureRandom.hex]
end
end
let(:hashes) do
Array.new(count) do |index|
{ 'a' => SecureRandom.h... |
github | salsify/offline-sort | https://github.com/salsify/offline-sort | spec/offline_sort/chunk/input_output/yaml_spec.rb | Ruby | mit | 84 | master | 228 | # frozen_string_literal: true
require 'spec_helper'
describe OfflineSort::Chunk::InputOutput::Yaml do
it_behaves_like "a valid chunk input output" do
let(:chunk_class) { OfflineSort::Chunk::InputOutput::Yaml }
end
end |
github | salsify/offline-sort | https://github.com/salsify/offline-sort | spec/offline_sort/chunk/input_output/message_pack_spec.rb | Ruby | mit | 84 | master | 242 | # frozen_string_literal: true
require 'spec_helper'
describe OfflineSort::Chunk::InputOutput::MessagePack do
it_behaves_like "a valid chunk input output" do
let(:chunk_class) { OfflineSort::Chunk::InputOutput::MessagePack }
end
end |
github | salsify/offline-sort | https://github.com/salsify/offline-sort | lib/offline_sort/offline_sort.rb | Ruby | mit | 84 | master | 2,532 | # frozen_string_literal: true
require 'offline_sort/chunk'
require 'offline_sort/fixed_size_min_heap'
module OfflineSort
def self.sort(*args, **kwargs, &sort_by)
Sorter.new(*args, **kwargs, &sort_by).sort
end
class Sorter
DEFAULT_CHUNK_IO_CLASS = defined?(::MessagePack) ? Chunk::InputOutput::MessagePac... |
github | salsify/offline-sort | https://github.com/salsify/offline-sort | lib/offline_sort/fixed_size_min_heap.rb | Ruby | mit | 84 | master | 1,865 | # frozen_string_literal: true
module OfflineSort
class FixedSizeMinHeap
attr_accessor :array
attr_reader :sort_by, :size_limit, :heap_end
def initialize(array, &sort_by)
@array = array
@sort_by = sort_by || Proc.new { |item| item }
@size_limit = array.size
@heap_end = array.size ... |
github | salsify/offline-sort | https://github.com/salsify/offline-sort | lib/offline_sort/chunk.rb | Ruby | mit | 84 | master | 255 | # frozen_string_literal: true
require 'offline_sort/chunk/input_output/base'
require 'offline_sort/chunk/input_output/marshal'
require 'offline_sort/chunk/input_output/message_pack' if defined?(MessagePack)
require 'offline_sort/chunk/input_output/yaml' |
github | salsify/offline-sort | https://github.com/salsify/offline-sort | lib/offline_sort/chunk/input_output/base.rb | Ruby | mit | 84 | master | 1,035 | # frozen_string_literal: true
module OfflineSort
module Chunk
module InputOutput
class Base
MethodNotImplementedError = Class.new(StandardError)
attr_reader :io
def initialize(io)
@io = io
end
def read_entry
raise MethodNotImplementedError.new... |
github | salsify/offline-sort | https://github.com/salsify/offline-sort | lib/offline_sort/chunk/input_output/yaml.rb | Ruby | mit | 84 | master | 1,128 | # frozen_string_literal: true
require 'yaml'
module OfflineSort
module Chunk
module InputOutput
class Yaml < OfflineSort::Chunk::InputOutput::Base
# The yaml parser does not expose a document enumerator that we can call next on without loading the entire file
def read_entry
YAML.... |
github | salsify/offline-sort | https://github.com/salsify/offline-sort | lib/offline_sort/chunk/input_output/message_pack.rb | Ruby | mit | 84 | master | 649 | # frozen_string_literal: true
require 'msgpack'
require 'offline_sort/chunk/input_output/base'
module OfflineSort
module Chunk
module InputOutput
class MessagePack < OfflineSort::Chunk::InputOutput::Base
attr_reader :packer, :unpacker
def initialize(io)
super
@packer =... |
github | salsify/offline-sort | https://github.com/salsify/offline-sort | lib/offline_sort/chunk/input_output/marshal.rb | Ruby | mit | 84 | master | 404 | # frozen_string_literal: true
module OfflineSort
module Chunk
module InputOutput
class Marshal < OfflineSort::Chunk::InputOutput::Base
def read_entry
::Marshal.load(io) # rubocop:disable Security/MarshalLoad, this is loading from a trusted source
end
def write_entry(entry... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | simple_executor.rb | Ruby | apache-2.0 | 84 | master | 222 | #
# Copyright 2008-2010 Amazon.com, Inc. or its affiliates. All Rights Reserved.
class SimpleExecutor
def exec(cmd)
puts(cmd)
if ! system(cmd) then
raise RuntimeError, "Command failed."
end
end
end |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | json.rb | Ruby | apache-2.0 | 84 | master | 1,384 | #
# Copyright 2008-2010 Amazon.com, Inc. or its affiliates. All Rights Reserved.
require 'json/objects'
require 'json/lexer'
require 'stringio'
module JSON
def self.parse(str)
return Lexer.new(str).nextvalue
end
def self.pretty_generate(obj)
s = []
self.pretty_generate_recursive(obj, s, "")
re... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | uuidtools.rb | Ruby | apache-2.0 | 84 | master | 22,886 | #--
# UUIDTools, Copyright (c) 2005-2008 Bob Aman
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge,... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | elastic-mapreduce-cli.rb | Ruby | apache-2.0 | 84 | master | 550 | #!/usr/bin/env ruby
#
# Copyright 2008-2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
require 'commands'
require 'simple_logger'
require 'simple_executor'
exit_code = 0
begin
logger = SimpleLogger.new
executor = SimpleExecutor.new
commands = Commands::create_and_execute_commands(
ARGV, Amazo... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | commands.rb | Ruby | apache-2.0 | 84 | master | 73,650 | #
# Copyright 2008-2010 Amazon.com, Inc. or its affiliates. All Rights Reserved.
require 'set'
require 'credentials'
require 'optparse'
require 'client'
require 'ec2_client_wrapper'
require 'open3'
module Commands
ELASTIC_MAPREDUCE_CLIENT_VERSION = "2012-09-18"
class Commands
attr_accessor :opts, :global_o... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | client.rb | Ruby | apache-2.0 | 84 | master | 4,325 | #
# Copyright 2008-2010 Amazon.com, Inc. or its affiliates. All Rights Reserved.
require 'credentials'
require 'amazon/retry_delegator'
require 'amazon/coral/elasticmapreduceclient'
class EmrClient
attr_accessor :commands, :logger, :options
def initialize(commands, logger, client_class)
@commands = commands... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | ec2_client_wrapper.rb | Ruby | apache-2.0 | 84 | master | 2,244 | #
# Copyright 2008-2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
require 'credentials'
require 'amazon/retry_delegator'
require 'amazon/coral/ec2client'
class Ec2ClientWrapper
attr_accessor :commands, :logger, :options
def initialize(commands, logger)
@commands = commands
@logger = logge... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | credentials.rb | Ruby | apache-2.0 | 84 | master | 3,291 | #
# Copyright 2008-2010 Amazon.com, Inc. or its affiliates. All Rights Reserved.
require 'json'
class Credentials
def initialize(commands)
@options = commands.global_options
end
def parse_credentials(credentials, options)
conversions = [
# These first ones use an incorrect naming co... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | simple_logger.rb | Ruby | apache-2.0 | 84 | master | 762 | #
# Copyright 2008-2010 Amazon.com, Inc. or its affiliates. All Rights Reserved.
class SimpleLogger
attr_accessor :level
def initialize
@level = :info
end
def puts(msg)
STDOUT.puts msg
end
def trace(msg)
if [:debug, :trace].include?(level) then
STDOUT.puts "#{Time.now.utc} TRACE " + m... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | tests/commands_test.rb | Ruby | apache-2.0 | 84 | master | 23,683 | #
# Copyright 2008-2010 Amazon.com, Inc. or its affiliates. All Rights Reserved.
require 'commands'
require 'test/unit'
module Commands
class MockExecutor
def exec(cmd)
end
end
class MockEMRClient
attr_accessor :state
def initialize(config)
@config = config
@state = "RUNNING"
... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | json/lexer.rb | Ruby | apache-2.0 | 84 | master | 7,352 | #
# Lexical analyzer for JSON
# Copyright (C) 2003,2005 Rafael R. Sevilla <dido@imperium.ph>
# This file is part of JSON for Ruby
#
# JSON for Ruby is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; e... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | json/objects.rb | Ruby | apache-2.0 | 84 | master | 4,530 | #
# JSON Objects
# Copyright (C) 2003,2005 Rafael R. Sevilla <dido@imperium.ph>
# This file is part of JSON for Ruby
#
# JSON for Ruby is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | uuidtools/version.rb | Ruby | apache-2.0 | 84 | master | 1,251 | #--
# Copyright (c) 2005-2008 Robert Aman
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | amazon/stderr_logger.rb | Ruby | apache-2.0 | 84 | master | 460 | #
# Copyright 2008-2010 Amazon.com, Inc. or its affiliates. All Rights Reserved.
module Amazon
class StdErrLogger
INFO = { :level => 4, :string => "INFO" }
def initialize(level=nil)
@level = level || INFO[:level]
@file = STDERR
end
def message(level, msg)
if level[:level] <= @le... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | amazon/retry_delegator.rb | Ruby | apache-2.0 | 84 | master | 2,225 | #
# Copyright 2008-2010 Amazon.com, Inc. or its affiliates. All Rights Reserved.
require 'amazon/stderr_logger.rb'
module Amazon
# RetryDelegator
# this is a wrapper around a client that will retry if exceptions are raised.
class RetryDelegator
def initialize(client, options={})
@client ... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | amazon/coral/orchestrator.rb | Ruby | apache-2.0 | 84 | master | 1,318 | #
# Copyright 2008-2010 Amazon.com, Inc. or its affiliates. All Rights Reserved.
require 'amazon/coral/job'
require 'amazon/coral/logfactory'
module Amazon
module Coral
# Directs a Job through a Handler chain for processing.
class Orchestrator
# Instantiate an orchestrator with the given ... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | amazon/coral/v0signaturehandler.rb | Ruby | apache-2.0 | 84 | master | 855 | #
# Copyright 2008-2010 Amazon.com, Inc. or its affiliates. All Rights Reserved.
require 'openssl'
require 'base64'
require 'time'
require 'amazon/coral/handler'
require 'amazon/coral/v0signaturehelper'
module Amazon
module Coral
# Applies an AWS version 0 signature to the outgoing request.
class V0Si... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | amazon/coral/v1signaturehelper.rb | Ruby | apache-2.0 | 84 | master | 1,690 | #
# Copyright 2008-2010 Amazon.com, Inc. or its affiliates. All Rights Reserved.
require 'openssl'
require 'base64'
require 'time'
module Amazon
module Coral
class V1SignatureHelper
def initialize(aws_access_key_id, aws_secret_key)
@aws_access_key_id = aws_access_key_id.to_s
@aws_secret_... |
github | tc/elastic-mapreduce-ruby | https://github.com/tc/elastic-mapreduce-ruby | amazon/coral/logfactory.rb | Ruby | apache-2.0 | 84 | master | 835 | #
# Copyright 2008-2010 Amazon.com, Inc. or its affiliates. All Rights Reserved.
require 'logger'
module Amazon
module Coral
# A simple log retrieval interface to allow injection of common logging frameworks.
class LogFactory
@@instance = LogFactory.new
# Invokes the singleton LogFactory instance to retrieve ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.