rummageable 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rummageable.rb CHANGED
@@ -41,6 +41,10 @@ module Rummageable
41
41
  implementation.delete(link, index_name)
42
42
  end
43
43
 
44
+ def delete_all(index_name = default_index)
45
+ implementation.delete_all(index_name)
46
+ end
47
+
44
48
  def amend(link, amendments, index_name = default_index)
45
49
  implementation.amend(link, amendments, index_name)
46
50
  end
@@ -21,6 +21,10 @@ module Rummageable
21
21
  RestClient.delete url_for(link, index_name), content_type: :json, accept: :json
22
22
  end
23
23
 
24
+ def delete_all(index_name)
25
+ RestClient.delete unescaped_url_for("*", index_name), content_type: :json, accept: :json
26
+ end
27
+
24
28
  def commit(index_name)
25
29
  url = Rummageable.rummager_host + index_name + "/commit"
26
30
  RestClient.post url, {}
@@ -43,11 +47,17 @@ module Rummageable
43
47
  end
44
48
 
45
49
  private
50
+
51
+ def url_components(index_name)
52
+ [Rummageable.rummager_host, index_name, "/documents/"]
53
+ end
54
+
46
55
  def url_for(link, index_name)
47
- [
48
- Rummageable.rummager_host, index_name,
49
- "/documents/", CGI.escape(link)
50
- ].join("")
56
+ (url_components(index_name) << CGI.escape(link)).join
57
+ end
58
+
59
+ def unescaped_url_for(link, index_name)
60
+ (url_components(index_name) << link).join
51
61
  end
52
62
  end
53
63
  end
@@ -1,3 +1,3 @@
1
1
  module Rummageable
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -134,6 +134,20 @@ class RummageableTest < MiniTest::Unit::TestCase
134
134
  Rummageable.delete(link, '/alternative')
135
135
  end
136
136
 
137
+ def test_should_allow_delete_all
138
+ stub_request(:delete, "#{API}/documents/*").
139
+ to_return(status: 200, body: '{"status":"OK"}')
140
+
141
+ Rummageable.delete_all
142
+ end
143
+
144
+ def test_should_allow_delete_all_from_an_alternative_index
145
+ stub_request(:delete, "#{API}/alternative/documents/*").
146
+ to_return(status: 200, body: '{"status":"OK"}')
147
+
148
+ Rummageable.delete_all('/alternative')
149
+ end
150
+
137
151
  def test_should_post_amendments
138
152
  stub_request(:post, "#{API}/documents/%2Ffoobang").
139
153
  with(body: {"title" => "Cheese", "indexable_content" => "Blah"}).
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rummageable
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.0
5
+ version: 0.6.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - GovUK Beta Team
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-10-03 00:00:00 Z
13
+ date: 2012-11-20 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -105,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - ">="
107
107
  - !ruby/object:Gem::Version
108
- hash: 636288066068398025
108
+ hash: -1342120021253896970
109
109
  segments:
110
110
  - 0
111
111
  version: "0"
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- hash: 636288066068398025
117
+ hash: -1342120021253896970
118
118
  segments:
119
119
  - 0
120
120
  version: "0"