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 | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/list.rb | Ruby | bsd-2-clause | 91 | master | 1,475 | module Mollie
class List < Base
include Enumerable
attr_accessor :klass, :items, :_links
alias links _links
def initialize(list_attributes, klass)
@klass = klass
list_attributes['items'] ||= if list_attributes['_embedded']
list_attributes['_embedded'... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/payment.rb | Ruby | bsd-2-clause | 91 | master | 7,234 | module Mollie
class Payment < Base
STATUS_OPEN = 'open'.freeze
STATUS_CANCELED = 'canceled'.freeze
STATUS_PENDING = 'pending'.freeze
STATUS_EXPIRED = 'expired'.freeze
STATUS_FAILED = 'failed'.freeze
STATUS_PAID = 'paid'.freeze
STATUS_AUTHORIZED = 'authorized'.freeze... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/permission.rb | Ruby | bsd-2-clause | 91 | master | 516 | module Mollie
class Permission < Base
AVAILABLE = %w[
payments.read
payments.write
refunds.read
refunds.write
customers.read
customers.write
mandates.read
mandates.write
subscriptions.read
subscriptions.write
profiles.read
profiles.write
... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/onboarding.rb | Ruby | bsd-2-clause | 91 | master | 962 | module Mollie
class Onboarding < Base
attr_accessor :name,
:signed_up_at,
:status,
:can_receive_payments,
:can_receive_settlements,
:_links
alias links _links
def self.me(options = {})
response = Client.insta... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/refund.rb | Ruby | bsd-2-clause | 91 | master | 1,798 | module Mollie
class Refund < Base
STATUS_QUEUED = 'queued'.freeze
STATUS_PENDING = 'pending'.freeze
STATUS_PROCESSING = 'processing'.freeze
STATUS_REFUNDED = 'refunded'.freeze
STATUS_FAILED = 'failed'.freeze
attr_accessor :id,
:amount,
:settlem... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/balance.rb | Ruby | bsd-2-clause | 91 | master | 1,378 | module Mollie
class Balance < Base
attr_accessor :id,
:mode,
:currency,
:description,
:status,
:transfer_frequency,
:transfer_reference,
:_links
attr_reader :transfer_threshold,
... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/payment_link.rb | Ruby | bsd-2-clause | 91 | master | 1,392 | module Mollie
class PaymentLink < Base
attr_accessor :id,
:mode,
:description,
:archived,
:redirect_url,
:webhook_url,
:profile_id,
:_links
attr_reader :amount,
:created_at,
:paid_at,
:updated_at,
:expires_at
alias_method :links, :_links
... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/util.rb | Ruby | bsd-2-clause | 91 | master | 2,265 | module Mollie
module Util
module_function
def nested_underscore_keys(obj)
if obj.is_a?(Hash)
obj.each_with_object({}) do |(key, value), underscored|
underscored[underscore(key)] = nested_underscore_keys(value)
end
elsif obj.is_a?(Array)
obj.map { |v| nested_under... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/method.rb | Ruby | bsd-2-clause | 91 | master | 2,244 | module Mollie
class Method < Base
ALMA = 'alma'.freeze
APPLEPAY = 'applepay'.freeze
BANCONTACT = 'bancontact'.freeze
BANCOMAT_PAY = 'bancomatpay'.freeze
BANKTRANSFER = 'banktransfer'.freeze
BELFIUS = 'belfius'.freeze
BILLIE = 'billie'.freeze
BLIK ... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/organization.rb | Ruby | bsd-2-clause | 91 | master | 579 | module Mollie
class Organization < Base
attr_accessor :id,
:name,
:locale,
:email,
:address,
:registration_number,
:vat_number,
:vat_regulation,
:_links
alias links ... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/order.rb | Ruby | bsd-2-clause | 91 | master | 4,241 | module Mollie
class Order < Base
STATUS_PENDING = 'pending'.freeze
STATUS_AUTHORIZED = 'authorized'.freeze
STATUS_PAID = 'paid'.freeze
STATUS_SHIPPING = 'shipping'.freeze
STATUS_EXPIRED = 'expired'.freeze
STATUS_CANCELED = 'canceled'.freeze
STATUS_COMPLETED = 'completed'.f... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/client.rb | Ruby | bsd-2-clause | 91 | master | 5,149 | module Mollie
class Client
API_ENDPOINT = 'https://api.mollie.com'.freeze
API_VERSION = 'v2'.freeze
MODE_TEST = 'test'.freeze
MODE_LIVE = 'live'.freeze
class << self
attr_accessor :configuration
end
class Configuration
attr_accessor :api_key, :open_timeout, :read_timeout
... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/exception.rb | Ruby | bsd-2-clause | 91 | master | 728 | module Mollie
class Exception < StandardError
end
class RequestError < Mollie::Exception
attr_accessor :status, :title, :detail, :field, :links
def initialize(error, response = nil)
exception.status = error['status']
exception.title = error['title']
exception.detail = error['detail']
... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/subscription.rb | Ruby | bsd-2-clause | 91 | master | 2,729 | module Mollie
class Subscription < Base
STATUS_ACTIVE = 'active'.freeze
STATUS_PENDING = 'pending'.freeze # Waiting for a valid mandate.
STATUS_CANCELED = 'canceled'.freeze
STATUS_SUSPENDED = 'suspended'.freeze # Active, but mandate became invalid.
STATUS_COMPLETED = 'completed'.freeze
... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/order/line.rb | Ruby | bsd-2-clause | 91 | master | 2,596 | module Mollie
class Order
class Line < Base
attr_accessor :id,
:order_id,
:type,
:name,
:status,
:metadata,
:is_cancelable,
:quantity,
:quantity_shi... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/order/shipment.rb | Ruby | bsd-2-clause | 91 | master | 718 | module Mollie
class Order
class Shipment < Base
attr_accessor :id,
:order_id,
:created_at,
:tracking,
:lines,
:_links
alias links _links
def tracking
@tracking || OpenStruct.new
en... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/customer/mandate.rb | Ruby | bsd-2-clause | 91 | master | 1,153 | module Mollie
class Customer
class Mandate < Base
STATUS_VALID = 'valid'.freeze
STATUS_INVALID = 'invalid'.freeze
STATUS_PENDING = 'pending'.freeze
attr_accessor :id,
:mode,
:status,
:method,
:details,
... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/payment/line.rb | Ruby | bsd-2-clause | 91 | master | 1,218 | module Mollie
class Payment
class Line < Base
attr_accessor :type,
:description,
:quantity,
:quantity_unit,
:vat_rate,
:sku,
:categories,
:image_url,
... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/payment/capture.rb | Ruby | bsd-2-clause | 91 | master | 1,112 | module Mollie
class Payment
class Capture < Base
attr_accessor :id,
:mode,
:amount,
:settlement_amount,
:payment_id,
:shipment_id,
:settlement_id,
:created_at,
... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/balance/report.rb | Ruby | bsd-2-clause | 91 | master | 488 | module Mollie
class Balance
class Report < Base
attr_accessor :balance_id,
:time_zone,
:grouping,
:totals,
:_links
attr_reader :from,
:until
alias links _links
def from=(from)
@from... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | lib/mollie/balance/transaction.rb | Ruby | bsd-2-clause | 91 | master | 904 | module Mollie
class Balance
class Transaction < Base
attr_accessor :id,
:type,
:_links
attr_reader :result_amount,
:initial_amount,
:deductions,
:context,
:created_at
alias links _li... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | examples/profiles/create.rb | Ruby | bsd-2-clause | 91 | master | 276 | profile = Mollie::Profile.create(
name: 'My website name',
website: 'https://www.mywebsite.com',
email: 'info@mywebsite.com',
phone: '+31208202070',
business_category: 'OTHER_MERCHANDISE',
mode: 'live'
) |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | examples/connect/tokens.rb | Ruby | bsd-2-clause | 91 | master | 484 | require 'rack/oauth2'
client = Rack::OAuth2::Client.new(
identifier: client_id,
secret: secret,
state: 'some_state',
redirect_uri: redirect_url,
authorization_endpoint: 'https://my.mollie.com/oauth2/authorize',
token_endpoint: 'https://api.moll... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | examples/connect/authorize.rb | Ruby | bsd-2-clause | 91 | master | 494 | require 'rack/oauth2'
client = Rack::OAuth2::Client.new(
identifier: client_id,
secret: secret,
state: 'some_state',
redirect_uri: redirect_url,
authorization_endpoint: 'https://my.mollie.com/oauth2/authorize',
token_endpoint: 'https://api.moll... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | examples/payments/create.rb | Ruby | bsd-2-clause | 91 | master | 290 | payment = Mollie::Payment.create(
amount: { value: '10.00', currency: 'EUR' },
description: 'My first payment',
redirect_url: 'https://webshop.example.org/order/12345/',
webhook_url: 'https://webshop.example.org/payments/webhook/',
metadata: {
order_id: '12345'
}
) |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | examples/payments/webhook.rb | Ruby | bsd-2-clause | 91 | master | 293 | payment = Mollie::Payment.get('tr_7UhSN1zuXS')
if payment.paid?
#
# At this point you'd probably want to start the process of delivering the
# product to the customer.
#
elsif !payment.open?
#
# The payment isn't paid and isn't open anymore. We can assume it was aborted.
#
end |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | examples/shipments/create.rb | Ruby | bsd-2-clause | 91 | master | 326 | shipment = Mollie::Order::Shipment.create(
order_id: 'ord_kEn1PlbGa',
lines: [
{
id: 'odl_dgtxyl',
quantity: 1
},
{
id: 'odl_jp31jz'
}
],
tracking: {
carrier: 'PostNL',
code: '3SKABA000000000',
url: 'http://postnl.nl/tracktrace/?B=3SKABA000000000&P=1016EE&D=NL&T=C'
... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | examples/shipments/update.rb | Ruby | bsd-2-clause | 91 | master | 240 | shipment = Mollie::Order::Shipment.update(
'shp_3wmsgCJN4U',
order_id: 'ord_kEn1PlbGa',
tracking: {
carrier: 'PostNL',
code: '3SKABA000000000',
url: 'http://postnl.nl/tracktrace/?B=3SKABA000000000&P=1016EE&D=NL&T=C'
}
) |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | examples/orders/update.rb | Ruby | bsd-2-clause | 91 | master | 343 | order = Mollie::Order.update(
'ord_kEn1PlbGa',
billingAddress: {
city: 'Amsterdam',
country: 'NL',
email: 'piet@mondriaan.com',
familyName: 'Mondriaan',
givenName: 'Piet',
phone: '+31208202070',
postalCode: '1234AB',
region: 'Noord-Holland',
streetAndNumber: 'Keizersgracht 313',
... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | examples/orders/create.rb | Ruby | bsd-2-clause | 91 | master | 2,134 | order = Mollie::Order.create(
amount: {
value: '1027.99',
currency: 'EUR'
},
billingAddress: {
streetAndNumber: 'Keizersgracht 313',
city: 'Amsterdam',
region: 'Noord-Holland',
postalCode: '1234AB',
country: 'NL',
title: 'Dhr',
givenName: 'Piet',
familyName: 'Mondriaan',
... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | examples/orders/create-refund.rb | Ruby | bsd-2-clause | 91 | master | 339 | # Refund all order lines
order = Mollie::Order.get('ord_kEn1PlbGa')
refund = order.refund!
# Refund a specific order line
order = Mollie::Order.get('ord_kEn1PlbGa')
refund = order.refund!(
lines: [
{
id: 'odl_dgtxyl',
quantity: 1
}
],
description: 'Required quantity not in stock, refunding ... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | examples/customers/create-payment.rb | Ruby | bsd-2-clause | 91 | master | 225 | payment = Mollie::Customer::Payment.create(
customer_id: 'cst_8wmqcHMN4U',
amount: { value: '10.00', currency: 'EUR' },
description: 'First payment',
redirect_url: 'https://webshop.example.org/order/12345/'
) |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | examples/onboarding/submit.rb | Ruby | bsd-2-clause | 91 | master | 441 | Mollie::Onboarding.submit(
organization: {
name: "Mollie B.V.",
address: {
streetAndNumber: "Keizersgracht 313",
postalCode: "1018 EE",
city: "Amsterdam",
country: "NL"
},
registrationNumber: "30204462",
vatNumber: "NL815839091B01"
},
profile: {
name: "Mollie",
... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | examples/methods/list.rb | Ruby | bsd-2-clause | 91 | master | 654 | # Retrieve all enabled payment methods
methods = Mollie::Method.all
# Filter by amount and currency
methods = Mollie::Method.all(amount: { value: '100.00', currency: 'EUR' })
# Retrieve all payment methods that Mollie offers and can be activated by the Organization
methods = Mollie::Method.all_available
# Include is... |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | examples/mandates/create.rb | Ruby | bsd-2-clause | 91 | master | 309 | mandate = Mollie::Customer::Mandate.create(
customer_id: 'cst_4qqhO89gsT',
method: 'directdebit',
consumer_name: 'John Doe',
consumer_account: 'NL55INGB0000000000',
consumer_bic: 'INGBNL2A',
signature_date: '2018-05-07',
mandate_reference: 'YOUR-COMPANY-MD13804'
) |
github | mollie/mollie-api-ruby | https://github.com/mollie/mollie-api-ruby | examples/subscriptions/create.rb | Ruby | bsd-2-clause | 91 | master | 324 | subscription = Mollie::Customer::Subscription.create(
customer_id: 'cst_5a2pPrwaWy',
amount: { value: '20.00', currency: 'EUR' },
times: 4,
interval: '3 months',
description: 'Quarterly payment',
metadata: { my_field: 'value' },
webhook_url: 'https://webshop.example.org/payments/webhook/'... |
github | salsify/avromatic | https://github.com/salsify/avromatic | Rakefile | Ruby | mit | 91 | master | 966 | # frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'appraisal/task'
require 'avro/builder'
RSpec::Core::RakeTask.new(:default_spec)
Appraisal::Task.new
# rubocop:disable Rake/DuplicateTask
if !ENV['APPRAISAL_INITIALIZED']
task default: :appraisal
task spec: :apprais... |
github | salsify/avromatic | https://github.com/salsify/avromatic | Appraisals | Ruby | mit | 91 | master | 546 | # frozen_string_literal: true
appraise 'avro1_11-rails7_2' do
gem 'avro', '~> 1.11.0'
gem 'activesupport', '~> 7.2.2'
gem 'activemodel', '~> 7.2.2'
end
appraise 'avro1_11-rails8_0' do
gem 'avro', '~> 1.11.0'
gem 'activesupport', '~> 8.0.3'
gem 'activemodel', '~> 8.0.3'
end
appraise 'avro1_12-rails7_2' do... |
github | salsify/avromatic | https://github.com/salsify/avromatic | avromatic.gemspec | Ruby | mit | 91 | master | 2,086 | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'avromatic/version'
Gem::Specification.new do |spec|
spec.name = 'avromatic'
spec.version = Avromatic::VERSION
spec.authors = ['Salsify Engineering']
spec.e... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avromatic_spec.rb | Ruby | mit | 91 | master | 3,456 | # frozen_string_literal: true
describe Avromatic do
it "has a version number" do
expect(Avromatic::VERSION).not_to be_nil
end
describe ".build_schema_registry" do
context "when the registry_url is unset" do
before { Avromatic.registry_url = nil }
it "raises an error" do
expect { Avr... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/spec_helper.rb | Ruby | mit | 91 | master | 967 | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'simplecov'
SimpleCov.start do
add_filter 'spec'
minimum_coverage 95
end
require 'avro/builder'
require 'avromatic'
require 'active_support/core_ext/hash/keys'
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each ... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avro/dsl/test/real_union.rb | Ruby | mit | 91 | master | 267 | # frozen_string_literal: true
namespace :test
record :foo do
required :foo_message, :string
end
record :bar do
required :bar_message, :string
end
record :real_union do
required :header, :string
required :message, :union, types: [:foo, :bar, :boolean]
end |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avro/dsl/test/optional_union.rb | Ruby | mit | 91 | master | 261 | # frozen_string_literal: true
namespace :test
record :foo do
required :foo_message, :string
end
record :bar do
required :bar_message, :string
end
record :optional_union do
required :header, :string
optional :message, :union, types: [:foo, :bar]
end |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avro/dsl/test/real_int_union.rb | Ruby | mit | 91 | master | 225 | # frozen_string_literal: true
namespace :test
record :real_int_union do
required :header, :string
required :message, :union, types: [:int, :string, :long]
optional :string_or_long, :union, types: [:string, :long]
end |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avro/dsl/test/defaults.rb | Ruby | mit | 91 | master | 240 | # frozen_string_literal: true
namespace 'test'
record :defaults do
required :defaulted_enum, :enum, symbols: [:A, :B], default: :A
required :defaulted_string, :string, default: 'fnord'
required :defaulted_int, :int, default: 42
end |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avro/dsl/test/logical_types.rb | Ruby | mit | 91 | master | 372 | # frozen_string_literal: true
record :logical_types, namespace: :test do
required :date, :int, logical_type: 'date'
required :ts_msec, :long, logical_type: 'timestamp-millis'
required :ts_usec, :long, logical_type: 'timestamp-micros'
required :decimal, :bytes, logical_type: 'decimal', precision: 4, scale: 2
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avro/dsl/test/wrapper.rb | Ruby | mit | 91 | master | 246 | # frozen_string_literal: true
namespace 'test'
record :wrapped1 do
required :i, :int
end
record :wrapped2 do
required :i, :int
end
record :wrapper do
required :sub1, :wrapped1
required :sub2, :wrapped1
required :sub3, :wrapped2
end |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avro/dsl/test/null_in_union.rb | Ruby | mit | 91 | master | 219 | # frozen_string_literal: true
namespace :test
record :i_rec do
required :i, :int
end
record :s_rec do
required :s, :string
end
record :null_in_union do
required :values, array(union(:i_rec, null, :s_rec))
end |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avro/dsl/test/primitive_types.rb | Ruby | mit | 91 | master | 328 | # frozen_string_literal: true
namespace :test
record :primitive_types do
required :s, :string
required :b, :bytes
required :tf, :boolean
required :i, :int
required :l, :long
required :f, :float
required :d, :double
required :n, :null
required :fx, :fixed, size: 7
required :e, :enum, symbols: [:A, ... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avro/dsl/test/nested_record.rb | Ruby | mit | 91 | master | 226 | # frozen_string_literal: true
namespace :test
record :nested_record do
required :str, :string, default: 'A'
required :sub, :record do
required :str, :string, default: 'B'
required :i, :int, default: 0
end
end |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avro/dsl/test/nested_nested_record.rb | Ruby | mit | 91 | master | 2,204 | # frozen_string_literal: true
namespace :test
record :nested_nested_record do
# primitive types
required :n, :null
required :b, :boolean
required :i, :int
required :l, :long
required :f, :float
required :d, :double
required :bs, :bytes
required :str, :string
# logical types
required :date, :int... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/support/helpers/logical_types_helper.rb | Ruby | mit | 91 | master | 285 | # frozen_string_literal: true
module LogicalTypesHelper
def with_logical_types
yield if logical_types?
end
def without_logical_types
yield unless logical_types?
end
private
def logical_types?
Avro::Schema.instance_methods.include?(:logical_type)
end
end |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/support/contexts/logical_types_serialization.rb | Ruby | mit | 91 | master | 1,519 | # frozen_string_literal: true
# This examples expects let-variables to be defined for:
# decoded: a model instance based on the encoded_value
shared_examples_for "logical type encoding and decoding" do
context "logical types" do
let(:schema_name) { 'test.logical_types_with_decimal' }
let(:test_class) do
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avromatic/model_spec.rb | Ruby | mit | 91 | master | 790 | # frozen_string_literal: true
require 'spec_helper'
describe Avromatic::Model do
let(:args) { { schema_name: 'test_schema' } }
describe ".build" do
it "delegates to Avromatic::Model::Builder" do
builder = instance_double(Avromatic::Model::Builder, mod: Module.new)
allow(Avromatic::Model::Builder)... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avromatic/model_registry_spec.rb | Ruby | mit | 91 | master | 4,731 | # frozen_string_literal: true
describe Avromatic::ModelRegistry do
let(:model) { Avromatic::Model.model(schema_name: 'test.nested_record') }
let(:instance) { described_class.new }
describe "#registered?" do
context "for a model that has not been registered" do
it "returns false" do
expect(inst... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avromatic/model/message_decoder_spec.rb | Ruby | mit | 91 | master | 5,394 | # frozen_string_literal: true
require 'spec_helper'
describe Avromatic::Model::MessageDecoder do
let(:instance) { described_class.new(*models) }
let(:model1) do
Avromatic::Model.model(
value_schema_name: 'test.encode_value',
key_schema_name: 'test.encode_key'
)
end
let(:model2) do
Avro... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avromatic/model/builder_nested_models_spec.rb | Ruby | mit | 91 | master | 2,799 | # frozen_string_literal: true
describe Avromatic::Model::Builder, 'nested_models' do
let(:schema) do
Avro::Builder.build_schema do
record :rec do
required :sub, :record, type_name: :sub_rec, type_namespace: 'test.bar' do
required :s, :string
end
optional :opt_sub, :sub_rec... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avromatic/model/messaging_serialization_spec.rb | Ruby | mit | 91 | master | 15,825 | # frozen_string_literal: true
require 'avro/builder'
describe Avromatic::Model::MessagingSerialization do
let(:values) { { id: rand(99) } }
let(:instance) { test_class.new(values) }
let(:avro_message_value) { instance.avro_message_value }
let(:avro_message_key) { instance.avro_message_key }
before do
a... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avromatic/model/raw_serialization_spec.rb | Ruby | mit | 91 | master | 22,915 | # frozen_string_literal: true
require 'spec_helper'
require 'avro/builder'
describe Avromatic::Model::RawSerialization do
let(:values) { { id: rand(99) } }
let(:test_class) { Avromatic::Model.model(value_schema_name: schema_name) }
let(:instance) { test_class.new(values) }
let(:avro_raw_value) { instance.avro... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avromatic/model/builder_spec.rb | Ruby | mit | 91 | master | 42,430 | # frozen_string_literal: true
describe Avromatic::Model::Builder do
let(:schema_store) { Avromatic.schema_store }
let(:schema) { schema_store.find(schema_name) }
let(:key_schema) { schema_store.find(key_schema_name) }
let(:test_class) do
described_class.model(schema_name: schema_name)
end
let(:values) ... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avromatic/model/builder_validation_spec.rb | Ruby | mit | 91 | master | 9,662 | # frozen_string_literal: true
describe Avromatic::Model::Builder, 'validation' do
let(:schema) { schema_store.find(schema_name) }
let(:test_class) do
described_class.model(schema_name: schema_name)
end
let(:attribute_names) do
test_class.attribute_definitions.keys.map(&:to_s)
end
context "required... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avromatic/io/datum_writer_spec.rb | Ruby | mit | 91 | master | 3,277 | # frozen_string_literal: true
describe Avromatic::IO::DatumWriter do
let(:encoder) { instance_double(Avro::IO::BinaryEncoder) }
let(:schema_name) { 'test.real_union' }
let(:test_class) do
Avromatic::Model.model(schema_name: schema_name)
end
let(:values) do
{
header: 'foo',
message: { bar_... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avromatic/io/union_datum_spec.rb | Ruby | mit | 91 | master | 1,446 | # frozen_string_literal: true
describe Avromatic::IO::UnionDatum do
describe "#==" do
it "returns true when the member index and datum are equal" do
member1 = described_class.new(1, foo: 'bar')
member2 = described_class.new(1, foo: 'bar')
expect(member1).to eq(member2)
end
it "returns ... |
github | salsify/avromatic | https://github.com/salsify/avromatic | spec/avromatic/io/datum_reader_spec.rb | Ruby | mit | 91 | master | 4,441 | # frozen_string_literal: true
describe Avromatic::IO::DatumReader do
let(:test_class) do
Avromatic::Model.model(schema_name: schema_name)
end
let(:instance) { test_class.new(values) }
let(:avro_message_value) { instance.avro_message_value }
let(:attributes) { test_class.avro_message_attributes(avro_messa... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic.rb | Ruby | mit | 91 | master | 2,740 | # frozen_string_literal: true
require 'avromatic/version'
require 'avro_schema_registry-client'
require 'ice_nine'
require 'ice_nine/core_ext/object'
require 'avromatic/model'
require 'avromatic/model_registry'
require 'avromatic/messaging'
require 'active_support/core_ext/string/inflections'
module Avromatic
class... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model.rb | Ruby | mit | 91 | master | 1,817 | # frozen_string_literal: true
require 'avromatic/model/builder'
require 'avromatic/model/coercion_error'
require 'avromatic/model/message_decoder'
require 'avromatic/model/custom_type_registry'
require 'avromatic/model/validation_error'
require 'avromatic/model/unknown_attribute_error'
module Avromatic
module Model... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/railtie.rb | Ruby | mit | 91 | master | 303 | # frozen_string_literal: true
module Avromatic
class Railtie < Rails::Railtie
initializer 'avromatic.configure' do
Avromatic.configure do |config|
config.logger = Rails.logger
end
Rails.configuration.to_prepare do
Avromatic.prepare!
end
end
end
end |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/rspec.rb | Ruby | mit | 91 | master | 537 | # frozen_string_literal: true
require 'uri'
require 'webmock/rspec'
require 'avro_schema_registry/test/fake_server'
RSpec.configure do |config|
config.before(:each) do
# Strip the username/password from the URL so WebMock can match the URL
registry_uri = URI(Avromatic.registry_url)
registry_uri.userinfo... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/messaging.rb | Ruby | mit | 91 | master | 2,192 | # frozen_string_literal: true
require 'avro_turf/messaging'
require 'avromatic/io'
module Avromatic
# Subclass AvroTurf::Messaging to use a custom DatumReader and DatumWriter
class Messaging < AvroTurf::Messaging
attr_reader :registry
def decode(data, schema_name: nil, namespace: @namespace)
reader... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model_registry.rb | Ruby | mit | 91 | master | 2,146 | # frozen_string_literal: true
require 'active_support/core_ext/string/access'
module Avromatic
# The ModelRegistry class is used to store and fetch nested models by
# their fullname. An optional namespace prefix can be removed from the full
# name that is used to store and fetch models.
class ModelRegistry
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/io/union_datum.rb | Ruby | mit | 91 | master | 507 | # frozen_string_literal: true
module Avromatic
module IO
class UnionDatum
attr_reader :member_index, :datum
def initialize(member_index, datum)
@member_index = member_index
@datum = datum
end
def ==(other)
other.is_a?(Avromatic::IO::UnionDatum) &&
membe... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/io/datum_writer.rb | Ruby | mit | 91 | master | 1,161 | # frozen_string_literal: true
module Avromatic
module IO
# Subclass DatumWriter to use additional information about union member
# index.
class DatumWriter < Avro::IO::DatumWriter
def write_union(writers_schema, datum, encoder)
optional = writers_schema.schemas.first.type_sym == :null
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/io/datum_reader.rb | Ruby | mit | 91 | master | 1,526 | # frozen_string_literal: true
module Avromatic
module IO
# Subclass DatumReader to include additional information about the union
# member index used. The code modified below is based on salsify/avro,
# branch 'salsify-master' with the tag 'v1.9.0.3'
class DatumReader < Avro::IO::DatumReader
d... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/builder.rb | Ruby | mit | 91 | master | 1,993 | # frozen_string_literal: true
require 'active_support/concern'
require 'active_model'
require 'avromatic/model/configuration'
require 'avromatic/model/value_object'
require 'avromatic/model/configurable'
require 'avromatic/model/field_helper'
require 'avromatic/model/nested_models'
require 'avromatic/model/validation'... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/message_decoder.rb | Ruby | mit | 91 | master | 4,284 | # frozen_string_literal: true
module Avromatic
module Model
# This class is used to decode messages encoded using Avro to their
# corresponding models.
class MessageDecoder
MAGIC_BYTE = [0].pack('C').freeze
class UnexpectedKeyError < StandardError
attr_reader :key_schema_name, :valu... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/attributes.rb | Ruby | mit | 91 | master | 8,616 | # frozen_string_literal: true
require 'active_support/core_ext/object/duplicable'
require 'active_support/time'
module Avromatic
module Model
# This module supports defining Virtus attributes for a model based on the
# fields of Avro schemas.
module Attributes
extend ActiveSupport::Concern
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/validation.rb | Ruby | mit | 91 | master | 2,415 | # frozen_string_literal: true
module Avromatic
module Model
module Validation
extend ActiveSupport::Concern
include ActiveModel::Validations
EMPTY_ARRAY = [].freeze
def self.missing_nested_attributes(attribute, value)
if value.is_a?(Array)
results = []
value.... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/value_object.rb | Ruby | mit | 91 | master | 684 | # frozen_string_literal: true
module Avromatic
module Model
# This module is used to override the comparisons defined by
# Virtus::Equalizer which is pulled in by Virtus::ValueObject.
module ValueObject
def eql?(other)
other.instance_of?(self.class) && attributes == other.attributes
e... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/configurable.rb | Ruby | mit | 91 | master | 2,554 | # frozen_string_literal: true
module Avromatic
module Model
# This concern adds methods for configuration for a model generated from
# Avro schema(s).
module Configurable
extend ActiveSupport::Concern
# Wraps a reference to a field so we can access both the string and symbolized versions of... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/custom_type_registry.rb | Ruby | mit | 91 | master | 1,660 | # frozen_string_literal: true
require 'avromatic/model/custom_type_configuration'
module Avromatic
module Model
class CustomTypeRegistry
delegate :clear, to: :custom_types
def initialize
@custom_types = {}
end
# @param fullname [String] The fullname of the Avro type.
# @... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/configuration.rb | Ruby | mit | 91 | master | 2,705 | # frozen_string_literal: true
module Avromatic
module Model
# This class holds configuration for a model built from Avro schema(s).
class Configuration
attr_reader :avro_schema, :key_avro_schema, :nested_models, :mutable,
:allow_optional_key_fields, :avro_schema_subject, :key_avro_s... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/nested_models.rb | Ruby | mit | 91 | master | 1,059 | # frozen_string_literal: true
require 'active_support/inflector/methods'
module Avromatic
module Model
# This module handles integration with the ModelRegistry and support
# for nested model reuse.
module NestedModels
extend ActiveSupport::Concern
module ClassMethods
# Register this... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/field_helper.rb | Ruby | mit | 91 | master | 662 | # frozen_string_literal: true
module Avromatic
module Model
module FieldHelper
extend self
# An optional field is represented as a union where the first member
# is null.
def optional?(field)
field.type.type_sym == :union &&
field.type.schemas.first.type_sym == :null
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/unknown_attribute_error.rb | Ruby | mit | 91 | master | 392 | # frozen_string_literal: true
module Avromatic
module Model
class UnknownAttributeError < StandardError
attr_reader :unknown_attributes, :allowed_attributes
def initialize(message, unknown_attributes:, allowed_attributes:)
super(message)
@unknown_attributes = unknown_attributes
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/raw_serialization.rb | Ruby | mit | 91 | master | 6,056 | # frozen_string_literal: true
require 'active_support/deprecation'
module Avromatic
module Model
# This module provides serialization support for encoding directly to Avro
# without dependency on a schema registry.
module RawSerialization
extend ActiveSupport::Concern
module Encode
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/custom_type_configuration.rb | Ruby | mit | 91 | master | 1,634 | # frozen_string_literal: true
module Avromatic
module Model
# Instances of this class contains the configuration for custom handling of
# a named type (record, enum, fixed).
class CustomTypeConfiguration
attr_accessor :to_avro, :from_avro, :value_class
def initialize(value_class)
@... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/messaging_serialization.rb | Ruby | mit | 91 | master | 2,669 | # frozen_string_literal: true
module Avromatic
module Model
# This concern adds support for serialization based on AvroTurf::Messaging.
# This serialization leverages a schema registry to prefix encoded values
# with an id for the schema.
module MessagingSerialization
extend ActiveSupport::Con... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/types/float_type.rb | Ruby | mit | 91 | master | 880 | # frozen_string_literal: true
require 'avromatic/model/types/abstract_type'
module Avromatic
module Model
module Types
class FloatType < AbstractType
VALUE_CLASSES = [::Float].freeze
INPUT_CLASSES = [::Float, ::Integer].freeze
def value_classes
VALUE_CLASSES
end
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/types/fixed_type.rb | Ruby | mit | 91 | master | 966 | # frozen_string_literal: true
require 'avromatic/model/types/abstract_type'
module Avromatic
module Model
module Types
class FixedType < AbstractType
VALUE_CLASSES = [::String].freeze
attr_reader :size
def initialize(size)
super()
@size = size
end
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/types/abstract_type.rb | Ruby | mit | 91 | master | 1,201 | # frozen_string_literal: true
module Avromatic
module Model
module Types
class AbstractType
EMPTY_ARRAY = [].freeze
private_constant :EMPTY_ARRAY
def value_classes
raise "#{__method__} must be overridden by #{self.class.name}"
end
def input_classes
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/types/date_type.rb | Ruby | mit | 91 | master | 932 | # frozen_string_literal: true
require 'avromatic/model/types/abstract_type'
module Avromatic
module Model
module Types
class DateType < AbstractType
VALUE_CLASSES = [::Date].freeze
INPUT_CLASSES = [::Date, ::Time].freeze
def value_classes
VALUE_CLASSES
end
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/types/big_int_type.rb | Ruby | mit | 91 | master | 982 | # frozen_string_literal: true
require 'avromatic/model/types/abstract_type'
module Avromatic
module Model
module Types
class BigIntType < AbstractType
VALUE_CLASSES = [::Integer].freeze
MAX_RANGE = 2**63
def self.in_range?(value)
value.is_a?(::Integer) && value.between?... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/types/map_type.rb | Ruby | mit | 91 | master | 2,135 | # frozen_string_literal: true
require 'avromatic/model/types/abstract_type'
module Avromatic
module Model
module Types
class MapType < AbstractType
VALUE_CLASSES = [::Hash].freeze
attr_reader :value_type, :key_type
def initialize(key_type:, value_type:)
super()
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/types/timestamp_millis_type.rb | Ruby | mit | 91 | master | 806 | # frozen_string_literal: true
require 'avromatic/model/types/abstract_timestamp_type'
module Avromatic
module Model
module Types
# This subclass is used to truncate timestamp values to milliseconds.
class TimestampMillisType < Avromatic::Model::Types::AbstractTimestampType
def name
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/types/abstract_timestamp_type.rb | Ruby | mit | 91 | master | 1,526 | # frozen_string_literal: true
require 'active_support/time_with_zone'
module Avromatic
module Model
module Types
class AbstractTimestampType < AbstractType
VALUE_CLASSES = [::Time].freeze
INPUT_CLASSES = [::Time, ::DateTime, ::ActiveSupport::TimeWithZone].freeze
def value_classes
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/types/timestamp_micros_type.rb | Ruby | mit | 91 | master | 788 | # frozen_string_literal: true
require 'avromatic/model/types/abstract_timestamp_type'
module Avromatic
module Model
module Types
# This subclass is used to truncate timestamp values to microseconds.
class TimestampMicrosType < Avromatic::Model::Types::AbstractTimestampType
def name
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/types/record_type.rb | Ruby | mit | 91 | master | 1,363 | # frozen_string_literal: true
require 'avromatic/model/types/abstract_type'
module Avromatic
module Model
module Types
class RecordType < AbstractType
attr_reader :record_class, :value_classes, :input_classes
def initialize(record_class:)
super()
@record_class = record... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/types/string_type.rb | Ruby | mit | 91 | master | 883 | # frozen_string_literal: true
require 'avromatic/model/types/abstract_type'
module Avromatic
module Model
module Types
class StringType < AbstractType
VALUE_CLASSES = [::String].freeze
INPUT_CLASSES = [::String, ::Symbol].freeze
def value_classes
VALUE_CLASSES
en... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/types/null_type.rb | Ruby | mit | 91 | master | 786 | # frozen_string_literal: true
require 'avromatic/model/types/abstract_type'
module Avromatic
module Model
module Types
class NullType < AbstractType
VALUE_CLASSES = [::NilClass].freeze
def value_classes
VALUE_CLASSES
end
def name
'null'
end
... |
github | salsify/avromatic | https://github.com/salsify/avromatic | lib/avromatic/model/types/boolean_type.rb | Ruby | mit | 91 | master | 708 | # frozen_string_literal: true
require 'avromatic/model/types/abstract_type'
module Avromatic
module Model
module Types
class BooleanType < AbstractType
VALUE_CLASSES = [::TrueClass, ::FalseClass].freeze
def value_classes
VALUE_CLASSES
end
def name
'boo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.