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 | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch_spec.rb | Ruby | mit | 223 | main | 2,694 | # frozen_string_literal: true
RSpec.describe Meilisearch do
it 'has a version number' do
expect(Meilisearch::VERSION).not_to be_nil
end
it 'has a qualified version number' do
expect(described_class.qualified_version).to eq("Meilisearch Ruby (v#{Meilisearch::VERSION})")
end
it 'raises an exception w... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/support/default_shared_context.rb | Ruby | mit | 223 | main | 552 | # frozen_string_literal: true
RSpec.shared_context 'test defaults' do
let(:client) { Meilisearch::Client.new(URL, MASTER_KEY, { timeout: 2, max_retries: 1 }) }
before do
clear_all_indexes(client)
clear_all_keys(client)
end
def random_uid
SecureRandom.hex(4)
end
def snake_case_word(camel_case... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/support/books_contexts.rb | Ruby | mit | 223 | main | 3,989 | # frozen_string_literal: true
RSpec.shared_context 'search books with genre' do
let(:index) { client.index('books') }
let(:documents) do
[
{ objectId: 123, title: 'Pride and Prejudice', genre: 'romance' },
{ objectId: 456, title: 'Le Petit Prince', genr... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/support/indexes_helpers.rb | Ruby | mit | 223 | main | 227 | # frozen_string_literal: true
module IndexesHelpers
def clear_all_indexes(client)
indexes = client.indexes
uids = indexes['results'].map(&:uid)
uids.each do |uid|
client.delete_index(uid)
end
end
end |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/support/exceptions_helpers.rb | Ruby | mit | 223 | main | 992 | # frozen_string_literal: true
module ExceptionsHelpers
def raise_meilisearch_api_error_with(http_code, ms_code, ms_type)
raise_exception(an_instance_of(Meilisearch::ApiError)
.and(having_attributes(
http_code: http_code,
ms_code: ms_code,
ms_type: ms_type
)... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/support/experimental_feature_helpers.rb | Ruby | mit | 223 | main | 876 | # frozen_string_literal: true
require 'net/http'
require 'json'
module ExperimentalFeatureHelpers
def enable_edit_documents_by_function(toggle)
configure_feature('editDocumentsByFunction', toggle)
end
def enable_composite_embedders(toggle)
configure_feature('compositeEmbedders', toggle)
end
privat... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/utils_spec.rb | Ruby | mit | 223 | main | 6,034 | # frozen_string_literal: true
RSpec.describe Meilisearch::Utils do
let(:logger) { instance_double(Logger, warn: nil) }
describe '.soft_deprecate' do
before { described_class.logger = logger }
after { described_class.logger = nil }
it 'outputs a warning' do
described_class.soft_deprecate('footba... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/models/task_spec.rb | Ruby | mit | 223 | main | 14,957 | # frozen_string_literal: true
describe Meilisearch::Models::Task do
subject { described_class.new task_hash, endpoint }
let(:new_index_uid) { random_uid }
let(:task_hash) { client.http_post '/indexes', { 'uid' => new_index_uid } }
let(:endpoint) { Meilisearch::Task.new(URL, MASTER_KEY, client.options) }
le... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/client/batches_spec.rb | Ruby | mit | 223 | main | 1,959 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Client - Batches' do
let(:index) { client.index(random_uid) }
def new_task
index.add_documents({ id: 1 })
end
describe '#batches' do
it 'includes the most recent batch' do
new_task.await
expect(client.batches).to match(
'... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/client/indexes_spec.rb | Ruby | mit | 223 | main | 10,820 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Client - Indexes' do
describe '#create_index' do
context 'without a primary key' do
it 'creates an index' do
task = client.create_index('books')
expect(task.type).to eq('indexCreation')
task.await
index = client.fet... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/client/health_spec.rb | Ruby | mit | 223 | main | 554 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Client - Health' do
let(:client) { Meilisearch::Client.new(URL, MASTER_KEY) }
let(:wrong_client) { Meilisearch::Client.new('bad_url') }
it 'is healthy when the url is valid' do
expect(client.healthy?).to be true
end
it 'is unhealthy when ... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/client/snapshots_spec.rb | Ruby | mit | 223 | main | 394 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Client - Snapshots' do
it 'creates a new snapshot' do
response = client.create_snapshot
expect(response).to be_a(Hash)
expect(response['taskUid']).to_not be_nil
expect(response['status']).to_not be_nil
expect(response['status']).to eq('en... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/client/experimental_features_spec.rb | Ruby | mit | 223 | main | 1,890 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Client - Experimental features' do
describe '#experimental_features' do
it 'returns the available experimental features' do
expect(client.experimental_features).to be_kind_of(Hash)
end
end
context '#update_experimental_features' do
con... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/client/keys_spec.rb | Ruby | mit | 223 | main | 3,908 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Client - Keys' do
context 'When managing keys' do
let(:uuid_v4) { 'c483e150-cff1-4a45-ac26-bb8eb8e01d36' }
let(:delete_docs_key_options) do
{
description: 'A new key to delete docs',
actions: ['documents.delete'],
indexe... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/client/tasks_spec.rb | Ruby | mit | 223 | main | 7,703 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Tasks' do
include_context 'search books with genre'
let(:enqueued_task_keys) { ['uid', 'indexUid', 'status', 'type', 'enqueuedAt'] }
let(:succeeded_task_keys) { [*enqueued_task_keys, 'duration', 'startedAt', 'finishedAt'] }
let!(:doc_addition_task) { ... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/client/requests_spec.rb | Ruby | mit | 223 | main | 539 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Client requests' do
let(:key) { SecureRandom.uuid }
before do
expect(Meilisearch::Client).to receive(:post)
.with(kind_of(String), hash_including(body: "{\"primaryKey\":\"#{key}\",\"uid\":\"#{key}\"}"))
.and_call_original
end
it 'pars... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/client/errors_spec.rb | Ruby | mit | 223 | main | 2,128 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Client - Errors' do
describe 'Meilisearch::Error' do
it 'catches all other errors' do
expect(Meilisearch::TimeoutError.ancestors).to include(Meilisearch::Error)
expect(Meilisearch::CommunicationError.ancestors).to include(Meilisearch::Error)
... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/client/stats_spec.rb | Ruby | mit | 223 | main | 422 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Client - Stats' do
it 'gets version' do
response = client.version
expect(response).to be_a(Hash)
expect(response).to have_key('commitSha')
expect(response).to have_key('commitDate')
expect(response).to have_key('pkgVersion')
end
it '... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/client/multi_search_spec.rb | Ruby | mit | 223 | main | 2,863 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Client - Multiple Index Search' do
before do
client.create_index('books')
client.create_index('movies').await
end
it 'does a custom search with two different indexes' do
response = client.multi_search(queries: [
... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/client/token_spec.rb | Ruby | mit | 223 | main | 5,159 | # frozen_string_literal: true
require 'jwt'
VERIFY_OPTIONS = {
required_claims: ['exp', 'apiKeyUid', 'searchRules'],
algorithm: 'HS256'
}.freeze
RSpec.describe Meilisearch::TenantToken do
let(:instance) { dummy_class.new(client_key) }
let(:dummy_class) do
Class.new do
include Meilisearch::TenantTok... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/documents_spec.rb | Ruby | mit | 223 | main | 31,383 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Documents' do
let(:index) { client.index(random_uid) }
context 'All basic tests with primary-key inference' do
let(:documents) do
[
{ objectId: 123, title: 'Pride and Prejudice', comment: 'A great book' },
... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/base_spec.rb | Ruby | mit | 223 | main | 7,236 | # frozen_string_literal: true
RSpec.describe Meilisearch::Index do
it 'fetch the info of the index' do
client.create_index('books').await
index = client.fetch_index('books')
expect(index).to be_a(described_class)
expect(index.uid).to eq('books')
expect(index.created_at).to be_a(Time)
expect(... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/stats_spec.rb | Ruby | mit | 223 | main | 607 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Stats' do
include_context 'search books with genre'
it 'returns stats of the index' do
response = index.stats
expect(response).to be_a(Hash)
expect(response).not_to be_empty
end
it 'gets the number of documents' do
response = ... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/rename_spec.rb | Ruby | mit | 223 | main | 3,582 | # frozen_string_literal: true
RSpec.describe Meilisearch::Index, '- Rename' do
it 'renames an existing index' do
client.create_index('uid').await
index = client.fetch_index('uid')
task = client.index('uid').update(uid: 'uid_renamed')
expect(task.type).to eq('indexUpdate')
task.await
renamed... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/compact_spec.rb | Ruby | mit | 223 | main | 307 | # frozen_string_literal: true
RSpec.describe Meilisearch::Index, '- Compact' do
it 'runs index compaction task' do
client.create_index('uid').await
task = client.fetch_index('uid').compact
expect(task.type).to eq('indexCompaction')
task.await
expect(task).to be_succeeded
end
end |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/settings_spec.rb | Ruby | mit | 223 | main | 28,920 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Settings' do
let(:default_ranking_rules) do
[
'words',
'typo',
'proximity',
'attributeRank',
'sort',
'wordPosition',
'exactness'
]
end
let(:default_searchable_attributes) { ['*'] }
let(:default_... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/sort_spec.rb | Ruby | mit | 223 | main | 1,523 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Sorted search' do
include_context 'search books with author, genre, year'
before do
sortable_update = index.update_sortable_attributes(['year', 'author'])
index.update_ranking_rules([
'sort',
... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/ranking_score_threshold_spec.rb | Ruby | mit | 223 | main | 496 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Search with rankingScoreThreshold' do
include_context 'search books with genre'
it 'does a custom search with rankingScoreThreshold' do
response = index.search('harry potter and the prisoner of azkaban', { rankingScoreThreshold: 0.9 })
exp... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/attributes_to_retrieve_spec.rb | Ruby | mit | 223 | main | 2,995 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Search with attributes to retrieve' do
include_context 'search books with genre'
it 'does a custom search with one attributes_to_retrieve' do
response = index.search('the', attributes_to_retrieve: ['title'])
expect(response).to be_a(Hash)
... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/vector_search_spec.rb | Ruby | mit | 223 | main | 2,108 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Vector search' do
let!(:documents) do
[
{ objectId: 0, _vectors: { custom: [0, 0.8, -0.2] }, title: 'Across The Universe' },
{ objectId: 1, _vectors: { custom: [1, -0.2, 0] }, title: 'All Things Must Pass' },
{ objectId: 2, _vec... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/offset_spec.rb | Ruby | mit | 223 | main | 1,085 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Search with offset' do
include_context 'search books with genre'
it 'does a custom search with an offset set to 1' do
response = index.search('prince')
response_with_offset = index.search('prince', offset: 1)
expect(response['hits'][1]... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/multi_params_spec.rb | Ruby | mit | 223 | main | 3,518 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Multi-paramaters search' do
include_context 'search books with genre'
before { index.update_filterable_attributes(['genre']).await }
it 'does a custom search with attributes to crop, filter and attributes to highlight' do
response = index.s... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/filter_spec.rb | Ruby | mit | 223 | main | 2,340 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Filtered search' do
include_context 'search books with author, genre, year'
before { index.update_filterable_attributes(['genre', 'year', 'author']).await }
it 'does a custom search with one filter' do
response = index.search('le', { filter... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/similar_spec.rb | Ruby | mit | 223 | main | 1,303 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Search for similar documents' do
let(:new_index) { client.index('similar_test_search') }
before do
client.create_index('similar_test_search').await
end
it 'requires document_id parameter' do
expect { new_index.search_similar_documents... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/matching_strategy_spec.rb | Ruby | mit | 223 | main | 727 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Search with matching_strategy' do
include_context 'search books with nested fields'
it 'does a custom search with a matching strategy ALL' do
response = index.search('best book again', matching_strategy: 'all')
expect(response['hits'].cou... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/facets_distribution_spec.rb | Ruby | mit | 223 | main | 2,396 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Search with facets' do
include_context 'search books with author, genre, year'
before do
index.update_filterable_attributes(['genre', 'year', 'author']).await
end
it 'does a custom search with facets' do
response = index.search('prine... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/attributes_to_crop_spec.rb | Ruby | mit | 223 | main | 2,356 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Cropped search' do
let(:index) { client.index('books') }
let(:document) do
{
objectId: 42,
title: 'The Hitchhiker\'s Guide to the Galaxy',
description: 'The Hitchhiker\'s Guide to the Galaxy is a comedy science fiction series ... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/distinct_spec.rb | Ruby | mit | 223 | main | 510 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Distinct search' do
include_context 'search books with genre'
before do
index.update_filterable_attributes(['genre']).await
end
it 'does a search without distinct' do
response = index.search('harry potter')
expect(response['hits']... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/matches_spec.rb | Ruby | mit | 223 | main | 824 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Search with showMatchesPosition' do
include_context 'search books with genre'
it 'does a custom search with showMatchesPosition' do
response = index.search('the', show_matches_position: true)
expect(response).to be_a(Hash)
expect(respo... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/show_ranking_score_details_spec.rb | Ruby | mit | 223 | main | 546 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Search with ranking score details' do
include_context 'search books with genre'
it 'shows the ranking score details' do
response = index.search('hobbit', { show_ranking_score_details: true })
expect(response['hits'][0]).to have_key('_ranki... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/q_spec.rb | Ruby | mit | 223 | main | 4,643 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Basic search' do
include_context 'search books with genre'
it 'does a basic search in index' do
response = index.search('prince')
expect(response).to be_a(Hash)
expect(response.keys).to include(*DEFAULT_SEARCH_RESPONSE_KEYS)
expect... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/show_ranking_score_spec.rb | Ruby | mit | 223 | main | 729 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Search with ranking score' do
include_context 'search books with genre'
it 'shows the ranking score when showRankingScore is true' do
response = index.search('hobbit', { show_ranking_score: true })
expect(response['hits'][0]).to have_key('... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/facet_search_spec.rb | Ruby | mit | 223 | main | 3,038 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Facet search' do
include_context 'search books with author, genre, year'
before do
response = index.update_filterable_attributes(['genre', 'year', 'author'])
index.wait_for_task(response['taskUid'])
end
it 'requires facet name paramet... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/limit_spec.rb | Ruby | mit | 223 | main | 1,014 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Search with limit' do
include_context 'search books with genre'
it 'does a custom search with limit' do
response = index.search('the', limit: 1)
expect(response).to be_a(Hash)
expect(response.keys).to include(*DEFAULT_SEARCH_RESPONSE_K... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/nested_fields_spec.rb | Ruby | mit | 223 | main | 1,352 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - nested fields search' do
include_context 'search books with nested fields'
it 'searches without params' do
response = index.search('an awesome')
expect(response['hits'].count).to eq(1)
expect(response.dig('hits', 0, 'info', 'comment')... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | spec/meilisearch/index/search/attributes_to_highlight_spec.rb | Ruby | mit | 223 | main | 1,270 | # frozen_string_literal: true
RSpec.describe 'Meilisearch::Index - Search with highlight' do
include_context 'search books with genre'
it 'does a custom search with highlight' do
response = index.search('the', attributes_to_highlight: ['title'])
expect(response).to be_a(Hash)
expect(response.keys).to ... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | lib/meilisearch.rb | Ruby | mit | 223 | main | 1,203 | # frozen_string_literal: true
require 'json'
require 'meilisearch/version'
require 'meilisearch/utils'
require 'meilisearch/models/task'
require 'meilisearch/http_request'
require 'meilisearch/multi_search'
require 'meilisearch/tenant_token'
require 'meilisearch/task'
require 'meilisearch/client'
require 'meilisearch... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | lib/meilisearch/http_request.rb | Ruby | mit | 223 | main | 4,831 | # frozen_string_literal: true
require 'httparty'
require 'meilisearch/error'
module Meilisearch
class HTTPRequest
include HTTParty
attr_reader :options, :headers
DEFAULT_OPTIONS = {
timeout: 10,
max_retries: 2,
retry_multiplier: 1.2,
convert_body?: true
}.freeze
def in... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | lib/meilisearch/utils.rb | Ruby | mit | 223 | main | 3,030 | # frozen_string_literal: true
require 'logger'
module Meilisearch
module Utils
SNAKE_CASE = /[^a-zA-Z0-9]+(.)/
class << self
attr_writer :logger
def logger
@logger ||= Logger.new($stdout)
end
def soft_deprecate(subject, replacement)
logger.warn("[meilisearch-ruby] ... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | lib/meilisearch/tenant_token.rb | Ruby | mit | 223 | main | 1,553 | # frozen_string_literal: true
module Meilisearch
module TenantToken
HEADER = {
typ: 'JWT',
alg: 'HS256'
}.freeze
def generate_tenant_token(api_key_uid, search_rules, api_key: nil, expires_at: nil)
signature = retrieve_valid_key!(api_key, @api_key)
expiration = validate_expires_at... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | lib/meilisearch/client.rb | Ruby | mit | 223 | main | 19,445 | # frozen_string_literal: true
module Meilisearch
# Manages a connection to a Meilisearch server.
# client = Meilisearch::Client.new(MEILISEARCH_URL, MASTER_KEY, options)
#
# @see #indexes Managing search indexes
# @see #keys Managing API keys
# @see #stats View usage statistics
# @see #tasks Managing o... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | lib/meilisearch/multi_search.rb | Ruby | mit | 223 | main | 664 | # frozen_string_literal: true
module Meilisearch
module MultiSearch
# Performs search on one or more indexes
#
# @param [Hash] federation_options
# - `limit`: number of results in the merged list
# - `offset`: number of results to skip in the merged list
def multi_search(data = nil, queri... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | lib/meilisearch/error.rb | Ruby | mit | 223 | main | 2,869 | # frozen_string_literal: true
module Meilisearch
class Error < StandardError
end
class ApiError < Error
# :http_code # e.g. 400, 404...
# :http_message # e.g. Bad Request, Not Found...
# :http_body # The response body received from the Meilisearch API
# :ms_code # The error code given... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | lib/meilisearch/index.rb | Ruby | mit | 223 | main | 55,864 | # frozen_string_literal: true
require 'meilisearch/http_request'
module Meilisearch
# Manages a Meilisearch indexes.
# index = client.index(INDEX_UID)
#
# Indexes store documents to be searched.
# @see https://www.meilisearch.com/docs/learn/getting_started/indexes Learn more about indexes
class Index < ... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | lib/meilisearch/task.rb | Ruby | mit | 223 | main | 2,039 | # frozen_string_literal: true
require 'meilisearch/http_request'
require 'timeout'
module Meilisearch
class Task < HTTPRequest
ALLOWED_PARAMS = [
:limit, :from, :index_uids, :types, :statuses, :uids, :canceled_by,
:before_enqueued_at, :after_enqueued_at, :before_started_at, :after_started_at,
... |
github | meilisearch/meilisearch-ruby | https://github.com/meilisearch/meilisearch-ruby | lib/meilisearch/models/task.rb | Ruby | mit | 223 | main | 3,779 | # frozen_string_literal: true
require 'forwardable'
module Meilisearch
module Models
class Task
DEFAULT_TIMEOUT_MS = 5000
DEFAULT_INTERVAL_MS = 50
class << self
attr_writer :default_timeout_ms, :default_interval_ms
def default_timeout_ms
@default_timeout_ms || DEFAU... |
github | RubyMoney/eu_central_bank | https://github.com/RubyMoney/eu_central_bank | eu_central_bank.gemspec | Ruby | mit | 223 | main | 1,340 | #!/bin/env ruby
# frozen_string_literal: true
Gem::Specification.new do |s|
s.name = "eu_central_bank"
# Please also update `eu_central_bank/version.rb`.
#
# We cannot use this constant here because of the `money` dependency when
# inheriting from `Money::Bank::VariableExchange`.
s.version = ... |
github | RubyMoney/eu_central_bank | https://github.com/RubyMoney/eu_central_bank | lib/eu_central_bank.rb | Ruby | mit | 223 | main | 7,060 | require 'open-uri'
require 'nokogiri'
require 'money'
require 'money/rates_store/store_with_historical_data_support'
require 'eu_central_bank/rates_document'
require 'eu_central_bank/version'
class InvalidCache < StandardError ; end
class CurrencyUnavailable < StandardError; end
class EuCentralBank < Money::Bank::Va... |
github | RubyMoney/eu_central_bank | https://github.com/RubyMoney/eu_central_bank | lib/money/rates_store/store_with_historical_data_support.rb | Ruby | mit | 223 | main | 1,770 | module Money::RatesStore
class StoreWithHistoricalDataSupport < Money::RatesStore::Memory
INDEX_DATE_SEPARATOR = '_AT_'.freeze
def add_rate(currency_iso_from, currency_iso_to, rate, date = nil)
transaction { rates[rate_key_for(currency_iso_from, currency_iso_to, date)] = rate }
end
def get_rat... |
github | RubyMoney/eu_central_bank | https://github.com/RubyMoney/eu_central_bank | lib/eu_central_bank/rates_document.rb | Ruby | mit | 223 | main | 1,201 | class EuCentralBank < Money::Bank::VariableExchange
class RatesDocument < Nokogiri::XML::SAX::Document
attr_reader :rates
attr_reader :errors
attr_reader :updated_at
def initialize
@rates = {}
@errors = []
@updated_at = nil
@current_date = nil
end
def error(msg)
... |
github | RubyMoney/eu_central_bank | https://github.com/RubyMoney/eu_central_bank | spec/eu_central_bank_spec.rb | Ruby | mit | 223 | main | 12,392 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe EuCentralBank do
before(:each) do
Money.rounding_mode = BigDecimal::ROUND_HALF_UP
@bank = EuCentralBank.new
@dir_path = File.dirname(__FILE__)
@cache_path = File.expand_path(@dir_path + '/exchange_rates.xml')
@history_cac... |
github | RubyMoney/eu_central_bank | https://github.com/RubyMoney/eu_central_bank | spec/spec_helper.rb | Ruby | mit | 223 | main | 397 | require 'eu_central_bank'
require 'yaml'
I18n.enforce_available_locales = false
def load_exchange_rates_from_file(file)
load_exchange_rates(File.open(file))
end
def load_exchange_rates(input)
if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0')
::YAML.safe_load(input, permitted_classes: [ BigDeci... |
github | derekprior/momentjs-rails | https://github.com/derekprior/momentjs-rails | Rakefile | Ruby | mit | 222 | main | 360 | #!/usr/bin/env rake
require 'rake/testtask'
begin
require 'bundler/setup'
require 'bundler/gem_tasks'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verb... |
github | derekprior/momentjs-rails | https://github.com/derekprior/momentjs-rails | momentjs-rails.gemspec | Ruby | mit | 222 | main | 866 | $:.push File.expand_path("../lib", __FILE__)
Gem::Specification.new do |s|
s.name = "momentjs-rails"
s.version = "2.29.4.1"
s.authors = ["Derek Prior"]
s.homepage = "https://github.com/derekprior/momentjs-rails"
s.summary = "The Moment.js JavaScript library ready to play with Rails."
... |
github | derekprior/momentjs-rails | https://github.com/derekprior/momentjs-rails | test/dummy/config/application.rb | Ruby | mit | 222 | main | 2,781 | require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
# require "active_record/railtie"
# require "action_controller/railtie"
require "action_mailer/railtie"
# require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
Bundler.require
require "momentjs-ra... |
github | derekprior/momentjs-rails | https://github.com/derekprior/momentjs-rails | test/dummy/config/environments/production.rb | Ruby | mit | 222 | main | 2,337 | Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_c... |
github | derekprior/momentjs-rails | https://github.com/derekprior/momentjs-rails | test/dummy/config/environments/development.rb | Ruby | mit | 222 | main | 1,099 | Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... |
github | derekprior/momentjs-rails | https://github.com/derekprior/momentjs-rails | test/dummy/config/environments/test.rb | Ruby | mit | 222 | main | 1,420 | Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suit... |
github | derekprior/momentjs-rails | https://github.com/derekprior/momentjs-rails | test/dummy/config/initializers/secret_token.rb | Ruby | mit | 222 | main | 496 | # Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... |
github | derekprior/momentjs-rails | https://github.com/derekprior/momentjs-rails | test/integration/navigation_test.rb | Ruby | mit | 222 | main | 444 | require 'test_helper'
class NavigationTest < ActionDispatch::IntegrationTest
test 'can access momentjs' do
get '/assets/moment.js'
assert_response :success
end
test 'momentjs response is for the expected version' do
get '/assets/moment.js'
assert_match(/hooks.version = '2\.29\.4'/, @response.bod... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | readygo.rb | Ruby | mit | 222 | master | 1,536 | require_relative "lib/ready_go"
def ready(name, &block)
ReadyGo.application.add_context(name, &block)
end
module ReadyGo
class << self
attr_reader :application
end
def self.main
@application = Application.new
@application.run
end
class Application
def initialize
@contexts = []
... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | lib/ready_go.rb | Ruby | mit | 222 | master | 771 | require "json"
require "optparse"
require "forwardable"
require_relative "ready_go/configuration"
require_relative "ready_go/context"
require_relative "ready_go/values"
require_relative "ready_go/benchmark_collection"
require_relative "ready_go/runner"
require_relative "ready_go/suite"
require_relative "ready_go/plot_... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | lib/ready_go/values.rb | Ruby | mit | 222 | master | 985 | module ReadyGo
# The `nothing` attribute exists to provide a way to measure baseline
# performance to null out benchmarking overhead.
class BenchmarkProcs < Struct.new(:before_proc,
:after_proc,
:benchmark_proc,
... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | lib/ready_go/statistics.rb | Ruby | mit | 222 | master | 430 | module ReadyGo
module Statistics
def self.percentile(times, percentile)
ratio = percentile * 0.01
return times.min if percentile == 0
return times.max if percentile == 100
times_sorted = times.sort
k = (ratio*(times_sorted.length-1)+1).floor - 1
f = (ratio*(times_sorted.length-... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | lib/ready_go/runner.rb | Ruby | mit | 222 | master | 2,505 | module ReadyGo
class Runner
def initialize(definition, enforce_minimum_runtime=false)
@definition = definition
@enforce_minimum_runtime = enforce_minimum_runtime
end
def repetitions
@definition.repetitions
end
def prime
@definition.before_proc.call
@definition.bench... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | lib/ready_go/benchmark_definition.rb | Ruby | mit | 222 | master | 956 | module ReadyGo
class BenchmarkDefinition < Struct.new(:name,
:procs,
:type,
:repetitions)
TYPES = [:runtime, :runtime_without_gc, :gc_time]
extend Forwardable
delegate :before_proc ... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | lib/ready_go/context.rb | Ruby | mit | 222 | master | 935 | module ReadyGo
class Context
attr_reader :suite, :definitions
def initialize(name)
@name = name
@before_proc = lambda { }
@after_proc = lambda { }
@definitions = []
end
def before(&block)
@before_proc = block
end
def after(&block)
@after_proc = block
... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | lib/ready_go/plot_renderer.rb | Ruby | mit | 222 | master | 926 | module ReadyGo
class PlotRenderer
attr_reader :before, :after, :plot_width
def initialize(comparison, plot_width)
@before = comparison.before
@after = comparison.after
@plot_width = plot_width
end
def render
titles.zip(bars).map { |title, bar| title + bar }
end
def t... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | lib/ready_go/bar_renderer.rb | Ruby | mit | 222 | master | 789 | module ReadyGo
class BarRenderer
def initialize(series_statistics, max_value, bar_length)
@statistics = series_statistics
@max_value = max_value
# Make room for pipes that we'll add to either side of the bar
@bar_length = bar_length - 2
end
def render
min = scale_value(@stat... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | lib/ready_go/configuration.rb | Ruby | mit | 222 | master | 916 | module ReadyGo
class Configuration < Struct.new(:record, :compare, :files)
alias_method :record?, :record
alias_method :compare?, :compare
def self.parse_options(argv)
argv = argv.dup
record = false
compare = false
parser = OptionParser.new do |opts|
opts.banner = "Usage... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | lib/ready_go/suite.rb | Ruby | mit | 222 | master | 843 | module ReadyGo
class Suite
attr_reader :benchmark_results
def initialize(benchmark_results=[])
@benchmark_results = benchmark_results
end
def add(benchmark_result)
Suite.new(@benchmark_results + [benchmark_result])
end
def benchmark_names
@benchmark_results.map(&:name)
... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | lib/ready_go/serializer.rb | Ruby | mit | 222 | master | 986 | module ReadyGo
class Serializer
def self.load
begin
serialized = JSON.parse(File.read(".readygo"))
rescue Errno::ENOENT
return new
end
version = serialized.fetch("readygo_file_format_version")
unless version == ReadyGo::FILE_FORMAT_VERSION
raise "Cowardly ref... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | lib/ready_go/benchmark_collection.rb | Ruby | mit | 222 | master | 2,373 | module ReadyGo
class BenchmarkCollection
def initialize(definitions)
@definitions = definitions
end
def run
prime_all_definitions
benchmark_times, definitions = run_benchmarks_once_and_calibrate_repetitions
remaining_iterations = ITERATIONS - 1
# The calibration runs serve ... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | lib/ready_go/time_formatting.rb | Ruby | mit | 222 | master | 464 | module ReadyGo
module TimeFormatting
def self.format_duration(duration_in_ms)
duration = duration_in_ms / 10.0 ** 3
if duration < 10.0 ** -6
duration *= 10 ** 9
units = "ns"
elsif duration < 10.0 ** -3
duration *= 10 ** 6
units = "us"
elsif duration < 1.0
... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | spec/time_spec.rb | Ruby | mit | 222 | master | 456 | require "spec_helper"
module ReadyGo
describe TimeFormatting do
it "formats time as strings" do
TimeFormatting.format_duration(50006).should == "50.006 s"
TimeFormatting.format_duration(3.0).should == "3.000 ms"
TimeFormatting.format_duration(0.040).should == "40.000 us"
TimeFormatting.fo... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | spec/context_spec.rb | Ruby | mit | 222 | master | 1,184 | require "spec_helper"
module ReadyGo
describe Context do
it "creates benchmark definitions" do
context = Context.new("a context")
context.go("a benchmark") { "a benchmark block" }
context.definitions.count.should == 1
definition = context.definitions.first
definition.name.should == ... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | spec/bar_renderer_spec.rb | Ruby | mit | 222 | master | 892 | require "spec_helper"
module ReadyGo
describe BarRenderer do
it "renders only the median when there's room for nothing else" do
stats = SeriesStatistics.new(1.0, 1.0)
renderer = BarRenderer.new(stats, 2.0, 10)
renderer.render.should == "| X |"
end
it "renders lines connecting the ... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | spec/benchmark_definition_spec.rb | Ruby | mit | 222 | master | 330 | require "spec_helper"
module ReadyGo
describe BenchmarkDefinition do
it "raises an exception when the benchmark type is invalid" do
expect do
BenchmarkDefinition.new("a benchmark", nil, :invalid_benchmark_type)
end.to raise_error("BUG: unknown benchmark type :invalid_benchmark_type")
end
... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | spec/runner_spec.rb | Ruby | mit | 222 | master | 3,807 | require "timecop"
require "spec_helper"
module ReadyGo
describe Runner do
let(:procs) { BenchmarkProcs.new(Proc.new { }, Proc.new { }, Proc.new { }) }
let(:definition) { BenchmarkDefinition.new("a definition", procs, :runtime, 1) }
let(:time) { Time.new(1990, 1, 1, 12, 0, 0) }
before { Timecop.freez... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | spec/statistics_spec.rb | Ruby | mit | 222 | master | 448 | require "spec_helper"
module ReadyGo
describe Statistics do
let(:values) { [1.0, 2.0, 100.0, 101.0, 102.0] }
it "calculates percentiles" do
Statistics.percentile(values, 0).should == 1.0
Statistics.percentile(values, 50).should == 100
Statistics.percentile(values, 62.5).should == 100.5
... |
github | garybernhardt/readygo | https://github.com/garybernhardt/readygo | spec/suite_spec.rb | Ruby | mit | 222 | master | 1,207 | require "spec_helper"
module ReadyGo
describe Suite do
let(:result) { BenchmarkResult.new("a benchmark", [1.0, 2.0]) }
it "adds benchmark results" do
Suite.new.add(result).benchmark_results.should == [result]
end
it "knows its benchmarks' names" do
Suite.new.add(result).benchmark_names.... |
github | paulspringett/csv_shaper | https://github.com/paulspringett/csv_shaper | csv_shaper.gemspec | Ruby | mit | 222 | main | 1,218 | require File.expand_path('../lib/csv_shaper/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Paul Springett"]
gem.email = ["paul@springett.me"]
gem.summary = %q{Beautiful DSL for creating CSV output in Ruby & Rails}
gem.description = %q{
Creating CSV files in Ruby ... |
github | paulspringett/csv_shaper | https://github.com/paulspringett/csv_shaper | lib/csv_shaper_handler.rb | Ruby | mit | 222 | main | 929 | require 'csv_shaper_template'
# CsvShaperHandler
# Template handler for Rails
class CsvShaperHandler
cattr_accessor :default_format
self.default_format = Mime[:csv]
# Expected `call` class method
# Set response headers with filename
# Primarily calls CsvShaperTemplate.encode, passing through the context (se... |
github | paulspringett/csv_shaper | https://github.com/paulspringett/csv_shaper | lib/csv_shaper_template.rb | Ruby | mit | 222 | main | 389 | # CsvShaperTemplate
# Rails view template class
class CsvShaperTemplate < CsvShaper::Shaper
# Expected `encode` call
# Instantiates a new CsvShaperTemplate object and calls `to_csv` on it
def self.encode(context)
new(context).tap { |shaper| yield shaper }.to_csv
end
def initialize(context)
@context =... |
github | paulspringett/csv_shaper | https://github.com/paulspringett/csv_shaper | lib/csv_shaper.rb | Ruby | mit | 222 | main | 576 | require 'active_support/ordered_hash'
require 'active_support/inflector'
require 'csv_shaper/version'
require 'csv_shaper/header'
require 'csv_shaper/row'
require 'csv_shaper/encoder'
require 'csv_shaper/config'
require 'csv_shaper/shaper'
module CsvShaper
class MissingHeadersError < StandardError; end
# Shortcu... |
github | paulspringett/csv_shaper | https://github.com/paulspringett/csv_shaper | lib/csv_shaper/encoder.rb | Ruby | mit | 222 | main | 1,651 | require 'csv'
module CsvShaper
# Encoder
# Takes a Header and Array of Rows and converts them to a valid CSV formatted String
# Example:
# ```
# CsvShaper::Encoder.new(@header, @rows).to_csv
# ```
class Encoder
def initialize(header, rows = [])
if header.nil?
raise MissingHeadersError, ... |
github | paulspringett/csv_shaper | https://github.com/paulspringett/csv_shaper | lib/csv_shaper/shaper.rb | Ruby | mit | 222 | main | 2,549 | module CsvShaper
# Shaper
# Core CsvShaper class. Delegates header and row generating.
class Shaper
attr_reader :header, :rows
def self.config
@config ||= Config.new
end
def self.config=(new_config)
@config = new_config
end
def initialize(options = {})
@rows = []
... |
github | paulspringett/csv_shaper | https://github.com/paulspringett/csv_shaper | lib/csv_shaper/config.rb | Ruby | mit | 222 | main | 1,266 | require 'csv'
module CsvShaper
# Config
# Configure the standard CSV default options
# as well the option to output the header row
class Config
CUSTOM_DEFAULT_OPTIONS = { header_inflector: :humanize }
attr_reader :options
def initialize
@options = {}
@options.merge!(CUSTOM_DEFAULT_OP... |
github | paulspringett/csv_shaper | https://github.com/paulspringett/csv_shaper | lib/csv_shaper/header.rb | Ruby | mit | 222 | main | 2,377 | module CsvShaper
# Header
# Handles creating and mapping of the headers
# Examples:
# ```
# # assign the headers from the attributes of a class
# csv.headers User
#
# # assigns headers normally
# csv.headers :name, :age, :location
#
# # pass a block
# csv.headers do |csv|
# csv.columns :name... |
github | paulspringett/csv_shaper | https://github.com/paulspringett/csv_shaper | lib/csv_shaper/row.rb | Ruby | mit | 222 | main | 2,263 | module CsvShaper
# Row
# Handles creating of cells within a row and
# assigning of the model's values to cells
# Examples:
# ```
# # pass a model to the row
# csv.row @model do |csv, model|
# ...
# end
#
# # create an empty row instance
# csv.row do |csv|
# ...
# end
#
# # creat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.