xamplr 1.9.2 → 1.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/xamplr/notifications.rb +5 -0
- data/lib/xamplr/persister.rb +5 -2
- data/lib/xamplr/persisters/caching.rb +2 -0
- data/lib/xamplr/persisters/dumb.rb +48 -0
- data/lib/xamplr/persisters/tokyo-cabinet.rb +37 -17
- data/xamplr.gemspec +3 -2
- metadata +3 -2
data/VERSION.yml
CHANGED
data/lib/xamplr/notifications.rb
CHANGED
data/lib/xamplr/persister.rb
CHANGED
@@ -144,11 +144,13 @@ module Xampl
|
|
144
144
|
# Normally we'd expect to see the representation in the @format format, but
|
145
145
|
# that isn't necessarily the case. Try to work out what the format might be...
|
146
146
|
|
147
|
+
xampl = nil
|
147
148
|
if representation =~ /^</ then
|
148
|
-
|
149
|
+
xampl = XamplObject.realise_from_xml_string(representation, target)
|
149
150
|
else
|
150
|
-
XamplObject.from_ruby(representation, target)
|
151
|
+
xampl = XamplObject.from_ruby(representation, target)
|
151
152
|
end
|
153
|
+
return xampl.note_realised
|
152
154
|
end
|
153
155
|
|
154
156
|
def write(xampl)
|
@@ -333,6 +335,7 @@ module Xampl
|
|
333
335
|
end
|
334
336
|
|
335
337
|
require "xamplr/persisters/simple"
|
338
|
+
require "xamplr/persisters/dumb"
|
336
339
|
require "xamplr/persisters/in-memory"
|
337
340
|
require "xamplr/persisters/filesystem"
|
338
341
|
|
@@ -134,6 +134,8 @@ module Xampl
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def read(klass, pid, target=nil)
|
137
|
+
#return nil unless pid
|
138
|
+
|
137
139
|
# puts "#{File.basename(__FILE__)} #{__LINE__} READ:: klass: #{klass} pid: #{pid} target: [[#{target}]], PM: #{ self }"
|
138
140
|
|
139
141
|
xampl, target = read_from_cache(klass, pid, target)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Xampl
|
2
|
+
|
3
|
+
class DumbPersister < Persister
|
4
|
+
|
5
|
+
def initialize(name=nil, format=nil)
|
6
|
+
super(name, format)
|
7
|
+
|
8
|
+
@module_map = {}
|
9
|
+
@cache = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def DumbPersister.kind
|
13
|
+
:dumb
|
14
|
+
end
|
15
|
+
|
16
|
+
def kind
|
17
|
+
DumbPersister.kind
|
18
|
+
end
|
19
|
+
|
20
|
+
def sync_done
|
21
|
+
end
|
22
|
+
|
23
|
+
def has_changed(xampl)
|
24
|
+
throw :mixed_persisters unless self == xampl.persister
|
25
|
+
end
|
26
|
+
|
27
|
+
def cache(xampl)
|
28
|
+
xampl
|
29
|
+
end
|
30
|
+
|
31
|
+
def uncache(xampl)
|
32
|
+
end
|
33
|
+
|
34
|
+
def clear_cache
|
35
|
+
end
|
36
|
+
|
37
|
+
def write(xampl)
|
38
|
+
return true
|
39
|
+
end
|
40
|
+
|
41
|
+
def read(klass, pid, target=nil)
|
42
|
+
return nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Xampl.register_persister_kind(DumbPersister)
|
47
|
+
end
|
48
|
+
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module Xampl
|
2
2
|
|
3
3
|
require 'fileutils'
|
4
|
+
require 'set'
|
5
|
+
require 'json'
|
6
|
+
require 'yaml'
|
7
|
+
|
4
8
|
require 'tokyocabinet'
|
9
|
+
|
5
10
|
require 'xamplr/persisters/caching'
|
6
|
-
require 'set'
|
7
11
|
|
8
12
|
# require 'ruby-prof'
|
9
13
|
|
@@ -472,6 +476,7 @@ module Xampl
|
|
472
476
|
end
|
473
477
|
|
474
478
|
def write(xampl)
|
479
|
+
|
475
480
|
raise XamplException.new(:no_index_so_no_persist) unless xampl.get_the_index
|
476
481
|
|
477
482
|
expunging = self.expunged.include?(xampl)
|
@@ -541,23 +546,12 @@ module Xampl
|
|
541
546
|
xampl_hash = primary_description.merge(xampl_hash)
|
542
547
|
end
|
543
548
|
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
File.open(file_place, "w") do |out|
|
549
|
-
out.write xampl_hash['xampl']
|
550
|
-
if :sync == Xampl.raw_persister_options[:write_through] then
|
551
|
-
out.fsync
|
552
|
-
if $is_darwin then
|
553
|
-
out.fcntl(51, 0) # Attempt an F_FULLFSYNC fcntl to commit data to disk (darwin *ONLY*)
|
554
|
-
end
|
555
|
-
end
|
556
|
-
end
|
557
|
-
|
558
|
-
end
|
559
|
-
@tc_db.put(place, xampl_hash)
|
549
|
+
index_info = {}
|
550
|
+
if primary_description && 0 < primary_description.size then
|
551
|
+
index_info[:primary] = xampl_hash.dup
|
552
|
+
index_info[:primary].delete('xampl')
|
560
553
|
end
|
554
|
+
index_info[:secondary] = []
|
561
555
|
|
562
556
|
#TODO -- smarter regarding when to delete (e.g. mentions)
|
563
557
|
if xampl.should_schedule_delete? and xampl.scheduled_for_deletion_at then
|
@@ -577,6 +571,7 @@ module Xampl
|
|
577
571
|
|
578
572
|
secondary_descriptions.each do | secondary_description |
|
579
573
|
description = secondary_description.merge(xampl_hash)
|
574
|
+
index_info[:secondary] << secondary_description
|
580
575
|
|
581
576
|
note_errors("TC[[#{ @filename }]]:: write error: %s\n") do
|
582
577
|
pk = @tc_db.genuid
|
@@ -585,6 +580,30 @@ module Xampl
|
|
585
580
|
end
|
586
581
|
end
|
587
582
|
|
583
|
+
note_errors("TC[[#{ @filename }]]:: write error: %s\n") do
|
584
|
+
if Xampl.raw_persister_options[:write_through] then
|
585
|
+
FileUtils.mkdir_p(place_dir) unless File.exist?(place_dir)
|
586
|
+
file_place = "#{ @files_dir }/#{ place }"
|
587
|
+
File.open(file_place, "w") do |out|
|
588
|
+
out.write xampl_hash['xampl']
|
589
|
+
if :sync == Xampl.raw_persister_options[:write_through] then
|
590
|
+
out.fsync
|
591
|
+
if $is_darwin then
|
592
|
+
out.fcntl(51, 0) # Attempt an F_FULLFSYNC fcntl to commit data to disk (darwin *ONLY*)
|
593
|
+
end
|
594
|
+
end
|
595
|
+
end
|
596
|
+
if index_info[:primary] && 0 < index_info[:secondary].size then
|
597
|
+
file_place += ".idx"
|
598
|
+
File.open(file_place, "w") do |out|
|
599
|
+
out.write index_info.to_yaml
|
600
|
+
end
|
601
|
+
end
|
602
|
+
end
|
603
|
+
|
604
|
+
@tc_db.put(place, xampl_hash)
|
605
|
+
end
|
606
|
+
|
588
607
|
@write_count = @write_count + 1
|
589
608
|
xampl.changes_accepted
|
590
609
|
end
|
@@ -607,6 +626,7 @@ module Xampl
|
|
607
626
|
# puts "#{ __FILE__ }:#{ __LINE__ } [#{__method__}] READ REP"
|
608
627
|
open_tc_db
|
609
628
|
end
|
629
|
+
|
610
630
|
place = File.join(klass.name.split("::"), pid)
|
611
631
|
|
612
632
|
meta = @tc_db[place]
|
data/xamplr.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{xamplr}
|
8
|
-
s.version = "1.9.
|
8
|
+
s.version = "1.9.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bob Hutchison"]
|
12
|
-
s.date = %q{2010-01
|
12
|
+
s.date = %q{2010-02-01}
|
13
13
|
s.description = %q{xamplr is the ruby version of xampl.}
|
14
14
|
s.email = %q{hutch@recursive.ca}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -44,6 +44,7 @@ Gem::Specification.new do |s|
|
|
44
44
|
"lib/xamplr/persister.rb",
|
45
45
|
"lib/xamplr/persisters/caches.rb",
|
46
46
|
"lib/xamplr/persisters/caching.rb",
|
47
|
+
"lib/xamplr/persisters/dumb.rb",
|
47
48
|
"lib/xamplr/persisters/filesystem.rb",
|
48
49
|
"lib/xamplr/persisters/in-memory.rb",
|
49
50
|
"lib/xamplr/persisters/simple.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xamplr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Hutchison
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01
|
12
|
+
date: 2010-02-01 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/xamplr/persister.rb
|
70
70
|
- lib/xamplr/persisters/caches.rb
|
71
71
|
- lib/xamplr/persisters/caching.rb
|
72
|
+
- lib/xamplr/persisters/dumb.rb
|
72
73
|
- lib/xamplr/persisters/filesystem.rb
|
73
74
|
- lib/xamplr/persisters/in-memory.rb
|
74
75
|
- lib/xamplr/persisters/simple.rb
|