swiftype-rb 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -375,8 +375,6 @@ The Simple Client is a convenience class that gives you basic, direct access to
375
375
  Todo
376
376
  ===
377
377
 
378
- + Proper response code handling for non-successful requests.
379
- + Publish gem to rubygems.org
380
378
  + Tests!
381
379
 
382
380
 
@@ -2,7 +2,7 @@ module Swiftype
2
2
  class DocumentType < BaseModel
3
3
  parents Engine
4
4
  include Swiftype::Search
5
-
5
+
6
6
  def build_document(params={})
7
7
  Document.new({
8
8
  :document_type_id => id || slug,
@@ -55,7 +55,7 @@ module Swiftype
55
55
 
56
56
  def suggest(query, options={})
57
57
  search_params = { :q => query }.merge(parse_suggest_options(options))
58
- response = get("engines/#{engine_id}/document_types/#{slug}/suggest.json", search_params)
58
+ response = post("engines/#{engine_id}/document_types/#{slug}/suggest.json", search_params)
59
59
  results = {}
60
60
  response['records'].each { |document_type, records| results[document_type] = records.map { |d| Swiftype::Document.new(d) }}
61
61
  results
@@ -63,7 +63,7 @@ module Swiftype
63
63
 
64
64
  def search(query, options={})
65
65
  search_params = { :q => query }.merge(parse_search_options(options))
66
- response = get("engines/#{engine_id}/document_types/#{slug}/search.json", search_params)
66
+ response = post("engines/#{engine_id}/document_types/#{slug}/search.json", search_params)
67
67
  results = {}
68
68
  response['records'].each { |document_type, records| results[document_type] = records.map { |d| Swiftype::Document.new(d) }}
69
69
  results
@@ -21,14 +21,14 @@ module Swiftype
21
21
  end
22
22
  def suggest(engine_id, query, options={})
23
23
  search_params = { :q => query }.merge(parse_suggest_options(options))
24
- response = get("engines/#{engine_id}/suggest.json", search_params)
24
+ response = post("engines/#{engine_id}/suggest.json", search_params)
25
25
  results = {}
26
26
  response['records'].each { |document_type, records| results[document_type] = records.map { |d| Swiftype::Document.new(d) }}
27
27
  results
28
28
  end
29
29
  def search(engine_id, query, options={})
30
30
  search_params = { :q => query }.merge(parse_search_options(options))
31
- response = get("engines/#{engine_id}/search.json", search_params)
31
+ response = post("engines/#{engine_id}/search.json", search_params)
32
32
  results = {}
33
33
  response['records'].each { |document_type, records| results[document_type] = records.map { |d| Swiftype::Document.new(d) }}
34
34
  results
@@ -1,37 +1,23 @@
1
1
  module Swiftype
2
2
  module Search
3
-
4
- VALID_SEARCH_OPTIONS = [:fetch_fields, :search_fields, :filters, :per_page, :page, :document_types, :functional_boosts]
5
- VALID_SUGGEST_OPTIONS = [:fetch_fields, :search_fields, :filters, :document_types, :functional_boosts]
3
+ VALID_SUGGEST_OPTIONS = [:fetch_fields, :search_fields, :filters, :document_types, :functional_boosts, :page, :per_page]
4
+ VALID_SEARCH_OPTIONS = [:fetch_fields, :search_fields, :filters, :document_types, :functional_boosts, :page, :per_page, :sort_field, :sort_direction]
6
5
 
7
6
  def parse_search_options(options)
8
- parse_options(options,VALID_SEARCH_OPTIONS)
7
+ parse_options(options, VALID_SEARCH_OPTIONS)
9
8
  end
10
9
 
11
10
  def parse_suggest_options(options)
12
- parse_options(options,VALID_SUGGEST_OPTIONS)
11
+ parse_options(options, VALID_SUGGEST_OPTIONS)
13
12
  end
14
13
 
15
- def parse_options(options,valid_options)
14
+ def parse_options(options, valid_options)
16
15
  parsed_options = {}
17
16
  valid_options.each do |option_name|
18
- next unless options[option_name]
19
- encode_single_option(parsed_options,option_name,options[option_name])
17
+ next unless options[option_name]
18
+ parsed_options[option_name] = options[option_name]
20
19
  end
21
20
  parsed_options
22
21
  end
23
-
24
- # recursive method to encode arrays, hashes, and values the 'Rails' way, to make server-side parsing simpler
25
- def encode_single_option(parsed_options,key,value,prefix='')
26
- prefix = key if prefix.empty?
27
- if value.instance_of?(Hash)
28
- value.each { |k,v| encode_single_option(parsed_options,k,v,"#{prefix}[#{k}]") }
29
- elsif value.instance_of?(Array)
30
- parsed_options["#{prefix}[]"] = value
31
- else
32
- parsed_options["#{prefix}"] = value
33
- end
34
- end
35
-
36
22
  end
37
23
  end
@@ -1,3 +1,3 @@
1
1
  module Swiftype
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -21,8 +21,8 @@ Gem::Specification.new do |s|
21
21
  # specify any dependencies here; for example:
22
22
  # s.add_development_dependency "rspec"
23
23
  s.add_runtime_dependency "json"
24
- s.add_runtime_dependency "faraday", ['~> 0.7.6']
25
- s.add_runtime_dependency "faraday_middleware", ['~> 0.8.4']
24
+ s.add_runtime_dependency "faraday", ['~> 0.8.1']
25
+ s.add_runtime_dependency "faraday_middleware", ['~> 0.8.7']
26
26
  s.add_runtime_dependency "hashie", ['~> 1.2.0']
27
27
  s.add_runtime_dependency 'activesupport', ['>= 2.3.9', '< 4']
28
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swiftype-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-07-05 00:00:00.000000000Z
13
+ date: 2012-08-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
17
- requirement: &70265771944420 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,32 +22,47 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70265771944420
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
26
31
  - !ruby/object:Gem::Dependency
27
32
  name: faraday
28
- requirement: &70265771943900 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
29
34
  none: false
30
35
  requirements:
31
36
  - - ~>
32
37
  - !ruby/object:Gem::Version
33
- version: 0.7.6
38
+ version: 0.8.1
34
39
  type: :runtime
35
40
  prerelease: false
36
- version_requirements: *70265771943900
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 0.8.1
37
47
  - !ruby/object:Gem::Dependency
38
48
  name: faraday_middleware
39
- requirement: &70265771943380 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
40
50
  none: false
41
51
  requirements:
42
52
  - - ~>
43
53
  - !ruby/object:Gem::Version
44
- version: 0.8.4
54
+ version: 0.8.7
45
55
  type: :runtime
46
56
  prerelease: false
47
- version_requirements: *70265771943380
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: 0.8.7
48
63
  - !ruby/object:Gem::Dependency
49
64
  name: hashie
50
- requirement: &70265771942900 !ruby/object:Gem::Requirement
65
+ requirement: !ruby/object:Gem::Requirement
51
66
  none: false
52
67
  requirements:
53
68
  - - ~>
@@ -55,10 +70,15 @@ dependencies:
55
70
  version: 1.2.0
56
71
  type: :runtime
57
72
  prerelease: false
58
- version_requirements: *70265771942900
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 1.2.0
59
79
  - !ruby/object:Gem::Dependency
60
80
  name: activesupport
61
- requirement: &70265771942400 !ruby/object:Gem::Requirement
81
+ requirement: !ruby/object:Gem::Requirement
62
82
  none: false
63
83
  requirements:
64
84
  - - ! '>='
@@ -69,7 +89,15 @@ dependencies:
69
89
  version: '4'
70
90
  type: :runtime
71
91
  prerelease: false
72
- version_requirements: *70265771942400
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: 2.3.9
98
+ - - <
99
+ - !ruby/object:Gem::Version
100
+ version: '4'
73
101
  description: Official Gem for accessing the Swiftype Search API
74
102
  email:
75
103
  - team@swiftype.com
@@ -115,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
143
  version: '0'
116
144
  requirements: []
117
145
  rubyforge_project: swiftype-rb
118
- rubygems_version: 1.8.10
146
+ rubygems_version: 1.8.23
119
147
  signing_key:
120
148
  specification_version: 3
121
149
  summary: Swiftype API Gem