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 | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/config_spec.rb | Ruby | mit | 194 | main | 548 | require 'spec_helper'
RSpec.describe Chronicle::ETL::Config do
include_context 'mocked config directory'
# TODO: remove this after proper tests written for Config
it 'can set a custom homedir' do
data = {}
data[Time.now.to_i] = Time.now
Chronicle::ETL::Config.write('jobs', 'foo', data)
expect(Ch... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/configurable_spec.rb | Ruby | mit | 194 | main | 4,009 | require 'spec_helper'
RSpec.describe Chronicle::ETL::Configurable do
let(:basic) do
Class.new do
include Chronicle::ETL::Configurable
setting :foo
def initialize(options = {})
apply_options(options)
end
end
end
let(:inherited) do
Class.new(basic)
end
let(:inher... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/extractor_spec.rb | Ruby | mit | 194 | main | 256 | require 'spec_helper'
RSpec.describe Chronicle::ETL::Extractor do
describe '#extract' do
it 'raises an exception by default' do
e = Chronicle::ETL::Extractor.new
expect { e.extract }.to raise_error(NotImplementedError)
end
end
end |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/extractors/json_extractor_spec.rb | Ruby | mit | 194 | main | 1,001 | require 'spec_helper'
RSpec.describe Chronicle::ETL::JSONExtractor do
let(:json_filename) { 'spec/support/sample_data/sample.json' }
let(:jsonl_filename) { 'spec/support/sample_data/sample.jsonl' }
let(:invalid_filename) { 'spec/support/sample_data/test.csv' }
describe '#results_count' do
it 'can extract ... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/extractors/csv_extractor_spec.rb | Ruby | mit | 194 | main | 612 | require 'spec_helper'
RSpec.describe Chronicle::ETL::CSVExtractor do
let(:filename) { 'spec/support/sample_data/two-records.csv' }
describe '#results_count' do
it 'can extract from a CSV file' do
e = Chronicle::ETL::CSVExtractor.new(input: filename)
e.prepare
expect(e.results_count).to eql(2... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/extractors/file_extractor_spec.rb | Ruby | mit | 194 | main | 1,363 | require 'spec_helper'
RSpec.describe Chronicle::ETL::FileExtractor do
let(:filename) { 'spec/support/sample_data/two-records.csv' }
let(:directory) { 'spec/support/sample_data/directories/simple' }
context 'for a simple directory' do
describe '#results_count' do
it 'can extract from a CSV file' do
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/registry/self_registering_spec.rb | Ruby | mit | 194 | main | 531 | require 'spec_helper'
RSpec.describe Chronicle::ETL::CLI::Connectors do
describe '#register_connector' do
it 'can register a new class' do
expect do
class TestExtractor < Chronicle::ETL::Extractor
register_connector do |r|
r.description = 'foobar'
end
end
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/transformers.rb/null_transformer_spec.rb | Ruby | mit | 194 | main | 335 | require 'spec_helper'
RSpec.describe Chronicle::ETL::NullTransformer do
let(:record) { Chronicle::ETL::Record.new(data: { foo: 'bar' }) }
describe '#transform' do
it 'does nothing' do
Chronicle::ETL::NullTransformer.new.transform(record) do |result|
expect(result).to eq(foo: 'bar')
end
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/cli/main_spec.rb | Ruby | mit | 194 | main | 592 | require 'spec_helper'
RSpec.describe Chronicle::ETL::CLI::Main do
describe '#version' do
it 'outputs correct version' do
output, = invoke_cli(['version'])
expect(output).to match("chronicle-etl #{Chronicle::ETL::VERSION}")
end
it 'can be shown by calling cli with `--version`' do
output... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/cli/authorizations_spec.rb | Ruby | mit | 194 | main | 2,813 | require 'spec_helper'
RSpec.describe Chronicle::ETL::CLI::Authorizations do
describe '#new' do
context 'with an available plugin' do
before do
%w[foo empty error].each do |plugin|
path = File.expand_path(File.join(RSPEC_ROOT, "support/mock_plugins/chronicle-#{plugin}"))
$LOAD_PA... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/cli/connectors_spec.rb | Ruby | mit | 194 | main | 2,116 | require 'spec_helper'
RSpec.describe Chronicle::ETL::CLI::Connectors do
describe '#list' do
it 'lists installed connectors' do
expected_klasses = Chronicle::ETL::Registry::Connectors.connectors.map(&:klass_name)
stdout, = invoke_cli(%w[connectors:list])
outputted_klasses = stdout
.spli... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/cli/plugins_spec.rb | Ruby | mit | 194 | main | 832 | require 'spec_helper'
RSpec.describe Chronicle::ETL::CLI::Plugins do
describe '#list' do
it 'shows installed plugins' do
VCR.use_cassette('plugins-on-rubygems') do
stdout, = invoke_cli(%w[plugins:list])
expect(stdout.split("\n").first).to match(/Available plugins/)
end
end
end
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/cli/secrets_spec.rb | Ruby | mit | 194 | main | 1,311 | require 'spec_helper'
RSpec.describe Chronicle::ETL::CLI::Secrets do
include_context 'mocked config directory'
describe 'chronicle-etl secrets:list' do
it 'can list available secrets' do
args = ['secrets:list']
output, = invoke_cli(args)
all_secrets = Chronicle::ETL::Secrets.all.values.map(... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/cli/jobs_spec.rb | Ruby | mit | 194 | main | 2,197 | require 'spec_helper'
RSpec.describe Chronicle::ETL::CLI::Jobs do
let(:csv_filename) { 'spec/support/sample_data/test.csv' }
let(:csv_job_args) do
%w[
--extractor csv
--log-level fatal
--extractor-opts
] << "input:#{csv_filename}"
end
describe 'chronicle-etl jobs:run' do
it 'run ... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/loaders/json_loader_spec.rb | Ruby | mit | 194 | main | 954 | require 'spec_helper'
require 'fakefs/safe'
RSpec.describe Chronicle::ETL::JSONLoader do
let(:record) do
{ foo: 'bar' }
end
context 'when using stdout as destination' do
it 'can output JSON from a Raw model' do
l = Chronicle::ETL::JSONLoader.new
output, = capture do
l.start
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/loaders/table_loader_spec.rb | Ruby | mit | 194 | main | 449 | require 'spec_helper'
RSpec.describe Chronicle::ETL::TableLoader do
let(:record) do
{
provider: 'foo',
verb: 'tested',
actor: {
represent: 'identity',
provider: 'bar'
}
}
end
it 'can output a table' do
l = Chronicle::ETL::TableLoader.new
l.load(record)
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | spec/chronicle/etl/loaders/csv_loader_spec.rb | Ruby | mit | 194 | main | 902 | require 'spec_helper'
require 'csv'
RSpec.describe Chronicle::ETL::CSVLoader do
# TODO: consolidate this with other specs
let(:record) do
{
provider: 'foo',
verb: 'tested',
actor: {
represent: 'identity',
provider: 'bar'
}
}
end
context 'when destination is stdo... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl.rb | Ruby | mit | 194 | main | 869 | # frozen_string_literal: true
require 'chronicle/schema'
require 'chronicle/models/base'
require_relative 'etl/registry/registry'
require_relative 'etl/authorizer'
require_relative 'etl/config'
require_relative 'etl/configurable'
require_relative 'etl/exceptions'
require_relative 'etl/extraction'
require_relative 'et... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/job_log.rb | Ruby | mit | 194 | main | 2,577 | require 'forwardable'
module Chronicle
module ETL
# A record of what happened in the running of a job. We're interested in
# tracking when it ran, if it was successful, and what the latest record
# we found is (to use as a cursor for the next time)
class JobLog
extend Forwardable
attr_ac... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/config.rb | Ruby | mit | 194 | main | 2,533 | require 'active_support/core_ext/hash/keys'
require 'fileutils'
require 'yaml'
module Chronicle
module ETL
# Utility methods to read, write, and access config files
module Config
extend self
attr_accessor :xdg_environment
def load(type, identifier)
base = config_pathname_for_type(... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/exceptions.rb | Ruby | mit | 194 | main | 1,452 | module Chronicle
module ETL
class Error < StandardError; end
class SecretsError < Error; end
class AuthorizationError < Error; end
class ConfigError < Error; end
class RunnerError < Error; end
class RunInterruptedError < RunnerError; end
class RunnerTypeError < Error; end
class J... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/extraction.rb | Ruby | mit | 194 | main | 507 | # frozen_string_literal: true
module Chronicle
module ETL
class Extraction
attr_accessor :data, :meta, :source, :type, :strategy, :extractor
def initialize(data: {}, meta: {}, source: nil, type: nil, strategy: nil, extractor: nil)
@data = data
@meta = meta
@source = source
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/job.rb | Ruby | mit | 194 | main | 2,597 | # frozen_string_literal: true
require 'forwardable'
module Chronicle
module ETL
# A runner job
#
# TODO: this can probably be merged with JobDefinition. Not clear
# where the boundaries are
class Job
extend Forwardable
def_delegators :@job_definition, :dry_run?
attr_accessor ... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/job_logger.rb | Ruby | mit | 194 | main | 2,031 | require 'forwardable'
require 'sequel'
require 'xdg'
module Chronicle
module ETL
# Saves JobLogs to db and loads previous ones
class JobLogger
extend Forwardable
def_delegators :@job_log, :start, :finish, :error, :log_transformation, :duration, :success
attr_accessor :job_log
# For ... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/record.rb | Ruby | mit | 194 | main | 341 | # frozen_string_literal: true
# TODO: move this into chronicle-core after figuring out what to do about data vs properties
module Chronicle
module ETL
class Record
attr_accessor :data, :extraction
def initialize(data: {}, extraction: nil)
@data = data
@extraction = extraction
e... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/secrets.rb | Ruby | mit | 194 | main | 2,038 | require 'active_support/core_ext/hash/keys'
module Chronicle
module ETL
# Secret management module
module Secrets
module_function
# Whether a given namespace exists
def exists?(namespace)
Chronicle::ETL::Config.exists?('secrets', namespace)
end
# Save a setting to a na... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/authorization_server.rb | Ruby | mit | 194 | main | 1,417 | require 'sinatra'
require 'omniauth'
module Chronicle
module ETL
class AuthorizationServer < Sinatra::Base
class << self
attr_accessor :latest_authorization
end
configure do
set :inline_templates, true
set :dump_errors, false
set :raise_errors, true
disa... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/logger.rb | Ruby | mit | 194 | main | 838 | module Chronicle
module ETL
module Logger
extend self
DEBUG = 0
INFO = 1
WARN = 2
ERROR = 3
FATAL = 4
SILENT = 5
attr_accessor :log_level
@log_level = INFO
def output(message, level)
return unless level >= @log_level
if @ui_element
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/runner.rb | Ruby | mit | 194 | main | 5,244 | # frozen_string_literal: true
require 'colorize'
require 'chronic_duration'
require 'tty-spinner'
module Chronicle
module ETL
class Runner
def initialize(job)
@job = job
@job_logger = Chronicle::ETL::JobLogger.new(@job)
end
def run!
begin_job
validate_job
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/job_definition.rb | Ruby | mit | 194 | main | 4,190 | # frozen_string_literal: true
require 'active_support/core_ext/hash/deep_merge'
module Chronicle
module ETL
class JobDefinition
SKELETON_DEFINITION = {
incremental: false,
extractor: {
name: 'stdin',
options: {}
},
transformers: [
{
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/cli.rb | Ruby | mit | 194 | main | 366 | require 'thor'
require 'thor/hollaback'
require 'chronicle/etl'
require 'chronicle/etl/cli/cli_base'
require 'chronicle/etl/cli/subcommand_base'
require 'chronicle/etl/cli/authorizations'
require 'chronicle/etl/cli/connectors'
require 'chronicle/etl/cli/jobs'
require 'chronicle/etl/cli/plugins'
require 'chronicle/etl/... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/configurable.rb | Ruby | mit | 194 | main | 5,590 | # frozen_string_literal: true
require 'ostruct'
require 'chronic_duration'
module Chronicle
module ETL
# A mixin that gives a class
# a {Chronicle::ETL::Configurable::ClassMethods#setting} macro to define
# settings and their properties (require, type, etc)
#
# @example Basic usage
# class... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/oauth_authorizer.rb | Ruby | mit | 194 | main | 4,333 | require 'omniauth'
require 'tty-spinner'
module Chronicle
module ETL
# An authorization strategy that uses oauth2 (and omniauth under the hood)
class OauthAuthorizer < Authorizer
class << self
attr_reader :strategy, :provider_name, :authorization_to_secret_map
attr_accessor :client_id, ... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/authorizer.rb | Ruby | mit | 194 | main | 1,024 | module Chronicle
module ETL
# An authorization strategy for a third-party data source
class Authorizer
class << self
attr_reader :provider_name
# Macro for setting provider on an Authorizer
def provider(provider_name)
@provider_name = provider_name.to_sym
end
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/registry/self_registering.rb | Ruby | mit | 194 | main | 795 | require 'forwardable'
module Chronicle
module ETL
module Registry
# Gives a connector class the ability to let the Chronicle::ETL::Registry
# know about itself
module SelfRegistering
extend Forwardable
attr_accessor :connector_registration
def_delegators :@connector_re... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/registry/connectors.rb | Ruby | mit | 194 | main | 4,273 | # frozen_string_literal: true
require 'rubygems'
module Chronicle
module ETL
module Registry
# A singleton class that acts as a registry of connector classes available for ETL jobs
module Connectors
PHASES = %i[extractor transformer loader].freeze
public_constant :PHASES
cla... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/registry/connector_registration.rb | Ruby | mit | 194 | main | 1,541 | # frozen_string_literal: true
module Chronicle
module ETL
module Registry
# Records details about a connector such as its source provider and a description
class ConnectorRegistration
attr_accessor :klass, :identifier, :source, :strategy, :type, :description, :from_schema, :to_schema
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/registry/plugin_registration.rb | Ruby | mit | 194 | main | 392 | module Chronicle
module ETL
module Registry
class PluginRegistration
attr_accessor :name, :description, :gem, :version, :installed, :gemspec
def initialize(name = nil)
@installed = false
@name = name
yield self if block_given?
end
def installed... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/registry/registry.rb | Ruby | mit | 194 | main | 243 | module Chronicle
module ETL
module Registry
end
end
end
require_relative 'self_registering'
require_relative 'connector_registration'
require_relative 'connectors'
require_relative 'plugin_registration'
require_relative 'plugins' |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/registry/plugins.rb | Ruby | mit | 194 | main | 5,863 | # frozen_string_literal: true
require 'rubygems'
require 'rubygems/command'
require 'rubygems/commands/install_command'
require 'rubygems/uninstaller'
require 'gems'
require 'active_support/core_ext/hash/deep_merge'
module Chronicle
module ETL
module Registry
# Responsible for managing plugins available t... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/cli/cli_base.rb | Ruby | mit | 194 | main | 1,201 | module Chronicle
module ETL
module CLI
# Base class for CLI commands
class CLIBase < ::Thor
no_commands do
# Shorthand for cli_exit(status: :failure)
def cli_fail(message: nil, exception: nil)
if exception && Chronicle::ETL::Logger.log_level > Chronicle::ETL::Lo... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/cli/secrets.rb | Ruby | mit | 194 | main | 2,215 | # frozen_string_literal: true
require 'tty-prompt'
module Chronicle
module ETL
module CLI
# CLI commands for working with ETL plugins
class Secrets < SubcommandBase
default_task 'list'
namespace :secrets
desc 'set NAMESPACE KEY [VALUE]', 'Add a secret. VALUE can be set as ar... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/cli/plugins.rb | Ruby | mit | 194 | main | 2,532 | # frozen_string_literal: true
require 'tty-prompt'
require 'tty-spinner'
module Chronicle
module ETL
module CLI
# CLI commands for working with ETL plugins
class Plugins < SubcommandBase
default_task 'list'
namespace :plugins
desc 'install', 'Install a plugin'
def in... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/cli/main.rb | Ruby | mit | 194 | main | 5,448 | require 'colorize'
module Chronicle
module ETL
module CLI
# Main entrypoint for CLI app
class Main < Chronicle::ETL::CLI::CLIBase
class_before :set_log_level
class_before :set_color_output
class_option :log_level, desc: 'Log level (debug, info, warn, error, fatal, silent)', d... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/cli/subcommand_base.rb | Ruby | mit | 194 | main | 1,354 | module Chronicle
module ETL
module CLI
# Base class for CLI subcommands. Overrides Thor methods so we can use command:subcommand syntax
class SubcommandBase < Chronicle::ETL::CLI::CLIBase
# Print usage instructions for a subcommand
def self.help(shell, subcommand = false)
lis... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/cli/authorizations.rb | Ruby | mit | 194 | main | 2,691 | # frozen_string_literal: true
require 'sinatra'
require 'launchy'
module Chronicle
module ETL
module CLI
# CLI commands for authorizing chronicle-etl with third-party services
class Authorizations < SubcommandBase
default_task 'new'
namespace :authorizations
desc 'authorize'... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/cli/connectors.rb | Ruby | mit | 194 | main | 2,544 | # frozen_string_literal: true
module Chronicle
module ETL
module CLI
# CLI commands for working with ETL connectors
#
# @todo make this work with new plugin system (i.e. no loading of all plugins)
class Connectors < SubcommandBase
default_task 'list'
namespace :connectors
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/cli/jobs.rb | Ruby | mit | 194 | main | 12,401 | # frozen_string_literal: true
require 'tty-prompt'
module Chronicle
module ETL
module CLI
# CLI commands for working with ETL jobs
class Jobs < SubcommandBase
default_task 'start'
namespace :jobs
class_option :extractor, aliases: '-e', desc: 'Extractor class. Default: stdin'... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/loaders/table_loader.rb | Ruby | mit | 194 | main | 2,072 | # frozen_string_literal: true
require 'tty/table'
require 'chronicle/utils/hash_utils'
require 'active_support/core_ext/string/filters'
require 'active_support/core_ext/hash/reverse_merge'
module Chronicle
module ETL
class TableLoader < Chronicle::ETL::Loader
register_connector do |r|
r.identifie... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/loaders/loader.rb | Ruby | mit | 194 | main | 1,097 | require_relative 'helpers/encoding_helper'
require_relative 'helpers/stdout_helper'
module Chronicle
module ETL
# Abstract class representing a Loader for an ETL job
class Loader
extend Chronicle::ETL::Registry::SelfRegistering
include Chronicle::ETL::Configurable
include Chronicle::ETL::Lo... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/loaders/json_loader.rb | Ruby | mit | 194 | main | 2,641 | # frozen_string_literal: true
require 'tempfile'
module Chronicle
module ETL
class JSONLoader < Chronicle::ETL::Loader
include Chronicle::ETL::Loaders::Helpers::StdoutHelper
register_connector do |r|
r.identifier = :json
r.description = 'json'
end
setting :output
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/loaders/rest_loader.rb | Ruby | mit | 194 | main | 932 | # frozen_string_literal: true
require 'net/http'
require 'uri'
require 'json'
require 'chronicle/serialization'
module Chronicle
module ETL
class RestLoader < Chronicle::ETL::Loader
register_connector do |r|
r.identifier = :rest
r.description = 'a REST endpoint'
end
setting :h... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/loaders/csv_loader.rb | Ruby | mit | 194 | main | 1,568 | # frozen_string_literal: true
require 'csv'
require 'chronicle/utils/hash_utils'
module Chronicle
module ETL
class CSVLoader < Chronicle::ETL::Loader
include Chronicle::ETL::Loaders::Helpers::StdoutHelper
register_connector do |r|
r.identifier = :csv
r.description = 'CSV'
end
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/loaders/helpers/encoding_helper.rb | Ruby | mit | 194 | main | 428 | require 'pathname'
module Chronicle
module ETL
module Loaders
module Helpers
module EncodingHelper
# Mostly useful for handling loading with binary data from a raw extraction
def force_utf8(value)
return value unless value.is_a?(String)
value.encode('UTF... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/loaders/helpers/stdout_helper.rb | Ruby | mit | 194 | main | 997 | # frozen_string_literal: true
require 'tempfile'
module Chronicle
module ETL
module Loaders
module Helpers
module StdoutHelper
# TODO: have option to immediately output to stdout
# TODO: let users use "stdout" as an option for the `output` setting
# Assume we're usin... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/utils/progress_bar.rb | Ruby | mit | 194 | main | 1,884 | require 'tty/progressbar'
require 'colorize'
module Chronicle
module ETL
module Utils
class ProgressBar
FORMAT_WITH_TOTAL = [
':bar ',
':percent'.light_white,
' | '.light_black,
':current'.light_white,
'/'.light_black,
':total'.light_white... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/utils/binary_attachments.rb | Ruby | mit | 194 | main | 508 | require 'marcel'
require 'base64'
module Chronicle
module ETL
module Utils
# Utility methods for dealing with binary files
module BinaryAttachments
def self.filename_to_base64(filename:, mimetype: nil)
mimetype ||= guess_mimetype(filename: filename)
"data:#{mimetype};base... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/transformers/format_transformer.rb | Ruby | mit | 194 | main | 737 | # frozen_string_literal: true
module Chronicle
module ETL
class FormatTransformer < Chronicle::ETL::Transformer
register_connector do |r|
r.identifier = :format
r.description = 'records to a differnet hash/json format'
end
setting :format, default: nil
def transform(reco... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/transformers/filter_transformer.rb | Ruby | mit | 194 | main | 732 | # frozen_string_literal: true
module Chronicle
module ETL
# Return only records that match all the conditions of the filters
# setting.
class FilterTransformer < Chronicle::ETL::Transformer
register_connector do |r|
r.identifier = :filter
r.description = 'by only accepting records t... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/transformers/multiply_transformer.rb | Ruby | mit | 194 | main | 493 | # frozen_string_literal: true
module Chronicle
module ETL
class MultiplyTransformer < Chronicle::ETL::Transformer
register_connector do |r|
r.identifier = :multiply
r.description = 'by taking a sample'
end
setting :n, default: 2, type: :numeric
# return the result, sampl... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/transformers/chronobase_transformer.rb | Ruby | mit | 194 | main | 2,522 | # frozen_string_literal: true
module Chronicle
module ETL
class ChronobaseTransformer < Chronicle::ETL::Transformer
PROPERTY_MAP = {
source: :provider,
source_id: :provider_id,
url: :provider_url,
end_time: :end_at,
start_time: :start_at,
name: :title,
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/transformers/sort_transformer.rb | Ruby | mit | 194 | main | 735 | # frozen_string_literal: true
module Chronicle
module ETL
class SortTransformer < Chronicle::ETL::Transformer
register_connector do |r|
r.identifier = :sort
r.description = 'sorts records by a given field'
end
setting :key, required: true, default: 'id'
setting :direction... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/transformers/buffer_transformer.rb | Ruby | mit | 194 | main | 731 | # frozen_string_literal: true
module Chronicle
module ETL
class BufferTransformer < Chronicle::ETL::Transformer
register_connector do |r|
r.identifier = :buffer
r.description = 'by buffering'
end
setting :size, default: 10, description: 'The size of the buffer'
def trans... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/transformers/sampler_transformer.rb | Ruby | mit | 194 | main | 495 | # frozen_string_literal: true
module Chronicle
module ETL
class SamplerTransformer < Chronicle::ETL::Transformer
register_connector do |r|
r.identifier = :sampler
r.description = 'by taking a sample'
end
setting :percent, default: 10, type: :numeric
# return the result, ... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/transformers/chronicle_transformer.rb | Ruby | mit | 194 | main | 820 | # frozen_string_literal: true
module Chronicle
module ETL
class ChronicleTransformer < Chronicle::ETL::Transformer
register_connector do |r|
r.identifier = :chronicle
r.description = 'records to Chronicle schema'
end
def transform(record)
converter_klass = find_converte... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/transformers/merge_meta_transformer.rb | Ruby | mit | 194 | main | 452 | # frozen_string_literal: true
module Chronicle
module ETL
class MergeMetaTransformer < Chronicle::ETL::Transformer
register_connector do |r|
r.identifier = :merge_meta
r.description = 'merge extraction meta fields into the record'
end
def transform(record)
record.data u... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/transformers/null_transformer.rb | Ruby | mit | 194 | main | 307 | # frozen_string_literal: true
module Chronicle
module ETL
class NullTransformer < Chronicle::ETL::Transformer
register_connector do |r|
r.identifier = :null
r.description = 'in no way'
end
def transform(record)
yield record.data
end
end
end
end |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/transformers/filter_fields_transformer.rb | Ruby | mit | 194 | main | 1,700 | # frozen_string_literal: true
module Chronicle
module ETL
# A transformer that filters the fields of a record and returns a new hash with only the specified fields.
class FilterFieldsTransformer < Chronicle::ETL::Transformer
register_connector do |r|
r.identifier = :filter_fields
r.desc... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/transformers/fields_limit_transformer.rb | Ruby | mit | 194 | main | 666 | # frozen_string_literal: true
require 'chronicle/utils/hash_utils'
module Chronicle
module ETL
# A transformer that filters the fields of a record and returns a new hash with only the specified fields.
class FieldsLimitTransformer < Chronicle::ETL::Transformer
register_connector do |r|
r.ident... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/transformers/transformer.rb | Ruby | mit | 194 | main | 2,528 | # frozen_string_literal: true
module Chronicle
module ETL
# Abstract class representing an Transformer for an ETL job
class Transformer
extend Chronicle::ETL::Registry::SelfRegistering
include Chronicle::ETL::Configurable
attr_reader :stashed_records
# Construct a new instance of th... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/extractors/stdin_extractor.rb | Ruby | mit | 194 | main | 414 | # frozen_string_literal: true
module Chronicle
module ETL
class StdinExtractor < Chronicle::ETL::Extractor
register_connector do |r|
r.identifier = :stdin
r.description = 'stdin'
end
def extract
$stdin.read.each_line do |line|
data = { line: line.strip }
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/extractors/file_extractor.rb | Ruby | mit | 194 | main | 1,682 | # frozen_string_literal: true
require 'pathname'
module Chronicle
module ETL
# Return filenames that match a pattern in a directory
class FileExtractor < Chronicle::ETL::Extractor
register_connector do |r|
r.identifier = :file
r.description = 'file or directory of files'
end
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/extractors/json_extractor.rb | Ruby | mit | 194 | main | 1,203 | # frozen_string_literal: true
module Chronicle
module ETL
class JSONExtractor < Chronicle::ETL::Extractor
include Extractors::Helpers::InputReader
register_connector do |r|
r.identifier = :json
r.description = 'JSON'
end
setting :jsonl, default: true, type: :boolean
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/extractors/extractor.rb | Ruby | mit | 194 | main | 2,069 | # frozen_string_literal: true
require 'chronicle/etl'
module Chronicle
module ETL
# Abstract class representing an Extractor for an ETL job
class Extractor
extend Chronicle::ETL::Registry::SelfRegistering
include Chronicle::ETL::Configurable
setting :since, type: :time
setting :unti... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/extractors/csv_extractor.rb | Ruby | mit | 194 | main | 1,237 | # frozen_string_literal: true
require 'csv'
module Chronicle
module ETL
class CSVExtractor < Chronicle::ETL::Extractor
include Extractors::Helpers::InputReader
register_connector do |r|
r.identifier = :csv
r.description = 'CSV'
end
setting :headers, default: true
... |
github | chronicle-app/chronicle-etl | https://github.com/chronicle-app/chronicle-etl | lib/chronicle/etl/extractors/helpers/input_reader.rb | Ruby | mit | 194 | main | 2,020 | require 'pathname'
module Chronicle
module ETL
module Extractors
module Helpers
module InputReader
# Return an array of input filenames; converts a single string
# to an array if necessary
def filenames
[@config.input].flatten.map
end
#... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | Rakefile | Ruby | mit | 193 | main | 233 | # frozen_string_literal: true
require "bundler/setup"
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
require "rubocop/rake_task"
RuboCop::RakeTask.new
task default: [:spec, :rubocop] |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | rabarber.gemspec | Ruby | mit | 193 | main | 1,260 | # frozen_string_literal: true
require_relative "lib/rabarber/version"
Gem::Specification.new do |spec|
spec.name = "rabarber"
spec.version = Rabarber::VERSION
spec.authors = ["enjaku4", "trafium"]
spec.email = ["contact@brownbox.dev"]
spec.homepage = "https://github.com/enjaku4/rabarber"
spec.metadata["ho... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | Gemfile | Ruby | mit | 193 | main | 451 | # frozen_string_literal: true
source "https://rubygems.org"
gemspec
rails_version = ENV.fetch("RAILS_VERSION", "~> 7.2")
gem "byebug"
gem "database_cleaner-active_record"
gem "rails", rails_version
gem "rake"
gem "rspec"
gem "rspec-rails"
gem "rubocop"
gem "rubocop-md"
gem "rubocop-packaging"
gem "rubocop-performan... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/spec_helper.rb | Ruby | mit | 193 | main | 1,366 | # frozen_string_literal: true
require "byebug"
require "rabarber"
require "database_cleaner/active_record"
require "action_controller/railtie"
require "rspec/rails"
RSpec.configure do |config|
config.example_status_persistence_file_path = ".rspec_status"
config.expose_dsl_globally = true
config.mock_with :rsp... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber_spec.rb | Ruby | mit | 193 | main | 3,850 | # frozen_string_literal: true
RSpec.describe Rabarber do
let(:config) { Rabarber::Configuration }
it "has a version number" do
expect(Rabarber::VERSION).not_to be_nil
end
describe ".configure" do
context "when not configured" do
it "has default configurations" do
expect(config.cache_ena... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/railtie_spec.rb | Ruby | mit | 193 | main | 5,770 | # frozen_string_literal: true
RSpec.describe Rabarber::Railtie do
describe ".server_running?" do
context "when Rails::Server is defined" do
before do
stub_const("Rails::Server", Class.new)
end
it "returns true" do
expect(described_class.server_running?).to be true
end
... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/models/role_spec.rb | Ruby | mit | 193 | main | 15,806 | # frozen_string_literal: true
RSpec.describe Rabarber::Role do
describe ".list" do
subject { described_class.list(context:) }
let(:context) { nil }
context "when there are no roles" do
it { is_expected.to eq([]) }
end
context "when there are some roles" do
let(:role_names) { [:admi... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/models/concerns/roleable_spec.rb | Ruby | mit | 193 | main | 17,544 | # frozen_string_literal: true
RSpec.describe Rabarber::Roleable do
describe "can be included only once" do
it "raises an error when included twice" do
expect { Client.include(described_class) }
.to raise_error(Rabarber::Error, "#{described_class} can only be included once")
end
end
shared_... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/controllers/shared_examples.rb | Ruby | mit | 193 | main | 975 | # frozen_string_literal: true
shared_examples_for "it allows access" do |hash|
it "allows access" do
send(hash.keys.first, hash.values.first, params: hash[:params])
expect(response).to have_http_status(:success)
end
end
shared_examples_for "it does not allow access" do |hash|
it "does not allow access" ... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/controllers/dummy_child_controller_spec.rb | Ruby | mit | 193 | main | 1,198 | # frozen_string_literal: true
require_relative "shared_examples"
RSpec.describe DummyChildController, type: :controller do
let(:user) { User.create! }
before { allow(controller).to receive(:current_user).and_return(user) }
describe "when a controller rule is applied to the parent" do
context "when the use... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/controllers/dummy_controller_spec.rb | Ruby | mit | 193 | main | 4,788 | # frozen_string_literal: true
require_relative "shared_examples"
RSpec.describe DummyController, type: :controller do
let(:user) { User.create! }
before { allow(controller).to receive(:current_user).and_return(user) }
describe "when multiple roles are allowed" do
context "when one user's role allows acces... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/controllers/context_controller_spec.rb | Ruby | mit | 193 | main | 2,007 | # frozen_string_literal: true
require_relative "shared_examples"
RSpec.describe ContextController, type: :controller do
let(:user) { User.create! }
before { allow(controller).to receive(:current_user).and_return(user) }
describe "when context is global" do
context "when the user's role allows access" do
... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/controllers/no_rules_controller_spec.rb | Ruby | mit | 193 | main | 512 | # frozen_string_literal: true
require_relative "shared_examples"
RSpec.describe NoRulesController, type: :controller do
let(:user) { User.create! }
before { allow(controller).to receive(:current_user).and_return(user) }
context "when the user has a role" do
before { user.assign_roles(:admin) }
it_beh... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/controllers/api_controller_spec.rb | Ruby | mit | 193 | main | 630 | # frozen_string_literal: true
require_relative "shared_examples"
RSpec.describe ApiController, type: :controller do
let(:user) { User.create! }
before { allow(controller).to receive(:current_user).and_return(user) }
describe "it works with ActionController::API" do
context "when the user's role allows acc... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/controllers/dummy_parent_controller_spec.rb | Ruby | mit | 193 | main | 928 | # frozen_string_literal: true
require_relative "shared_examples"
RSpec.describe DummyParentController, type: :controller do
let(:user) { User.create! }
before { allow(controller).to receive(:current_user).and_return(user) }
describe "when a controller rule is applied" do
context "when the user's role allo... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/controllers/no_user_controller_spec.rb | Ruby | mit | 193 | main | 582 | # frozen_string_literal: true
require_relative "shared_examples"
RSpec.describe NoUserController, type: :controller do
before { allow(controller).to receive(:current_user).and_return(nil) }
describe "when a role is allowed" do
it_behaves_like "it raises an error on nil current_user", put: :access_with_roles
... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/controllers/all_access_controller_spec.rb | Ruby | mit | 193 | main | 539 | # frozen_string_literal: true
require_relative "shared_examples"
RSpec.describe AllAccessController, type: :controller do
let(:user) { User.create! }
before { allow(controller).to receive(:current_user).and_return(user) }
describe "when everyone is allowed" do
context "when the user has a role" do
b... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/controllers/multiple_rules_controller_spec.rb | Ruby | mit | 193 | main | 972 | # frozen_string_literal: true
require_relative "shared_examples"
RSpec.describe MultipleRulesController, type: :controller do
let(:user) { User.create! }
before { allow(controller).to receive(:current_user).and_return(user) }
describe "when multitple controller rules are applied" do
context "when one of t... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/controllers/skip_authorization_controller_spec.rb | Ruby | mit | 193 | main | 604 | # frozen_string_literal: true
require_relative "shared_examples"
describe SkipAuthorizationController, type: :controller do
let(:user) { User.create! }
before { allow(controller).to receive(:current_user).and_return(user) }
describe "when action is skipped and no rules are applied" do
it_behaves_like "it ... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/controllers/concerns/authorization_spec.rb | Ruby | mit | 193 | main | 3,459 | # frozen_string_literal: true
RSpec.describe Rabarber::Authorization do
describe ".with_authorization" do
it "passes the options to before_action" do
expect(DummyAuthController).to receive(:before_action).with(:with_authorization, only: [:index, :show], if: :foo?)
DummyAuthController.with_authorizati... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/inputs/model_spec.rb | Ruby | mit | 193 | main | 922 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Rabarber::Inputs::Model do
describe "#process" do
subject { described_class.new(value, error: Rabarber::Error, message: "Error").process }
context "when the given value is valid" do
["User", "Project"].each do |valid_value|
co... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/inputs/context_spec.rb | Ruby | mit | 193 | main | 1,689 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Rabarber::Inputs::Context do
describe "#resolve" do
subject { described_class.new(context, error: Rabarber::InvalidArgumentError, message: "Error").resolve }
context "when the given context is valid" do
context "when a class is given"... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/inputs/roles_spec.rb | Ruby | mit | 193 | main | 1,135 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Rabarber::Inputs::Roles do
describe "#process" do
subject { described_class.new(roles, error: Rabarber::InvalidArgumentError, message: "Error").process }
context "when the given roles are valid" do
context "when an array of roles is g... |
github | enjaku4/rabarber | https://github.com/enjaku4/rabarber | spec/rabarber/inputs/non_empty_string_spec.rb | Ruby | mit | 193 | main | 887 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Rabarber::Inputs::NonEmptyString do
describe "#process" do
subject { described_class.new(value, error: Rabarber::Error, message: "Error").process }
context "when the given value is valid" do
["foo", "bar", "0", "test123"].each do |val... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.