hosted_solr-api 0.6.0
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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +3 -0
- data/.rubocop.yml +4 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/Guardfile +23 -0
- data/LICENSE.txt +21 -0
- data/README.md +147 -0
- data/Rakefile +12 -0
- data/assets/images/dkd_logo.png +0 -0
- data/bin/console +7 -0
- data/bin/setup +7 -0
- data/hosted_solr-api.gemspec +39 -0
- data/lib/hosted_solr/api.rb +11 -0
- data/lib/hosted_solr/api/client.rb +47 -0
- data/lib/hosted_solr/api/configuration.rb +29 -0
- data/lib/hosted_solr/api/configuration_sugar.rb +17 -0
- data/lib/hosted_solr/api/drupal_solr_core.rb +11 -0
- data/lib/hosted_solr/api/errors.rb +18 -0
- data/lib/hosted_solr/api/has_configuration.rb +20 -0
- data/lib/hosted_solr/api/magento_solr_bridge_search_solr_core.rb +11 -0
- data/lib/hosted_solr/api/magento_solr_core.rb +11 -0
- data/lib/hosted_solr/api/solr_core.rb +38 -0
- data/lib/hosted_solr/api/solr_cores_api_client.rb +40 -0
- data/lib/hosted_solr/api/solr_for_typo3_20x_solr_core.rb +11 -0
- data/lib/hosted_solr/api/solr_for_typo3_301_solr_core.rb +11 -0
- data/lib/hosted_solr/api/solr_for_typo3_310_solr_core.rb +11 -0
- data/lib/hosted_solr/api/sunspot_solr_core.rb +11 -0
- data/lib/hosted_solr/api/version.rb +5 -0
- metadata +297 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7399c0b428a4cf34d8a3c751639d07cbc4159285
|
4
|
+
data.tar.gz: 6ae15e4793b1a406c4516e3b3a498e35efb47d49
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3514464f758f4aa1c5436c11e5cd8b0612b5f60fd6f2b0c09ba7383376d7e4a7f1e3afe7c4af96faa66860c7b7089a539f7116887453f1e5be617e3099fd53a8
|
7
|
+
data.tar.gz: 44677188cfc5dd939e574a34ead7da4308aa95bf2ce745297e428fe17cbe8e6159012922e3200f330c582a06f81a0e31a58879fb6da0786316418f8320fd8ad5
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
group :rubocop_and_rspec, halt_on_fail: true do
|
2
|
+
guard :rubocop, cmd: 'bundle exec rubocop' do
|
3
|
+
watch(/.+\.rb$/)
|
4
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
5
|
+
end
|
6
|
+
|
7
|
+
guard :rspec, cmd: 'bundle exec rspec', all_on_start: true, all_after_pass: true do
|
8
|
+
require 'guard/rspec/dsl'
|
9
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
10
|
+
|
11
|
+
# RSpec files
|
12
|
+
rspec = dsl.rspec
|
13
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
14
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
15
|
+
watch(rspec.spec_files)
|
16
|
+
|
17
|
+
# Ruby files
|
18
|
+
ruby = dsl.ruby
|
19
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
scope group: :rubocop_and_rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Nicolai Reuschling, dkd Internet Service GmbH
|
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,147 @@
|
|
1
|
+
# HostedSolr::API
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/hosted_solr-api) [](https://travis-ci.org/dkd/hosted_solr-api) [](https://coveralls.io/github/dkd/hosted_solr-api?branch=master)
|
4
|
+
|
5
|
+
|
6
|
+
This Rubygem allows convient access to [Hosted Solr](https://www.hosted-solr.com/) API. You can create new Solr Cores, check the status of your Solr Cores and destroy them as well.
|
7
|
+
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```Ruby
|
14
|
+
gem 'hosted_solr-api', '~> 0.1'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
```Shell
|
20
|
+
$ bundle
|
21
|
+
```
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
```Shell
|
26
|
+
$ gem install hosted_solr-api
|
27
|
+
```
|
28
|
+
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
### Configuration
|
33
|
+
|
34
|
+
You need to configure your API and Secret Tokens, which you find in your [Hosted Solr profile](https://www.hosted-solr.com/account/api_credentials). There are two ways to accomplish this:
|
35
|
+
|
36
|
+
1. Either set enviromental variables like this (e.g. Ubuntu):
|
37
|
+
|
38
|
+
```Shell
|
39
|
+
export HOSTED_SOLR_API_TOKEN=your-api-token
|
40
|
+
export HOSTED_SOLR_SECRET_TOKEN=your-secret-token
|
41
|
+
```
|
42
|
+
|
43
|
+
2. Set your tokens Rails-like in an included config file (`config/initializers/hosted_solr_api.rb`):
|
44
|
+
|
45
|
+
```Ruby
|
46
|
+
require 'hosted_solr/api'
|
47
|
+
|
48
|
+
HostedSolr::API.configure do |config|
|
49
|
+
config.api_token = 'your-api-token'
|
50
|
+
config.secret_token = 'your-secret-token'
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
|
55
|
+
### API calls
|
56
|
+
|
57
|
+
#### 1. Create new Solr Cores
|
58
|
+
|
59
|
+
This Rubygem ships with preconfigured SolrCore objects of all supported systems. See section "Available Core Configurations" for more details. Let's create a first generic Solr Core:
|
60
|
+
|
61
|
+
```Ruby
|
62
|
+
require 'hosted_solr/api'
|
63
|
+
|
64
|
+
client = HostedSolr::API::Client.new
|
65
|
+
|
66
|
+
solr_core = HostedSolr::API::SolrCore.new name: 'my-new-solr-core',
|
67
|
+
system: 'sunspot',
|
68
|
+
solr_version: '3.5',
|
69
|
+
schema: 'standard'
|
70
|
+
|
71
|
+
solr_core.valid? # => true, client will only accept valid Solr Core objects
|
72
|
+
|
73
|
+
client.create_solr_core solr_core
|
74
|
+
```
|
75
|
+
|
76
|
+
#### 2. Checking status of existing Solr Cores
|
77
|
+
|
78
|
+
To check the status and configuration of your Cores use the following:
|
79
|
+
|
80
|
+
```Ruby
|
81
|
+
all_cores = client.all_solr_cores
|
82
|
+
|
83
|
+
first_core = all_cores.first
|
84
|
+
first_core.name # => 'my-new-solr-core'; assuming, we created the Core above
|
85
|
+
first_core.id # => 675
|
86
|
+
|
87
|
+
first_core.connection_uri.to_s # => 'https://b9a3e9c5c85-my-little-solr-index:ec397fb47bf@97a04a.hosted-solr.com/b9a3e9c5c85-my-new-solr-core/core'
|
88
|
+
```
|
89
|
+
|
90
|
+
#### 3. Destroying Solr Cores
|
91
|
+
|
92
|
+
Existing Cores can be destroyed as well:
|
93
|
+
|
94
|
+
```Ruby
|
95
|
+
client.destroy_solr_core solr_core # either SolrCore object or id
|
96
|
+
```
|
97
|
+
|
98
|
+
### Available Core Configurations
|
99
|
+
|
100
|
+
Only following system configurations are supported:
|
101
|
+
|
102
|
+
|System|Class Name|system|schema|solr_version|
|
103
|
+
|:---|:---|:---|---:|---:|
|
104
|
+
|[TYPO3](https://typo3.org/extensions/repository/view/solr/)|`SolrForTypo320xSolrCore` or `SolrForTypo3301SolrCore`|`typo3`|`german` or `english`|`3.6` or `4.8`|
|
105
|
+
|[Sunspot](https://sunspot.github.io/)|`SunspotSolrCore`|`sunspot`|`standard`|`3.5`|
|
106
|
+
|[Magento](http://magento.com/)|`MagentoSolrCore`|`magento`|`german` or `english`|`3.6` or `4.8`|
|
107
|
+
|[Magento Solr Bridge Search](http://www.magentocommerce.com/magento-connect/solr-bridge-search.html)|`MagentoSolrBridgeSearchSolrCore`|`solrbridge`|`german`|`4.9`|
|
108
|
+
|[Drupal](https://www.drupal.org/)|`DrupalSolrCore`|`drupal`|`standard`|`4.8`|
|
109
|
+
|
110
|
+
Every given class name is a from SolrCore rerived class, which simplifies creation of new cores. Following constructors are available:
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
# Solr for TYPO3 v2.0.x
|
114
|
+
core = SolrForTypo320xSolrCore.new 'core_name'
|
115
|
+
|
116
|
+
# Solr for TYPO3 v3.0.1
|
117
|
+
core = SolrForTypo3301SolrCore.new 'core_name'
|
118
|
+
|
119
|
+
# Sunspot
|
120
|
+
core = SunspotSolrCore.new 'core_name'
|
121
|
+
|
122
|
+
# Magento
|
123
|
+
core = MagentoSolrCore.new 'core_name', 'german', '3.6' # see available options above
|
124
|
+
|
125
|
+
# Magento Solr Bridge Search
|
126
|
+
core = MagentoSolrBridgeSearchSolrCore.new 'core_name'
|
127
|
+
|
128
|
+
# Drupal
|
129
|
+
core = DrupalSolrCore.new 'core_name'
|
130
|
+
```
|
131
|
+
|
132
|
+
|
133
|
+
## Contributing
|
134
|
+
|
135
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/dkd/hosted_solr-api).
|
136
|
+
|
137
|
+
|
138
|
+
## License
|
139
|
+
|
140
|
+
The Rubygem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
141
|
+
|
142
|
+
|
143
|
+
## Credits
|
144
|
+
|
145
|
+
[](https://dkd.de/)
|
146
|
+
|
147
|
+
* Nicolai Reuschling
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
RuboCop::RakeTask.new
|
5
|
+
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
RSpec::Core::RakeTask.new('spec')
|
8
|
+
task default: :spec
|
9
|
+
|
10
|
+
require 'coveralls/rake/task'
|
11
|
+
Coveralls::RakeTask.new
|
12
|
+
task test_with_coveralls: [:rubocop, :spec, 'coveralls:push']
|
Binary file
|
data/bin/console
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hosted_solr/api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'hosted_solr-api'
|
8
|
+
spec.version = HostedSolr::API::VERSION
|
9
|
+
spec.authors = ['Nicolai Reuschling']
|
10
|
+
spec.email = ['nicolai.reuschling@dkd.de']
|
11
|
+
|
12
|
+
spec.summary = 'Client for Hosted Solr API'
|
13
|
+
spec.description = 'Allow access to Hosted Solr API.'
|
14
|
+
spec.homepage = 'https://github.com/dkd/hosted_solr-api'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
25
|
+
spec.add_development_dependency 'rspec-nc', '~> 0.2'
|
26
|
+
spec.add_development_dependency 'guard', '~> 2.13'
|
27
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.6'
|
28
|
+
spec.add_development_dependency 'guard-rubocop', '~> 1.2'
|
29
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
30
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.2'
|
31
|
+
spec.add_development_dependency 'rubocop', '~> 0.33'
|
32
|
+
spec.add_development_dependency 'coveralls', '~> 0.8'
|
33
|
+
spec.add_development_dependency 'growl', '~> 1.0'
|
34
|
+
spec.add_development_dependency 'shoulda-matchers', '~> 2.8'
|
35
|
+
|
36
|
+
spec.add_dependency 'activemodel', '~> 4.2'
|
37
|
+
spec.add_dependency 'activesupport', '~> 4.2'
|
38
|
+
spec.add_dependency 'active_rest_client', '~> 1.1'
|
39
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'hosted_solr/api/version'
|
2
|
+
require 'hosted_solr/api/errors'
|
3
|
+
require 'hosted_solr/api/has_configuration'
|
4
|
+
require 'hosted_solr/api/client'
|
5
|
+
require 'hosted_solr/api/sunspot_solr_core'
|
6
|
+
require 'hosted_solr/api/drupal_solr_core'
|
7
|
+
require 'hosted_solr/api/magento_solr_core'
|
8
|
+
require 'hosted_solr/api/magento_solr_bridge_search_solr_core'
|
9
|
+
require 'hosted_solr/api/solr_for_typo3_20x_solr_core'
|
10
|
+
require 'hosted_solr/api/solr_for_typo3_301_solr_core'
|
11
|
+
require 'hosted_solr/api/solr_for_typo3_310_solr_core'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'hosted_solr/api/errors'
|
3
|
+
require 'hosted_solr/api/has_configuration'
|
4
|
+
require 'hosted_solr/api/solr_core'
|
5
|
+
require 'hosted_solr/api/solr_cores_api_client'
|
6
|
+
|
7
|
+
module HostedSolr
|
8
|
+
module API
|
9
|
+
class Client
|
10
|
+
include HostedSolr::API::HasConfiguration
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
fail APITokenMissingError if configuration.api_token.nil?
|
14
|
+
fail SecretTokenMissingError if configuration.secret_token.nil?
|
15
|
+
@api_client = SolrCoresAPIClient.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def all_solr_cores
|
19
|
+
@api_client.all.map do |response_entry|
|
20
|
+
SolrCore.from_hash response_entry.to_hash
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_solr_core(solr_core)
|
25
|
+
fail ArgumentError, 'Error: SolrCore expected!' unless solr_core.is_a? SolrCore
|
26
|
+
return false unless solr_core.valid?
|
27
|
+
@api_client.name = solr_core.name
|
28
|
+
@api_client.solr_version = solr_core.solr_version
|
29
|
+
@api_client.schema = solr_core.schema
|
30
|
+
@api_client.system = solr_core.system
|
31
|
+
@api_client.create
|
32
|
+
end
|
33
|
+
|
34
|
+
def destroy_solr_core(solr_core)
|
35
|
+
case solr_core
|
36
|
+
when Integer, String
|
37
|
+
id = solr_core
|
38
|
+
when SolrCore
|
39
|
+
id = solr_core.id
|
40
|
+
else
|
41
|
+
fail ArgumentError, 'Error: SolrCore or SolrCore id expected!'
|
42
|
+
end
|
43
|
+
@api_client.destroy String(id)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module HostedSolr
|
2
|
+
module API
|
3
|
+
class Configuration
|
4
|
+
attr_accessor :base_url, :api_token, :secret_token
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@base_url = 'https://www.hosted-solr.com/api'
|
8
|
+
end
|
9
|
+
|
10
|
+
def api_token
|
11
|
+
@api_token = find_api_token
|
12
|
+
end
|
13
|
+
|
14
|
+
def secret_token
|
15
|
+
@secret_token = find_secret_token
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def find_api_token
|
21
|
+
@api_token || ENV['HOSTED_SOLR_API_TOKEN']
|
22
|
+
end
|
23
|
+
|
24
|
+
def find_secret_token
|
25
|
+
@secret_token || ENV['HOSTED_SOLR_SECRET_TOKEN']
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'hosted_solr/api/configuration'
|
2
|
+
|
3
|
+
module HostedSolr
|
4
|
+
module API
|
5
|
+
class << self
|
6
|
+
attr_accessor :configuration
|
7
|
+
|
8
|
+
def configuration
|
9
|
+
@configuration ||= Configuration.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def configure
|
13
|
+
yield configuration
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module HostedSolr
|
2
|
+
module API
|
3
|
+
class Error < RuntimeError
|
4
|
+
end
|
5
|
+
|
6
|
+
class APITokenMissingError < Error
|
7
|
+
def message
|
8
|
+
'Please configure Hosted Solr API token or set HOSTED_SOLR_API_TOKEN environment variable.'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class SecretTokenMissingError < Error
|
13
|
+
def message
|
14
|
+
'Please configure Hosted Solr Secret token or set HOSTED_SOLR_SECRET_TOKEN environment variable.'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
require 'hosted_solr/api/configuration_sugar'
|
3
|
+
|
4
|
+
module HostedSolr
|
5
|
+
module API
|
6
|
+
module HasConfiguration
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
def self.configuration
|
11
|
+
HostedSolr::API.configuration
|
12
|
+
end
|
13
|
+
|
14
|
+
def configuration
|
15
|
+
self.class.configuration
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'hosted_solr/api/solr_core'
|
2
|
+
|
3
|
+
module HostedSolr
|
4
|
+
module API
|
5
|
+
class MagentoSolrCore < SolrCore
|
6
|
+
def initialize(name, solr_version, schema)
|
7
|
+
super(name: name, system: 'magento', solr_version: solr_version, schema: schema)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'active_model'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module HostedSolr
|
5
|
+
module API
|
6
|
+
class SolrCore
|
7
|
+
include ActiveModel::Model
|
8
|
+
|
9
|
+
attr_accessor :id, :solr_version, :system, :schema, :host,
|
10
|
+
:name, :internal_name, :password,
|
11
|
+
:is_activated, :created_at, :updated_at
|
12
|
+
|
13
|
+
validates :name, presence: true,
|
14
|
+
format: { with: /^[a-z0-9\-]+$/, multiline: true, message: 'Name is allowed to contain only lower case characters, numbers and dashes' },
|
15
|
+
length: { maximum: 20 }
|
16
|
+
|
17
|
+
validates :solr_version, presence: true
|
18
|
+
validates :schema, presence: true
|
19
|
+
validates :system, presence: true
|
20
|
+
|
21
|
+
def self.from_hash(attributes_hash = {})
|
22
|
+
new(attributes_hash.slice(*%w(id solr_version system schema name host internal_name password is_activated created_at updated_at)))
|
23
|
+
end
|
24
|
+
|
25
|
+
def port
|
26
|
+
443
|
27
|
+
end
|
28
|
+
|
29
|
+
def protocol
|
30
|
+
'https'
|
31
|
+
end
|
32
|
+
|
33
|
+
def connection_uri
|
34
|
+
URI("#{protocol}://#{internal_name}:#{password}@#{host}:#{port}/#{internal_name}/core")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'active_rest_client'
|
2
|
+
require 'hosted_solr/api/has_configuration'
|
3
|
+
require 'hosted_solr/api/solr_core'
|
4
|
+
|
5
|
+
module HostedSolr
|
6
|
+
module API
|
7
|
+
class SolrCoresAPIClient < ActiveRestClient::Base
|
8
|
+
include HostedSolr::API::HasConfiguration
|
9
|
+
|
10
|
+
# Configuration
|
11
|
+
base_url configuration.base_url
|
12
|
+
request_body_type :json
|
13
|
+
whiny_missing false
|
14
|
+
|
15
|
+
# Helpers
|
16
|
+
class << self
|
17
|
+
def solr_cores_path(suffix = '')
|
18
|
+
"/solr_cores#{suffix}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def configured_authentication_params
|
22
|
+
{
|
23
|
+
api_token: configuration.api_token,
|
24
|
+
secret_token: configuration.secret_token
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Routes
|
30
|
+
get :all, solr_cores_path
|
31
|
+
post :create, solr_cores_path
|
32
|
+
delete :destroy, solr_cores_path('/:id')
|
33
|
+
|
34
|
+
# Callbacks
|
35
|
+
before_request do |_, request|
|
36
|
+
request.get_params.merge!(configured_authentication_params)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,297 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hosted_solr-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nicolai Reuschling
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-nc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.13'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.13'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '4.6'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '4.6'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard-rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.2'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.2'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.10'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.10'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-byebug
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '3.2'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '3.2'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.33'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.33'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: coveralls
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.8'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0.8'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: growl
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '1.0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '1.0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: shoulda-matchers
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '2.8'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '2.8'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: activemodel
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '4.2'
|
202
|
+
type: :runtime
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '4.2'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: activesupport
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '4.2'
|
216
|
+
type: :runtime
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - "~>"
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '4.2'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: active_rest_client
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - "~>"
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '1.1'
|
230
|
+
type: :runtime
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - "~>"
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '1.1'
|
237
|
+
description: Allow access to Hosted Solr API.
|
238
|
+
email:
|
239
|
+
- nicolai.reuschling@dkd.de
|
240
|
+
executables: []
|
241
|
+
extensions: []
|
242
|
+
extra_rdoc_files: []
|
243
|
+
files:
|
244
|
+
- ".gitignore"
|
245
|
+
- ".rspec"
|
246
|
+
- ".rubocop.yml"
|
247
|
+
- ".travis.yml"
|
248
|
+
- Gemfile
|
249
|
+
- Guardfile
|
250
|
+
- LICENSE.txt
|
251
|
+
- README.md
|
252
|
+
- Rakefile
|
253
|
+
- assets/images/dkd_logo.png
|
254
|
+
- bin/console
|
255
|
+
- bin/setup
|
256
|
+
- hosted_solr-api.gemspec
|
257
|
+
- lib/hosted_solr/api.rb
|
258
|
+
- lib/hosted_solr/api/client.rb
|
259
|
+
- lib/hosted_solr/api/configuration.rb
|
260
|
+
- lib/hosted_solr/api/configuration_sugar.rb
|
261
|
+
- lib/hosted_solr/api/drupal_solr_core.rb
|
262
|
+
- lib/hosted_solr/api/errors.rb
|
263
|
+
- lib/hosted_solr/api/has_configuration.rb
|
264
|
+
- lib/hosted_solr/api/magento_solr_bridge_search_solr_core.rb
|
265
|
+
- lib/hosted_solr/api/magento_solr_core.rb
|
266
|
+
- lib/hosted_solr/api/solr_core.rb
|
267
|
+
- lib/hosted_solr/api/solr_cores_api_client.rb
|
268
|
+
- lib/hosted_solr/api/solr_for_typo3_20x_solr_core.rb
|
269
|
+
- lib/hosted_solr/api/solr_for_typo3_301_solr_core.rb
|
270
|
+
- lib/hosted_solr/api/solr_for_typo3_310_solr_core.rb
|
271
|
+
- lib/hosted_solr/api/sunspot_solr_core.rb
|
272
|
+
- lib/hosted_solr/api/version.rb
|
273
|
+
homepage: https://github.com/dkd/hosted_solr-api
|
274
|
+
licenses:
|
275
|
+
- MIT
|
276
|
+
metadata: {}
|
277
|
+
post_install_message:
|
278
|
+
rdoc_options: []
|
279
|
+
require_paths:
|
280
|
+
- lib
|
281
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
282
|
+
requirements:
|
283
|
+
- - ">="
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: '0'
|
286
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
287
|
+
requirements:
|
288
|
+
- - ">="
|
289
|
+
- !ruby/object:Gem::Version
|
290
|
+
version: '0'
|
291
|
+
requirements: []
|
292
|
+
rubyforge_project:
|
293
|
+
rubygems_version: 2.5.1
|
294
|
+
signing_key:
|
295
|
+
specification_version: 4
|
296
|
+
summary: Client for Hosted Solr API
|
297
|
+
test_files: []
|