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 | tompng/katakata_irb | https://github.com/tompng/katakata_irb | test/test_katakata_irb.rb | Ruby | mit | 94 | main | 2,966 | # frozen_string_literal: true
require 'ripper'
require 'test_helper'
KatakataIrb::Types.preload_in_thread.join
class TestKatakataIrb < Minitest::Test
def test_analyze_does_not_raise_error
verbose, $VERBOSE = $VERBOSE, nil
original_output = KatakataIrb.log_output
KatakataIrb::TypeAnalyzer::DigTarget.cla... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | Gemfile | Ruby | mit | 94 | master | 925 | # frozen_string_literal: true
# This is a file to declare which gems (libraries) to install and use.
#
# Since this file contains no gems required to run the tool so far,
# you will not need to install gems if you are just a user.
# You will need these gems only on developing/testing the tool.
#
# You can install gems... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/spec_helper.rb | Ruby | mit | 94 | master | 5,433 | # frozen_string_literal: true
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to expl... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/config_spec.rb | Ruby | mit | 94 | master | 4,457 | require 'rspec/its'
require 'tempfile'
RSpec.describe KofamScan::Config do
let(:config) { described_class.new }
describe 'default values' do
subject { config }
its(:output_file) { is_expected.to be_nil }
its(:output_io) { is_expected.to eq STDOUT }
its(:cpu) { is_expected.to eq 1 ... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/parallel_spec.rb | Ruby | mit | 94 | master | 1,469 | RSpec.describe KofamScan::Parallel do
describe '#parallel_command' do
context 'when full path is fed' do
it 'returns the path' do
path = "/usr/local/bin/parallel"
obj = described_class.new(full_path: path, command: "some_cmd")
expect(obj.parallel_command).to eq path
end
end... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/output_rearranger_spec.rb | Ruby | mit | 94 | master | 2,154 | require 'rspec/temp_dir'
require 'kofam_scan/output_rearranger'
RSpec.describe KofamScan::OutputRearranger do
include_context 'uses temp dir'
let(:rearranger) { described_class.new(from_dir, to_dir) }
let(:from_dir) { spec_root.join('test_data', 'output') }
let(:to_dir) { temp_dir_path }
let(:result_with_on... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/executor_spec.rb | Ruby | mit | 94 | master | 5,791 | require 'rspec/temp_dir'
RSpec.describe KofamScan::Executor do
subject(:executor) { described_class.new(config) }
let(:config) { KofamScan::Config.new }
describe '#setup_directories' do
include_context 'uses temp dir'
shared_examples 'making tabular' do |tmp_path_blk|
let(:tmp_path, &tmp_path_bl... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/cli_spec.rb | Ruby | mit | 94 | master | 5,099 | require 'rspec/temp_dir'
require 'fileutils'
require 'kofam_scan/cli'
RSpec.describe KofamScan::CLI do
describe '.run' do
subject(:execute_run) { described_class.run(options) }
let(:options) { ["query"] }
before do
allow(KofamScan::Executor).to receive(:execute)
end
context 'with -h or -... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/hmmsearch_spec.rb | Ruby | mit | 94 | master | 869 | RSpec.describe KofamScan::HMMSearch do
let(:obj) { described_class.new("profile", "sequences", cpu: 2, o: "out file") }
describe '#to_a' do
subject(:command_array) { obj.to_a }
it 'returns array of command and arguments' do
expect(command_array).to match_array(%w[hmmsearch --cpu=2 -oout\ file profil... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/result_spec.rb | Ruby | mit | 94 | master | 1,012 | require_relative 'result/shared_examples'
RSpec.describe KofamScan::Result do
include_context 'result context'
let(:initialize_result) { described_class.create(query_list) }
it_behaves_like 'result common'
describe 'each hit' do
include_context 'hit context'
it_behaves_like 'hit common'
descri... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/ko_spec.rb | Ruby | mit | 94 | master | 4,195 | require 'stringio'
RSpec.describe KofamScan::KO do
let(:k00001) { described_class["K00001"] }
let(:k00005) { described_class["K00005"] }
let(:k01977) { described_class["K01977"] }
before { described_class.parse(StringIO.new(<<~KOLIST)) }
knum threshold score_type profile_type F-measure nseq nseq_used alen... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/output_formatter/shared_contexts.rb | Ruby | mit | 94 | master | 2,640 | require 'stringio'
RSpec.shared_context 'basic context' do
subject(:formatter) { described_class.new }
let(:result) { KofamScan::Result.new(%w[gene1 gene2 gene3 gene4 gene5]) }
let(:out_file) { StringIO.new("", "w") }
let(:ko1) do
KofamScan::KO.new("K00001", 99.52, :full, :all, 0.8, 100, 100, 200, 100,
... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/output_formatter/simple_tabular_formatter_spec.rb | Ruby | mit | 94 | master | 1,312 | require_relative 'shared_contexts'
RSpec.describe KofamScan::OutputFormatter::SimpleTabularFormatter do
describe '#format' do
context 'the simplest context' do
include_context 'one hit for one gene'
let(:expected_output) { <<~RESULT }
gene1
gene2\tK00002
gene3
gene4\tK... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/output_formatter/hit_detail_formatter_spec.rb | Ruby | mit | 94 | master | 3,813 | require_relative 'shared_contexts'
RSpec.describe KofamScan::OutputFormatter::HitDetailFormatter do
def output_array
output_lines = output.split(/\n/).grep_v(/^#/)
output_lines.map do |line|
mark = line.slice!(0, 1)
[mark, *line.split(nil, 6)]
end
end
describe '#format' do
context 't... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/output_formatter/one_line_tabular_formatter_spec.rb | Ruby | mit | 94 | master | 1,218 | require_relative 'shared_contexts'
RSpec.describe KofamScan::OutputFormatter::OneLineTabularFormatter do
describe '#format' do
context 'the simplest context' do
include_context 'one hit for one gene'
let(:expected_output) { <<~RESULT }
gene1
gene2\tK00002
gene3
gene4\t... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/output_formatter/hit_detail_tsv_formatter_spec.rb | Ruby | mit | 94 | master | 3,594 | require_relative 'shared_contexts'
RSpec.describe KofamScan::OutputFormatter::HitDetailTsvFormatter do
def output_array
output_lines = output.split(/\n/).grep_v(/^#/)
output_lines.map do |line|
line.split("\t")
end
end
describe '#format' do
context 'the simplest context' do
include_c... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/cli/option_parser_spec.rb | Ruby | mit | 94 | master | 3,560 | require 'kofam_scan/cli'
RSpec.describe KofamScan::CLI::OptionParser do
let(:parser) { described_class.new(config) }
let(:config) { KofamScan::Config.new }
describe '-o option' do
it 'calls config.output_file=' do
file_name = "hoge"
expect(config).to receive(:output_file=).with file_name
p... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/result/with_threshold_scale_spec.rb | Ruby | mit | 94 | master | 2,540 | require_relative 'shared_examples'
RSpec.describe KofamScan::Result::WithThresholdScale do
include_context 'result context'
let(:initialize_result) { KofamScan::Result.create(query_list, threshold_scale: threshold_scale) }
let(:threshold_scale) { 1 }
it_behaves_like 'result common'
describe 'each hit' do... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/result/with_threshold_scale_and_evalue_threshold_spec.rb | Ruby | mit | 94 | master | 4,113 | require_relative 'shared_examples'
RSpec.describe KofamScan::Result::WithThresholdScaleAndEvalueThreshold do
include_context 'result context'
let(:initialize_result) do
KofamScan::Result.create(query_list,
threshold_scale: threshold_scale,
e_value_th... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/result/with_evalue_threshold_spec.rb | Ruby | mit | 94 | master | 1,966 | require_relative 'shared_examples'
RSpec.describe KofamScan::Result::WithEvalueThreshold do
include_context 'result context'
let(:initialize_result) { KofamScan::Result.create(query_list, e_value_threshold: e_value_threshold) }
let(:e_value_threshold) { 0.01 }
it_behaves_like 'result common'
describe 'ea... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/kofam_scan/result/shared_examples.rb | Ruby | mit | 94 | master | 4,002 | require 'stringio'
RSpec.shared_context 'result context' do
let(:hmmsearch_result1) { spec_root.join('test_data', 'tabular', 'K00001').open }
let(:hmmsearch_result2) { spec_root.join('test_data', 'tabular', 'K00004').open }
let(:hmmsearch_result3) { spec_root.join('test_data', 'tabular', 'K00002').open }
let(... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | spec/support/matchers/exit_script.rb | Ruby | mit | 94 | master | 1,156 | require 'rspec/expectations'
RSpec::Matchers.define :exit_script do
supports_block_expectations
def expects_call_stack_jump?
true
end
match do |block|
@actual_status = nil
begin
block.call
rescue SystemExit => e
@actual_status = e.status
end
# when SystemExit not raised, ... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan.rb | Ruby | mit | 94 | master | 565 | # frozen_string_literal: true
# add ./lib directory to the load path if not included
$LOAD_PATH.unshift(__dir__) unless $LOAD_PATH.include?(__dir__)
require 'kofam_scan/autoload'
require 'kofam_scan/config'
require 'kofam_scan/executor'
require 'kofam_scan/ko'
require 'kofam_scan/result'
module KofamScan
extend Au... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/output_rearranger.rb | Ruby | mit | 94 | master | 1,521 | # frozen_string_literal: false
module KofamScan
class OutputRearranger
def initialize(from_dir, to_dir)
@from_dir = from_dir
@to_dir = to_dir
@gene2aln = Hash.new { |h, k| h[k] = [] }
@current_ko, @current_gene, @current_alignment = nil
end
def rearrange
parse_files
... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/cli.rb | Ruby | mit | 94 | master | 1,667 | # frozen_string_literal: false
require 'kofam_scan/cli/option_parser'
module KofamScan
module CLI
class << self
def run(argv = ARGV)
# display help first if with -h option
if ["-h", "--help"].any? { |h| argv.include? h }
puts OptionParser.usage
exit 0
end
... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/config.rb | Ruby | mit | 94 | master | 1,202 | # frozen_string_literal: true
module KofamScan
Config = Struct.new(:output_file, :profile, :ko_list, :e_value, :hmmsearch,
:cpu, :tmp_dir, :parallel, :formatter, :reannotation,
:threshold_scale, :create_alignment, :keep_output,
:keep_tabular, :query) ... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/autoload.rb | Ruby | mit | 94 | master | 491 | # frozen_string_literal: true
module KofamScan
module Autoload
def autoload(const_name, path = nil)
unless path
dirs = name.split("::").push(const_name.to_s)
dirs.map!(&method(:snake_case))
path = dirs.join("/")
end
super(const_name, path)
end
private
def ... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/hmmsearch.rb | Ruby | mit | 94 | master | 982 | # frozen_string_literal: false
autoload :Shellwords, 'shellwords'
module KofamScan
class HMMSearch
class << self
attr_accessor :command_path
end
def initialize(hmmfile, seqdb, options = {})
@hmmfile = hmmfile
@seqdb = seqdb
@options = options
@command_array = nil
en... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/result.rb | Ruby | mit | 94 | master | 1,359 | # frozen_string_literal: true
require 'kofam_scan/result/hit'
require 'kofam_scan/result/parser'
# TODO: alignment
module KofamScan
class Result
extend Autoload
autoload :WithEvalueThreshold
autoload :WithThresholdScale
autoload :WithThresholdScaleAndEvalueThreshold
def self.create(query_list,... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/executor.rb | Ruby | mit | 94 | master | 4,835 | # frozen_string_literal: true
module KofamScan
class Executor
attr_reader :config
def self.execute(config)
new(config).execute
end
def initialize(config = nil)
if config
@config = config
elsif File.exist?(DEFAULT_CONFIG_FILE)
@config = Config.load(DEFAULT_CONFIG_FI... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/output_formatter.rb | Ruby | mit | 94 | master | 543 | # frozen_string_literal: true
module KofamScan
# Base class for output formatter classes.
# Each formatters shall respond to `#format' with two arguments.
# The first argument is a `KofamScan::Result' instance, and the second
# is an IO object or any instance responding `#<<' to get the output.
class OutputF... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/parallel.rb | Ruby | mit | 94 | master | 953 | # frozen_string_literal: true
require 'open3'
autoload :Shellwords, 'shellwords'
module KofamScan
class Parallel
attr_accessor :cpu, :command, :inputs
def initialize(cpu: 1, command: nil, inputs: nil, full_path: nil)
@cpu = cpu
@command = command
@inputs = inputs
@full_path = full_p... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/ko.rb | Ruby | mit | 94 | master | 1,567 | # frozen_string_literal: true
module KofamScan
class KO
class << self
def [](k_num)
instances[k_num]
end
def parse(ko_file)
ko_file.gets
ko_file.each_line do |line|
data = line.chomp.split("\t").map { |col| col unless col == "-" }
name = data[0]
... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/result/with_threshold_scale.rb | Ruby | mit | 94 | master | 377 | # frozen_string_literal: true
module KofamScan
class Result
class WithThresholdScale < Result
require 'kofam_scan/result/with_threshold_scale/hit'
def initialize(query_list, scale)
super(query_list)
@scale = scale
end
def <<(hit)
wrapped_hit = Hit.new(hit, @scale... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/result/with_evalue_threshold.rb | Ruby | mit | 94 | master | 411 | # frozen_string_literal: true
module KofamScan
class Result
class WithEvalueThreshold < Result
require 'kofam_scan/result/with_evalue_threshold/hit'
def initialize(query_list, e_value_threshold)
super(query_list)
@threshold = e_value_threshold
end
def <<(hit)
wra... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/result/parser.rb | Ruby | mit | 94 | master | 1,363 | # frozen_string_literal: true
module KofamScan
class Result
class Parser
NAME_POSITION = 0
KO_POSITION = 2
FULL_SCORE_POSITION = 5
DOMAIN_SCORE_POSITION = 8
FULL_E_VALUE_POSITION = 4
DOMAIN_E_VALUE_POSITION = 7
def self.parse(tabular_files,... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/result/with_threshold_scale_and_evalue_threshold.rb | Ruby | mit | 94 | master | 482 | # frozen_string_literal: true
module KofamScan
class Result
class WithThresholdScaleAndEvalueThreshold < Result
require 'kofam_scan/result/with_threshold_scale_and_evalue_threshold/hit'
def initialize(query_list, scale, e_val_threshold)
super(query_list)
@scale = scale
@thres... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/result/hit.rb | Ruby | mit | 94 | master | 536 | # frozen_string_literal: true
module KofamScan
class Result
class Hit
attr_reader :gene_name
attr_reader :ko
attr_reader :score
attr_reader :e_value
def initialize(gene_name, ko, score, e_value)
@gene_name = gene_name
@ko = ko.kind_of?(KO) ? ko : ... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/result/with_threshold_scale_and_evalue_threshold/hit.rb | Ruby | mit | 94 | master | 722 | # frozen_string_literal: true
require 'forwardable'
module KofamScan
class Result
class WithThresholdScaleAndEvalueThreshold
class Hit
extend Forwardable
def_delegators :@hit, :gene_name, :ko, :score, :e_value
def initialize(hit, scale, threshold)
@hit = hit
@... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/result/with_evalue_threshold/hit.rb | Ruby | mit | 94 | master | 457 | # frozen_string_literal: true
require 'forwardable'
module KofamScan
class Result
class WithEvalueThreshold
class Hit
extend Forwardable
def_delegators :@hit, :gene_name, :ko, :score, :e_value
def initialize(hit, threshold)
@hit = hit
@threshold = threshold
... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/result/with_threshold_scale/hit.rb | Ruby | mit | 94 | master | 612 | # frozen_string_literal: true
require 'forwardable'
module KofamScan
class Result
class WithThresholdScale
class Hit
extend Forwardable
def_delegators :@hit, :gene_name, :ko, :score, :e_value
def initialize(hit, scale)
@hit = hit
@scale = scale
end
... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/cli/option_parser.rb | Ruby | mit | 94 | master | 4,794 | # frozen_string_literal: true
autoload :OptionParser, 'optparse'
module KofamScan
module CLI
class OptionParser
def self.usage
<<~USAGE
Usage: #{File.basename($PROGRAM_NAME)} [options] <query>
<query> FASTA formatted query sequence file
-o <file... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/output_formatter/simple_tabular_formatter.rb | Ruby | mit | 94 | master | 591 | # frozen_string_literal: true
module KofamScan
class OutputFormatter
class SimpleTabularFormatter < OutputFormatter
def initialize
@report_unannotated = true
end
def format(result, output)
result.query_list.each do |query|
ko_list = result.for_gene(query).select(&:abo... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/output_formatter/hit_detail_formatter.rb | Ruby | mit | 94 | master | 1,956 | # frozen_string_literal: true
module KofamScan
class OutputFormatter
class HitDetailFormatter < OutputFormatter
def initialize
@report_unannotated = false
end
def format(result, output)
@max_query_name_length = result.query_list.map(&:size).max
output << header
... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/output_formatter/hit_detail_tsv_formatter.rb | Ruby | mit | 94 | master | 1,915 | # frozen_string_literal: true
module KofamScan
class OutputFormatter
class HitDetailTsvFormatter < OutputFormatter
def initialize
@report_unannotated = false
end
def format(result, output)
@max_query_name_length = result.query_list.map(&:size).max
output << header
... |
github | takaram/kofam_scan | https://github.com/takaram/kofam_scan | lib/kofam_scan/output_formatter/one_line_tabular_formatter.rb | Ruby | mit | 94 | master | 569 | # frozen_string_literal: true
module KofamScan
class OutputFormatter
class OneLineTabularFormatter < OutputFormatter
def initialize
@report_unannotated = true
end
def format(result, output)
result.query_list.each do |query|
ko_list = result.for_gene(query).select(&:ab... |
github | arydjmal/to_csv | https://github.com/arydjmal/to_csv | Rakefile | Ruby | mit | 94 | master | 217 | require 'rake'
require 'rake/testtask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the to_csv plugin.'
Rake::TestTask.new(:test) do |t|
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end |
github | arydjmal/to_csv | https://github.com/arydjmal/to_csv | test/test_helper.rb | Ruby | mit | 94 | master | 764 | begin
require 'rubygems'
require 'test/unit'
require 'active_support'
require 'active_support/inflector'
if RUBY_VERSION >= "1.9.0"
require 'csv'
else
require 'fastercsv'
end
require File.dirname(__FILE__) + '/../lib/to_csv'
rescue LoadError
puts 'to_csv tests rely on active_support, and faste... |
github | arydjmal/to_csv | https://github.com/arydjmal/to_csv | test/to_csv_test.rb | Ruby | mit | 94 | master | 1,384 | require File.dirname(__FILE__) + '/test_helper'
class ToCsvTest < Test::Unit::TestCase
def setup
@users = [
User.new(:id => 1, :name => 'Ary', :age => 25),
User.new(:id => 2, :name => 'Nati', :age => 22)
]
end
def test_with_empty_array
assert_equal( "", [].to_csv )
end
def test_with... |
github | arydjmal/to_csv | https://github.com/arydjmal/to_csv | lib/to_csv.rb | Ruby | mit | 94 | master | 745 | class Array
def to_csv(options = {}, csv_options = {})
return '' if self.empty?
klass = self.first.class
attributes = self.first.attributes.keys.sort.map(&:to_sym)
if options[:only]
columns = Array(options[:only]) & attributes
else
columns = attributes - Array(options[:except])
... |
github | rainforestapp/http-exceptions | https://github.com/rainforestapp/http-exceptions | http-exceptions.gemspec | Ruby | mit | 94 | master | 1,097 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'http/exceptions/version'
Gem::Specification.new do |spec|
spec.name = "http-exceptions"
spec.version = Http::Exceptions::VERSION
spec.authors = ["Simon Mathieu"]
spec... |
github | rainforestapp/http-exceptions | https://github.com/rainforestapp/http-exceptions | lib/http/exceptions.rb | Ruby | mit | 94 | master | 1,057 | require "http/exceptions/version"
require "http/exceptions/configuration"
require "http/exceptions/http_exception"
module Http
module Exceptions
def self.wrap_exception
begin
yield
rescue *configuration.exceptions_to_convert => e
raise HttpException.new original_exception: e
end... |
github | rainforestapp/http-exceptions | https://github.com/rainforestapp/http-exceptions | lib/http/exceptions/configuration.rb | Ruby | mit | 94 | master | 979 | # frozen_string_literal: true
# Some stdlib need to be required for accessing those error classes
# Required for bundler 1.14.5
require "net/http"
require "openssl"
require "socket"
module Http
module Exceptions
class Configuration
DEFAULT_EXCEPTIONS_TO_CONVERT = [
SocketError,
Errno::ETIM... |
github | rainforestapp/http-exceptions | https://github.com/rainforestapp/http-exceptions | lib/http/exceptions/http_exception.rb | Ruby | mit | 94 | master | 519 | module Http
module Exceptions
class HttpException < RuntimeError
attr_reader :response, :original_exception
def initialize(options = {})
@original_exception = options[:original_exception]
@response = options[:response]
msg = 'An error has occurred while processing response.'
... |
github | rainforestapp/http-exceptions | https://github.com/rainforestapp/http-exceptions | spec/spec_helper.rb | Ruby | mit | 94 | master | 4,252 | require 'http/exceptions'
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause this
# file to always be loaded, without a need to explicit... |
github | rainforestapp/http-exceptions | https://github.com/rainforestapp/http-exceptions | spec/http_exception_spec.rb | Ruby | mit | 94 | master | 3,102 | require 'spec_helper'
describe Http::Exceptions do
let(:code) { 200 }
let(:response) { double(code: code, body: '') }
class TestException < RuntimeError
end
describe ".wrap_exception" do
let(:supported_exception_class) { Http::Exceptions::Configuration::DEFAULT_EXCEPTIONS_TO_CONVERT.first }
l... |
github | rainforestapp/http-exceptions | https://github.com/rainforestapp/http-exceptions | spec/http/exceptions/configuration_spec.rb | Ruby | mit | 94 | master | 1,146 | require 'spec_helper'
describe Http::Exceptions::Configuration do
attribute_name_and_default_value_mappings = {
exceptions_to_convert: Http::Exceptions::Configuration::DEFAULT_EXCEPTIONS_TO_CONVERT,
}.freeze
describe "default values" do
subject(:model) { described_class.new }
attribute_name_and_def... |
github | rubyist/guard-rake | https://github.com/rubyist/guard-rake | guard-rake.gemspec | Ruby | mit | 94 | master | 822 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require 'guard/rake/version'
Gem::Specification.new do |s|
s.name = 'guard-rake'
s.version = Guard::RakeVersion::VERSION
s.authors = ['Scott Barron']
s.email = ['scott@elitists.net']
s.homepage = 'http://github.com... |
github | rubyist/guard-rake | https://github.com/rubyist/guard-rake | lib/guard/rake.rb | Ruby | mit | 94 | master | 1,772 | require 'guard'
require 'guard/version'
require 'rake'
module Guard
class Rake < Plugin
class << self
attr_accessor :rakefile_loaded
end
def initialize(options={})
super
@options = {
:run_on_start => true,
:run_on_all => true,
:task_args => []
}.update(opt... |
github | rubyist/guard-rake | https://github.com/rubyist/guard-rake | lib/guard/rake/task.rb | Ruby | mit | 94 | master | 1,771 | # frozen_string_literal: true
require 'rake'
require 'rake/tasklib'
require 'rake/application'
require 'erb'
# This file was inspired by https://github.com/troessner/reek/blob/master/lib/reek/rake/task.rb
module Guard
#
# Defines a task library for running Guard-Rake.
#
# @public
module Rake
GUARDFILE_... |
github | ploubser/JSON-Grep | https://github.com/ploubser/JSON-Grep | Rakefile | Ruby | apache-2.0 | 94 | master | 208 | require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
desc "Run rubycop style checks"
task :rubocop do
sh("rubocop -f progress -f offenses lib spec bin")
end
task :default => [:rubocop, :spec] |
github | ploubser/JSON-Grep | https://github.com/ploubser/JSON-Grep | jgrep.gemspec | Ruby | apache-2.0 | 94 | master | 818 | require 'date'
Gem::Specification.new do |s|
s.name = "jgrep"
s.version = "1.5.4"
s.date = Date.today.to_s
s.summary = "Filter JSON documents with a simple logical language"
s.description = "Compare a list of json documents to a simple logical language and returns matches as output"
s.homepag... |
github | ploubser/JSON-Grep | https://github.com/ploubser/JSON-Grep | lib/jgrep.rb | Ruby | apache-2.0 | 94 | master | 8,817 | require "parser/parser.rb"
require "parser/scanner.rb"
require "rubygems"
require "json"
module JGrep
@verbose = false
@flatten = false
def self.verbose_on
@verbose = true
end
def self.flatten_on
@flatten = true
end
# Parse json and return documents that match the logical expression
# Filter... |
github | ploubser/JSON-Grep | https://github.com/ploubser/JSON-Grep | lib/parser/parser.rb | Ruby | apache-2.0 | 94 | master | 4,013 | module JGrep
class Parser
attr_reader :scanner, :execution_stack
def initialize(args)
@scanner = Scanner.new(args)
@execution_stack = []
parse
end
# Parse the input string, one token at a time a contruct the call stack
def parse(substatement = nil, token_index = 0)
p_tok... |
github | ploubser/JSON-Grep | https://github.com/ploubser/JSON-Grep | lib/parser/scanner.rb | Ruby | apache-2.0 | 94 | master | 4,271 | module JGrep
class Scanner
attr_accessor :arguments, :token_index
def initialize(arguments)
@token_index = 0
@arguments = arguments
end
# Scans the input string and identifies single language tokens
def get_token
return nil if @token_index >= @arguments.size
begin
... |
github | ploubser/JSON-Grep | https://github.com/ploubser/JSON-Grep | spec/Rakefile | Ruby | apache-2.0 | 94 | master | 241 | require "spec_helper.rb"
require "rake"
require "rspec/core/rake_task"
desc "Run JGrep tests"
RSpec::Core::RakeTask.new(:test) do |t|
t.pattern = "unit/*_spec.rb"
t.rspec_opts = "--format s --color --backtrace"
end
task default: :test |
github | ploubser/JSON-Grep | https://github.com/ploubser/JSON-Grep | spec/unit/jgrep_spec.rb | Ruby | apache-2.0 | 94 | master | 8,824 | require File.dirname(__FILE__) + "/../spec_helper"
module JGrep
describe JGrep do
describe "#validate_expression" do
it "should be true for valid expressions" do
expect(JGrep.validate_expression("bob=true")).to be(true)
end
it "should return errors for invalid ones" do
expect(J... |
github | ploubser/JSON-Grep | https://github.com/ploubser/JSON-Grep | spec/unit/parser_spec.rb | Ruby | apache-2.0 | 94 | master | 5,156 | require File.dirname(__FILE__) + "/../spec_helper"
module JGrep
describe Parser do
describe "#parse" do
it "should parse statements seperated by '='" do
parser = Parser.new("foo.bar=bar")
expect(parser.execution_stack).to eq([{"statement" => "foo.bar=bar"}])
end
it "should pars... |
github | ploubser/JSON-Grep | https://github.com/ploubser/JSON-Grep | spec/unit/scanner_spec.rb | Ruby | apache-2.0 | 94 | master | 2,747 | require File.dirname(__FILE__) + "/../spec_helper"
module JGrep
describe Scanner do
describe "#get_token" do
it "should identify a '(' token" do
scanner = Scanner.new("(")
token = scanner.get_token
expect(token).to eq(["(", "("])
end
it "should identify a ')' token" do
... |
github | evrone/carrierwave-video-thumbnailer | https://github.com/evrone/carrierwave-video-thumbnailer | Rakefile | Ruby | mit | 94 | master | 567 | # encoding: utf-8
require 'rubygems'
begin
require 'bundler'
rescue LoadError => e
warn e.message
warn "Run `gem install bundler` to install Bundler."
exit -1
end
begin
Bundler.setup(:development)
rescue Bundler::BundlerError => e
warn e.message
warn "Run `bundle install` to install missing gems."
ex... |
github | evrone/carrierwave-video-thumbnailer | https://github.com/evrone/carrierwave-video-thumbnailer | carrierwave-video-thumbnailer.gemspec | Ruby | mit | 94 | master | 2,068 | # encoding: utf-8
require 'yaml'
Gem::Specification.new do |gem|
gemspec = YAML.load_file('gemspec.yml')
gem.name = gemspec.fetch('name')
gem.version = gemspec.fetch('version') do
lib_dir = File.join(File.dirname(__FILE__),'lib')
$LOAD_PATH << lib_dir unless $LOAD_PATH.in... |
github | evrone/carrierwave-video-thumbnailer | https://github.com/evrone/carrierwave-video-thumbnailer | spec/spec_helper.rb | Ruby | mit | 94 | master | 212 | require 'rspec'
require 'active_support/all'
require 'carrierwave/video/thumbnailer'
RSpec.configure do |config|
config.mock_with :rspec
config.formatter = 'progress'
config.color_enabled = true
end |
github | evrone/carrierwave-video-thumbnailer | https://github.com/evrone/carrierwave-video-thumbnailer | spec/lib/thumbnailer_spec.rb | Ruby | mit | 94 | master | 5,034 | require 'spec_helper'
require 'carrierwave/video/thumbnailer'
describe CarrierWave::Video::Thumbnailer do
it "should have a VERSION constant" do
subject.const_get('VERSION').should_not be_empty
end
#class FFMpegThumbnailer; end
class TestVideoUploader
include CarrierWave::Video::Thumbnailer
def ... |
github | evrone/carrierwave-video-thumbnailer | https://github.com/evrone/carrierwave-video-thumbnailer | spec/lib/ffmpegthumbnailer_spec.rb | Ruby | mit | 94 | master | 2,003 | require 'spec_helper'
require 'carrierwave/video/thumbnailer'
describe CarrierWave::Video::Thumbnailer::FFMpegThumbnailer do
describe "#run" do
let(:input_file_path) { '/tmp/file.mov' }
let(:output_file_path) { '/tmp/file.jpg' }
let(:binary) { 'thumbnailrrr' }
let(:thumbnailer) { CarrierWave::Video... |
github | evrone/carrierwave-video-thumbnailer | https://github.com/evrone/carrierwave-video-thumbnailer | lib/carrierwave/video/thumbnailer.rb | Ruby | mit | 94 | master | 2,232 | require 'carrierwave'
require 'carrierwave/video/thumbnailer/version'
require 'carrierwave/video/thumbnailer/ffmpegthumbnailer'
module CarrierWave
module Video
module Thumbnailer
extend ActiveSupport::Concern
module ClassMethods
def thumbnail options = {}
process thumbnail: option... |
github | evrone/carrierwave-video-thumbnailer | https://github.com/evrone/carrierwave-video-thumbnailer | lib/carrierwave/video/thumbnailer/ffmpegthumbnailer.rb | Ruby | mit | 94 | master | 1,952 | require 'carrierwave/video/thumbnailer/ffmpegthumbnailer/options'
require 'open3'
module CarrierWave
module Video
module Thumbnailer
class FFMpegThumbnailer
# Explicit class methods
class << self
# Sets a required thumbnailer binary
def binary=(bin)
@ffmpeg... |
github | evrone/carrierwave-video-thumbnailer | https://github.com/evrone/carrierwave-video-thumbnailer | lib/carrierwave/video/thumbnailer/ffmpegthumbnailer/options.rb | Ruby | mit | 94 | master | 1,597 | module CarrierWave
module Video
module Thumbnailer
# Options to be be converted to CLI parameters
class Options < Hash
BOOLEAN = [
:square,
:strip,
:workaround
]
def initialize opts
opts.each { |k, v| self[k] = v}
end
... |
github | yyuu/capistrano-rbenv | https://github.com/yyuu/capistrano-rbenv | capistrano-rbenv.gemspec | Ruby | mit | 94 | develop | 858 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/capistrano-rbenv/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Yamashita Yuu"]
gem.email = ["yamashita@geishatokyo.com"]
gem.description = %q{a capistrano recipe to manage rubies with rbenv.}
gem.summary = %q... |
github | yyuu/capistrano-rbenv | https://github.com/yyuu/capistrano-rbenv | test/config/deploy.rb | Ruby | mit | 94 | develop | 3,329 | set :application, "capistrano-rbenv"
set :repository, "."
set :deploy_to do
File.join("/home", user, application)
end
set :deploy_via, :copy
set :scm, :none
set :use_sudo, false
set :user, "vagrant"
set :password, "vagrant"
set :ssh_options, {
:auth_methods => %w(publickey password),
:keys => File.join(ENV["HOME... |
github | yyuu/capistrano-rbenv | https://github.com/yyuu/capistrano-rbenv | test/precise64/Vagrantfile | Ruby | mit | 94 | develop | 3,981 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment r... |
github | yyuu/capistrano-rbenv | https://github.com/yyuu/capistrano-rbenv | test/centos6-64/Vagrantfile | Ruby | mit | 94 | develop | 4,023 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment r... |
github | yyuu/capistrano-rbenv | https://github.com/yyuu/capistrano-rbenv | lib/capistrano-rbenv.rb | Ruby | mit | 94 | develop | 16,572 | require "capistrano-rbenv/version"
require "capistrano/configuration"
require "capistrano/configuration/resources/platform_resources"
require "capistrano/recipes/deploy/scm"
module Capistrano
module RbEnv
def self.extended(configuration)
configuration.load {
namespace(:rbenv) {
_cset(:rbe... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | Rakefile | Ruby | bsd-2-clause | 94 | master | 718 | require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'
spec = Gem::Specification.new do |s|
s.name = 'freightrain'
s.version = '0.8.5'
s.add_dependency('require_all', '>= 1.1.0')
s.has_rdoc = false
s.homepage = "http://github.com/b... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/spec_helper.rb | Ruby | bsd-2-clause | 94 | master | 259 | $:.unshift File.join(File.dirname(__FILE__),'..','lib')
require 'rubygems'
require 'spec'
require 'mocha'
require 'needle'
require 'test/unit'
require 'freightrain.rb'
include Freightrain
Spec::Runner.configure do |config|
config.mock_with :mocha
end |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/auto_requirer_spec.rb | Ruby | bsd-2-clause | 94 | master | 2,369 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Freightrain do
describe "auto_require!" do
before :each do
Freightrain.app_path = "testpath"
Freightrain.stubs(:require_all)
File.stubs(:directory?).returns(false)
Dir.stubs(:entries).returns(false)
end
... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/string_patch_spec.rb | Ruby | bsd-2-clause | 94 | master | 1,159 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe String do
describe "to convention sym" do
it "should return nil if string is empty" do
"".to_convention_sym.should == nil
end
it "should return string as symbol if no uppercase letters" do
"noupperca... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/bootstrapper_spec.rb | Ruby | bsd-2-clause | 94 | master | 2,117 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "bootstrapper" do
after :each do
Freightrain.toolkit = nil
end
describe "views path" do
it "should return app_path + views if toolkit_path does not exists" do
Freightrain.app_path = "testpath"
Freightrain.views_p... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/elements/freight_element_view_model_spec.rb | Ruby | bsd-2-clause | 94 | master | 2,747 | require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe FreightElementViewModel do
before :each do
@view = stub()
@view.stubs(:hook_to_signals)
@view.stubs(:data_source=)
Freightrain.stubs(:[]).with(:test_element_view).returns(@view)
end
it "should always have a 'select... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/elements/freight_element_view_spec.rb | Ruby | bsd-2-clause | 94 | master | 1,744 | require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe FreightElementView do
before :each do
Freightrain.app_path = "dummy"
end
it "should always have a 'selected' signal" do
klass = Class.new(FreightElementView)
p Freightrain.toolkit
instance = klass.new
instance.... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/elements/layout_widget_spec.rb | Ruby | bsd-2-clause | 94 | master | 1,272 | require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe LayoutWidget do
before :each do
@class = Class.new
@class.instance_eval("include LayoutWidget")
end
describe "add signal callback" do
it "should add the specified proc to target signal" do
instance = @class.new
... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/binding/binding_host_spec.rb | Ruby | bsd-2-clause | 94 | master | 3,445 | require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe BindingHost do
before :each do
klass = Class.new
klass.instance_eval("include BindingHost")
@instance = klass.new
end
describe "load bindings from file" do
it "should always call BindingLoader with class n... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/binding/binding_loader_spec.rb | Ruby | bsd-2-clause | 94 | master | 2,621 | require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe BindingLoader do
before :each do
Freightrain.app_path = "testpath"
end
describe "filename" do
it "should return nil if dir does not contain file" do
loader = BindingLoader.new("Noclass")
loader.filename.shou... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/binding/freight_binding_spec.rb | Ruby | bsd-2-clause | 94 | master | 4,324 | require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe FreightBinding do
it "should raise if options parameter does not respond to indexer" do
lambda do
FreightBinding.new(nil, nil)
end.should raise_error
end
describe "data source" do
it "should always retur... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/binding/converters/default_converter_spec.rb | Ruby | bsd-2-clause | 94 | master | 382 | require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe DefaultConverter do
describe "from" do
it "should return same value passed" do
DefaultConverter.new.from(:test).should == :test
end
end
describe "to" do
it "should return same value passed" do
Default... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/services/service_host_spec.rb | Ruby | bsd-2-clause | 94 | master | 1,646 | require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe ServiceHost do
it "should do nothing if no service is added" do
Freightrain.expects(:[]).never
Class.new(FreightService).new
end
it "should call container for each service registered" do
Freightrain.expects(:[]).with... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/services/freight_service_spec.rb | Ruby | bsd-2-clause | 94 | master | 996 | require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe FreightService do
before :each do
@class = Class.new(FreightService)
end
it "should always extend ServiceHost" do
@class.kind_of? ServiceHost
end
describe "ctor" do
it "should always instantiate services" do
... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/views/interface_builder_spec.rb | Ruby | bsd-2-clause | 94 | master | 1,344 | require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe InterfaceBuilder do
describe "load from file" do
before :each do
klass = Class.new
klass.instance_eval("include InterfaceBuilder")
@instance = klass.new
@instance.stubs(:get_all_callbacks).returns([])
... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/views/callback_wrapper_spec.rb | Ruby | bsd-2-clause | 94 | master | 1,347 | require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe CallbackWrapper do
describe "matches widget?" do
it "should return false if widget name is not contained in method name" do
method = stub(:name => "bau!!")
result = CallbackWrapper.new(method).target == "my_name"
... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/views/freight_view_spec.rb | Ruby | bsd-2-clause | 94 | master | 2,896 | require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe FreightView do
before :each do
@class = Class.new(FreightView)
File.stubs(:join).returns("nofile")
Freightrain.toolkit = :test
Freightrain.stubs(:get_interface_builder).returns(stub(:file_found? => false))
@class.st... |
github | bolthar/freightrain | https://github.com/bolthar/freightrain | spec/freightrain/ioc/container_hookable_spec.rb | Ruby | bsd-2-clause | 94 | master | 1,118 | $:.unshift File.join(File.dirname(__FILE__),'..','lib')
require File.dirname(__FILE__) + '/../../../lib/freightrain/ioc/container_hookable.rb'
include Freightrain
describe ContainerHookable do
describe "subclasses" do
before :each do
ContainerHookable.classes.clear
end
it "should return an emp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.