neuromancer-indexer 0.1.0 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/workflows/ruby-gems.yml +46 -0
- data/.github/workflows/tests.yml +43 -0
- data/.rubocop.yml +56 -0
- data/CHANGELOG.md +13 -0
- data/README.md +37 -7
- data/Rakefile +2 -0
- data/gems.locked +70 -0
- data/{Gemfile → gems.rb} +2 -0
- data/lib/neuromancer-indexer/rspec.rb +17 -0
- data/lib/neuromancer/indexer.rb +34 -6
- data/lib/neuromancer/indexer/client.rb +42 -25
- data/lib/neuromancer/indexer/configuration.rb +7 -13
- data/lib/neuromancer/indexer/document.rb +37 -0
- data/lib/neuromancer/indexer/version.rb +3 -1
- data/neuromancer-indexer.gemspec +5 -15
- metadata +32 -19
- data/.travis.yml +0 -10
- data/Gemfile.lock +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 923187d8ea912f966d2bfc1c323fdb736706867359b7adc17466a220ee7e50fc
|
4
|
+
data.tar.gz: 3b8f4cf05967b285d7ed583c06abcb1d596fa3e0cb2e384441c04756f896cd3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaabed6b75d852e09f27b0e032291adb90727585b22a698f1af8a3512e6aa6c34720a9684b5c2f64bd57e45be461e0c44e1069057dd38190a0f7362b34829957
|
7
|
+
data.tar.gz: afd1756604eb10e42d1a8004217a150477dc85d93b9793911868293dfc483ab4e5312de4484d7e5544eda282b66e28b2d726e3de17e30375d670c1f8f4f6be5c
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- 'v*'
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
ruby-gem:
|
10
|
+
name: Build + Publish
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- name: Set up Ruby 2.6
|
16
|
+
uses: actions/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: 2.6
|
19
|
+
|
20
|
+
- name: Install dependencies
|
21
|
+
run: |
|
22
|
+
gem install bundler
|
23
|
+
bundle install
|
24
|
+
|
25
|
+
- name: Push to GitHub Package Repository
|
26
|
+
run: |
|
27
|
+
mkdir -p $HOME/.gem
|
28
|
+
touch $HOME/.gem/credentials
|
29
|
+
chmod 0600 $HOME/.gem/credentials
|
30
|
+
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
31
|
+
gem build *.gemspec
|
32
|
+
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
33
|
+
env:
|
34
|
+
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
35
|
+
OWNER: ${{ github.repository_owner }}
|
36
|
+
|
37
|
+
- name: Push to RubyGems
|
38
|
+
run: |
|
39
|
+
mkdir -p $HOME/.gem
|
40
|
+
touch $HOME/.gem/credentials
|
41
|
+
chmod 0600 $HOME/.gem/credentials
|
42
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
43
|
+
gem build *.gemspec
|
44
|
+
gem push *.gem
|
45
|
+
env:
|
46
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
|
7
|
+
name: Tests
|
8
|
+
|
9
|
+
on:
|
10
|
+
push:
|
11
|
+
branches: [ develop ]
|
12
|
+
pull_request:
|
13
|
+
|
14
|
+
jobs:
|
15
|
+
rspec:
|
16
|
+
runs-on: ubuntu-latest
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
- name: Set up Ruby 2.6
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: 2.6
|
23
|
+
- name: Install dependencies
|
24
|
+
run: |
|
25
|
+
gem install bundler
|
26
|
+
bundle install
|
27
|
+
- name: Run RSpec
|
28
|
+
run: bundle exec rspec
|
29
|
+
|
30
|
+
rubocop:
|
31
|
+
runs-on: ubuntu-latest
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@v2
|
34
|
+
- name: Set up Ruby 2.6
|
35
|
+
uses: ruby/setup-ruby@v1
|
36
|
+
with:
|
37
|
+
ruby-version: 2.6
|
38
|
+
- name: Install dependencies
|
39
|
+
run: |
|
40
|
+
gem install bundler
|
41
|
+
bundle install
|
42
|
+
- name: Run Rubocop
|
43
|
+
run: bundle exec rubocop
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# The behavior of RuboCop can be controlled via the .rubocop.yml
|
2
|
+
# configuration file. It makes it possible to enable/disable
|
3
|
+
# certain cops (checks) and to alter their behavior if they accept
|
4
|
+
# any parameters. The file can be placed either in your home
|
5
|
+
# directory or in some project directory.
|
6
|
+
#
|
7
|
+
# RuboCop will start looking for the configuration file in the directory
|
8
|
+
# where the inspected file is and continue its way up to the root directory.
|
9
|
+
#
|
10
|
+
# See https://docs.rubocop.org/rubocop/configuration
|
11
|
+
|
12
|
+
AllCops:
|
13
|
+
TargetRubyVersion: 2.5
|
14
|
+
Exclude:
|
15
|
+
- 'bin/*'
|
16
|
+
- 'node_modules/**/*'
|
17
|
+
- 'vendor/**/*'
|
18
|
+
- 'spec/**/*'
|
19
|
+
|
20
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
21
|
+
Enabled: true
|
22
|
+
Layout/SpaceAroundMethodCallOperator:
|
23
|
+
Enabled: true
|
24
|
+
|
25
|
+
Lint/DeprecatedOpenSSLConstant:
|
26
|
+
Enabled: true
|
27
|
+
Lint/MixedRegexpCaptureTypes:
|
28
|
+
Enabled: true
|
29
|
+
Lint/RaiseException:
|
30
|
+
Enabled: true
|
31
|
+
Lint/StructNewOverride:
|
32
|
+
Enabled: true
|
33
|
+
|
34
|
+
Metrics/MethodLength:
|
35
|
+
Enabled: false
|
36
|
+
Metrics/ModuleLength:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
Style/Documentation:
|
40
|
+
Enabled: false
|
41
|
+
Style/ExponentialNotation:
|
42
|
+
Enabled: true
|
43
|
+
Style/HashEachMethods:
|
44
|
+
Enabled: true
|
45
|
+
Style/HashTransformKeys:
|
46
|
+
Enabled: true
|
47
|
+
Style/HashTransformValues:
|
48
|
+
Enabled: true
|
49
|
+
Style/RedundantFetchBlock:
|
50
|
+
Enabled: true
|
51
|
+
Style/RedundantRegexpCharacterClass:
|
52
|
+
Enabled: true
|
53
|
+
Style/RedundantRegexpEscape:
|
54
|
+
Enabled: true
|
55
|
+
Style/SlicingWithRange:
|
56
|
+
Enabled: true
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,17 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
+
#### 0.4.4
|
4
|
+
- [fix] rename `obj.body` to `obj.attributes`
|
5
|
+
|
6
|
+
#### 0.4.3
|
7
|
+
- add `Neuromancer::Indexer.delete`
|
8
|
+
- add GitHub workflows for `RSpec`, `Rubocop` and `RubyGems`
|
9
|
+
|
10
|
+
#### 0.3.0
|
11
|
+
- optionally use AWS user credentials for SQS instead of role credentials
|
12
|
+
|
13
|
+
#### 0.2.0
|
14
|
+
- add `NeuromancerSpec.stub` to support unit tests
|
15
|
+
|
3
16
|
#### 0.1.0
|
4
17
|
- initial version
|
data/README.md
CHANGED
@@ -1,26 +1,56 @@
|
|
1
1
|
# neuromancer-indexer
|
2
2
|
|
3
|
-
[](https://github.com/jdahlke/neuromancer-indexer/actions)
|
4
4
|
|
5
|
-
Ruby gem to push data for indexing to the Neuromancer service
|
5
|
+
Ruby gem to push data for indexing to the Neuromancer service.
|
6
6
|
|
7
|
-
|
7
|
+
|
8
|
+
### Getting started
|
9
|
+
|
10
|
+
Configuration
|
8
11
|
|
9
12
|
```
|
10
13
|
Neuromancer::Indexer.configure do |config|
|
11
14
|
config.region = 'eu-central-1'
|
12
15
|
config.sqs_url = 'https://sqs.eu-central-1.amazonaws.com/1234567890/neuromancer-index'
|
16
|
+
|
17
|
+
# optional
|
18
|
+
config.access_key_id = 'AWS_ACCESS_KEY_ID'
|
19
|
+
config.secret_access_key = 'AWS_SECRET_ACCESS_KEY'
|
13
20
|
end
|
21
|
+
```
|
14
22
|
|
15
|
-
|
23
|
+
Indexing objects
|
24
|
+
|
25
|
+
```
|
26
|
+
Neuromancer::Indexer.index(
|
16
27
|
id: 'id-1',
|
17
28
|
type: 'objects',
|
18
|
-
|
29
|
+
attributes: {
|
19
30
|
foo: 'foo-string',
|
20
31
|
bar: 123,
|
21
32
|
baz: ['abc', 'def']
|
22
33
|
}
|
23
|
-
|
34
|
+
)
|
35
|
+
```
|
36
|
+
|
37
|
+
Deleting objects
|
38
|
+
|
39
|
+
```
|
40
|
+
Neuromancer::Indexer.delete(
|
41
|
+
id: 'id-1',
|
42
|
+
type: 'objects'
|
43
|
+
)
|
44
|
+
```
|
45
|
+
|
46
|
+
Stubbing in Specs
|
47
|
+
|
48
|
+
```
|
49
|
+
RSpec.configure do |config|
|
50
|
+
config.before :each do
|
51
|
+
NeuromancerSpec.stub
|
52
|
+
end
|
53
|
+
end
|
24
54
|
```
|
25
55
|
|
26
56
|
|
@@ -35,5 +65,5 @@ gem 'neuromancer-indexer'
|
|
35
65
|
### Test
|
36
66
|
|
37
67
|
```
|
38
|
-
bundle exec
|
68
|
+
bundle exec rspec spec
|
39
69
|
```
|
data/Rakefile
CHANGED
data/gems.locked
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
neuromancer-indexer (0.4.4)
|
5
|
+
aws-sdk-sqs
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.1)
|
11
|
+
aws-eventstream (1.1.0)
|
12
|
+
aws-partitions (1.354.0)
|
13
|
+
aws-sdk-core (3.104.3)
|
14
|
+
aws-eventstream (~> 1, >= 1.0.2)
|
15
|
+
aws-partitions (~> 1, >= 1.239.0)
|
16
|
+
aws-sigv4 (~> 1.1)
|
17
|
+
jmespath (~> 1.0)
|
18
|
+
aws-sdk-sqs (1.30.0)
|
19
|
+
aws-sdk-core (~> 3, >= 3.99.0)
|
20
|
+
aws-sigv4 (~> 1.1)
|
21
|
+
aws-sigv4 (1.2.1)
|
22
|
+
aws-eventstream (~> 1, >= 1.0.2)
|
23
|
+
diff-lcs (1.3)
|
24
|
+
jmespath (1.4.0)
|
25
|
+
parallel (1.19.2)
|
26
|
+
parser (2.7.1.4)
|
27
|
+
ast (~> 2.4.1)
|
28
|
+
rainbow (3.0.0)
|
29
|
+
rake (13.0.1)
|
30
|
+
regexp_parser (1.7.1)
|
31
|
+
rexml (3.2.4)
|
32
|
+
rspec (3.9.0)
|
33
|
+
rspec-core (~> 3.9.0)
|
34
|
+
rspec-expectations (~> 3.9.0)
|
35
|
+
rspec-mocks (~> 3.9.0)
|
36
|
+
rspec-core (3.9.0)
|
37
|
+
rspec-support (~> 3.9.0)
|
38
|
+
rspec-expectations (3.9.0)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.9.0)
|
41
|
+
rspec-mocks (3.9.0)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.9.0)
|
44
|
+
rspec-support (3.9.0)
|
45
|
+
rubocop (0.86.0)
|
46
|
+
parallel (~> 1.10)
|
47
|
+
parser (>= 2.7.0.1)
|
48
|
+
rainbow (>= 2.2.2, < 4.0)
|
49
|
+
regexp_parser (>= 1.7)
|
50
|
+
rexml
|
51
|
+
rubocop-ast (>= 0.0.3, < 1.0)
|
52
|
+
ruby-progressbar (~> 1.7)
|
53
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
54
|
+
rubocop-ast (0.3.0)
|
55
|
+
parser (>= 2.7.1.4)
|
56
|
+
ruby-progressbar (1.10.1)
|
57
|
+
unicode-display_width (1.7.0)
|
58
|
+
|
59
|
+
PLATFORMS
|
60
|
+
ruby
|
61
|
+
|
62
|
+
DEPENDENCIES
|
63
|
+
bundler
|
64
|
+
neuromancer-indexer!
|
65
|
+
rake (~> 13.0)
|
66
|
+
rspec (~> 3.0)
|
67
|
+
rubocop (= 0.86.0)
|
68
|
+
|
69
|
+
BUNDLED WITH
|
70
|
+
2.1.4
|
data/{Gemfile → gems.rb}
RENAMED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NeuromancerSpec
|
4
|
+
def self.stub
|
5
|
+
sqs = Aws::SQS::Client.new(
|
6
|
+
region: 'eu-central-1',
|
7
|
+
stub_responses: true
|
8
|
+
)
|
9
|
+
client = Neuromancer::Indexer::Client.new(sqs)
|
10
|
+
Neuromancer::Indexer.instance_variable_set('@client', client)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.unstub
|
14
|
+
client = Neuromancer::Indexer::Client.new
|
15
|
+
Neuromancer::Indexer.instance_variable_set('@client', client)
|
16
|
+
end
|
17
|
+
end
|
data/lib/neuromancer/indexer.rb
CHANGED
@@ -1,13 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'json'
|
4
|
+
require 'aws-sdk-sqs'
|
5
|
+
|
3
6
|
require 'neuromancer/indexer/version'
|
4
7
|
require 'neuromancer/indexer/client'
|
8
|
+
require 'neuromancer/indexer/document'
|
5
9
|
require 'neuromancer/indexer/configuration'
|
6
10
|
|
7
11
|
module Neuromancer
|
8
12
|
module Indexer
|
9
|
-
class Error < StandardError
|
10
|
-
|
13
|
+
class Error < StandardError
|
14
|
+
end
|
15
|
+
|
16
|
+
class ConfigurationError < Error
|
17
|
+
end
|
18
|
+
|
19
|
+
class InvalidDocument < Error
|
20
|
+
attr_reader :errors
|
21
|
+
|
22
|
+
def initialize(errors)
|
23
|
+
@errors = errors
|
24
|
+
end
|
25
|
+
|
26
|
+
def message
|
27
|
+
errors.join(', ')
|
28
|
+
end
|
29
|
+
|
30
|
+
def inspect
|
31
|
+
"#<#{self.class.name}: '#{message}'>"
|
32
|
+
end
|
33
|
+
end
|
11
34
|
|
12
35
|
def self.config
|
13
36
|
@config ||= Configuration.new
|
@@ -15,16 +38,21 @@ module Neuromancer
|
|
15
38
|
|
16
39
|
def self.configure
|
17
40
|
yield config
|
18
|
-
|
19
41
|
config.validate!
|
20
|
-
@client = Client.new
|
21
42
|
|
22
43
|
config
|
23
44
|
end
|
24
45
|
|
25
|
-
def self.
|
46
|
+
def self.client
|
26
47
|
@client ||= Client.new
|
27
|
-
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.index(obj)
|
51
|
+
client.index(obj)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.delete(obj)
|
55
|
+
client.delete(obj)
|
28
56
|
end
|
29
57
|
end
|
30
58
|
end
|
@@ -1,50 +1,67 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'json'
|
4
|
-
require 'aws-sdk-sqs'
|
5
|
-
|
6
3
|
module Neuromancer
|
7
4
|
module Indexer
|
8
5
|
class Client
|
9
6
|
attr_reader :config
|
10
7
|
|
11
|
-
def initialize
|
8
|
+
def initialize(sqs = nil)
|
12
9
|
@config = Neuromancer::Indexer.config
|
10
|
+
@sqs = sqs
|
11
|
+
end
|
12
|
+
|
13
|
+
def index(id:, type:, attributes:)
|
14
|
+
document = Document.new(id: id, type: type, attributes: attributes)
|
15
|
+
document.validate!
|
16
|
+
|
17
|
+
enqueue(action: 'index', document: document)
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete(id:, type:)
|
21
|
+
document = Document.new(id: id, type: type, attributes: {})
|
22
|
+
document.validate!
|
23
|
+
|
24
|
+
enqueue(action: 'delete', document: document)
|
13
25
|
end
|
14
26
|
|
15
|
-
def
|
16
|
-
message =
|
17
|
-
|
27
|
+
def enqueue(action:, document:)
|
28
|
+
message = {
|
29
|
+
action: action,
|
30
|
+
document: document
|
31
|
+
}
|
18
32
|
|
19
|
-
sqs.send_message(
|
33
|
+
sqs.send_message(
|
20
34
|
queue_url: config.sqs_url,
|
21
|
-
message_body: message,
|
35
|
+
message_body: message.to_json,
|
22
36
|
delay_seconds: 1
|
23
|
-
|
37
|
+
)
|
24
38
|
end
|
25
39
|
|
26
40
|
private
|
41
|
+
|
27
42
|
def sqs
|
28
|
-
@sqs ||= Aws::SQS::Client.new(
|
43
|
+
@sqs ||= Aws::SQS::Client.new(sqs_options)
|
29
44
|
end
|
30
45
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
46
|
+
def sqs_options
|
47
|
+
options = {
|
48
|
+
region: config.region
|
49
|
+
}
|
50
|
+
if present?(config.access_key_id) && present?(config.secret_access_key)
|
51
|
+
options[:credentials] = Aws::Credentials.new(
|
52
|
+
config.access_key_id,
|
53
|
+
config.secret_access_key
|
54
|
+
)
|
39
55
|
end
|
40
56
|
|
41
|
-
|
42
|
-
|
43
|
-
end
|
57
|
+
options
|
58
|
+
end
|
44
59
|
|
45
|
-
|
46
|
-
|
47
|
-
|
60
|
+
def present?(value)
|
61
|
+
return false if value.nil?
|
62
|
+
return false if value.empty?
|
63
|
+
|
64
|
+
true
|
48
65
|
end
|
49
66
|
end
|
50
67
|
end
|
@@ -7,30 +7,24 @@ module Neuromancer
|
|
7
7
|
class Configuration
|
8
8
|
attr_accessor :region
|
9
9
|
attr_accessor :sqs_url
|
10
|
-
attr_accessor :
|
10
|
+
attr_accessor :access_key_id, :secret_access_key
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
@region = 'eu-central-1'
|
14
14
|
end
|
15
15
|
|
16
16
|
def validate!
|
17
|
-
if region.to_s.empty?
|
18
|
-
raise ConfigurationError, '`region` cannot be empty'
|
19
|
-
end
|
17
|
+
raise ConfigurationError, '\'region\' cannot be empty' if region.to_s.empty?
|
20
18
|
|
21
|
-
if sqs_url.to_s.empty?
|
22
|
-
raise ConfigurationError, '`sqs_url` cannot be empty'
|
23
|
-
end
|
19
|
+
raise ConfigurationError, '\'sqs_url\' cannot be empty' if sqs_url.to_s.empty?
|
24
20
|
|
21
|
+
invalid_protocol = '\'sqs_url\' must be a HTTPS url'
|
25
22
|
begin
|
26
|
-
if URI(sqs_url).scheme != 'https'
|
27
|
-
|
28
|
-
|
29
|
-
rescue => e
|
30
|
-
raise ConfigurationError, '`sqs_url` must be a HTTPS url'
|
23
|
+
raise ConfigurationError, invalid_protocol if URI(sqs_url).scheme != 'https'
|
24
|
+
rescue StandardError
|
25
|
+
raise ConfigurationError, invalid_protocol
|
31
26
|
end
|
32
27
|
end
|
33
28
|
end
|
34
29
|
end
|
35
30
|
end
|
36
|
-
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Neuromancer
|
4
|
+
module Indexer
|
5
|
+
class Document
|
6
|
+
attr_reader :id, :type, :attributes
|
7
|
+
|
8
|
+
def initialize(attributes)
|
9
|
+
@id = indifferent_value(attributes, :id).to_s
|
10
|
+
@type = indifferent_value(attributes, :type).to_s
|
11
|
+
@attributes = indifferent_value(attributes, :attributes)
|
12
|
+
end
|
13
|
+
|
14
|
+
def as_json
|
15
|
+
{
|
16
|
+
id: id,
|
17
|
+
type: type,
|
18
|
+
attributes: attributes
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def validate!
|
23
|
+
errors = []
|
24
|
+
|
25
|
+
errors << 'document#id is empty' if id.empty?
|
26
|
+
errors << 'document#type is empty' if type.empty?
|
27
|
+
errors << 'document#attributes is not a Hash' unless attributes.is_a?(Hash)
|
28
|
+
|
29
|
+
raise(InvalidDocument, errors) unless errors.empty?
|
30
|
+
end
|
31
|
+
|
32
|
+
def indifferent_value(hash, key)
|
33
|
+
hash[key.to_sym] || hash[key.to_s]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/neuromancer-indexer.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'neuromancer/indexer/version'
|
@@ -12,19 +14,6 @@ Gem::Specification.new do |spec|
|
|
12
14
|
spec.description = 'Ruby gem to push data for indexing to the Neuromancer service.'
|
13
15
|
spec.homepage = 'https://github.com/jdahlke/neuromancer-indexer'
|
14
16
|
|
15
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
-
if spec.respond_to?(:metadata)
|
18
|
-
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
19
|
-
|
20
|
-
spec.metadata['homepage_uri'] = spec.homepage
|
21
|
-
spec.metadata['source_code_uri'] = 'https://github.com/jdahlke/neuromancer-indexer'
|
22
|
-
spec.metadata['changelog_uri'] = 'https://github.com/jdahlke/neuromancer-indexer/blob/master/CHANGELOG.md'
|
23
|
-
else
|
24
|
-
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
25
|
-
'public gem pushes.'
|
26
|
-
end
|
27
|
-
|
28
17
|
# Specify which files should be added to the gem when it is released.
|
29
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
19
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
@@ -36,7 +25,8 @@ Gem::Specification.new do |spec|
|
|
36
25
|
|
37
26
|
spec.add_dependency 'aws-sdk-sqs'
|
38
27
|
|
39
|
-
spec.add_development_dependency 'bundler'
|
28
|
+
spec.add_development_dependency 'bundler'
|
29
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
40
30
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
41
|
-
spec.add_development_dependency '
|
31
|
+
spec.add_development_dependency 'rubocop', '0.86.0'
|
42
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neuromancer-indexer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joergen Dahlke
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-sqs
|
@@ -26,18 +26,32 @@ dependencies:
|
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '13.0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '13.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,19 +67,19 @@ dependencies:
|
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '3.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: rubocop
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - '='
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
75
|
+
version: 0.86.0
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - '='
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
82
|
+
version: 0.86.0
|
69
83
|
description: Ruby gem to push data for indexing to the Neuromancer service.
|
70
84
|
email:
|
71
85
|
- joergen.dahlke@infopark.de
|
@@ -73,29 +87,29 @@ executables: []
|
|
73
87
|
extensions: []
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
90
|
+
- ".github/workflows/ruby-gems.yml"
|
91
|
+
- ".github/workflows/tests.yml"
|
76
92
|
- ".gitignore"
|
77
93
|
- ".rspec"
|
78
|
-
- ".
|
94
|
+
- ".rubocop.yml"
|
79
95
|
- CHANGELOG.md
|
80
|
-
- Gemfile
|
81
|
-
- Gemfile.lock
|
82
96
|
- LICENSE
|
83
97
|
- README.md
|
84
98
|
- Rakefile
|
85
99
|
- bin/console
|
86
100
|
- bin/setup
|
101
|
+
- gems.locked
|
102
|
+
- gems.rb
|
103
|
+
- lib/neuromancer-indexer/rspec.rb
|
87
104
|
- lib/neuromancer/indexer.rb
|
88
105
|
- lib/neuromancer/indexer/client.rb
|
89
106
|
- lib/neuromancer/indexer/configuration.rb
|
107
|
+
- lib/neuromancer/indexer/document.rb
|
90
108
|
- lib/neuromancer/indexer/version.rb
|
91
109
|
- neuromancer-indexer.gemspec
|
92
110
|
homepage: https://github.com/jdahlke/neuromancer-indexer
|
93
111
|
licenses: []
|
94
|
-
metadata:
|
95
|
-
allowed_push_host: https://rubygems.org
|
96
|
-
homepage_uri: https://github.com/jdahlke/neuromancer-indexer
|
97
|
-
source_code_uri: https://github.com/jdahlke/neuromancer-indexer
|
98
|
-
changelog_uri: https://github.com/jdahlke/neuromancer-indexer/blob/master/CHANGELOG.md
|
112
|
+
metadata: {}
|
99
113
|
post_install_message:
|
100
114
|
rdoc_options: []
|
101
115
|
require_paths:
|
@@ -111,8 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
125
|
- !ruby/object:Gem::Version
|
112
126
|
version: '0'
|
113
127
|
requirements: []
|
114
|
-
|
115
|
-
rubygems_version: 2.2.5
|
128
|
+
rubygems_version: 3.0.3
|
116
129
|
signing_key:
|
117
130
|
specification_version: 4
|
118
131
|
summary: Ruby gem to push data for indexing to the Neuromancer service.
|
data/.travis.yml
DELETED
data/Gemfile.lock
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
neuromancer-indexer (0.1.0)
|
5
|
-
aws-sdk-sqs
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
aws-eventstream (1.0.3)
|
11
|
-
aws-partitions (1.224.0)
|
12
|
-
aws-sdk-core (3.68.1)
|
13
|
-
aws-eventstream (~> 1.0, >= 1.0.2)
|
14
|
-
aws-partitions (~> 1.0)
|
15
|
-
aws-sigv4 (~> 1.1)
|
16
|
-
jmespath (~> 1.0)
|
17
|
-
aws-sdk-sqs (1.22.0)
|
18
|
-
aws-sdk-core (~> 3, >= 3.61.1)
|
19
|
-
aws-sigv4 (~> 1.1)
|
20
|
-
aws-sigv4 (1.1.0)
|
21
|
-
aws-eventstream (~> 1.0, >= 1.0.2)
|
22
|
-
diff-lcs (1.3)
|
23
|
-
jmespath (1.4.0)
|
24
|
-
rake (10.5.0)
|
25
|
-
rspec (3.9.0)
|
26
|
-
rspec-core (~> 3.9.0)
|
27
|
-
rspec-expectations (~> 3.9.0)
|
28
|
-
rspec-mocks (~> 3.9.0)
|
29
|
-
rspec-core (3.9.0)
|
30
|
-
rspec-support (~> 3.9.0)
|
31
|
-
rspec-expectations (3.9.0)
|
32
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
-
rspec-support (~> 3.9.0)
|
34
|
-
rspec-mocks (3.9.0)
|
35
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
-
rspec-support (~> 3.9.0)
|
37
|
-
rspec-support (3.9.0)
|
38
|
-
|
39
|
-
PLATFORMS
|
40
|
-
ruby
|
41
|
-
|
42
|
-
DEPENDENCIES
|
43
|
-
bundler (~> 2.0)
|
44
|
-
neuromancer-indexer!
|
45
|
-
rake (~> 10.0)
|
46
|
-
rspec (~> 3.0)
|
47
|
-
|
48
|
-
BUNDLED WITH
|
49
|
-
1.17.3
|