-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19f092c
commit e352e87
Showing
12 changed files
with
146 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
AllCops: | ||
TargetRubyVersion: 2.4 | ||
|
||
# Configuration parameters: CountComments, ExcludedMethods. | ||
Metrics/BlockLength: | ||
Max: 26 | ||
|
||
# Configuration parameters: CountComments. | ||
Metrics/MethodLength: | ||
Max: 18 | ||
|
||
# Offense count: 2 | ||
Style/Documentation: | ||
Exclude: | ||
- '**/*' | ||
|
||
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. | ||
# URISchemes: http, https | ||
Metrics/LineLength: | ||
Max: 102 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
source "https://rubygems.org" | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in es_index.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
require "bundler/gem_tasks" | ||
require "rspec/core/rake_task" | ||
require 'bundler/gem_tasks' | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task :default => :spec | ||
task default: :spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require "bundler/setup" | ||
require "es_index" | ||
require 'bundler/setup' | ||
require 'es_index' | ||
|
||
# You can add fixtures and/or initialization code here to make experimenting | ||
# with your gem easier. You can also use a different console, if you like. | ||
|
||
# (If you use this, don't forget to add pry to your Gemfile!) | ||
require "pry" | ||
require 'pry' | ||
Pry.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
|
||
lib = File.expand_path("../lib", __FILE__) | ||
lib = File.expand_path('../lib', __FILE__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
require "es_index/version" | ||
require 'es_index/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "es_index" | ||
spec.name = 'es_index' | ||
spec.version = EsIndex::VERSION | ||
spec.authors = ["Isaac Seymour"] | ||
spec.email = ["i.seymour@oxon.org"] | ||
spec.authors = ['Isaac Seymour'] | ||
spec.email = ['i.seymour@oxon.org'] | ||
|
||
spec.summary = %q{Zero-downtime (re-)indexing of ActiveRecord models into Elasticsearch.} | ||
spec.description = %q{An index manager for Elasticsearch and ActiveRecord} | ||
spec.homepage = "https://github.com/carwow/es_index" | ||
spec.license = "MIT" | ||
spec.summary = 'Zero-downtime (re-)indexing of ActiveRecord models into Elasticsearch.' | ||
spec.description = 'An index manager for Elasticsearch and ActiveRecord' | ||
spec.homepage = 'https://github.com/carwow/es_index' | ||
spec.license = 'MIT' | ||
|
||
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' | ||
# to allow pushing to a single host or delete this section to allow pushing to any host. | ||
if spec.respond_to?(:metadata) | ||
spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'" | ||
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'" | ||
else | ||
raise "RubyGems 2.0 or newer is required to protect against " \ | ||
"public gem pushes." | ||
raise 'RubyGems 2.0 or newer is required to protect against ' \ | ||
'public gem pushes.' | ||
end | ||
|
||
spec.files = `git ls-files -z`.split("\x0").reject do |f| | ||
spec.files = `git ls-files -z`.split("\x0").reject do |f| | ||
f.match(%r{^(test|spec|features)/}) | ||
end | ||
spec.bindir = "exe" | ||
spec.bindir = 'exe' | ||
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } | ||
spec.require_paths = ["lib"] | ||
spec.require_paths = ['lib'] | ||
|
||
spec.add_dependency "activesupport" | ||
spec.add_dependency 'activesupport' | ||
|
||
spec.add_development_dependency "bundler" | ||
spec.add_development_dependency "pry" | ||
spec.add_development_dependency "rubocop" | ||
spec.add_development_dependency "rspec" | ||
spec.add_development_dependency "rake" | ||
spec.add_development_dependency 'bundler' | ||
spec.add_development_dependency 'pry' | ||
spec.add_development_dependency 'rake' | ||
spec.add_development_dependency 'rspec' | ||
spec.add_development_dependency 'rubocop' | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module EsIndex | ||
class Config | ||
attr_reader :client, :data_source | ||
|
||
def initialize( | ||
client:, | ||
data_source:, | ||
mapping:, | ||
**overrides, | ||
&index_data | ||
) | ||
@client = client | ||
@data_source = data_source | ||
@mapping = mapping | ||
@index_data = index_data | ||
@overrides = overrides | ||
end | ||
|
||
def index_data(model) | ||
@index_data.call(model) | ||
end | ||
|
||
def read_alias | ||
@read_alias ||= overrides.fetch(:read_alias) { data_source.table_name } | ||
end | ||
|
||
def write_alias | ||
@write_alias ||= overrides.fetch(:write_alias) { [read_alias, 'write'].join('_') } | ||
end | ||
|
||
def type | ||
@type ||= overrides.fetch(:type, read_alias.singularize) | ||
end | ||
|
||
def logger | ||
return Rails.logger if defined?(Rails) | ||
@logger ||= Logger.new(STDOUT) | ||
end | ||
|
||
def index_definition | ||
{ | ||
settings: overrides.fetch(:index_settings, {}), | ||
mappings: { type => mapping } | ||
} | ||
end | ||
|
||
private | ||
|
||
attr_reader :overrides, :mapping | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module EsIndex | ||
VERSION = "0.1.0" | ||
VERSION = '0.1.0'.freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
RSpec.describe EsIndex do | ||
it "has a version number" do | ||
it 'has a version number' do | ||
expect(EsIndex::VERSION).not_to be nil | ||
end | ||
|
||
it "does something useful" do | ||
it 'does something useful' do | ||
expect(false).to eq(true) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters