repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/spec/circuitry/config/file_loader_spec.rb | spec/circuitry/config/file_loader_spec.rb | require 'spec_helper'
RSpec.describe Circuitry::Config::FileLoader do
subject { described_class }
describe '.load' do
context 'with valid fixture' do
before do
subject.load('spec/support/fixtures/example_config.yml.erb', 'test')
end
it 'loads publisher config' do
expect(Circ... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/spec/circuitry/config/publisher_settings_spec.rb | spec/circuitry/config/publisher_settings_spec.rb | require 'spec_helper'
RSpec.describe Circuitry::Config::PublisherSettings do
describe '.new' do
context 'initialized with a hash' do
subject { described_class.new(secret_key: '123', region: 'us-west-1') }
it 'is configured' do
expect(subject.secret_key).to eql('123')
end
end
end
... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/spec/circuitry/config/subscriber_settings_spec.rb | spec/circuitry/config/subscriber_settings_spec.rb | require 'spec_helper'
RSpec.describe Circuitry::Config::SubscriberSettings do
describe '#async_strategy=' do
it_behaves_like 'a validated setting', Circuitry::Subscriber.async_strategies, :async_strategy
end
describe '#queue_name' do
it 'sets #dead_letter_queue_name' do
expect {
subject.qu... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/spec/circuitry/processors/batcher_spec.rb | spec/circuitry/processors/batcher_spec.rb | require 'spec_helper'
RSpec.describe Circuitry::Processors::Batcher, type: :model do
subject { described_class }
it { is_expected.to be_a Circuitry::Processor }
describe '.batch' do
let(:pool) { double('Array', '<<' => []) }
let(:block) { -> {} }
before do
allow(subject).to receive(:pool).an... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/spec/circuitry/processors/threader_spec.rb | spec/circuitry/processors/threader_spec.rb | require 'spec_helper'
RSpec.describe Circuitry::Processors::Threader, type: :model do
subject { described_class }
it { is_expected.to be_a Circuitry::Processor }
it_behaves_like 'an asyncronous processor'
describe '.process' do
let(:pool) { double('Array', '<<': []) }
let(:block) { ->{ } }
let(:... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/spec/circuitry/processors/forker_spec.rb | spec/circuitry/processors/forker_spec.rb | require 'spec_helper'
RSpec.describe Circuitry::Processors::Forker, type: :model do
subject { described_class }
it { is_expected.to be_a Circuitry::Processor }
it_behaves_like 'an asyncronous processor'
describe '.fork' do
before do
allow(subject).to receive(:fork).and_return(pid)
allow(Proc... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry.rb | lib/circuitry.rb | require 'circuitry/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
require 'circuitry/config/publisher_settings'
require 'circuitry/config/subscriber_settings'
require 'circuitry/locks/base'
require 'circuitry/locks/memcache'
require 'circuitry/locks/memory'
require 'circuitry/locks/noop'
require 'circuitry/l... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/version.rb | lib/circuitry/version.rb | module Circuitry
VERSION = '3.5.0'
end
| ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/topic.rb | lib/circuitry/topic.rb | require 'circuitry/services/sns'
module Circuitry
class Topic
class Finder
include Services::SNS
def initialize(name)
self.name = name
end
def find
sns.create_topic(name: name)
end
private
attr_accessor :name
end
attr_reader :arn
def ini... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/processor.rb | lib/circuitry/processor.rb | module Circuitry
module Processor
def process(&_block)
raise NotImplementedError, "#{self} must implement class method `process`"
end
def flush
raise NotImplementedError, "#{self} must implement class method `flush`"
end
def on_exit
Circuitry.subscriber_config.on_async_exit
... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/publisher.rb | lib/circuitry/publisher.rb | require 'json'
require 'timeout'
require 'circuitry/concerns/async'
require 'circuitry/services/sns'
module Circuitry
class PublishError < StandardError; end
class SnsPublishError < StandardError
def initialize(topic:, message:, exception:)
msg = {
error: "#{exception.class}: #{exception.message... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/queue.rb | lib/circuitry/queue.rb | require 'circuitry/services/sqs'
module Circuitry
class Queue
include Services::SQS
class Finder
include Services::SQS
def initialize(name)
self.name = name
end
def find
sqs.get_queue_url(queue_name: name)
end
private
attr_accessor :name
end
... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/railtie.rb | lib/circuitry/railtie.rb | require 'rails'
require 'circuitry/config/file_loader'
module Circuitry
class Railtie < Rails::Railtie
rake_tasks do
load 'circuitry/tasks.rb'
end
initializer 'circuitry' do
env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
%w[config/circuitry.yml.erb config/circuitry.yml].de... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/message.rb | lib/circuitry/message.rb | require 'json'
require 'circuitry/topic'
module Circuitry
class Message
attr_reader :sqs_message
def initialize(sqs_message)
@sqs_message = sqs_message
end
def context
@context ||= JSON.parse(sqs_message.body)
end
def body
@body ||= JSON.parse(context['Message'], quirks_m... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/subscriber.rb | lib/circuitry/subscriber.rb | require 'retries'
require 'timeout'
require 'circuitry/concerns/async'
require 'circuitry/services/sqs'
require 'circuitry/message'
require 'circuitry/queue'
module Circuitry
class SubscribeError < StandardError; end
class Subscriber
include Concerns::Async
include Services::SQS
attr_reader :queue, :... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/cli.rb | lib/circuitry/cli.rb | require 'circuitry/provisioning'
require 'thor'
module Circuitry
class CLI < Thor
class_option :verbose, aliases: :v, type: :boolean
desc 'provision <queue> -t <topic> [<topic> ...]', <<-END
Provision a queue subscribed to one or more topics
END
long_desc <<-END
Creates an SQS queue wit... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/tasks.rb | lib/circuitry/tasks.rb | namespace :circuitry do
desc 'Create subscriber queues and subscribe queue to topics'
task :setup do
require 'logger'
require 'circuitry/provisioning'
logger = Logger.new(STDOUT)
logger.level = Logger::INFO
if Rake::Task.task_defined?(:environment)
Rake::Task[:environment].invoke
end... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/provisioning.rb | lib/circuitry/provisioning.rb | require 'circuitry/provisioning/provisioner'
module Circuitry
module Provisioning
def self.provision(logger: Logger.new(STDOUT))
Provisioning::Provisioner.new(logger).run
end
end
end
| ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/testing.rb | lib/circuitry/testing.rb | require 'circuitry'
module Circuitry
class Publisher
def publish(_topic_name, _object)
# noop
end
end
class Subscriber
def subscribe(&_block)
# noop
end
end
end
| ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/services/sqs.rb | lib/circuitry/services/sqs.rb | require 'aws-sdk-sqs'
module Circuitry
module Services
module SQS
def sqs
@sqs ||= Aws::SQS::Client.new(Circuitry.subscriber_config.aws_options)
end
end
end
end
| ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/services/sns.rb | lib/circuitry/services/sns.rb | require 'aws-sdk-sns'
module Circuitry
module Services
module SNS
def sns
@sns ||= Aws::SNS::Client.new(Circuitry.publisher_config.aws_options)
end
end
end
end
| ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/concerns/async.rb | lib/circuitry/concerns/async.rb | require 'circuitry/processors/batcher'
require 'circuitry/processors/forker'
require 'circuitry/processors/threader'
module Circuitry
class NotSupportedError < StandardError; end
module Concerns
module Async
attr_reader :async
def self.included(base)
base.extend(ClassMethods)
end
... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/provisioning/topic_creator.rb | lib/circuitry/provisioning/topic_creator.rb | require 'circuitry/services/sns'
require 'circuitry/topic'
module Circuitry
module Provisioning
class TopicCreator
include Services::SNS
attr_reader :topic_name
def self.find_or_create(topic_name)
new(topic_name).topic
end
def initialize(topic_name)
self.topic_nam... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/provisioning/queue_creator.rb | lib/circuitry/provisioning/queue_creator.rb | require 'circuitry/services/sqs'
require 'circuitry/queue'
module Circuitry
module Provisioning
class QueueCreator
include Services::SQS
attr_reader :queue_name
attr_reader :visibility_timeout
def self.find_or_create(queue_name,
dead_letter_queue_name: nil,... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/provisioning/subscription_creator.rb | lib/circuitry/provisioning/subscription_creator.rb | require 'circuitry/services/sns'
require 'circuitry/topic'
module Circuitry
module Provisioning
class SubscriptionCreator
include Services::SNS
include Services::SQS
attr_reader :queue
attr_reader :topics
def self.subscribe_all(queue, topics)
new(queue, topics).subscribe_a... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/provisioning/provisioner.rb | lib/circuitry/provisioning/provisioner.rb | require 'circuitry'
require 'circuitry/provisioning/queue_creator'
require 'circuitry/provisioning/topic_creator'
require 'circuitry/provisioning/subscription_creator'
module Circuitry
module Provisioning
class Provisioner
def initialize(logger)
self.logger = logger
end
def run
... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/middleware/entry.rb | lib/circuitry/middleware/entry.rb | module Circuitry
module Middleware
class Entry
attr_reader :klass, :args
def initialize(klass, *args)
self.klass = klass
self.args = args
end
def build
klass.new(*args)
end
private
attr_writer :klass, :args
end
end
end
| ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/middleware/chain.rb | lib/circuitry/middleware/chain.rb | require 'circuitry/middleware/entry'
module Circuitry
module Middleware
class Chain
include Enumerable
def initialize
yield self if block_given?
end
def each(&block)
entries.each(&block)
end
def entries
@entries ||= []
end
def add(klass,... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/locks/memory.rb | lib/circuitry/locks/memory.rb | module Circuitry
module Locks
class Memory
include Base
class << self
def store
@store ||= {}
end
def semaphore
@semaphore ||= Mutex.new
end
end
protected
def lock(key, ttl)
reap
store do |store|
if st... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/locks/redis.rb | lib/circuitry/locks/redis.rb | module Circuitry
module Locks
class Redis
include Base
def initialize(options = {})
super(options)
self.client = options.fetch(:client) do
require 'redis'
::Redis.new(options)
end
end
protected
def lock(key, ttl)
with_pool do |c... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/locks/noop.rb | lib/circuitry/locks/noop.rb | module Circuitry
module Locks
class NOOP
include Base
protected
def lock(_key, _ttl)
true
end
def lock!(key, ttl)
# do nothing
end
def unlock!(key)
# do nothing
end
end
end
end
| ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/locks/memcache.rb | lib/circuitry/locks/memcache.rb | module Circuitry
module Locks
class Memcache
include Base
def initialize(options = {})
super(options)
self.client = options.fetch(:client) do
require 'dalli'
::Dalli::Client.new(options[:host], options)
end
end
protected
def lock(key, t... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/locks/base.rb | lib/circuitry/locks/base.rb | module Circuitry
module Locks
module Base
DEFAULT_SOFT_TTL = (5 * 60).freeze # 5 minutes
DEFAULT_HARD_TTL = (24 * 60 * 60).freeze # 24 hours
attr_reader :soft_ttl, :hard_ttl
def initialize(options = {})
self.soft_ttl = options.fetch(:soft_ttl, DEFAULT_SOFT_TTL)
se... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/config/file_loader.rb | lib/circuitry/config/file_loader.rb | require 'yaml'
require 'erb'
require 'fileutils'
module Circuitry
module Config
module FileLoader
def self.load(cfile, environment = 'development')
return nil unless File.exist?(cfile)
opts = {}
opts = YAML.load(ERB.new(IO.read(cfile)).result) || opts
opts = opts.merge(opts... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/config/shared_settings.rb | lib/circuitry/config/shared_settings.rb | require 'logger'
module Circuitry
class ConfigError < StandardError; end
module Config
module SharedSettings
def self.included(base)
base.attribute :access_key, String
base.attribute :secret_key, String
base.attribute :region, String, default: 'us-east-1'
base.attribute :... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/config/publisher_settings.rb | lib/circuitry/config/publisher_settings.rb | require 'virtus'
require 'circuitry/config/shared_settings'
module Circuitry
module Config
class PublisherSettings
include Virtus::Model
include SharedSettings
def async_strategy=(value)
validate_setting(value, Publisher.async_strategies)
super
end
end
end
end
| ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/config/subscriber_settings.rb | lib/circuitry/config/subscriber_settings.rb | require 'virtus'
require 'circuitry/config/shared_settings'
module Circuitry
module Config
class SubscriberSettings
include Virtus::Model
include SharedSettings
attribute :queue_name, String
attribute :dead_letter_queue_name, String
attribute :visibility_timeout, Integer, default: ... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/processors/forker.rb | lib/circuitry/processors/forker.rb | require 'circuitry/processor'
module Circuitry
module Processors
module Forker
class << self
include Processor
def process(&block)
pid = fork do
safely_process(&block)
on_exit.call if on_exit
end
Process.detach(pid)
end
... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/processors/batcher.rb | lib/circuitry/processors/batcher.rb | require 'circuitry/processor'
module Circuitry
module Processors
module Batcher
class << self
include Processor
def process(&block)
raise ArgumentError, 'no block given' unless block_given?
pool << block
end
def flush
while (block = pool.shift... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
kapost/circuitry | https://github.com/kapost/circuitry/blob/d49325462ab43c98af6af18c98dbfa609fba1851/lib/circuitry/processors/threader.rb | lib/circuitry/processors/threader.rb | require 'circuitry/processor'
module Circuitry
module Processors
module Threader
class << self
include Processor
def process(&block)
raise ArgumentError, 'no block given' unless block_given?
pool << Thread.new do
safely_process(&block)
on_exit.c... | ruby | MIT | d49325462ab43c98af6af18c98dbfa609fba1851 | 2026-01-04T17:44:26.741626Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/error_class_spec.rb | spec/error_class_spec.rb | require 'spec_helper'
describe Contentful::Error do
let(:r) { Contentful::Response.new raw_fixture('not_found', 404) }
describe '#response' do
it 'returns the response the error has been initialized with' do
expect(Contentful::Error.new(r).response).to be r
end
end
describe '#message' do
it... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/file_spec.rb | spec/file_spec.rb | require 'spec_helper'
describe Contentful::File do
let(:file) { vcr('asset') { create_client.asset('nyancat').file } }
describe 'Properties' do
it 'has #file_name' do
expect(file.file_name).to eq 'Nyan_cat_250px_frame.png'
end
it 'has #content_type' do
expect(file.content_type).to eq 'ima... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/deleted_asset_spec.rb | spec/deleted_asset_spec.rb | require 'spec_helper'
describe 'DeletedAsset' do
let(:deleted_asset)do
vcr('sync_deleted_asset')do
create_client.sync(initial: true, type: 'DeletedAsset').first_page.items[0]
end
end
describe 'SystemProperties' do
it 'has a #sys getter returning a hash with symbol keys' do
expect(deleted... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/response_spec.rb | spec/response_spec.rb | require 'spec_helper'
describe Contentful::Response do
let(:successful_response) { Contentful::Response.new raw_fixture('nyancat'), Contentful::Request.new(nil, '/entries', nil, 'nyancat') }
let(:error_response) { Contentful::Response.new raw_fixture('not_found', 404) }
let(:unparsable_response) { Contentful::Re... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/request_spec.rb | spec/request_spec.rb | require 'spec_helper'
describe Contentful::Request do
describe '#get' do
it 'calls client' do
client = create_client
request = Contentful::Request.new(client, '/content_types', nil, 'nyancat')
expect(client).to receive(:get).with(request)
request.get
end
end
describe '#query' d... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/client_class_spec.rb | spec/client_class_spec.rb | require 'spec_helper'
describe Contentful::Client do
describe '#get' do
let(:client) { create_client() }
let(:proxy_client) { create_client(proxy_host: '183.207.232.194',
proxy_port: 8080,
secure: false) }
let(:timeout_client) ... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/entry_spec.rb | spec/entry_spec.rb | require 'spec_helper'
describe Contentful::Entry do
let(:entry) { vcr('entry') { create_client.entry 'nyancat' } }
let(:subclass) do
Class.new(described_class) do
# An overridden sys method:
def created_at; 'yesterday'; end
# An overridden field method:
def best_friend; 'octocat'; end... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/space_spec.rb | spec/space_spec.rb | require 'spec_helper'
describe Contentful::Space do
let(:space) { vcr('space') { create_client.space } }
describe 'SystemProperties' do
it 'has a #sys getter returning a hash with symbol keys' do
expect(space.sys).to be_a Hash
expect(space.sys.keys.sample).to be_a Symbol
end
it 'has #id' ... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/array_spec.rb | spec/array_spec.rb | require 'spec_helper'
class CustomClass < Contentful::Entry; end
describe Contentful::Array do
let(:client) { create_client }
let(:array) { vcr('array') { client.content_types } }
describe 'SystemProperties' do
it 'has a #sys getter returning a hash with symbol keys' do
expect(array.sys).to be_a Hash... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/resource_building_spec.rb | spec/resource_building_spec.rb | require 'spec_helper'
describe 'Resource Building Examples' do
it 'can deal with arrays' do
request = Contentful::Request.new(nil, 'entries')
response = Contentful::Response.new(raw_fixture('link_array'), request)
resource = Contentful::ResourceBuilder.new(response.object).run
expect(resource.fields... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/field_spec.rb | spec/field_spec.rb | require 'spec_helper'
describe Contentful::Field do
let(:field) { vcr('field') { create_client.content_type('cat').fields.first } }
let(:linkField) { vcr('linkField') {
create_client.content_type('cat').fields.select { |f| f.id == 'image' }.first
} }
let(:arrayField) { vcr('arrayField') {
Contentful::C... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/taxonomy_concept_spec.rb | spec/taxonomy_concept_spec.rb | require 'spec_helper'
describe Contentful::TaxonomyConcept do
let(:client) { create_client }
let(:taxonomy_concept) { vcr('taxonomy_concept') { client.taxonomy_concept('5iRG7dAusVFUOh9SrexDqQ') } }
describe 'Client method' do
it 'can be retrieved via client.taxonomy_concept' do
expect(taxonomy_concept... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/locale_spec.rb | spec/locale_spec.rb | require 'spec_helper'
describe Contentful::Locale do
let(:locale) { vcr('locale') { create_client.space.locales.first } }
describe 'Properties' do
it 'has #code' do
expect(locale.code).to eq 'en-US'
end
it 'has #name' do
expect(locale.name).to eq 'English'
end
it 'has #default' d... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/sync_page_spec.rb | spec/sync_page_spec.rb | require 'spec_helper'
describe Contentful::SyncPage do
let(:page_with_more) { vcr('sync_page') { create_client.sync(initial: true).first_page } }
let(:page) { vcr('sync_page_2') { create_client.sync.get('https://cdn.contentful.com/spaces/cfexampleapi/environments/master/sync?sync_token=w5ZGw6JFwqZmVcKsE8Kow4grw45Q... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/error_requests_spec.rb | spec/error_requests_spec.rb | require 'spec_helper'
class NonCachingClient < Contentful::Client
def request_headers
headers = super
headers['Cf-No-Cache'] = 'foobar'
headers
end
end
class RetryLoggerMock < Logger
attr_reader :retry_attempts
def initialize(*)
super
@retry_attempts = 0
end
def info(message)
sup... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/deleted_entry_spec.rb | spec/deleted_entry_spec.rb | require 'spec_helper'
describe 'DeletedEntry' do
let(:deleted_entry)do
vcr('sync_deleted_entry')do
create_client.sync(initial: true, type: 'DeletedEntry').first_page.items[0]
end
end
describe 'SystemProperties' do
it 'has a #sys getter returning a hash with symbol keys' do
expect(deleted... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/includes_spec.rb | spec/includes_spec.rb | require 'spec_helper'
describe Contentful::Includes do
let(:example_json) { json_fixture('includes') }
# This is the expected transformation of the JSON above
let(:example_array) { [{"sys"=>{"space"=>{"sys"=>{"type"=>"Link", "linkType"=>"Space", "id"=>"6yahkaf5ehkk"}}, "type"=>"Entry", "contentType"=>{"sys"=>{"... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/location_spec.rb | spec/location_spec.rb | require 'spec_helper'
describe Contentful::Location do
let(:location)do
vcr('location')do
Contentful::Client.new(
space: 'lzjz8hygvfgu',
access_token: '0c6ef483524b5e46b3bafda1bf355f38f5f40b4830f7599f790a410860c7c271',
dynamic_entries: :auto,
).entry('3f6fq5ylFCi4kIYAQKsAYG').... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/link_spec.rb | spec/link_spec.rb | require 'spec_helper'
describe Contentful::Link do
let(:client) { create_client }
let(:entry) { vcr('entry') { create_client.entry('nyancat') } }
let(:link) { entry.space }
let(:content_type_link) { entry.content_type }
describe 'SystemProperties' do
it 'has a #sys getter returning a hash with symbol ke... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/auto_includes_spec.rb | spec/auto_includes_spec.rb | require 'spec_helper'
describe 'Auto-include resources' do
let(:entries) { vcr('entries') { create_client.entries } } # entries come with asset includes
it 'replaces Contentful::Links which are actually included with the resource' do
asset = entries.items[1].fields[:image]
expect(asset).not_to be_a Conte... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/client_configuration_spec.rb | spec/client_configuration_spec.rb | require 'spec_helper'
describe 'Client Configuration Options' do
describe ':space' do
it 'is required' do
expect do
Contentful::Client.new(access_token: 'b4c0n73n7fu1')
end.to raise_error(ArgumentError)
end
end
describe ':access_token' do
it 'is required' do
expect do
... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/taxonomy_concept_scheme_spec.rb | spec/taxonomy_concept_scheme_spec.rb | require 'spec_helper'
describe Contentful::TaxonomyConceptScheme do
let(:client) { create_client }
let(:taxonomy_concept_scheme) { vcr('taxonomy_concept_scheme') { client.taxonomy_concept_scheme('4EQT881T6sG9XpzNwb9y9R') } }
describe 'Client method' do
it 'can be retrieved via client.taxonomy_concept_scheme... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/sync_spec.rb | spec/sync_spec.rb | require 'spec_helper'
describe Contentful::Sync do
before :each do
Contentful::ContentTypeCache.clear!
end
let(:first_page) do
vcr('sync_page')do
create_client.sync(initial: true).first_page
end
end
let(:last_page) do
vcr('sync_page')do
vcr('sync_page_2')do
create_client... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/content_type_spec.rb | spec/content_type_spec.rb | require 'spec_helper'
describe Contentful::ContentType do
let(:content_type) { vcr('content_type') { create_client.content_type 'cat' } }
describe 'SystemProperties' do
it 'has a #sys getter returning a hash with symbol keys' do
expect(content_type.sys).to be_a Hash
expect(content_type.sys.keys.sa... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/spec_helper.rb | spec/spec_helper.rb | require 'simplecov'
SimpleCov.start
require 'rspec'
require 'contentful'
require 'securerandom'
require 'rr'
Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each { |f| require f }
RSpec.configure do |config|
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
end
| ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/asset_spec.rb | spec/asset_spec.rb | require 'spec_helper'
describe Contentful::Asset do
let(:asset) { vcr('asset') { create_client.asset('nyancat') } }
describe 'SystemProperties' do
it 'has a #sys getter returning a hash with symbol keys' do
expect(asset.sys).to be_a Hash
expect(asset.sys.keys.sample).to be_a Symbol
end
it... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/support/json_responses.rb | spec/support/json_responses.rb | require 'multi_json'
def raw_fixture(which, status = 200, _as_json = false, headers = {})
object = Object.new
allow(object).to receive(:status) { status }
allow(object).to receive(:headers) { headers }
allow(object).to receive(:to_s) { File.read File.dirname(__FILE__) + "/../fixtures/json_responses/#{which}.js... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/support/vcr.rb | spec/support/vcr.rb | require 'vcr'
VCR.configure do |c|
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
c.ignore_localhost = true
c.hook_into :webmock
c.default_cassette_options = { record: :once }
end
def vcr(name, &block)
VCR.use_cassette(name, &block)
end
def expect_vcr(name, &block)
expect { VCR.use_cassette(name,... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/spec/support/client.rb | spec/support/client.rb | def create_client(options = {})
Contentful::Client.new({
space: 'cfexampleapi',
access_token: 'b4c0n73n7fu1',
}.merge(options))
end
| ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/examples/custom_classes.rb | examples/custom_classes.rb | require 'contentful'
# You can define your own custom classes that inherit from Contentful::Entry.
# This allows you to define custom behaviour, for example, in this case, we want
# the :country field to act as a Contentful::Locale
class MyResource < Contentful::Entry
def country(locale = nil)
@country ||= Conte... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/examples/raise_errors.rb | examples/raise_errors.rb | require 'contentful'
client = Contentful::Client.new(
space: 'cfexampleapi',
access_token: 'b4c0n73n7fu1',
)
begin
p client.asset 'not found'
rescue => error
p error
end
client2 = Contentful::Client.new(
space: 'cfexampleapi',
access_token: 'b4c0n73n7fu1',
raise_errors: false,
)
p client2.asset 'not f... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/examples/example_queries.rb | examples/example_queries.rb | require 'contentful'
client = Contentful::Client.new(
space: 'cfexampleapi',
access_token: 'b4c0n73n7fu1',
)
p client.space
p client.content_types
p client.entry 'nyancat', locale: 'tlh'
p client.entries(
'content_type' => 'cat',
'fields.likes' => 'lasagna',
)
p client.entries(
query: 'bacon',
)
p cli... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/examples/raw_mode.rb | examples/raw_mode.rb | require 'contentful'
client = Contentful::Client.new(
space: 'cfexampleapi',
access_token: 'b4c0n73n7fu1',
raw_mode: true,
)
entry = client.entry 'nyancat'
p entry.is_a? Contentful::Resource # false
p entry.is_a? Contentful::Response # true
p entry.status
p entry
puts entry.raw
| ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful.rb | lib/contentful.rb | require 'contentful/version'
require 'contentful/support'
require 'contentful/client'
| ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/entry.rb | lib/contentful/entry.rb | require_relative 'error'
require_relative 'fields_resource'
require_relative 'content_type_cache'
require_relative 'resource_references'
require_relative 'includes'
module Contentful
# Resource class for Entry.
# @see _ https://www.contentful.com/developers/documentation/content-delivery-api/#entries
class Entry... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/version.rb | lib/contentful/version.rb | # Contentful Namespace
module Contentful
# Gem Version
VERSION = '2.19.0'
end
| ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/content_type.rb | lib/contentful/content_type.rb | require_relative 'base_resource'
require_relative 'field'
require_relative 'support'
module Contentful
# Resource Class for Content Types
# https://www.contentful.com/developers/documentation/content-delivery-api/#content-types
class ContentType < BaseResource
attr_reader :name, :description, :fields, :displ... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/resource_builder.rb | lib/contentful/resource_builder.rb | require_relative 'error'
require_relative 'space'
require_relative 'content_type'
require_relative 'entry'
require_relative 'asset'
require_relative 'array'
require_relative 'link'
require_relative 'deleted_entry'
require_relative 'deleted_asset'
require_relative 'locale'
require_relative 'includes'
require_relative 't... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/array_like.rb | lib/contentful/array_like.rb | # frozen_string_literal: true
module Contentful
# Useful methods for array-like resources that can be included if an
# :items property exists
module ArrayLike
include Enumerable
# Returns true for array-like resources
#
# @return [true]
def array?
true
end
# Delegates to items... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/deleted_entry.rb | lib/contentful/deleted_entry.rb | require_relative 'base_resource'
module Contentful
# Resource class for deleted entries
# https://www.contentful.com/developers/documentation/content-delivery-api/http/#sync-item-types
class DeletedEntry < BaseResource; end
end
| ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/base_resource.rb | lib/contentful/base_resource.rb | # frozen_string_literal: true
require_relative 'support'
module Contentful
# Base definition of a Contentful Resource containing Sys properties
class BaseResource
attr_reader :raw, :default_locale, :sys, :_metadata
# rubocop:disable Metrics/ParameterLists
def initialize(item, configuration = {}, _loc... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/sync.rb | lib/contentful/sync.rb | require_relative 'resource_builder'
require_relative 'deleted_entry'
require_relative 'deleted_asset'
require_relative 'sync_page'
module Contentful
# Resource class for Sync.
# @see _ https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/synchronization
class Sync
attr_reade... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/content_type_cache.rb | lib/contentful/content_type_cache.rb | module Contentful
# Cache for Content Types
class ContentTypeCache
@cache = {}
class << self
attr_reader :cache
end
# Clears the Content Type Cache
def self.clear!
@cache = {}
end
# Gets a Content Type from the Cache
def self.cache_get(space_id, content_type_id)
... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/coercions.rb | lib/contentful/coercions.rb | require_relative 'location'
require_relative 'link'
module Contentful
# Basic Coercion
class BaseCoercion
attr_reader :value, :options
def initialize(value, options = {})
@value = value
@options = options
end
# Coerces value
def coerce(*)
value
end
end
# Coercion for... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/field.rb | lib/contentful/field.rb | require_relative 'location'
require_relative 'coercions'
module Contentful
# A ContentType's field schema
# See https://www.contentful.com/developers/documentation/content-management-api/#resources-content-types-fields
class Field
# Coercions from Contentful Types to Ruby native types
KNOWN_TYPES = {
... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/array.rb | lib/contentful/array.rb | require_relative 'base_resource'
require_relative 'array_like'
require_relative 'includes'
module Contentful
# Resource Class for Arrays (e.g. search results)
# @see _ https://www.contentful.com/developers/documentation/content-delivery-api/#arrays
# @note It also provides an #each method and includes Ruby's Enu... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/file.rb | lib/contentful/file.rb | module Contentful
# An Assets's file info
class File
def initialize(json, configuration)
@configuration = configuration
define_fields!(json)
end
private
def define_fields!(json)
json.each do |k, v|
define_singleton_method Support.snakify(k, @configuration[:use_camel_case... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/response.rb | lib/contentful/response.rb | require_relative 'error'
require 'multi_json'
require 'zlib'
module Contentful
# An object representing an answer by the contentful service. It is later used
# to build a Resource, which is done by the ResourceBuilder.
#
# The Response parses the http response (as returned by the underlying http library) to
... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/taxonomy_concept.rb | lib/contentful/taxonomy_concept.rb | require_relative 'base_resource'
module Contentful
# Resource class for TaxonomyConcept.
# @see _ https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/taxonomy/concept
class TaxonomyConcept < BaseResource
attr_reader :uri, :notations, :broader, :related, :concept_schemes
... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/location.rb | lib/contentful/location.rb | module Contentful
# Location Field Type
# You can directly query for them: https://www.contentful.com/developers/documentation/content-delivery-api/#search-filter-geo
class Location
attr_reader :lat, :lon
alias latitude lat
alias longitude lon
def initialize(json)
@lat = json.fetch('lat', n... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/link.rb | lib/contentful/link.rb | require_relative 'base_resource'
module Contentful
# Resource Class for Links
# https://www.contentful.com/developers/documentation/content-delivery-api/#links
class Link < BaseResource
# Queries contentful for the Resource the Link is refering to
# Takes an optional query hash
def resolve(client, qu... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/taxonomy_concept_scheme.rb | lib/contentful/taxonomy_concept_scheme.rb | require_relative 'base_resource'
module Contentful
# Resource class for TaxonomyConceptScheme.
# @see _ https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/taxonomy/concept-scheme
class TaxonomyConceptScheme < BaseResource
attr_reader :uri, :top_concepts, :concepts, :total_... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/locale.rb | lib/contentful/locale.rb | require_relative 'base_resource'
module Contentful
# A Locale definition as included in Space
# Read more about Localization at https://www.contentful.com/developers/documentation/content-delivery-api/#i18n
class Locale < BaseResource
attr_reader :code, :name, :default, :fallback_code
def initialize(ite... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/resource_references.rb | lib/contentful/resource_references.rb | module Contentful
# Method to retrieve references (incoming links) for a given entry or asset
module ResourceReferences
# Gets a collection of entries which links to current entry
#
# @param [Contentful::Client] client
# @param [Hash] query
#
# @return [Contentful::Array<Contentful::Entry>, ... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/client.rb | lib/contentful/client.rb | require_relative 'request'
require_relative 'response'
require_relative 'resource_builder'
require_relative 'sync'
require_relative 'content_type_cache'
require 'http'
require 'logger'
require 'rbconfig'
module Contentful
# The client object is initialized with a space and a key and then used
# for querying resou... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/request.rb | lib/contentful/request.rb | module Contentful
# This object represents a request that is to be made. It gets initialized by the client
# with domain specific logic. The client later uses the Request's #url and #query methods
# to execute the HTTP request.
class Request
attr_reader :client, :type, :query, :id, :endpoint
def initia... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/includes.rb | lib/contentful/includes.rb | require_relative 'array_like'
module Contentful
# The includes hashes returned when include_level is specified
class Includes
include ArrayLike
attr_accessor :items, :lookup
def initialize(items = [], lookup = nil)
self.items = items
self.lookup = lookup || build_lookup
end
def s... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/fields_resource.rb | lib/contentful/fields_resource.rb | # frozen_string_literal: true
require_relative 'support'
require_relative 'base_resource'
require_relative 'includes'
module Contentful
# Base definition of a Contentful Resource containing Field properties
class FieldsResource < BaseResource
attr_reader :localized
# rubocop:disable Metrics/ParameterList... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/space.rb | lib/contentful/space.rb | require_relative 'base_resource'
require_relative 'locale'
module Contentful
# Resource class for Space.
# https://www.contentful.com/developers/documentation/content-delivery-api/#spaces
class Space < BaseResource
attr_reader :name, :locales
def initialize(item, *)
super
@name = item.fetch... | ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
contentful/contentful.rb | https://github.com/contentful/contentful.rb/blob/7e62f9e1accd70f9b5e01892cc42015015a92ee0/lib/contentful/deleted_asset.rb | lib/contentful/deleted_asset.rb | require_relative 'base_resource'
module Contentful
# Resource class for deleted entries
# https://www.contentful.com/developers/documentation/content-delivery-api/http/#sync-item-types
class DeletedAsset < BaseResource; end
end
| ruby | MIT | 7e62f9e1accd70f9b5e01892cc42015015a92ee0 | 2026-01-04T17:44:22.911350Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.