-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🍺 Create ElasticsearchReader::Config and add Readme files
- Add Guard-bundler gem and configure it - Add ActiveSupport gem - Fix RuboCop issues - Create `ElasticsearchReader::Config` Class as a Singleton - Add specs for `ElasticsearchReader::Config` Class - Delegate all methods from `ElasticsearchReader::Config` to `ElasticsearchReader` - Add PULL_REQUEST_TEMPLATE.md - Add ISSUE_TEMPLATE.md - Add CONTRIBUTING.md - Add .ruby-version
- Loading branch information
Showing
17 changed files
with
177 additions
and
3 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,5 @@ | ||
engines: | ||
fixme: | ||
enabled: true | ||
exclude_fingerprints: | ||
- 303f76d18a54a13422463f2edab9bacd |
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 @@ | ||
ruby-2.4.1 |
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,5 @@ | ||
# Contributing to ElasticsearchReader | ||
|
||
### Style (Ruby) | ||
|
||
We use Rubocop to enforce a few style-related conventions. Run the command rubocop to check for any style violations before submitting pull requests. |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
### Step 1: Are you in the right place? | ||
|
||
* For issues or feature requests related to the code **in this repository** file a Github issue. | ||
* For general technical questions, post a question on [StackOverflow](http://stackoverflow.com/) tagged appropriately. | ||
|
||
### Step 2: Describe your environment | ||
|
||
* Gem version: _____ | ||
* Rails version: _____ | ||
* Ruby version: _____ | ||
|
||
### Step 3: Describe the problem: | ||
|
||
#### Steps to reproduce: | ||
|
||
1. _____ | ||
2. _____ | ||
3. _____ | ||
|
||
#### Observed Results: | ||
|
||
* What happened? This could be a description, log output, etc. | ||
|
||
#### Expected Results: | ||
|
||
* What did you expect to happen? | ||
|
||
#### Relevant Code: | ||
|
||
``` | ||
// TODO(you): code here to reproduce the problem | ||
``` |
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,5 @@ | ||
## Todos | ||
- [ ] Tests | ||
- [ ] RuboCop | ||
- [ ] Documentation | ||
- [ ] Changelog |
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,5 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'bundler/gem_tasks' | ||
require 'rspec/core/rake_task' | ||
|
||
|
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,5 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
require 'bundler/setup' | ||
require 'elasticsearch_reader' | ||
|
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,5 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'active_support/concern' | ||
require 'active_support/deprecation' | ||
require 'active_support/json' | ||
require 'active_support/log_subscriber' | ||
|
||
require 'active_support/core_ext/array/access' | ||
require 'active_support/core_ext/array/wrap' | ||
require 'active_support/core_ext/enumerable' | ||
require 'active_support/core_ext/hash/reverse_merge' | ||
require 'active_support/core_ext/numeric/time' | ||
require 'active_support/core_ext/numeric/bytes' | ||
require 'active_support/core_ext/object/blank' | ||
require 'active_support/core_ext/object/inclusion' | ||
require 'active_support/core_ext/string/inflections' | ||
|
||
require 'singleton' | ||
require 'elasticsearch_reader/version' | ||
require 'elasticsearch_reader/config' | ||
|
||
module ElasticsearchReader | ||
# Your code goes here... | ||
class << self | ||
def config | ||
ElasticsearchReader::Config.instance | ||
end | ||
delegate(*ElasticsearchReader::Config.delegated, to: :config) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# frozen_string_literal: true | ||
|
||
module ElasticsearchReader | ||
# ElasticsearchReader core configuration. | ||
class Config | ||
include Singleton | ||
|
||
attr_accessor :settings, :logger, | ||
|
||
# Where ElasticsearchReader expects to find index definitions | ||
# within a Rails app folder. | ||
:indices_path | ||
|
||
def self.delegated | ||
public_instance_methods - | ||
superclass.public_instance_methods - | ||
Singleton.public_instance_methods | ||
end | ||
|
||
def initialize | ||
@settings = {} | ||
@indices_path = 'app/indices' | ||
end | ||
|
||
# ElasticsearchReader configurations. There is two ways to set it up: | ||
# use `ElasticsearchReader.settings=` method or, create | ||
# `config/elasticsearch_reader.yml` file (ERB supported), this file | ||
# support All Elasticsearch::Client options supports. | ||
# | ||
# test: | ||
# host: 'localhost:9250' | ||
# | ||
def configuration | ||
yaml_settings.merge(settings.deep_symbolize_keys).tap do |configuration| | ||
configuration[:logger] = logger | ||
configuration[:indices_path] ||= indices_path | ||
end | ||
end | ||
|
||
private | ||
|
||
def yaml_settings | ||
@yaml_settings ||= begin | ||
file = File.join(Dir.pwd, 'config', 'elasticsearch_reader.yml') | ||
|
||
if File.exist?(file) | ||
yaml = ERB.new(File.read(file)).result | ||
hash = YAML.safe_load(yaml) | ||
hash&.try(:deep_symbolize_keys) | ||
end | ||
end || {} | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module ElasticsearchReader | ||
VERSION = '0.1.0'.freeze | ||
VERSION = '0.1.0' | ||
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe ElasticsearchReader::Config do | ||
subject { described_class.send(:new) } | ||
|
||
its(:logger) { should be_nil } | ||
its(:indices_path) { should == 'app/indices' } | ||
|
||
describe '#configuration' do | ||
before { subject.settings = { indices_path: 'app/foobar' } } | ||
|
||
specify do | ||
expect(subject.configuration).to include(indices_path: 'app/foobar') | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.describe ElasticsearchReader do | ||
|
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