swiftype 0.0.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.travis.yml +6 -0
- data/Gemfile +1 -1
- data/README.md +202 -283
- data/lib/data/ca-bundle.crt +3554 -0
- data/lib/swiftype.rb +7 -31
- data/lib/swiftype/client.rb +439 -11
- data/lib/swiftype/configuration.rb +29 -4
- data/lib/swiftype/exceptions.rb +2 -0
- data/lib/swiftype/ext/backport-uri.rb +33 -0
- data/lib/swiftype/request.rb +88 -20
- data/lib/swiftype/result_set.rb +43 -6
- data/lib/swiftype/sso.rb +20 -0
- data/lib/swiftype/version.rb +1 -1
- data/spec/client_spec.rb +576 -0
- data/spec/configuration_spec.rb +36 -0
- data/spec/deprecated_spec.rb +20 -0
- data/spec/fixtures/vcr/analytics_autoselects.yml +55 -0
- data/spec/fixtures/vcr/analytics_autoselects_with_document_type.yml +55 -0
- data/spec/fixtures/vcr/analytics_autoselects_with_document_type_and_time_range.yml +55 -0
- data/spec/fixtures/vcr/analytics_autoselects_with_time_range.yml +55 -0
- data/spec/fixtures/vcr/analytics_clicks.yml +55 -0
- data/spec/fixtures/vcr/analytics_clicks_with_document_type.yml +55 -0
- data/spec/fixtures/vcr/analytics_clicks_with_document_type_and_time_range.yml +55 -0
- data/spec/fixtures/vcr/analytics_clicks_with_time_range.yml +55 -0
- data/spec/fixtures/vcr/analytics_searches.yml +55 -0
- data/spec/fixtures/vcr/analytics_searches_with_document_type_and_time_range.yml +55 -0
- data/spec/fixtures/vcr/analytics_searches_with_time_range.yml +55 -0
- data/spec/fixtures/vcr/analytics_searchs_with_document_type.yml +55 -0
- data/spec/fixtures/vcr/analytics_top_no_result_queries.yml +55 -0
- data/spec/fixtures/vcr/analytics_top_no_result_queries_paginated.yml +55 -0
- data/spec/fixtures/vcr/analytics_top_queries.yml +55 -0
- data/spec/fixtures/vcr/analytics_top_queries_paginated.yml +55 -0
- data/spec/fixtures/vcr/analytics_top_queries_too_large.yml +51 -0
- data/spec/fixtures/vcr/bulk_create_documents.yml +49 -0
- data/spec/fixtures/vcr/bulk_create_or_update_documents_failure.yml +45 -0
- data/spec/fixtures/vcr/bulk_create_or_update_documents_success.yml +49 -0
- data/spec/fixtures/vcr/bulk_destroy_documents.yml +45 -0
- data/spec/fixtures/vcr/crawl_url.yml +45 -0
- data/spec/fixtures/vcr/create_document.yml +48 -0
- data/spec/fixtures/vcr/create_document_type.yml +45 -0
- data/spec/fixtures/vcr/create_domain.yml +45 -0
- data/spec/fixtures/vcr/create_engine.yml +45 -0
- data/spec/fixtures/vcr/create_or_update_document_create.yml +47 -0
- data/spec/fixtures/vcr/create_or_update_document_update.yml +47 -0
- data/spec/fixtures/vcr/create_user.yml +45 -0
- data/spec/fixtures/vcr/destroy_document.yml +41 -0
- data/spec/fixtures/vcr/destroy_document_type.yml +41 -0
- data/spec/fixtures/vcr/destroy_domain.yml +41 -0
- data/spec/fixtures/vcr/destroy_engine.yml +41 -0
- data/spec/fixtures/vcr/destroy_non_existent_document_type.yml +43 -0
- data/spec/fixtures/vcr/document_type_search.yml +60 -0
- data/spec/fixtures/vcr/document_type_search_pagination.yml +45 -0
- data/spec/fixtures/vcr/document_type_suggest.yml +50 -0
- data/spec/fixtures/vcr/document_type_suggest_pagination.yml +45 -0
- data/spec/fixtures/vcr/engine_search.yml +64 -0
- data/spec/fixtures/vcr/engine_search_facets.yml +162 -0
- data/spec/fixtures/vcr/engine_search_pagination.yml +45 -0
- data/spec/fixtures/vcr/engine_suggest.yml +52 -0
- data/spec/fixtures/vcr/engine_suggest_pagination.yml +45 -0
- data/spec/fixtures/vcr/find_document.yml +47 -0
- data/spec/fixtures/vcr/find_document_type.yml +45 -0
- data/spec/fixtures/vcr/find_domain.yml +45 -0
- data/spec/fixtures/vcr/find_domain_failure.yml +43 -0
- data/spec/fixtures/vcr/find_engine.yml +45 -0
- data/spec/fixtures/vcr/list_document_type.yml +45 -0
- data/spec/fixtures/vcr/list_documents.yml +68 -0
- data/spec/fixtures/vcr/list_documents_with_pagination.yml +68 -0
- data/spec/fixtures/vcr/list_domains.yml +45 -0
- data/spec/fixtures/vcr/list_engines.yml +46 -0
- data/spec/fixtures/vcr/list_users.yml +45 -0
- data/spec/fixtures/vcr/list_users_with_pagination.yml +45 -0
- data/spec/fixtures/vcr/log_clickthrough_failure.yml +43 -0
- data/spec/fixtures/vcr/log_clickthrough_success.yml +45 -0
- data/spec/fixtures/vcr/recrawl_domain_failure.yml +44 -0
- data/spec/fixtures/vcr/recrawl_domain_success.yml +45 -0
- data/spec/fixtures/vcr/show_user.yml +45 -0
- data/spec/fixtures/vcr/update_document.yml +47 -0
- data/spec/fixtures/vcr/update_document_unknown_field_failure.yml +45 -0
- data/spec/fixtures/vcr/update_documents_failure_non_existent_document.yml +45 -0
- data/spec/fixtures/vcr/update_documents_success.yml +45 -0
- data/spec/fixtures/vcr/users_client_secret_incorrect.yml +42 -0
- data/spec/fixtures/vcr/users_no_api_key.yml +42 -0
- data/spec/fixtures/vcr/users_no_client_id_or_secret.yml +43 -0
- data/spec/platform_spec.rb +95 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/ssl_spec.rb +34 -0
- data/spec/sso_spec.rb +24 -0
- data/swiftype.gemspec +10 -11
- metadata +183 -52
- data/lib/swiftype/base_model.rb +0 -89
- data/lib/swiftype/connection.rb +0 -47
- data/lib/swiftype/document.rb +0 -17
- data/lib/swiftype/document_type.rb +0 -69
- data/lib/swiftype/easy.rb +0 -77
- data/lib/swiftype/engine.rb +0 -33
- data/lib/swiftype/search.rb +0 -23
data/swiftype.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
$:.push File.expand_path("../lib", __FILE__)
|
3
2
|
require "swiftype/version"
|
4
3
|
|
@@ -7,20 +6,20 @@ Gem::Specification.new do |s|
|
|
7
6
|
s.version = Swiftype::VERSION
|
8
7
|
s.authors = ["Quin Hoxie", "Matt Riley"]
|
9
8
|
s.email = ["team@swiftype.com"]
|
10
|
-
s.homepage = "
|
11
|
-
s.summary = %q{Swiftype API
|
12
|
-
s.description = %q{
|
9
|
+
s.homepage = "https://swiftype.com"
|
10
|
+
s.summary = %q{Official gem for accessing the Swiftype Search API}
|
11
|
+
s.description = %q{API client for accessing the Swiftype Search API with no dependencies (on Ruby 1.9, JSON needed for Ruby 1.8).}
|
13
12
|
|
14
13
|
s.files = `git ls-files`.split("\n")
|
15
14
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
15
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
16
|
s.require_paths = ["lib"]
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
s.
|
22
|
-
s.
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
s.add_development_dependency 'rspec'
|
19
|
+
s.add_development_dependency 'awesome_print'
|
20
|
+
s.add_development_dependency 'vcr'
|
21
|
+
s.add_development_dependency 'webmock'
|
22
|
+
if RUBY_VERSION < '1.9'
|
23
|
+
s.add_runtime_dependency 'json'
|
24
|
+
end
|
26
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swiftype
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,89 +10,74 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: rspec
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 1.7.7
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
|
-
requirements:
|
28
|
-
- - ~>
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
version: 1.7.7
|
31
|
-
- !ruby/object:Gem::Dependency
|
32
|
-
name: faraday
|
33
|
-
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
|
-
requirements:
|
36
|
-
- - ~>
|
20
|
+
- - ! '>='
|
37
21
|
- !ruby/object:Gem::Version
|
38
|
-
version: 0
|
39
|
-
type: :
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
40
24
|
prerelease: false
|
41
25
|
version_requirements: !ruby/object:Gem::Requirement
|
42
26
|
none: false
|
43
27
|
requirements:
|
44
|
-
- -
|
28
|
+
- - ! '>='
|
45
29
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0
|
30
|
+
version: '0'
|
47
31
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
32
|
+
name: awesome_print
|
49
33
|
requirement: !ruby/object:Gem::Requirement
|
50
34
|
none: false
|
51
35
|
requirements:
|
52
|
-
- -
|
36
|
+
- - ! '>='
|
53
37
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
55
|
-
type: :
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
56
40
|
prerelease: false
|
57
41
|
version_requirements: !ruby/object:Gem::Requirement
|
58
42
|
none: false
|
59
43
|
requirements:
|
60
|
-
- -
|
44
|
+
- - ! '>='
|
61
45
|
- !ruby/object:Gem::Version
|
62
|
-
version: 0
|
46
|
+
version: '0'
|
63
47
|
- !ruby/object:Gem::Dependency
|
64
|
-
name:
|
48
|
+
name: vcr
|
65
49
|
requirement: !ruby/object:Gem::Requirement
|
66
50
|
none: false
|
67
51
|
requirements:
|
68
|
-
- -
|
52
|
+
- - ! '>='
|
69
53
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
71
|
-
type: :
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
72
56
|
prerelease: false
|
73
57
|
version_requirements: !ruby/object:Gem::Requirement
|
74
58
|
none: false
|
75
59
|
requirements:
|
76
|
-
- -
|
60
|
+
- - ! '>='
|
77
61
|
- !ruby/object:Gem::Version
|
78
|
-
version:
|
62
|
+
version: '0'
|
79
63
|
- !ruby/object:Gem::Dependency
|
80
|
-
name:
|
64
|
+
name: webmock
|
81
65
|
requirement: !ruby/object:Gem::Requirement
|
82
66
|
none: false
|
83
67
|
requirements:
|
84
68
|
- - ! '>='
|
85
69
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
87
|
-
type: :
|
70
|
+
version: '0'
|
71
|
+
type: :development
|
88
72
|
prerelease: false
|
89
73
|
version_requirements: !ruby/object:Gem::Requirement
|
90
74
|
none: false
|
91
75
|
requirements:
|
92
76
|
- - ! '>='
|
93
77
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
95
|
-
description:
|
78
|
+
version: '0'
|
79
|
+
description: API client for accessing the Swiftype Search API with no dependencies
|
80
|
+
(on Ruby 1.9, JSON needed for Ruby 1.8).
|
96
81
|
email:
|
97
82
|
- team@swiftype.com
|
98
83
|
executables: []
|
@@ -100,26 +85,97 @@ extensions: []
|
|
100
85
|
extra_rdoc_files: []
|
101
86
|
files:
|
102
87
|
- .gitignore
|
88
|
+
- .travis.yml
|
103
89
|
- Gemfile
|
104
90
|
- LICENSE.txt
|
105
91
|
- README.md
|
106
92
|
- Rakefile
|
93
|
+
- lib/data/ca-bundle.crt
|
107
94
|
- lib/swiftype.rb
|
108
|
-
- lib/swiftype/base_model.rb
|
109
95
|
- lib/swiftype/client.rb
|
110
96
|
- lib/swiftype/configuration.rb
|
111
|
-
- lib/swiftype/connection.rb
|
112
|
-
- lib/swiftype/document.rb
|
113
|
-
- lib/swiftype/document_type.rb
|
114
|
-
- lib/swiftype/easy.rb
|
115
|
-
- lib/swiftype/engine.rb
|
116
97
|
- lib/swiftype/exceptions.rb
|
98
|
+
- lib/swiftype/ext/backport-uri.rb
|
117
99
|
- lib/swiftype/request.rb
|
118
100
|
- lib/swiftype/result_set.rb
|
119
|
-
- lib/swiftype/
|
101
|
+
- lib/swiftype/sso.rb
|
120
102
|
- lib/swiftype/version.rb
|
103
|
+
- spec/client_spec.rb
|
104
|
+
- spec/configuration_spec.rb
|
105
|
+
- spec/deprecated_spec.rb
|
106
|
+
- spec/fixtures/vcr/analytics_autoselects.yml
|
107
|
+
- spec/fixtures/vcr/analytics_autoselects_with_document_type.yml
|
108
|
+
- spec/fixtures/vcr/analytics_autoselects_with_document_type_and_time_range.yml
|
109
|
+
- spec/fixtures/vcr/analytics_autoselects_with_time_range.yml
|
110
|
+
- spec/fixtures/vcr/analytics_clicks.yml
|
111
|
+
- spec/fixtures/vcr/analytics_clicks_with_document_type.yml
|
112
|
+
- spec/fixtures/vcr/analytics_clicks_with_document_type_and_time_range.yml
|
113
|
+
- spec/fixtures/vcr/analytics_clicks_with_time_range.yml
|
114
|
+
- spec/fixtures/vcr/analytics_searches.yml
|
115
|
+
- spec/fixtures/vcr/analytics_searches_with_document_type_and_time_range.yml
|
116
|
+
- spec/fixtures/vcr/analytics_searches_with_time_range.yml
|
117
|
+
- spec/fixtures/vcr/analytics_searchs_with_document_type.yml
|
118
|
+
- spec/fixtures/vcr/analytics_top_no_result_queries.yml
|
119
|
+
- spec/fixtures/vcr/analytics_top_no_result_queries_paginated.yml
|
120
|
+
- spec/fixtures/vcr/analytics_top_queries.yml
|
121
|
+
- spec/fixtures/vcr/analytics_top_queries_paginated.yml
|
122
|
+
- spec/fixtures/vcr/analytics_top_queries_too_large.yml
|
123
|
+
- spec/fixtures/vcr/bulk_create_documents.yml
|
124
|
+
- spec/fixtures/vcr/bulk_create_or_update_documents_failure.yml
|
125
|
+
- spec/fixtures/vcr/bulk_create_or_update_documents_success.yml
|
126
|
+
- spec/fixtures/vcr/bulk_destroy_documents.yml
|
127
|
+
- spec/fixtures/vcr/crawl_url.yml
|
128
|
+
- spec/fixtures/vcr/create_document.yml
|
129
|
+
- spec/fixtures/vcr/create_document_type.yml
|
130
|
+
- spec/fixtures/vcr/create_domain.yml
|
131
|
+
- spec/fixtures/vcr/create_engine.yml
|
132
|
+
- spec/fixtures/vcr/create_or_update_document_create.yml
|
133
|
+
- spec/fixtures/vcr/create_or_update_document_update.yml
|
134
|
+
- spec/fixtures/vcr/create_user.yml
|
135
|
+
- spec/fixtures/vcr/destroy_document.yml
|
136
|
+
- spec/fixtures/vcr/destroy_document_type.yml
|
137
|
+
- spec/fixtures/vcr/destroy_domain.yml
|
138
|
+
- spec/fixtures/vcr/destroy_engine.yml
|
139
|
+
- spec/fixtures/vcr/destroy_non_existent_document_type.yml
|
140
|
+
- spec/fixtures/vcr/document_type_search.yml
|
141
|
+
- spec/fixtures/vcr/document_type_search_pagination.yml
|
142
|
+
- spec/fixtures/vcr/document_type_suggest.yml
|
143
|
+
- spec/fixtures/vcr/document_type_suggest_pagination.yml
|
144
|
+
- spec/fixtures/vcr/engine_search.yml
|
145
|
+
- spec/fixtures/vcr/engine_search_facets.yml
|
146
|
+
- spec/fixtures/vcr/engine_search_pagination.yml
|
147
|
+
- spec/fixtures/vcr/engine_suggest.yml
|
148
|
+
- spec/fixtures/vcr/engine_suggest_pagination.yml
|
149
|
+
- spec/fixtures/vcr/find_document.yml
|
150
|
+
- spec/fixtures/vcr/find_document_type.yml
|
151
|
+
- spec/fixtures/vcr/find_domain.yml
|
152
|
+
- spec/fixtures/vcr/find_domain_failure.yml
|
153
|
+
- spec/fixtures/vcr/find_engine.yml
|
154
|
+
- spec/fixtures/vcr/list_document_type.yml
|
155
|
+
- spec/fixtures/vcr/list_documents.yml
|
156
|
+
- spec/fixtures/vcr/list_documents_with_pagination.yml
|
157
|
+
- spec/fixtures/vcr/list_domains.yml
|
158
|
+
- spec/fixtures/vcr/list_engines.yml
|
159
|
+
- spec/fixtures/vcr/list_users.yml
|
160
|
+
- spec/fixtures/vcr/list_users_with_pagination.yml
|
161
|
+
- spec/fixtures/vcr/log_clickthrough_failure.yml
|
162
|
+
- spec/fixtures/vcr/log_clickthrough_success.yml
|
163
|
+
- spec/fixtures/vcr/recrawl_domain_failure.yml
|
164
|
+
- spec/fixtures/vcr/recrawl_domain_success.yml
|
165
|
+
- spec/fixtures/vcr/show_user.yml
|
166
|
+
- spec/fixtures/vcr/update_document.yml
|
167
|
+
- spec/fixtures/vcr/update_document_unknown_field_failure.yml
|
168
|
+
- spec/fixtures/vcr/update_documents_failure_non_existent_document.yml
|
169
|
+
- spec/fixtures/vcr/update_documents_success.yml
|
170
|
+
- spec/fixtures/vcr/users_client_secret_incorrect.yml
|
171
|
+
- spec/fixtures/vcr/users_no_api_key.yml
|
172
|
+
- spec/fixtures/vcr/users_no_client_id_or_secret.yml
|
173
|
+
- spec/platform_spec.rb
|
174
|
+
- spec/spec_helper.rb
|
175
|
+
- spec/ssl_spec.rb
|
176
|
+
- spec/sso_spec.rb
|
121
177
|
- swiftype.gemspec
|
122
|
-
homepage:
|
178
|
+
homepage: https://swiftype.com
|
123
179
|
licenses: []
|
124
180
|
post_install_message:
|
125
181
|
rdoc_options: []
|
@@ -139,8 +195,83 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
195
|
version: '0'
|
140
196
|
requirements: []
|
141
197
|
rubyforge_project:
|
142
|
-
rubygems_version: 1.8.
|
198
|
+
rubygems_version: 1.8.24
|
143
199
|
signing_key:
|
144
200
|
specification_version: 3
|
145
|
-
summary: Swiftype API
|
146
|
-
test_files:
|
201
|
+
summary: Official gem for accessing the Swiftype Search API
|
202
|
+
test_files:
|
203
|
+
- spec/client_spec.rb
|
204
|
+
- spec/configuration_spec.rb
|
205
|
+
- spec/deprecated_spec.rb
|
206
|
+
- spec/fixtures/vcr/analytics_autoselects.yml
|
207
|
+
- spec/fixtures/vcr/analytics_autoselects_with_document_type.yml
|
208
|
+
- spec/fixtures/vcr/analytics_autoselects_with_document_type_and_time_range.yml
|
209
|
+
- spec/fixtures/vcr/analytics_autoselects_with_time_range.yml
|
210
|
+
- spec/fixtures/vcr/analytics_clicks.yml
|
211
|
+
- spec/fixtures/vcr/analytics_clicks_with_document_type.yml
|
212
|
+
- spec/fixtures/vcr/analytics_clicks_with_document_type_and_time_range.yml
|
213
|
+
- spec/fixtures/vcr/analytics_clicks_with_time_range.yml
|
214
|
+
- spec/fixtures/vcr/analytics_searches.yml
|
215
|
+
- spec/fixtures/vcr/analytics_searches_with_document_type_and_time_range.yml
|
216
|
+
- spec/fixtures/vcr/analytics_searches_with_time_range.yml
|
217
|
+
- spec/fixtures/vcr/analytics_searchs_with_document_type.yml
|
218
|
+
- spec/fixtures/vcr/analytics_top_no_result_queries.yml
|
219
|
+
- spec/fixtures/vcr/analytics_top_no_result_queries_paginated.yml
|
220
|
+
- spec/fixtures/vcr/analytics_top_queries.yml
|
221
|
+
- spec/fixtures/vcr/analytics_top_queries_paginated.yml
|
222
|
+
- spec/fixtures/vcr/analytics_top_queries_too_large.yml
|
223
|
+
- spec/fixtures/vcr/bulk_create_documents.yml
|
224
|
+
- spec/fixtures/vcr/bulk_create_or_update_documents_failure.yml
|
225
|
+
- spec/fixtures/vcr/bulk_create_or_update_documents_success.yml
|
226
|
+
- spec/fixtures/vcr/bulk_destroy_documents.yml
|
227
|
+
- spec/fixtures/vcr/crawl_url.yml
|
228
|
+
- spec/fixtures/vcr/create_document.yml
|
229
|
+
- spec/fixtures/vcr/create_document_type.yml
|
230
|
+
- spec/fixtures/vcr/create_domain.yml
|
231
|
+
- spec/fixtures/vcr/create_engine.yml
|
232
|
+
- spec/fixtures/vcr/create_or_update_document_create.yml
|
233
|
+
- spec/fixtures/vcr/create_or_update_document_update.yml
|
234
|
+
- spec/fixtures/vcr/create_user.yml
|
235
|
+
- spec/fixtures/vcr/destroy_document.yml
|
236
|
+
- spec/fixtures/vcr/destroy_document_type.yml
|
237
|
+
- spec/fixtures/vcr/destroy_domain.yml
|
238
|
+
- spec/fixtures/vcr/destroy_engine.yml
|
239
|
+
- spec/fixtures/vcr/destroy_non_existent_document_type.yml
|
240
|
+
- spec/fixtures/vcr/document_type_search.yml
|
241
|
+
- spec/fixtures/vcr/document_type_search_pagination.yml
|
242
|
+
- spec/fixtures/vcr/document_type_suggest.yml
|
243
|
+
- spec/fixtures/vcr/document_type_suggest_pagination.yml
|
244
|
+
- spec/fixtures/vcr/engine_search.yml
|
245
|
+
- spec/fixtures/vcr/engine_search_facets.yml
|
246
|
+
- spec/fixtures/vcr/engine_search_pagination.yml
|
247
|
+
- spec/fixtures/vcr/engine_suggest.yml
|
248
|
+
- spec/fixtures/vcr/engine_suggest_pagination.yml
|
249
|
+
- spec/fixtures/vcr/find_document.yml
|
250
|
+
- spec/fixtures/vcr/find_document_type.yml
|
251
|
+
- spec/fixtures/vcr/find_domain.yml
|
252
|
+
- spec/fixtures/vcr/find_domain_failure.yml
|
253
|
+
- spec/fixtures/vcr/find_engine.yml
|
254
|
+
- spec/fixtures/vcr/list_document_type.yml
|
255
|
+
- spec/fixtures/vcr/list_documents.yml
|
256
|
+
- spec/fixtures/vcr/list_documents_with_pagination.yml
|
257
|
+
- spec/fixtures/vcr/list_domains.yml
|
258
|
+
- spec/fixtures/vcr/list_engines.yml
|
259
|
+
- spec/fixtures/vcr/list_users.yml
|
260
|
+
- spec/fixtures/vcr/list_users_with_pagination.yml
|
261
|
+
- spec/fixtures/vcr/log_clickthrough_failure.yml
|
262
|
+
- spec/fixtures/vcr/log_clickthrough_success.yml
|
263
|
+
- spec/fixtures/vcr/recrawl_domain_failure.yml
|
264
|
+
- spec/fixtures/vcr/recrawl_domain_success.yml
|
265
|
+
- spec/fixtures/vcr/show_user.yml
|
266
|
+
- spec/fixtures/vcr/update_document.yml
|
267
|
+
- spec/fixtures/vcr/update_document_unknown_field_failure.yml
|
268
|
+
- spec/fixtures/vcr/update_documents_failure_non_existent_document.yml
|
269
|
+
- spec/fixtures/vcr/update_documents_success.yml
|
270
|
+
- spec/fixtures/vcr/users_client_secret_incorrect.yml
|
271
|
+
- spec/fixtures/vcr/users_no_api_key.yml
|
272
|
+
- spec/fixtures/vcr/users_no_client_id_or_secret.yml
|
273
|
+
- spec/platform_spec.rb
|
274
|
+
- spec/spec_helper.rb
|
275
|
+
- spec/ssl_spec.rb
|
276
|
+
- spec/sso_spec.rb
|
277
|
+
has_rdoc:
|
data/lib/swiftype/base_model.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
require 'active_support/inflector'
|
2
|
-
|
3
|
-
module Swiftype
|
4
|
-
class BaseModel < OpenStruct
|
5
|
-
include Swiftype::Connection
|
6
|
-
include Swiftype::Request
|
7
|
-
|
8
|
-
class << self
|
9
|
-
attr_reader :parent_classes
|
10
|
-
|
11
|
-
def model_name
|
12
|
-
name.split('::').last.underscore
|
13
|
-
end
|
14
|
-
|
15
|
-
def collection_name
|
16
|
-
model_name.pluralize
|
17
|
-
end
|
18
|
-
|
19
|
-
def parents(*parent_classes)
|
20
|
-
@parent_classes = parent_classes
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def to_hash
|
25
|
-
table
|
26
|
-
end
|
27
|
-
|
28
|
-
def to_json
|
29
|
-
to_hash.to_json
|
30
|
-
end
|
31
|
-
|
32
|
-
def create!
|
33
|
-
update_with! post(path_to_collection, {self.class.model_name => to_hash})
|
34
|
-
end
|
35
|
-
|
36
|
-
def update!
|
37
|
-
update_with! put(path_to_model, {self.class.model_name => to_hash})
|
38
|
-
end
|
39
|
-
|
40
|
-
def destroy!
|
41
|
-
!!delete(path_to_model)
|
42
|
-
end
|
43
|
-
|
44
|
-
def path_to_model
|
45
|
-
"#{raw_path_to_model}.json"
|
46
|
-
end
|
47
|
-
|
48
|
-
def raw_path_to_model
|
49
|
-
path = (self.class.parent_classes || []).inject("") do |_, parent|
|
50
|
-
parent_id = send("#{parent.model_name}_id")
|
51
|
-
_ += "#{parent.collection_name}/#{parent_id}/"
|
52
|
-
_
|
53
|
-
end
|
54
|
-
"#{path}#{self.class.collection_name}/#{identifier}"
|
55
|
-
end
|
56
|
-
|
57
|
-
def path_to_collection
|
58
|
-
"#{raw_path_to_collection}.json"
|
59
|
-
end
|
60
|
-
|
61
|
-
def raw_path_to_collection
|
62
|
-
path = (self.class.parent_classes || []).inject("") do |_, parent|
|
63
|
-
parent_id = send("#{parent.model_name}_id")
|
64
|
-
_ += "#{parent.collection_name}/#{parent_id}/"
|
65
|
-
_
|
66
|
-
end
|
67
|
-
"#{path}#{self.class.collection_name}"
|
68
|
-
end
|
69
|
-
|
70
|
-
def update_with!(hash)
|
71
|
-
hash.each do |k, v|
|
72
|
-
send "#{k}=", v
|
73
|
-
end
|
74
|
-
self
|
75
|
-
end
|
76
|
-
|
77
|
-
def reload
|
78
|
-
update_with! get(path_to_model)
|
79
|
-
end
|
80
|
-
|
81
|
-
def identifier
|
82
|
-
slugged? ? slug : id
|
83
|
-
end
|
84
|
-
|
85
|
-
def slugged?
|
86
|
-
respond_to?(:slug)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
data/lib/swiftype/connection.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
module Swiftype
|
2
|
-
module Connection
|
3
|
-
include Swiftype::Request
|
4
|
-
|
5
|
-
def connection
|
6
|
-
raise(InvalidCredentials, "You must supply credentials to Swiftype.configure") unless (Swiftype.username && Swiftype.password ) || Swiftype.api_key
|
7
|
-
|
8
|
-
@connection ||= begin
|
9
|
-
conn = Faraday.new(Swiftype.endpoint) do |b|
|
10
|
-
b.response :raise_error
|
11
|
-
b.use Faraday::Request::UrlEncoded
|
12
|
-
b.use FaradayMiddleware::ParseJson
|
13
|
-
b.use FaradayMiddleware::Mashify
|
14
|
-
b.use ApiResponseMiddleware
|
15
|
-
b.adapter Faraday.default_adapter
|
16
|
-
end
|
17
|
-
|
18
|
-
conn.basic_auth Swiftype.username, Swiftype.password if Swiftype.username && Swiftype.password
|
19
|
-
conn.headers['User-Agent'] = Swiftype.user_agent
|
20
|
-
|
21
|
-
conn
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class ApiResponseMiddleware < Faraday::Response::Middleware
|
26
|
-
def on_complete(env)
|
27
|
-
case env[:status]
|
28
|
-
when 200, 201, 204
|
29
|
-
nil
|
30
|
-
when 401
|
31
|
-
raise InvalidCredentials
|
32
|
-
when 404
|
33
|
-
raise NonExistentRecord
|
34
|
-
when 409
|
35
|
-
raise RecordAlreadyExists
|
36
|
-
else
|
37
|
-
raise UnexpectedHTTPException, env[:body]
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def initialize(app)
|
42
|
-
super
|
43
|
-
@parser = nil
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|