sunspot_connector 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 70ce93e9fc78e66aa18b04945a82783f52ae2c6ffbc3d25536126e52c82008d7
4
+ data.tar.gz: fda318228db0bc148cf1bfd22cf06ad80cf28c232b24c62e44be1c2159f2249b
5
+ SHA512:
6
+ metadata.gz: 7759326385e9f18f65c5fbf4d7afe16f89140b1fb3f36917ed72c0b3b198f5663f297def3f974a84ae162e2f242247b0911c4efbd50fd19e27bef5db21ebaacb
7
+ data.tar.gz: 9889a1defa5c1257f46f20871f3ed2e500ea4fe090705711c7312af81631f53df7525b9660cfa4469d3fd92792302e95562b834567f76411bd407fed2960cab7
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.0
6
+ before_install: gem install bundler -v 2.1.2
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in sunspot_connector.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,159 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sunspot_connector (0.1.0)
5
+ faraday (~> 1.0)
6
+ sunspot_rails (~> 2.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actioncable (5.2.4.4)
12
+ actionpack (= 5.2.4.4)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailer (5.2.4.4)
16
+ actionpack (= 5.2.4.4)
17
+ actionview (= 5.2.4.4)
18
+ activejob (= 5.2.4.4)
19
+ mail (~> 2.5, >= 2.5.4)
20
+ rails-dom-testing (~> 2.0)
21
+ actionpack (5.2.4.4)
22
+ actionview (= 5.2.4.4)
23
+ activesupport (= 5.2.4.4)
24
+ rack (~> 2.0, >= 2.0.8)
25
+ rack-test (>= 0.6.3)
26
+ rails-dom-testing (~> 2.0)
27
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
+ actionview (5.2.4.4)
29
+ activesupport (= 5.2.4.4)
30
+ builder (~> 3.1)
31
+ erubi (~> 1.4)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
+ activejob (5.2.4.4)
35
+ activesupport (= 5.2.4.4)
36
+ globalid (>= 0.3.6)
37
+ activemodel (5.2.4.4)
38
+ activesupport (= 5.2.4.4)
39
+ activerecord (5.2.4.4)
40
+ activemodel (= 5.2.4.4)
41
+ activesupport (= 5.2.4.4)
42
+ arel (>= 9.0)
43
+ activestorage (5.2.4.4)
44
+ actionpack (= 5.2.4.4)
45
+ activerecord (= 5.2.4.4)
46
+ marcel (~> 0.3.1)
47
+ activesupport (5.2.4.4)
48
+ concurrent-ruby (~> 1.0, >= 1.0.2)
49
+ i18n (>= 0.7, < 2)
50
+ minitest (~> 5.1)
51
+ tzinfo (~> 1.1)
52
+ arel (9.0.0)
53
+ builder (3.2.4)
54
+ concurrent-ruby (1.1.8)
55
+ crass (1.0.6)
56
+ diff-lcs (1.4.4)
57
+ erubi (1.10.0)
58
+ faraday (1.3.0)
59
+ faraday-net_http (~> 1.0)
60
+ multipart-post (>= 1.2, < 3)
61
+ ruby2_keywords
62
+ faraday-net_http (1.0.1)
63
+ globalid (0.4.2)
64
+ activesupport (>= 4.2.0)
65
+ i18n (1.8.7)
66
+ concurrent-ruby (~> 1.0)
67
+ loofah (2.9.0)
68
+ crass (~> 1.0.2)
69
+ nokogiri (>= 1.5.9)
70
+ mail (2.7.1)
71
+ mini_mime (>= 0.1.1)
72
+ marcel (0.3.3)
73
+ mimemagic (~> 0.3.2)
74
+ method_source (1.0.0)
75
+ mimemagic (0.3.5)
76
+ mini_mime (1.0.2)
77
+ minitest (5.14.3)
78
+ multipart-post (2.1.1)
79
+ nio4r (2.5.4)
80
+ nokogiri (1.11.1-x86_64-darwin)
81
+ racc (~> 1.4)
82
+ pr_geohash (1.0.0)
83
+ racc (1.5.2)
84
+ rack (2.2.3)
85
+ rack-test (1.1.0)
86
+ rack (>= 1.0, < 3)
87
+ rails (5.2.4.4)
88
+ actioncable (= 5.2.4.4)
89
+ actionmailer (= 5.2.4.4)
90
+ actionpack (= 5.2.4.4)
91
+ actionview (= 5.2.4.4)
92
+ activejob (= 5.2.4.4)
93
+ activemodel (= 5.2.4.4)
94
+ activerecord (= 5.2.4.4)
95
+ activestorage (= 5.2.4.4)
96
+ activesupport (= 5.2.4.4)
97
+ bundler (>= 1.3.0)
98
+ railties (= 5.2.4.4)
99
+ sprockets-rails (>= 2.0.0)
100
+ rails-dom-testing (2.0.3)
101
+ activesupport (>= 4.2.0)
102
+ nokogiri (>= 1.6)
103
+ rails-html-sanitizer (1.3.0)
104
+ loofah (~> 2.3)
105
+ railties (5.2.4.4)
106
+ actionpack (= 5.2.4.4)
107
+ activesupport (= 5.2.4.4)
108
+ method_source
109
+ rake (>= 0.8.7)
110
+ thor (>= 0.19.0, < 2.0)
111
+ rake (12.3.3)
112
+ rsolr (2.3.0)
113
+ builder (>= 2.1.2)
114
+ faraday (>= 0.9.0)
115
+ rspec (3.8.0)
116
+ rspec-core (~> 3.8.0)
117
+ rspec-expectations (~> 3.8.0)
118
+ rspec-mocks (~> 3.8.0)
119
+ rspec-core (3.8.2)
120
+ rspec-support (~> 3.8.0)
121
+ rspec-expectations (3.8.6)
122
+ diff-lcs (>= 1.2.0, < 2.0)
123
+ rspec-support (~> 3.8.0)
124
+ rspec-mocks (3.8.2)
125
+ diff-lcs (>= 1.2.0, < 2.0)
126
+ rspec-support (~> 3.8.0)
127
+ rspec-support (3.8.3)
128
+ ruby2_keywords (0.0.4)
129
+ sprockets (4.0.2)
130
+ concurrent-ruby (~> 1.0)
131
+ rack (> 1, < 3)
132
+ sprockets-rails (3.2.2)
133
+ actionpack (>= 4.0)
134
+ activesupport (>= 4.0)
135
+ sprockets (>= 3.0.0)
136
+ sunspot (2.5.0)
137
+ pr_geohash (~> 1.0)
138
+ rsolr (>= 1.1.1, < 3)
139
+ sunspot_rails (2.5.0)
140
+ rails (>= 3)
141
+ sunspot (= 2.5.0)
142
+ thor (1.1.0)
143
+ thread_safe (0.3.6)
144
+ tzinfo (1.2.9)
145
+ thread_safe (~> 0.1)
146
+ websocket-driver (0.7.3)
147
+ websocket-extensions (>= 0.1.0)
148
+ websocket-extensions (0.1.5)
149
+
150
+ PLATFORMS
151
+ ruby
152
+
153
+ DEPENDENCIES
154
+ rake (~> 12.0)
155
+ rspec (~> 3.0)
156
+ sunspot_connector!
157
+
158
+ BUNDLED WITH
159
+ 2.1.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Mike Harris
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # SunspotConnector
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sunspot_connector`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'sunspot_connector'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install sunspot_connector
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sunspot_connector.
30
+
31
+
32
+ ## License
33
+
34
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sunspot_connector"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,9 @@
1
+ require "sunspot_connector/version"
2
+ require "sunspot_connector/config"
3
+ require "sunspot_connector/connection"
4
+ require "sunspot_connector/railtie"
5
+
6
+ module SunspotConnector
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SunspotConnector
4
+ # Config lets you add additional headers to solr requests
5
+ # and change the Faraday adapter RSolr is using
6
+ class Config
7
+ attr_accessor :headers, :adapter
8
+ def initialize
9
+ @headers = {}
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ require 'rsolr'
3
+ module SunspotConnector
4
+ class Connection
5
+ def initialize(config = Config.new)
6
+ raise ArgumentError, 'expected SunspotConnector::Config' unless config.is_a?(Config)
7
+ @config = config
8
+ end
9
+
10
+ def connect(opts = {})
11
+ RSolr::Client.new(build_connection, opts)
12
+ end
13
+
14
+ def build_connection
15
+ Faraday.new do |conn|
16
+ conn.headers = {
17
+ 'Keep-Alive' => 'timeout=10'
18
+ }.merge(@config.headers)
19
+ conn.adapter @config.adapter if @config.adapter
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ require 'rails/railtie'
3
+
4
+ module SunspotConnector
5
+
6
+ class Railtie < ::Rails::Railtie
7
+ config.solr_connection_overrides = nil
8
+ initializer 'override_solr_connection' do |app|
9
+ Sunspot::Session.connection_class = SunspotConnector::Connection.new(app.config.solr_connection_overrides)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module SunspotConnector
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,30 @@
1
+ require_relative 'lib/sunspot_connector/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "sunspot_connector"
5
+ spec.version = SunspotConnector::VERSION
6
+ spec.authors = ["Mike Harris"]
7
+ spec.email = ["mike.harris@cerner.com"]
8
+
9
+ spec.summary = "Allows the override of some Sunspot Solr HTTP settings"
10
+ spec.homepage = "https://github.com/mlh758/sunspot_connector"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = spec.homepage
17
+ spec.metadata["changelog_uri"] = spec.homepage
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_dependency 'sunspot_rails', '~> 2.0'
29
+ spec.add_dependency 'faraday', '~> 1.0'
30
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sunspot_connector
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mike Harris
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-02-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sunspot_rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ description:
42
+ email:
43
+ - mike.harris@cerner.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".rspec"
50
+ - ".travis.yml"
51
+ - Gemfile
52
+ - Gemfile.lock
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - bin/console
57
+ - bin/setup
58
+ - lib/sunspot_connector.rb
59
+ - lib/sunspot_connector/config.rb
60
+ - lib/sunspot_connector/connection.rb
61
+ - lib/sunspot_connector/railtie.rb
62
+ - lib/sunspot_connector/version.rb
63
+ - sunspot_connector.gemspec
64
+ homepage: https://github.com/mlh758/sunspot_connector
65
+ licenses:
66
+ - MIT
67
+ metadata:
68
+ homepage_uri: https://github.com/mlh758/sunspot_connector
69
+ source_code_uri: https://github.com/mlh758/sunspot_connector
70
+ changelog_uri: https://github.com/mlh758/sunspot_connector
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 2.3.0
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.1.2
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Allows the override of some Sunspot Solr HTTP settings
90
+ test_files: []