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 | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | lib/redmine_helpdesk/mail_handler_patch.rb | Ruby | mit | 201 | master | 5,363 | module RedmineHelpdesk
module MailHandlerPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval do
alias_method :dispatch_to_default_without_helpdesk, :dispatch_to_default
alias_method :dispatch_to_default, :dispatch_to_default_with_helpdesk
... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | lib/redmine_helpdesk/journal_patch.rb | Ruby | mit | 201 | master | 1,993 | module RedmineHelpdesk
module JournalPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval do
alias_method :send_notification_without_helpdesk, :send_notification
alias_method :send_notification, :send_notification_with_helpdesk
end
... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | lib/redmine_helpdesk/mailer_patch.rb | Ruby | mit | 201 | master | 3,496 | module RedmineHelpdesk
module MailerPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval do
alias_method :issue_edit_without_helpdesk, :issue_edit
alias_method :issue_edit, :issue_edit_with_helpdesk
end
end
module InstanceMe... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | lib/tasks/redmine.rake | Ruby | mit | 201 | master | 2,890 | require 'fileutils'
namespace :helpdesk do
namespace :redmine do
plugin_root = File.expand_path('../../../', __FILE__)
redmine_path = "#{plugin_root}/test/app"
tmp_dir = "#{plugin_root}/tmp"
redmine_source_url = "http://www.redmine.org/releases"
redmine_version = ENV['REDMINE_VERSION'] || "3.2.0... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | lib/tasks/local-db.rake | Ruby | mit | 201 | master | 1,712 | namespace :helpdesk do
namespace :localdb do
db_label = 'helpdesk-db'
def get_env ()
db_name = 'redmine'
db_host = 'localhost'
db_user = 'root'
db_adapter = ENV['DATABASE_ADAPTER']
case db_adapter
when "mysql"
env = "-e MYSQL_DATABASE=#{db_name} "\
"... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | lib/tasks/plugin_ci.rake | Ruby | mit | 201 | master | 1,738 | namespace :helpdesk do
plugin_root = File.expand_path('../../../', __FILE__)
coverage_dir = "#{plugin_root}/coverage"
desc 'Runs :ci target from plugin scope in test/app'
task :ext_ci do
cd('test/app') do
sh('bundle exec rake helpdesk:ci')
end
end
desc 'Prepared and configures DB in Docker c... |
github | mokemokechicken/CrashMonkey | https://github.com/mokemokechicken/CrashMonkey | Rakefile | Ruby | mit | 201 | master | 1,485 | # encoding: utf-8
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is... |
github | mokemokechicken/CrashMonkey | https://github.com/mokemokechicken/CrashMonkey | crash_monkey.gemspec | Ruby | mit | 201 | master | 3,255 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: crash_monkey 0.3.1 ruby lib
Gem::Specification.new do |s|
s.name = "crash_monkey"
s.version = "0.3.1"
s.required_rubygems_version = Gem::Requirement.new(">... |
github | mokemokechicken/CrashMonkey | https://github.com/mokemokechicken/CrashMonkey | Gemfile | Ruby | mit | 201 | master | 514 | source 'http://rubygems.org'
# Add dependencies required to use your gem here.
# Example:
# gem "activesupport", ">= 2.3.5"
gem 'erubis', '>= 2.7.0'
gem 'json', '>= 1.7.0'
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
gem 'rspec',... |
github | mokemokechicken/CrashMonkey | https://github.com/mokemokechicken/CrashMonkey | lib/crash_monkey/monkey_runner.rb | Ruby | mit | 201 | master | 10,477 | # coding: utf-8
module UIAutoMonkey
require 'fileutils'
require 'timeout'
require 'rexml/document'
require 'erubis'
require 'json'
class MonkeyRunner
TRACE_TEMPLATE='/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automati... |
github | mokemokechicken/CrashMonkey | https://github.com/mokemokechicken/CrashMonkey | lib/crash_monkey/command_helper.rb | Ruby | mit | 201 | master | 606 | module UIAutoMonkey
module CommandHelper
require 'open3'
def shell(cmds)
puts "Shell: #{cmds.inspect}"
Open3.popen3(*cmds) do |stdin, stdout, stderr|
stdin.close
return stdout.read
end
end
def run_process(cmds)
puts "Run: #{cmds.inspect}"
Kernel.system(c... |
github | mokemokechicken/CrashMonkey | https://github.com/mokemokechicken/CrashMonkey | spec/spec_helper.rb | Ruby | mit | 201 | master | 362 | $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
require 'crash_monkey'
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| requi... |
github | ruby/csv | https://github.com/ruby/csv | Rakefile | Ruby | bsd-2-clause | 202 | main | 2,276 | require "rbconfig"
require "rdoc/task"
require "yaml"
require "bundler/gem_tasks"
spec = Bundler::GemHelper.gemspec
desc "Run test"
task :test do
ruby("run-test.rb")
end
task :default => :test
namespace :warning do
desc "Treat warning as error"
task :error do
def Warning.warn(*message)
super
... |
github | ruby/csv | https://github.com/ruby/csv | csv.gemspec | Ruby | bsd-2-clause | 202 | main | 1,714 | # frozen_string_literal: true
begin
require_relative "lib/csv/version"
rescue LoadError
# for Ruby core repository
require_relative "version"
end
Gem::Specification.new do |spec|
spec.name = "csv"
spec.version = CSV::VERSION
spec.authors = ["James Edward Gray II", "Kouhei Sutou"]
sp... |
github | ruby/csv | https://github.com/ruby/csv | run-test.rb | Ruby | bsd-2-clause | 202 | main | 334 | #!/usr/bin/env ruby
$VERBOSE = true
$LOAD_PATH.unshift("test")
$LOAD_PATH.unshift("test/lib")
$LOAD_PATH.unshift("lib")
Dir.glob("test/csv/**/*test_*.rb") do |test_rb|
# Ensure we only load syntax that we can handle
next if RUBY_VERSION < "2.7" && test_rb.end_with?("test_patterns.rb")
require File.expand_path... |
github | ruby/csv | https://github.com/ruby/csv | Gemfile | Ruby | bsd-2-clause | 202 | main | 226 | source 'https://rubygems.org'
# Specify your gem's dependencies in csv.gemspec
gemspec
group :development do
gem "benchmark_driver"
gem "bundler"
gem "psych"
gem "rake"
gem "rdoc"
gem "test-unit", ">= 3.4.8"
end |
github | ruby/csv | https://github.com/ruby/csv | profile/parse.rb | Ruby | bsd-2-clause | 202 | main | 1,250 | #!/usr/bin/env ruby
require "csv"
require "optparse"
n_columns = 1000
n_rows = 1000
type = "unquoted"
alphas = nil
hiraganas = nil
builders = {
"unquoted" => lambda {(alphas.join(",") + "\r\n") * n_rows},
"quoted" => lambda {(alphas.map {|s| %("#{s}")}.join(",") + "\r\n") * n_rows},
"include-column-separator"... |
github | ruby/csv | https://github.com/ruby/csv | profile/write.rb | Ruby | bsd-2-clause | 202 | main | 979 | #!/usr/bin/env ruby
require "csv"
require "optparse"
n_columns = 5
n_rows = 100
type = "generate-line"
parser = OptionParser.new
parser.on("--n-columns=N", Integer,
"The number of columns to be generated",
"(#{n_columns})") do |n|
n_columns = n
end
parser.on("--n-rows=N", Integer,
"Th... |
github | ruby/csv | https://github.com/ruby/csv | lib/csv.rb | Ruby | bsd-2-clause | 202 | main | 100,172 | # encoding: US-ASCII
# frozen_string_literal: true
# = csv.rb -- CSV Reading and Writing
#
# Created by James Edward Gray II on 2005-10-31.
#
# See CSV for documentation.
#
# == Description
#
# Welcome to the new and improved CSV.
#
# This version of the CSV library began its life as FasterCSV. FasterCSV was
# intended... |
github | ruby/csv | https://github.com/ruby/csv | lib/csv/fields_converter.rb | Ruby | bsd-2-clause | 202 | main | 2,757 | # frozen_string_literal: true
class CSV
# Note: Don't use this class directly. This is an internal class.
class FieldsConverter
include Enumerable
NO_QUOTED_FIELDS = [] # :nodoc:
def NO_QUOTED_FIELDS.[](_index)
false
end
NO_QUOTED_FIELDS.freeze
#
# A CSV::FieldsConverter is a da... |
github | ruby/csv | https://github.com/ruby/csv | lib/csv/input_record_separator.rb | Ruby | bsd-2-clause | 202 | main | 277 | require "English"
require "stringio"
class CSV
module InputRecordSeparator
class << self
if RUBY_VERSION >= "3.0.0"
def value
"\n"
end
else
def value
$INPUT_RECORD_SEPARATOR
end
end
end
end
end |
github | ruby/csv | https://github.com/ruby/csv | lib/csv/row.rb | Ruby | bsd-2-clause | 202 | main | 24,767 | # frozen_string_literal: true
require "forwardable"
class CSV
# = \CSV::Row
# A \CSV::Row instance represents a \CSV table row.
# (see {class CSV}[../CSV.html]).
#
# The instance may have:
# - Fields: each is an object, not necessarily a \String.
# - Headers: each serves a key, and also need not be a \S... |
github | ruby/csv | https://github.com/ruby/csv | lib/csv/table.rb | Ruby | bsd-2-clause | 202 | main | 38,160 | # frozen_string_literal: true
require "forwardable"
class CSV
# = \CSV::Table
# A \CSV::Table instance represents \CSV data.
# (see {class CSV}[../CSV.html]).
#
# The instance may have:
# - Rows: each is a Table::Row object.
# - Headers: names for the columns.
#
# === Instance Methods
#
# \CSV::... |
github | ruby/csv | https://github.com/ruby/csv | lib/csv/parser.rb | Ruby | bsd-2-clause | 202 | main | 38,153 | # frozen_string_literal: true
require "strscan"
require_relative "input_record_separator"
require_relative "row"
require_relative "table"
class CSV
# Note: Don't use this class directly. This is an internal class.
class Parser
#
# A CSV::Parser is m17n aware. The parser works in the Encoding of the IO
... |
github | ruby/csv | https://github.com/ruby/csv | lib/csv/writer.rb | Ruby | bsd-2-clause | 202 | main | 5,950 | # frozen_string_literal: true
require_relative "input_record_separator"
require_relative "row"
class CSV
# Note: Don't use this class directly. This is an internal class.
class Writer
#
# A CSV::Writer receives an output, prepares the header, format and output.
# It allows us to write new rows in the ... |
github | ruby/csv | https://github.com/ruby/csv | test/lib/with_different_ofs.rb | Ruby | bsd-2-clause | 202 | main | 722 | # frozen_string_literal: true
module DifferentOFS
is_output_field_separator_deprecated = false
verbose, $VERBOSE = $VERBOSE, true
stderr, $stderr = $stderr, StringIO.new
begin
ofs, $, = $,, "-"
is_output_field_separator_deprecated = (not $stderr.string.empty?)
ensure
$, = ofs
$stderr = stderr... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/test_table.rb | Ruby | bsd-2-clause | 202 | main | 17,145 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "helper"
class TestCSVTable < Test::Unit::TestCase
extend DifferentOFS
def setup
super
@rows = [ CSV::Row.new(%w{A B C}, [1, 2, 3]),
CSV::Row.new(%w{A B C}, [4, 5, 6]),
CSV::Row.new(%w{A B C}, [7, 8, 9]... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/helper.rb | Ruby | bsd-2-clause | 202 | main | 927 | require "tempfile"
require "test/unit"
require "csv"
require_relative "../lib/with_different_ofs"
module CSVHelper
def with_chunk_size(chunk_size)
chunk_size_keep = ENV["CSV_PARSER_SCANNER_TEST_CHUNK_SIZE"]
begin
ENV["CSV_PARSER_SCANNER_TEST_CHUNK_SIZE"] = chunk_size
yield
ensure
ENV[... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/test_encodings.rb | Ruby | bsd-2-clause | 202 | main | 13,578 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "helper"
class TestCSVEncodings < Test::Unit::TestCase
extend DifferentOFS
include CSVHelper
def setup
super
require 'tempfile'
@temp_csv_file = Tempfile.new(%w"test_csv. .csv")
@temp_csv_path = @temp_csv_file.path
@tem... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/test_row.rb | Ruby | bsd-2-clause | 202 | main | 11,527 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "helper"
class TestCSVRow < Test::Unit::TestCase
extend DifferentOFS
def setup
super
@row = CSV::Row.new(%w{A B C A A}, [1, 2, 3, 4])
end
def test_initialize
# basic
row = CSV::Row.new(%w{A B C}, [1, 2, 3])
assert_no... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/test_data_converters.rb | Ruby | bsd-2-clause | 202 | main | 10,840 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "helper"
class TestCSVDataConverters < Test::Unit::TestCase
extend DifferentOFS
def setup
super
@win_safe_time_str = Time.now.strftime("%a %b %d %H:%M:%S %Y")
end
def test_builtin_integer_converter
# does convert
[-5, 1,... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/test_tsv.rb | Ruby | bsd-2-clause | 202 | main | 746 | require_relative "helper"
class TestTSV < Test::Unit::TestCase
def test_default_separator
tsv = CSV::TSV.new(String.new)
assert_equal("\t", tsv.col_sep)
end
def test_override_separator
tsv = CSV::TSV.new(String.new, col_sep: ",")
assert_equal(",", tsv.col_sep)
end
def test_read_tsv_data
... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/test_patterns.rb | Ruby | bsd-2-clause | 202 | main | 518 | # frozen_string_literal: true
require_relative "helper"
class TestCSVPatternMatching < Test::Unit::TestCase
def test_hash
case CSV::Row.new(%i{A B C}, [1, 2, 3])
in B: b, C: c
assert_equal([2, 3], [b, c])
end
end
def test_hash_rest
case CSV::Row.new(%i{A B C}, [1, 2, 3])
in B: b, **r... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/test_features.rb | Ruby | bsd-2-clause | 202 | main | 11,300 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
begin
require "zlib"
rescue LoadError
end
require_relative "helper"
require "tempfile"
class TestCSVFeatures < Test::Unit::TestCase
extend DifferentOFS
TEST_CASES = [ [%Q{a,b}, ["a", "b"]],
[%Q{a,"""b"""}, ["a", "\"b... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/interface/test_read.rb | Ruby | bsd-2-clause | 202 | main | 10,860 | # frozen_string_literal: false
require_relative "../helper"
class TestCSVInterfaceRead < Test::Unit::TestCase
extend DifferentOFS
def setup
super
@data = ""
@data << "1\t2\t3\r\n"
@data << "4\t5\r\n"
@input = Tempfile.new(["interface-read", ".csv"], binmode: true)
@input << @data
@inp... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/interface/test_delegation.rb | Ruby | bsd-2-clause | 202 | main | 831 | # frozen_string_literal: false
require_relative "../helper"
class TestCSVInterfaceDelegation < Test::Unit::TestCase
class TestStringIO < self
def setup
@csv = CSV.new("h1,h2")
end
def test_flock
assert_raise(NotImplementedError) do
@csv.flock(File::LOCK_EX)
end
end
de... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/interface/test_write.rb | Ruby | bsd-2-clause | 202 | main | 4,481 | # frozen_string_literal: false
require_relative "../helper"
class TestCSVInterfaceWrite < Test::Unit::TestCase
extend DifferentOFS
def setup
super
@output = Tempfile.new(["interface-write", ".csv"])
end
def teardown
@output.close(true)
super
end
def test_generate_default
csv_text = ... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/interface/test_read_write.rb | Ruby | bsd-2-clause | 202 | main | 2,460 | # frozen_string_literal: false
require_relative "../helper"
class TestCSVInterfaceReadWrite < Test::Unit::TestCase
extend DifferentOFS
def test_filter
input = <<-CSV.freeze
1;2;3
4;5
CSV
output = ""
CSV.filter(input, output,
in_col_sep: ";",
out_col_sep: ",",
... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/parse/test_rewind.rb | Ruby | bsd-2-clause | 202 | main | 973 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "../helper"
class TestCSVParseRewind < Test::Unit::TestCase
extend DifferentOFS
def parse(data, **options)
csv = CSV.new(data, **options)
records = csv.to_a
csv.rewind
[records, csv.to_a]
end
def test_default
data = ... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/parse/test_column_separator.rb | Ruby | bsd-2-clause | 202 | main | 957 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "../helper"
class TestCSVParseColumnSeparator < Test::Unit::TestCase
extend DifferentOFS
def test_comma
assert_equal([["a", "b", nil, "d"]],
CSV.parse("a,b,,d", col_sep: ","))
end
def test_space
assert_equal([["... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/parse/test_general.rb | Ruby | bsd-2-clause | 202 | main | 11,769 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require "timeout"
require_relative "../helper"
#
# Following tests are my interpretation of the
# {CSV RCF}[https://www.ietf.org/rfc/rfc4180.txt]. I only deviate from that
# document in one place (intentionally) and that is to make the default row
# separator <... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/parse/test_each.rb | Ruby | bsd-2-clause | 202 | main | 459 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "../helper"
class TestCSVParseEach < Test::Unit::TestCase
extend DifferentOFS
def test_twice
data = <<-CSV
Ruby,2.6.0,script
CSV
csv = CSV.new(data)
assert_equal([
[["Ruby", "2.6.0", "script"]],
... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/parse/test_liberal_parsing.rb | Ruby | bsd-2-clause | 202 | main | 6,016 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "../helper"
class TestCSVParseLiberalParsing < Test::Unit::TestCase
extend DifferentOFS
def test_middle_quote_start
input = '"Johnson, Dwayne",Dwayne "The Rock" Johnson'
error = assert_raise(CSV::MalformedCSVError) do
CSV.parse... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/parse/test_strip.rb | Ruby | bsd-2-clause | 202 | main | 3,000 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "../helper"
class TestCSVParseStrip < Test::Unit::TestCase
extend DifferentOFS
def test_both
assert_equal(["a", "b"],
CSV.parse_line(%Q{ a , b }, strip: true))
end
def test_left
assert_equal(["a", "b"],
... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/parse/test_header.rb | Ruby | bsd-2-clause | 202 | main | 9,935 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "../helper"
class TestCSVHeaders < Test::Unit::TestCase
extend DifferentOFS
def setup
super
@data = <<-CSV
first,second,third
A,B,C
1,2,3
CSV
end
def test_first_row
[:first_row, true].each do |setting| # two names for t... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/parse/test_read.rb | Ruby | bsd-2-clause | 202 | main | 490 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "../helper"
class TestCSVParseRead < Test::Unit::TestCase
extend DifferentOFS
def test_shift
data = <<-CSV
1
2
3
CSV
csv = CSV.new(data)
assert_equal([
["1"],
[["2"], ["3"]],
... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/parse/test_invalid.rb | Ruby | bsd-2-clause | 202 | main | 1,102 | # frozen_string_literal: false
require_relative "../helper"
class TestCSVParseInvalid < Test::Unit::TestCase
def test_ignore_invalid_line
csv = CSV.new(<<-CSV, headers: true, return_headers: true)
head1,head2,head3
aaa,bbb,ccc
ddd,ee"e.fff
ggg,hhh,iii
CSV
headers = ["head1", "head2", "head3"]
assert... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/parse/test_row_separator.rb | Ruby | bsd-2-clause | 202 | main | 356 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "../helper"
class TestCSVParseRowSeparator < Test::Unit::TestCase
extend DifferentOFS
include CSVHelper
def test_multiple_characters
with_chunk_size("1") do
assert_equal([["a"], ["b"]],
CSV.parse("a\r\nb\r\n", ... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/parse/test_skip_lines.rb | Ruby | bsd-2-clause | 202 | main | 2,956 | # frozen_string_literal: false
require_relative "../helper"
class TestCSVParseSkipLines < Test::Unit::TestCase
extend DifferentOFS
include CSVHelper
def test_default
csv = CSV.new("a,b,c\n")
assert_nil(csv.skip_lines)
end
def parse(data, **options)
# We use Tempfile here to use CSV::Parser::In... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/parse/test_inputs_scanner.rb | Ruby | bsd-2-clause | 202 | main | 2,927 | require_relative "../helper"
class TestCSVParseInputsScanner < Test::Unit::TestCase
include CSVHelper
def test_scan_keep_nested_back
input = CSV::Parser::UnoptimizedStringIO.new("abcdef")
scanner = CSV::Parser::InputsScanner.new([input],
Encoding::UTF_8,
... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/parse/test_convert.rb | Ruby | bsd-2-clause | 202 | main | 4,501 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "../helper"
class TestCSVParseConvert < Test::Unit::TestCase
extend DifferentOFS
def setup
super
@data = "Numbers,:integer,1,:float,3.015"
@parser = CSV.new(@data)
@custom = lambda {|field| /\A:(\S.*?)\s*\Z/ =~ field ? $1.... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/parse/test_quote_char_nil.rb | Ruby | bsd-2-clause | 202 | main | 2,409 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "../helper"
class TestCSVParseQuoteCharNil < Test::Unit::TestCase
extend DifferentOFS
def test_full
assert_equal(["a", "b"], CSV.parse_line(%Q{a,b}, quote_char: nil))
end
def test_end_with_nil
assert_equal(["a", nil, nil, nil], ... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/parse/test_unconverted_fields.rb | Ruby | bsd-2-clause | 202 | main | 3,488 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "../helper"
class TestCSVParseUnconvertedFields < Test::Unit::TestCase
extend DifferentOFS
def setup
super
@custom = lambda {|field| /\A:(\S.*?)\s*\Z/ =~ field ? $1.to_sym : field}
@headers = ["first", "second", "third"]
@da... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/write/test_general.rb | Ruby | bsd-2-clause | 202 | main | 6,975 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "../helper"
module TestCSVWriteGeneral
include CSVHelper
def test_tab
assert_equal("\t#{$INPUT_RECORD_SEPARATOR}",
generate_line(["\t"]))
end
def test_quote_character
assert_equal(%Q[foo,"""",baz#{$INPUT_RECORD_... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/write/test_force_quotes.rb | Ruby | bsd-2-clause | 202 | main | 2,260 | # frozen_string_literal: false
require_relative "../helper"
module TestCSVWriteForceQuotes
def test_default
assert_equal(%Q[1,2,3#{$INPUT_RECORD_SEPARATOR}],
generate_line(["1", "2", "3"]))
end
def test_true
assert_equal(%Q["1","2","3"#{$INPUT_RECORD_SEPARATOR}],
gener... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/write/test_converters.rb | Ruby | bsd-2-clause | 202 | main | 1,362 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "../helper"
module TestCSVWriteConverters
def test_one
assert_equal(%Q[=a,=b,=c\n],
generate_line(["a", "b", "c"],
write_converters: ->(value) {"=" + value}))
end
def test_multiple
as... |
github | ruby/csv | https://github.com/ruby/csv | test/csv/write/test_quote_empty.rb | Ruby | bsd-2-clause | 202 | main | 1,817 | # -*- coding: utf-8 -*-
# frozen_string_literal: false
require_relative "../helper"
module TestCSVWriteQuoteEmpty
def test_quote_empty_default
assert_equal(%Q["""",""#{$INPUT_RECORD_SEPARATOR}],
generate_line([%Q["], ""]))
end
def test_quote_empty_false
assert_equal(%Q["""",#{$INPUT_RE... |
github | ept/invoicing | https://github.com/ept/invoicing | Rakefile | Ruby | mit | 201 | master | 1,663 | %w[rubygems rake rake/clean fileutils newgem rubigen hoe].each { |f| require f }
require File.dirname(__FILE__) + '/lib/invoicing'
# Hoe calls Ruby with the "-w" set by default; unfortunately, ActiveRecord (at version 2.2.2
# at least) causes a lot of warnings internally, by no fault of our own, which clutters
# the o... |
github | ept/invoicing | https://github.com/ept/invoicing | lib/invoicing.rb | Ruby | mit | 201 | master | 612 | $:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
require 'active_record'
require 'invoicing/class_info' # load first because other modules depend on this
Dir.glob(File.join(File.dirname(__FILE__), 'invoicing/**/*.rb')).sort.each ... |
github | ept/invoicing | https://github.com/ept/invoicing | lib/invoicing/version.rb | Ruby | mit | 201 | master | 291 | module Invoicing
module Version
MAJOR = 0
MINOR = 2
BUILD = 1
def to_a
[MAJOR, MINOR, BUILD]
end
def to_s
to_a.join(".")
end
module_function :to_a
module_function :to_s
STRING = Version.to_s
end
VERSION = Version.to_s
end |
github | ept/invoicing | https://github.com/ept/invoicing | lib/invoicing/line_item.rb | Ruby | mit | 201 | master | 12,247 | module Invoicing
# = Line item objects
#
# A line item is a single charge on an invoice or credit note, for example representing the sale
# of one particular product. An invoice or credit note with a non-zero +total_amount+ must have at
# least one +LineItem+ object associated with it, and its +total_amount+ ... |
github | ept/invoicing | https://github.com/ept/invoicing | lib/invoicing/find_subclasses.rb | Ruby | mit | 201 | master | 10,550 | module Invoicing
# = Subclass-aware filtering by class methods
#
# Utility module which can be mixed into <tt>ActiveRecord::Base</tt> subclasses which use
# single table inheritance. It enables you to query the database for model objects based
# on static class properties without having to instantiate more mo... |
github | ept/invoicing | https://github.com/ept/invoicing | lib/invoicing/class_info.rb | Ruby | mit | 201 | master | 8,971 | module Invoicing
# This module is intended for use only internally within this framework. It implements
# a pattern needed in several other modules: an +acts_as_something_or_other+ method can
# be called within the scope of an +ActiveRecord+ class, given a number of arguments;
# including options which define h... |
github | ept/invoicing | https://github.com/ept/invoicing | lib/invoicing/taxable.rb | Ruby | mit | 201 | master | 20,597 | # encoding: utf-8
module Invoicing
# = Computation of tax on prices
#
# This module provides a general-purpose framework for calculating tax. Its most common application
# will probably be for computing VAT/sales tax on the price of your product, but since you can easily
# attach your own tax computation log... |
github | ept/invoicing | https://github.com/ept/invoicing | lib/invoicing/ledger_item.rb | Ruby | mit | 201 | master | 48,509 | module Invoicing
# = Ledger item objects
#
# This module implements a simple ledger, i.e. the record of all of the business transactions
# which are handled by your application. Each transaction is recorded as one +LedgerItem+ object,
# each of which may have one of the following three types:
#
# +Invoice... |
github | ept/invoicing | https://github.com/ept/invoicing | lib/invoicing/tax_rate.rb | Ruby | mit | 201 | master | 609 | module Invoicing
module TaxRate
module ActMethods
def acts_as_tax_rate(*args)
Invoicing::ClassInfo.acts_as(Invoicing::TaxRate, self, args)
info = tax_rate_class_info
if info.previous_info.nil? # Called for the first time?
# Import TimeDependent functionality
... |
github | ept/invoicing | https://github.com/ept/invoicing | lib/invoicing/cached_record.rb | Ruby | mit | 201 | master | 4,439 | module Invoicing
# == Aggressive ActiveRecord cache
#
# This module implements a cache of +ActiveRecord+ objects. It is suitable for database
# tables with a small number of rows (no more than a few dozen is recommended) which
# change very infrequently. The contents of the table is loaded into memory when th... |
github | ept/invoicing | https://github.com/ept/invoicing | lib/invoicing/connection_adapter_ext.rb | Ruby | mit | 201 | master | 2,177 | module Invoicing
# Extensions specific to certain database adapters. Currently only MySQL and PostgreSQL are
# supported.
class ConnectionAdapterExt
# Creates a database-specific SQL fragment for evaluating a three-legged conditional function
# in a query.
def self.conditional_function(condition, v... |
github | ept/invoicing | https://github.com/ept/invoicing | lib/invoicing/time_dependent.rb | Ruby | mit | 201 | master | 21,986 | module Invoicing
# == Time-dependent value objects
#
# This module implements the notion of a value (or a set of values) which may change at
# certain points in time, and for which it is important to have a full history of values
# for every point in time. It is used in the invoicing framework as basis for ta... |
github | ept/invoicing | https://github.com/ept/invoicing | lib/invoicing/currency_value.rb | Ruby | mit | 201 | master | 15,111 | module Invoicing
# = Input and output of monetary values
#
# This module simplifies model objects which need to store monetary values. It automatically takes care
# of currency rounding conventions and formatting values for output.
#
# == General notes on currency precision and rounding
#
# It is import... |
github | ept/invoicing | https://github.com/ept/invoicing | lib/invoicing/countries/uk.rb | Ruby | mit | 201 | master | 850 | module Invoicing
module Countries
module UK
# Extremely simplistic implementation of UK VAT. This needs to be fixed.
class VAT
def tax_rate(params)
params[:model_object].send(:tax_rate)
end
def tax_factor(params)
BigDecimal('1') + tax_rate(params).r... |
github | ept/invoicing | https://github.com/ept/invoicing | lib/invoicing/ledger_item/render_ubl.rb | Ruby | mit | 201 | master | 13,134 | require 'builder'
module Invoicing
module LedgerItem
# Included into ActiveRecord model object when +acts_as_ledger_item+ is invoked.
module RenderUBL
# Renders this invoice or credit note into a complete XML document conforming to the
# {OASIS Universal Business Language}[http://ubl.xml.o... |
github | ept/invoicing | https://github.com/ept/invoicing | lib/invoicing/ledger_item/render_html.rb | Ruby | mit | 201 | master | 20,162 | # encoding: utf-8
require 'builder'
module Invoicing
module LedgerItem
# Included into ActiveRecord model object when +acts_as_ledger_item+ is invoked.
module RenderHTML
# Shortcut for rendering an invoice or a credit note into a human-readable HTML format.
# Can be called without any arguments,... |
github | ept/invoicing | https://github.com/ept/invoicing | test/time_dependent_test.rb | Ruby | mit | 201 | master | 6,358 | require File.join(File.dirname(__FILE__), 'test_helper.rb')
class CachedRecordTest < Test::Unit::TestCase
class TimeDependentRecord < ActiveRecord::Base
# All columns are renamed to test renaming
set_primary_key 'id2'
acts_as_time_dependent :id => 'id2', :valid_from => 'valid_from2', :valid_until =>... |
github | ept/invoicing | https://github.com/ept/invoicing | test/cached_record_test.rb | Ruby | mit | 201 | master | 3,261 | require File.join(File.dirname(__FILE__), 'test_helper.rb')
class CachedRecordTest < Test::Unit::TestCase
class CachedRecord < ActiveRecord::Base
set_primary_key 'id2'
acts_as_cached_record :id => 'id2'
has_many :referrers, :class_name => 'RefersToCachedRecord', :foreign_key => 'cached_record_id'
... |
github | ept/invoicing | https://github.com/ept/invoicing | test/ledger_item_test.rb | Ruby | mit | 201 | master | 16,136 | # encoding: utf-8
require File.join(File.dirname(__FILE__), 'test_helper.rb')
####### Helper stuff
module LedgerItemMethods
RENAMED_METHODS = {
:id => :id2, :type => :type2, :sender_id => :sender_id2, :recipient_id => :recipient_id2,
:sender_details => :sender_details2, :recipient_details => :recipient_det... |
github | ept/invoicing | https://github.com/ept/invoicing | test/render_html_test.rb | Ruby | mit | 201 | master | 2,316 | # encoding: utf-8
require File.join(File.dirname(__FILE__), 'test_helper.rb')
class RenderHTMLTest < Test::Unit::TestCase
def reference_output(filename)
IO.readlines(File.join(File.dirname(__FILE__), 'ref-output', filename)).join
end
def test_render_default_html_invoice
assert_equal reference_output... |
github | ept/invoicing | https://github.com/ept/invoicing | test/connection_adapter_ext_test.rb | Ruby | mit | 201 | master | 2,691 | require File.join(File.dirname(__FILE__), 'test_helper.rb')
class ConnectionAdapterExtTest < Test::Unit::TestCase
# Don't run these tests in database transactions.
def setup
end
def teardown
end
def using_database(database_type)
if database_type.to_sym == database_used_for_testing
# If the te... |
github | ept/invoicing | https://github.com/ept/invoicing | test/taxable_test.rb | Ruby | mit | 201 | master | 6,029 | # encoding: utf-8
require File.join(File.dirname(__FILE__), 'test_helper.rb')
class TaxableTest < Test::Unit::TestCase
class SimpleTaxLogic
def apply_tax(params)
if params[:attribute].to_s == 'amount'
params[:value] * (BigDecimal('1.0') + params[:model_object].tax_factor)
else
par... |
github | ept/invoicing | https://github.com/ept/invoicing | test/setup.rb | Ruby | mit | 201 | master | 1,218 | # This file is silently executed before the entire test suite runs, when run by 'rake test'.
# To see its output, set the environment variable VERBOSE=1
require File.join(File.dirname(__FILE__), "test_helper.rb")
connection = ActiveRecord::Base.connection
Dir.glob(File.join(File.dirname(__FILE__), 'fixtures', '*.sql... |
github | ept/invoicing | https://github.com/ept/invoicing | test/find_subclasses_test.rb | Ruby | mit | 201 | master | 4,479 | require File.join(File.dirname(__FILE__), 'test_helper.rb')
# Associated with TestBaseclass
class FindSubclassesAssociate < ActiveRecord::Base
end
# Primary hierarchy of classes for testing.
class TestBaseclass < ActiveRecord::Base
set_table_name 'find_subclasses_records'
set_inheritance_column 'type_name' # u... |
github | ept/invoicing | https://github.com/ept/invoicing | test/currency_value_test.rb | Ruby | mit | 201 | master | 8,648 | # encoding: utf-8
require File.join(File.dirname(__FILE__), 'test_helper.rb')
# Test extending the default list of currency codes: include the Zimbabwe Dollar.
# This also tests rounding and seriously large numbers. -- Sorry, you shouldn't make
# jokes about this sort of thing. The people are suffering badly.
Invoici... |
github | ept/invoicing | https://github.com/ept/invoicing | test/render_ubl_test.rb | Ruby | mit | 201 | master | 1,404 | # encoding: utf-8
require File.join(File.dirname(__FILE__), 'test_helper.rb')
class RenderUBLTest < Test::Unit::TestCase
def reference_output(filename)
IO.readlines(File.join(File.dirname(__FILE__), 'ref-output', filename)).join
end
# Compares two strings, each being a serialised XML document, while ign... |
github | ept/invoicing | https://github.com/ept/invoicing | test/class_info_test.rb | Ruby | mit | 201 | master | 8,070 | require File.join(File.dirname(__FILE__), 'test_helper.rb')
# Mini implementation of the ClassInfo pattern, at which we can fire our tests
module MyNamespace
module ClassInfoTestModule
module ActMethods
def acts_as_class_info_test(*args)
Invoicing::ClassInfo.acts_as(MyNamespace::ClassInfoTestModul... |
github | ept/invoicing | https://github.com/ept/invoicing | test/line_item_test.rb | Ruby | mit | 201 | master | 3,715 | # encoding: utf-8
require File.join(File.dirname(__FILE__), 'test_helper.rb')
####### Helper stuff
module LineItemMethods
RENAMED_METHODS = {
:id => :id2, :type => :type2, :ledger_item_id => :ledger_item_id2,
:net_amount => :net_amount2, :tax_amount => :tax_amount2,
:description => :description2, :uuid... |
github | ept/invoicing | https://github.com/ept/invoicing | test/test_helper.rb | Ruby | mit | 201 | master | 2,209 | require 'test/unit'
require 'rubygems'
require 'active_record'
require 'active_support'
require 'flexmock/test_unit'
$: << File.join(File.dirname(__FILE__), '..', 'lib')
ActiveSupport::Dependencies.load_paths << File.join(File.dirname(__FILE__), 'models')
require 'invoicing'
# Overridden by ../../config/database.ym... |
github | ept/invoicing | https://github.com/ept/invoicing | test/models/test_subclass_not_in_database.rb | Ruby | mit | 201 | master | 335 | # Please do not require this file or the class name TestSubclassNotInDatabase
# anywhere. The whole point of it is that it is a subclass of TestBaseclass
# which exists, but is never loaded, because it isn't mentioned anywhere.
# FindSubclassesTest#test_known_subclasses tests this.
class TestSubclassNotInDatabase < Tes... |
github | KrauseFx/notes-exporter | https://github.com/KrauseFx/notes-exporter | export.rb | Ruby | mit | 201 | master | 1,889 | require "sqlite3"
require "reverse_markdown"
require "fileutils"
module NotesExporter
class Export
def run(path:, output_path:, include_tags:)
path = File.expand_path(path)
db = SQLite3::Database.new(path)
db.execute("select ZFOLDER, ZDATEEDITED, ZBODY, Z_PK from ZNOTE") do |row|
fold... |
github | akabiru/faker-bot | https://github.com/akabiru/faker-bot | Guardfile | Ruby | mit | 201 | main | 492 | # frozen_string_literal: true
# More info at https://github.com/guard/guard#readme
#
guard :rspec, cmd: 'bundle exec rspec' do
require 'guard/rspec/dsl'
dsl = Guard::RSpec::Dsl.new(self)
# Feel free to open issues for suggestions and improvements
# RSpec files
rspec = dsl.rspec
watch(rspec.spec_helper) {... |
github | akabiru/faker-bot | https://github.com/akabiru/faker-bot | faker-bot.gemspec | Ruby | mit | 201 | main | 1,427 | require_relative "lib/faker/bot/version"
Gem::Specification.new do |spec|
spec.name = "faker-bot"
spec.version = Faker::Bot::VERSION
spec.authors = ["Austin Kabiru"]
spec.email = ["makabby@gmail.com"]
spec.summary = %q{A faker-ruby/faker lookup command line tool.}
spec.d... |
github | akabiru/faker-bot | https://github.com/akabiru/faker-bot | spec/spec_helper.rb | Ruby | mit | 201 | main | 449 | # frozen_string_literal: true
require 'bundler/setup'
require 'pry'
require 'simplecov'
require 'faker-bot'
SimpleCov.start
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods global... |
github | akabiru/faker-bot | https://github.com/akabiru/faker-bot | spec/integration/list_spec.rb | Ruby | mit | 201 | main | 962 | # frozen_string_literal: true
RSpec.describe '`faker list` command', type: :cli do
it 'executes `faker help list` command successfully' do
output = `faker help list`
expected_output = <<~OUT
Usage:
faker list
Options:
-h, [--help], [--no-help], [--skip-help] # Display usage info... |
github | akabiru/faker-bot | https://github.com/akabiru/faker-bot | spec/integration/search_spec.rb | Ruby | mit | 201 | main | 1,127 | # frozen_string_literal: true
RSpec.describe '`faker search` command', type: :cli do
it 'executes `faker help search` command successfully' do
output = `faker help search`
expected_output = <<~OUT
Usage:
faker search [Faker]
Options:
-h, [--help], [--no-help], [--skip-help] # Di... |
github | akabiru/faker-bot | https://github.com/akabiru/faker-bot | spec/faker/bot/renderer_spec.rb | Ruby | mit | 201 | main | 4,487 | # frozen_string_literal: true
require 'spec_helper'
module MockFaker
class Foo
def self.bar
'bar'
end
end
end
RSpec.describe Faker::Bot::Renderer do
describe '#call' do
# FIXME: work out how to capture less
xcontext 'when paginable interface' do
before do
expect_any_instance... |
github | akabiru/faker-bot | https://github.com/akabiru/faker-bot | spec/faker/bot/reflectors/search_spec.rb | Ruby | mit | 201 | main | 1,323 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Faker::Bot::Reflectors::Search do
describe '#call' do
let(:result) { described_class.new(query).call }
context 'when passing a full method name' do
let(:query) { 'first_name' }
it 'it returns the list of matches' do
exp... |
github | akabiru/faker-bot | https://github.com/akabiru/faker-bot | spec/faker/bot/reflectors/list_spec.rb | Ruby | mit | 201 | main | 3,532 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Faker::Bot::Reflectors::List do
describe '#call' do
context 'when show methods is enabled' do
it 'returns all descendants and their methods' do
options = { show_methods: true }
reflector = described_class.new(options)
... |
github | akabiru/faker-bot | https://github.com/akabiru/faker-bot | spec/faker/bot/commands/search_spec.rb | Ruby | mit | 201 | main | 759 | # frozen_string_literal: true
require 'faker/bot/commands/search'
RSpec.describe Faker::Bot::Commands::Search do
context 'when query object exists' do
it 'returns results' do
output = StringIO.new
options = {}
command = described_class.new(options)
command.execute('image', output: outpu... |
github | akabiru/faker-bot | https://github.com/akabiru/faker-bot | spec/faker/bot/commands/list_spec.rb | Ruby | mit | 201 | main | 1,386 | # frozen_string_literal: true
require 'faker/bot/commands/list'
RSpec.describe Faker::Bot::Commands::List do
let(:output) { StringIO.new }
let(:options) { {} }
let(:command) { Faker::Bot::Commands::List.new(options) }
context 'when single `list` command' do
it 'executes successfully' do
command.exe... |
github | akabiru/faker-bot | https://github.com/akabiru/faker-bot | lib/faker/bot.rb | Ruby | mit | 201 | main | 1,744 | # frozen_string_literal: true
require 'thor'
require 'faker/bot/commands/list'
require 'faker/bot/commands/search'
require 'faker/bot/version'
module Faker
module Bot
class Base < Thor
Error = Class.new(StandardError)
desc 'version', 'Faker version'
def version
puts "v#{Faker::Bot::V... |
github | akabiru/faker-bot | https://github.com/akabiru/faker-bot | lib/faker/bot/reflector.rb | Ruby | mit | 201 | main | 2,256 | # frozen_string_literal: true
require 'faker'
module Faker
module Bot
# @abstract `Faker::Base` Reflection object
# * Introspects the `Faker::Base` class and it's descendants
#
# @api private
#
class Reflector
Faker::Base.class_eval do
# Skip default deprecation warning output;... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.