suggester 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -71,9 +71,9 @@ module Suggester
71
71
  #
72
72
  # * <tt>type</tt> - The name of the handler to refresh
73
73
  def refresh(type)
74
- url = "http://#{@host}:#{@port}/#{type}/refresh"
74
+ url = "http://#{@host}:#{@port}/#{type}/refresh.json"
75
75
  response = fetch_response(url)
76
- return response.is_a?(String) && response == "OK"
76
+ return response.is_a?(Hash) && response["return"] == "OK"
77
77
  end
78
78
 
79
79
  private
@@ -84,14 +84,24 @@ module Suggester
84
84
  end
85
85
 
86
86
  # force a refresh of the specified handler
87
- get "/:handler/refresh" do
87
+ get "/:handler/refresh.:format" do
88
+ format = params.delete("format")
88
89
  handler = params.delete("handler")
89
90
 
90
91
  if current_handler = self.class.handler(handler)
91
92
  current_handler.force_refresh!
92
- "OK"
93
+ response = {"return" => "OK"}
94
+ else
95
+ response = {"return" => "FAIL"}
96
+ end
97
+
98
+ case(format)
99
+ when 'yml'
100
+ response.to_yaml
101
+ when 'json'
102
+ response.to_json
93
103
  else
94
- "FAIL"
104
+ response.inspect
95
105
  end
96
106
  end
97
107
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{suggester}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Ching"]
12
- s.date = %q{2010-12-09}
12
+ s.date = %q{2011-04-04}
13
13
  s.default_executable = %q{suggester_server}
14
14
  s.description = %q{Extensible, cache-based auto-suggest server for ruby. Includes refresh and replication support out of the box.}
15
15
  s.email = %q{ching.jeff@gmail.com}
@@ -77,9 +77,10 @@ class BasicTest < Test::Unit::TestCase
77
77
  assert !Suggester::Server.handler("yaml_handler").needs_refresh?
78
78
 
79
79
  # force the server to refresh when it gets a chance
80
- get '/yaml_handler/refresh'
80
+ get '/yaml_handler/refresh.json'
81
81
  assert last_response.ok?
82
- assert_equal("OK", last_response.body)
82
+ response = JSON.parse(last_response.body)
83
+ assert_equal("OK", response["return"])
83
84
 
84
85
  # should need a refresh
85
86
  assert Suggester::Server.handler("yaml_handler").needs_refresh?
@@ -90,9 +91,10 @@ class BasicTest < Test::Unit::TestCase
90
91
  end
91
92
 
92
93
  should "fail to refresh non-existent handler" do
93
- get '/non_existent/refresh'
94
+ get '/non_existent/refresh.json'
94
95
  assert last_response.ok?
95
- assert_equal("FAIL", last_response.body)
96
+ response = JSON.parse(last_response.body)
97
+ assert_equal("FAIL", response["return"])
96
98
  end
97
99
 
98
100
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jeff Ching
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-09 00:00:00 -08:00
17
+ date: 2011-04-04 00:00:00 -07:00
18
18
  default_executable: suggester_server
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -151,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
151
  requirements:
152
152
  - - ">="
153
153
  - !ruby/object:Gem::Version
154
- hash: 595145928742037670
154
+ hash: -1297736483607632370
155
155
  segments:
156
156
  - 0
157
157
  version: "0"