rom-elasticsearch 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -8
  3. data/README.md +7 -7
  4. data/lib/rom-elasticsearch.rb +2 -0
  5. data/lib/rom/elasticsearch.rb +3 -1
  6. data/lib/rom/elasticsearch/attribute.rb +2 -0
  7. data/lib/rom/elasticsearch/commands.rb +2 -0
  8. data/lib/rom/elasticsearch/dataset.rb +6 -0
  9. data/lib/rom/elasticsearch/errors.rb +2 -0
  10. data/lib/rom/elasticsearch/gateway.rb +2 -0
  11. data/lib/rom/elasticsearch/index_name.rb +2 -0
  12. data/lib/rom/elasticsearch/plugins/relation/query_dsl.rb +2 -0
  13. data/lib/rom/elasticsearch/query_methods.rb +2 -0
  14. data/lib/rom/elasticsearch/relation.rb +60 -0
  15. data/lib/rom/elasticsearch/relation/loaded.rb +2 -0
  16. data/lib/rom/elasticsearch/schema.rb +5 -1
  17. data/lib/rom/elasticsearch/scroll_methods.rb +40 -0
  18. data/lib/rom/elasticsearch/types.rb +7 -5
  19. data/lib/rom/elasticsearch/version.rb +3 -1
  20. metadata +18 -78
  21. data/.codeclimate.yml +0 -6
  22. data/.gitignore +0 -22
  23. data/.rspec +0 -3
  24. data/.travis.yml +0 -27
  25. data/.yardopts +0 -7
  26. data/CONTRIBUTING.md +0 -29
  27. data/Gemfile +0 -19
  28. data/Rakefile +0 -19
  29. data/docker-compose.yml +0 -7
  30. data/rom-elasticsearch.gemspec +0 -27
  31. data/spec/integration/rom/elasticsearch/relation/command_spec.rb +0 -47
  32. data/spec/integration/rom/elasticsearch/relation/multi_index_spec.rb +0 -60
  33. data/spec/integration/rom/elasticsearch/relation/schema_spec.rb +0 -25
  34. data/spec/shared/setup.rb +0 -16
  35. data/spec/shared/unit/user_fixtures.rb +0 -15
  36. data/spec/shared/unit/users.rb +0 -18
  37. data/spec/spec_helper.rb +0 -42
  38. data/spec/unit/rom/elasticsearch/dataset/body_spec.rb +0 -13
  39. data/spec/unit/rom/elasticsearch/dataset/delete_spec.rb +0 -17
  40. data/spec/unit/rom/elasticsearch/dataset/params_spec.rb +0 -13
  41. data/spec/unit/rom/elasticsearch/dataset/put_spec.rb +0 -14
  42. data/spec/unit/rom/elasticsearch/dataset/query_string_spec.rb +0 -12
  43. data/spec/unit/rom/elasticsearch/dataset/search_spec.rb +0 -20
  44. data/spec/unit/rom/elasticsearch/gateway_spec.rb +0 -10
  45. data/spec/unit/rom/elasticsearch/plugins/relation/query_dsl_spec.rb +0 -34
  46. data/spec/unit/rom/elasticsearch/relation/call_spec.rb +0 -22
  47. data/spec/unit/rom/elasticsearch/relation/create_index_spec.rb +0 -75
  48. data/spec/unit/rom/elasticsearch/relation/dataset_spec.rb +0 -51
  49. data/spec/unit/rom/elasticsearch/relation/delete_spec.rb +0 -32
  50. data/spec/unit/rom/elasticsearch/relation/get_spec.rb +0 -22
  51. data/spec/unit/rom/elasticsearch/relation/map_spec.rb +0 -18
  52. data/spec/unit/rom/elasticsearch/relation/order_spec.rb +0 -40
  53. data/spec/unit/rom/elasticsearch/relation/page_spec.rb +0 -20
  54. data/spec/unit/rom/elasticsearch/relation/pluck_spec.rb +0 -18
  55. data/spec/unit/rom/elasticsearch/relation/query_spec.rb +0 -18
  56. data/spec/unit/rom/elasticsearch/relation/query_string_spec.rb +0 -18
  57. data/spec/unit/rom/elasticsearch/relation/search_spec.rb +0 -18
  58. data/spec/unit/rom/elasticsearch/relation/to_a_spec.rb +0 -28
@@ -1,6 +0,0 @@
1
- engines:
2
- rubocop:
3
- enabled: true
4
- ratings:
5
- paths:
6
- - lib/**
data/.gitignore DELETED
@@ -1,22 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- *.bundle
19
- *.so
20
- *.o
21
- *.a
22
- mkmf.log
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --order random
3
- --require ./spec/spec_helper.rb
@@ -1,27 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
- before_install: gem update --system
5
- services:
6
- - elasticsearch
7
- bundler_args: --without yard guard benchmarks tools
8
- before_script:
9
- - curl -XPUT http://localhost:9200/rom-test
10
- after_success:
11
- - '[ -d coverage ] && bundle exec codeclimate-test-reporter'
12
- script: "bundle exec rake ci"
13
- rvm:
14
- - 2.5.0
15
- - 2.4.3
16
- - 2.3.6
17
- - jruby-9.1.12.0
18
- env:
19
- global:
20
- - COVERAGE='true'
21
- notifications:
22
- webhooks:
23
- urls:
24
- - https://webhooks.gitter.im/e/39e1225f489f38b0bd09
25
- on_success: change
26
- on_failure: always
27
- on_start: false
data/.yardopts DELETED
@@ -1,7 +0,0 @@
1
- --plugin junk
2
- --query '@api.text != "private"'
3
- --embed-mixins
4
- -r README.md
5
- --markup-provider=redcarpet
6
- --markup=markdown
7
- --files CHANGELOG.md
@@ -1,29 +0,0 @@
1
- # Issue Guidelines
2
-
3
- ## Reporting bugs
4
-
5
- If you found a bug, report an issue and describe what's the expected behavior versus what actually happens. If the bug causes a crash, attach a full backtrace. If possible, a reproduction script showing the problem is highly appreciated.
6
-
7
- ## Reporting feature requests
8
-
9
- Report a feature request **only after discussing it first on [discourse.rom-rb.org](https://discourse.rom-rb.org)** where it was accepted. Please provide a concise description of the feature, don't link to a discussion thread, and instead summarize what was discussed.
10
-
11
- ## Reporting questions, support requests, ideas, concerns etc.
12
-
13
- **PLEASE DON'T** - use [discourse.rom-rb.org](http://discourse.rom-rb.org) instead.
14
-
15
- # Pull Request Guidelines
16
-
17
- A Pull Request will only be accepted if it addresses a specific issue that was reported previously, or fixes typos, mistakes in documentation etc.
18
-
19
- Other requirements:
20
-
21
- 1) Do not open a pull request if you can't provide tests along with it. If you have problems writing tests, ask for help in the related issue.
22
- 2) Follow the style conventions of the surrounding code. In most cases, this is standard ruby style.
23
- 3) Add API documentation if it's a new feature
24
- 4) Update API documentation if it changes an existing feature
25
- 5) Bonus points for sending a PR to [github.com/rom-rb/rom-rb.org](https://github.com/rom-rb/rom-rb.org) which updates user documentation and guides
26
-
27
- # Asking for help
28
-
29
- If these guidelines aren't helpful, and you're stuck, please post a message on [discourse.rom-rb.org](https://discourse.rom-rb.org).
data/Gemfile DELETED
@@ -1,19 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in rom-elasticsearch.gemspec
4
- gemspec
5
-
6
- gem 'rom', git: 'https://github.com/rom-rb/rom', branch: 'master' do
7
- gem 'rom-core'
8
- gem 'rom-mapper'
9
- end
10
-
11
- gem 'codeclimate-test-reporter', require: false
12
- gem 'simplecov', require: false
13
-
14
- gem 'byebug', platform: :mri
15
- gem 'elasticsearch-dsl'
16
-
17
- group :tools do
18
- gem 'kramdown' # for yard
19
- end
data/Rakefile DELETED
@@ -1,19 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
- task default: [:ci]
6
-
7
- desc "Run CI tasks"
8
- task ci: [:spec]
9
-
10
- begin
11
- require "rubocop/rake_task"
12
-
13
- Rake::Task[:default].enhance [:rubocop]
14
-
15
- RuboCop::RakeTask.new do |task|
16
- task.options << "--display-cop-names"
17
- end
18
- rescue LoadError
19
- end
@@ -1,7 +0,0 @@
1
- version: "2"
2
-
3
- services:
4
- elasticsearch:
5
- image: docker.elastic.co/elasticsearch/elasticsearch:6.0.0
6
- ports:
7
- - "9200:9200"
@@ -1,27 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'rom/elasticsearch/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'rom-elasticsearch'
8
- spec.version = ROM::Elasticsearch::VERSION
9
- spec.authors = ['Hannes Nevalainen', 'Piotr Solnica']
10
- spec.email = ['hannes.nevalainen@me.com', 'piotr.solnica+oss@gmail.com']
11
- spec.summary = %q{ROM adapter for Elasticsearch}
12
- spec.description = %q{}
13
- spec.homepage = 'http://rom-rb.org'
14
- spec.license = 'MIT'
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ['lib']
20
-
21
- spec.add_runtime_dependency 'rom-core', '~> 4.1'
22
- spec.add_runtime_dependency 'elasticsearch', '~> 6.0'
23
-
24
- spec.add_development_dependency 'bundler', '~> 1.6'
25
- spec.add_development_dependency 'rake'
26
- spec.add_development_dependency 'rspec'
27
- end
@@ -1,47 +0,0 @@
1
- RSpec.describe ROM::Elasticsearch::Relation, '#command' do
2
- subject(:relation) { relations[:users] }
3
-
4
- include_context 'setup'
5
-
6
- before do
7
- conf.relation(:users) do
8
- schema(:users) do
9
- attribute :id, ROM::Elasticsearch::Types::ID
10
- attribute :name, ROM::Types::String
11
- end
12
- end
13
- end
14
-
15
- describe ':create' do
16
- it 'returns a create command' do
17
- command = relation.command(:create, result: :one)
18
-
19
- expect(command.call(id: 1, name: 'Jane')).to eql(id: 1, name: 'Jane')
20
- end
21
-
22
- it 'applies input function' do
23
- command = relation.command(:create, result: :one)
24
-
25
- input = double(:user, to_hash: { id: 1, name: 'Jane' })
26
-
27
- expect(command.call(input)).to eql(id: 1, name: 'Jane')
28
- end
29
- end
30
-
31
- describe ':delete' do
32
- before do
33
- relation.command(:create).call(id: 1, name: 'Jane')
34
- relation.command(:create).call(id: 2, name: 'John')
35
-
36
- relation.refresh
37
- end
38
-
39
- it 'deletes matching data' do
40
- relation.get(2).command(:delete).call
41
-
42
- relation.refresh
43
-
44
- expect(relation.to_a).to eql([{ id: 1, name: 'Jane' }])
45
- end
46
- end
47
- end
@@ -1,60 +0,0 @@
1
- RSpec.describe ROM::Elasticsearch::Relation, '.schema' do
2
- subject(:relation) { relations[:search] }
3
-
4
- include_context 'setup'
5
-
6
- let(:posts) { relations[:posts] }
7
- let(:pages) { relations[:pages] }
8
-
9
- before do
10
- conf.relation(:posts) do
11
- schema(:posts) do
12
- attribute :id, ROM::Elasticsearch::Types::ID
13
- attribute :title, ROM::Elasticsearch::Types.Text
14
- end
15
- end
16
-
17
- conf.relation(:pages) do
18
- schema(:pages) do
19
- attribute :id, ROM::Elasticsearch::Types::ID
20
- attribute :title, ROM::Elasticsearch::Types.Text
21
- end
22
- end
23
-
24
- conf.relation(:search) do
25
- multi_index_types %i[post page]
26
-
27
- schema(multi: true) do
28
- attribute :id, ROM::Elasticsearch::Types::ID
29
- attribute :title, ROM::Elasticsearch::Types.Text
30
- end
31
- end
32
-
33
- posts.create_index
34
- pages.create_index
35
- end
36
-
37
- after do
38
- posts.delete_index
39
- pages.delete_index
40
- end
41
-
42
- it 'search through specified indices' do
43
- posts.command(:create).call(id: 1, title: 'Post 1')
44
- posts.command(:create).call(id: 2, title: 'Post 2')
45
-
46
- pages.command(:create).call(id: 1, title: 'Page 1')
47
- pages.command(:create).call(id: 2, title: 'Page 2')
48
-
49
- posts.refresh
50
- pages.refresh
51
-
52
- result = relation.query(match: { title: 'Post'})
53
-
54
- expect(result.to_a).to eql([{ id: 1, title: 'Post 1'}, { id: 2, title: 'Post 2'}])
55
-
56
- result = relation.query(match: { title: '1'})
57
-
58
- expect(result.to_a).to eql([{ id: 1, title: 'Page 1'}, { id: 1, title: 'Post 1'}])
59
- end
60
- end
@@ -1,25 +0,0 @@
1
- RSpec.describe ROM::Elasticsearch::Relation, '.schema' do
2
- subject(:relation) { relations[:users] }
3
-
4
- include_context 'setup'
5
-
6
- before do
7
- conf.relation(:users) do
8
- schema(:users) do
9
- attribute :id, ROM::Elasticsearch::Types::ID
10
- attribute :name, ROM::Elasticsearch::Types.Text, read: ROM::Types.Constructor(Symbol, &:to_sym)
11
- end
12
- end
13
- end
14
-
15
- it 'defines read/write types' do
16
- relation.create_index
17
-
18
- relation.command(:create).call(id: 1, name: 'Jane')
19
-
20
- user = relation.get(1).one
21
-
22
- expect(user[:id]).to be(1)
23
- expect(user[:name]).to be(:Jane)
24
- end
25
- end
@@ -1,16 +0,0 @@
1
- RSpec.shared_context 'setup' do
2
- let(:uri) { "http://127.0.0.1:9200" }
3
-
4
- let(:conf) { ROM::Configuration.new(:elasticsearch, uri) }
5
- let(:container) { ROM.container(conf) }
6
-
7
- let(:gateway) { conf.gateways[:default] }
8
- let(:client) { gateway.client }
9
-
10
- let(:relations) { container[:relations] }
11
- let(:commands) { container[:commands] }
12
-
13
- after do
14
- client.indices.delete(index: :users) if gateway.index?(:users)
15
- end
16
- end
@@ -1,15 +0,0 @@
1
- RSpec.shared_context 'user fixtures' do
2
- include_context 'setup'
3
-
4
- before do
5
- dataset.put(username: 'eve')
6
- dataset.put(username: 'bob')
7
- dataset.put(username: 'alice')
8
-
9
- dataset.refresh
10
- end
11
-
12
- after do
13
- gateway[:users].refresh.delete
14
- end
15
- end
@@ -1,18 +0,0 @@
1
- RSpec.shared_context 'users' do
2
- include_context 'setup'
3
-
4
- before do
5
- conf.relation(:users) do
6
- schema(:users) do
7
- attribute :id, ROM::Types::Int
8
- attribute :name, ROM::Types::String
9
-
10
- primary_key :id
11
- end
12
- end
13
- end
14
-
15
- after do
16
- gateway[:users].refresh.delete
17
- end
18
- end
@@ -1,42 +0,0 @@
1
- require 'bundler'
2
- Bundler.setup
3
-
4
- if RUBY_ENGINE == 'ruby' && ENV['COVERAGE'] == 'true'
5
- require 'yaml'
6
- rubies = YAML.load(File.read(File.join(__dir__, '..', '.travis.yml')))['rvm']
7
- latest_mri = rubies.select { |v| v =~ /\A\d+\.\d+.\d+\z/ }.max
8
-
9
- if RUBY_VERSION == latest_mri
10
- require 'simplecov'
11
- SimpleCov.start do
12
- add_filter '/spec/'
13
- end
14
- end
15
- end
16
-
17
- begin
18
- require 'byebug'
19
- rescue LoadError
20
- end
21
-
22
- require 'rom-elasticsearch'
23
-
24
- SPEC_ROOT = Pathname(__FILE__).dirname
25
-
26
- Dir[SPEC_ROOT.join('shared/**/*.rb')].each { |f| require f }
27
-
28
- RSpec.configure do |config|
29
- config.disable_monkey_patching!
30
-
31
- # elasticsearch-dsl warnings are killing me - solnic
32
- config.warnings = false
33
-
34
- config.before do
35
- module Test
36
- end
37
- end
38
-
39
- config.after do
40
- Object.send(:remove_const, :Test)
41
- end
42
- end
@@ -1,13 +0,0 @@
1
- RSpec.describe ROM::Elasticsearch::Dataset, '#body' do
2
- subject(:dataset) do
3
- ROM::Elasticsearch::Dataset.new(client, params: { index: :users, type: :user })
4
- end
5
-
6
- include_context 'user fixtures'
7
-
8
- it 'returns a new dataset with updated body' do
9
- new_ds = dataset.body(id: 1)
10
-
11
- expect(new_ds.body).to eql(id: 1)
12
- end
13
- end
@@ -1,17 +0,0 @@
1
- RSpec.describe ROM::Elasticsearch::Dataset, '#delete' do
2
- subject(:dataset) do
3
- ROM::Elasticsearch::Dataset.new(client, params: { index: :users, type: :user })
4
- end
5
-
6
- include_context 'user fixtures'
7
-
8
- it 'deletes data' do
9
- expect(dataset.to_a.size).to eql(3)
10
-
11
- dataset.refresh.delete
12
-
13
- dataset.refresh
14
-
15
- expect(dataset.to_a.size).to eql(0)
16
- end
17
- end