asari 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,6 +20,7 @@ class Asari
20
20
 
21
21
  attr_writer :api_version
22
22
  attr_writer :search_domain
23
+ attr_writer :aws_region
23
24
 
24
25
  def initialize(search_domain=nil)
25
26
  @search_domain = search_domain
@@ -40,6 +41,12 @@ class Asari
40
41
  @api_version || "2011-02-01"
41
42
  end
42
43
 
44
+ # Public: returns the current aws_region, or the sensible default of
45
+ # "us-east-1."
46
+ def aws_region
47
+ @aws_region || "us-east-1"
48
+ end
49
+
43
50
  # Public: Search for the specified term.
44
51
  #
45
52
  # Examples:
@@ -57,7 +64,7 @@ class Asari
57
64
 
58
65
  page_size = options[:page_size].nil? ? 10 : options[:page_size].to_i
59
66
 
60
- url = "http://search-#{search_domain}.us-east-1.cloudsearch.amazonaws.com/#{api_version}/search?q=#{CGI.escape(term)}&size=#{page_size}"
67
+ url = "http://search-#{search_domain}.#{aws_region}.cloudsearch.amazonaws.com/#{api_version}/search?q=#{CGI.escape(term)}&size=#{page_size}"
61
68
 
62
69
  if options[:page]
63
70
  start = (options[:page].to_i - 1) * page_size
@@ -1,3 +1,3 @@
1
1
  class Asari
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.2"
3
3
  end
@@ -15,6 +15,11 @@ describe "Asari" do
15
15
  expect(@asari.api_version).to eq "2015-10-21"
16
16
  end
17
17
 
18
+ it "allows you to set a specific aws region." do
19
+ @asari.aws_region = "us-west-1"
20
+ expect(@asari.aws_region).to eq("us-west-1")
21
+ end
22
+
18
23
  it "raises an exeception if no search domain is provided." do
19
24
  expect { @asari.search_domain }.to raise_error Asari::MissingSearchDomainException
20
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asari
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-27 00:00:00.000000000 Z
12
+ date: 2013-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty