rufus-cloche 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.txt CHANGED
@@ -2,6 +2,11 @@
2
2
  = rufus-cloche CHANGELOG.txt
3
3
 
4
4
 
5
+ == rufus-cloche - 0.1.13 released 2010/01/07
6
+
7
+ - implemented Cloche#ids(type) and Cloche#real_ids(type)
8
+
9
+
5
10
  == rufus-cloche - 0.1.12 released 2010/01/06
6
11
 
7
12
  - implemented Cloche#purge_type!(t)
data/TODO.txt CHANGED
@@ -5,10 +5,8 @@
5
5
  [o] thread-safe
6
6
  [o] readme : get_many example
7
7
  [o] subdir for types (2 last ascii chars argh)
8
+ [o] need for a purge mecha
9
+ [o] work/msgs/.0/8811-2151883888-1260352977.0.json issue...
8
10
 
9
11
  [ ] LRU ?
10
12
 
11
- [ ] need for a purge mecha
12
-
13
- [ ] work/msgs/.0/8811-2151883888-1260352977.0.json issue...
14
-
data/lib/rufus/cloche.rb CHANGED
@@ -43,7 +43,7 @@ module Rufus
43
43
  #
44
44
  class Cloche
45
45
 
46
- VERSION = '0.1.12'
46
+ VERSION = '0.1.13'
47
47
 
48
48
  attr_reader :dir
49
49
 
@@ -199,6 +199,30 @@ module Rufus
199
199
  FileUtils.rm_rf(dir_for(type))
200
200
  end
201
201
 
202
+ # Returns a sorted list of all the ids for a given type of documents.
203
+ #
204
+ # Warning : trusts the ids to be identical to the filenames
205
+ #
206
+ def ids (type)
207
+
208
+ Dir[File.join(dir_for(type), '**', '*.json')].collect { |p|
209
+ File.basename(p, '.json')
210
+ }.sort
211
+ end
212
+
213
+ # Returns a sorted list of all the ids for a given type of documents.
214
+ #
215
+ # Actually reads each file and returns the real _id list
216
+ #
217
+ def real_ids (type)
218
+
219
+ Dir[File.join(dir_for(type), '**', '*.json')].inject([]) { |a, p|
220
+ doc = do_get(File.new(p))
221
+ a << doc['_id'] if doc
222
+ a
223
+ }.sort
224
+ end
225
+
202
226
  protected
203
227
 
204
228
  def self.neutralize (s)
data/rufus-cloche.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rufus-cloche}
8
- s.version = "0.1.12"
8
+ s.version = "0.1.13"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John Mettraux"]
12
- s.date = %q{2010-01-06}
12
+ s.date = %q{2010-01-07}
13
13
  s.description = %q{
14
14
  A very stupid JSON hash store.
15
15
 
data/test/test.rb CHANGED
@@ -188,15 +188,24 @@ class ClocheTest < Test::Unit::TestCase
188
188
 
189
189
  def test_purge_type
190
190
 
191
- @c.put({ '_id' => 'thing.0', 'type' => 'unthing', 'color' => 'blue' })
192
- @c.put({ '_id' => 'thing.1', 'type' => 'unthing', 'color' => 'blue' })
193
- @c.put({ '_id' => 'thing.2', 'type' => 'unthing', 'color' => 'blue' })
191
+ load_people
192
+
193
+ assert_equal 4, @c.get_many('person').size
194
194
 
195
- assert_equal 3, @c.get_many('unthing').size
195
+ @c.purge_type!('person')
196
+
197
+ assert_equal 0, @c.get_many('person').size
198
+ end
199
+
200
+ def test_ids
201
+
202
+ load_people
196
203
 
197
- @c.purge_type!('unthing')
204
+ assert_equal %w[ hiro jami john minehiko ], @c.ids('person')
205
+ assert_equal %w[ chicko-chan ], @c.ids('animal')
198
206
 
199
- assert_equal 0, @c.get_many('unthing').size
207
+ assert_equal %w[ hiro jami john minehiko ], @c.real_ids('person')
208
+ assert_equal %w[ chicko-chan ], @c.real_ids('animal')
200
209
  end
201
210
 
202
211
  protected
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufus-cloche
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-06 00:00:00 +09:00
12
+ date: 2010-01-07 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency