idzebra 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/idzebra.rb +26 -25
- metadata +3 -3
data/lib/idzebra.rb
CHANGED
@@ -1,40 +1,41 @@
|
|
1
1
|
require 'ffi'
|
2
2
|
|
3
3
|
module IdZebra
|
4
|
-
|
4
|
+
|
5
5
|
module Native
|
6
6
|
extend FFI::Library
|
7
|
-
|
7
|
+
|
8
8
|
UPDATE_ACTIONS = enum [
|
9
9
|
:action_insert, 1,
|
10
10
|
:action_replace,
|
11
11
|
:action_delete,
|
12
12
|
:action_update,
|
13
13
|
:action_a_delete ]
|
14
|
-
|
14
|
+
|
15
15
|
ffi_lib_flags :now, :global
|
16
16
|
ffi_lib ['yaz', 'libyaz.so.4'],
|
17
|
+
['yaz_icu', 'libyaz_icu.so.4'],
|
17
18
|
['yaz_server', 'libyaz_server.so.4'],
|
18
19
|
['idzebra-2.0', 'libidzebra-2.0.so.0']
|
19
|
-
|
20
|
+
|
20
21
|
typedef :pointer, :zebra_handle
|
21
22
|
typedef :pointer, :zebra_service
|
22
23
|
typedef :short, :zebra_res
|
23
|
-
|
24
|
+
|
24
25
|
# Yaz functions to set logging level
|
25
26
|
attach_function :yaz_log_init_level, [:int], :void
|
26
27
|
attach_function :yaz_log_mask_str, [:string], :int
|
27
|
-
|
28
|
+
|
28
29
|
attach_function :zebra_start, [:string], :zebra_service
|
29
30
|
attach_function :zebra_stop, [:zebra_service], :zebra_res
|
30
31
|
attach_function :zebra_open, [:zebra_service, :pointer], :zebra_handle
|
31
32
|
attach_function :zebra_close, [:zebra_handle], :zebra_res
|
32
|
-
|
33
|
+
|
33
34
|
attach_function :zebra_init, [:zebra_handle], :zebra_res
|
34
35
|
attach_function :zebra_clean, [:zebra_handle], :zebra_res
|
35
36
|
attach_function :zebra_commit, [:zebra_handle], :zebra_res
|
36
37
|
attach_function :zebra_compact, [:zebra_handle], :zebra_res
|
37
|
-
|
38
|
+
|
38
39
|
attach_function :zebra_add_record, [
|
39
40
|
:zebra_handle,
|
40
41
|
:string, # buf
|
@@ -51,9 +52,9 @@ module IdZebra
|
|
51
52
|
:int], # buf_size
|
52
53
|
:zebra_res
|
53
54
|
end
|
54
|
-
|
55
|
+
|
55
56
|
class << self
|
56
|
-
|
57
|
+
|
57
58
|
def API(config_file, &block)
|
58
59
|
extend Native
|
59
60
|
log_level = :error
|
@@ -65,7 +66,7 @@ module IdZebra
|
|
65
66
|
zebra_close zh
|
66
67
|
zebra_stop zs
|
67
68
|
end
|
68
|
-
|
69
|
+
|
69
70
|
def log_level
|
70
71
|
extend Native
|
71
72
|
mask = yaz_log_mask_str('')
|
@@ -82,7 +83,7 @@ module IdZebra
|
|
82
83
|
mask
|
83
84
|
end
|
84
85
|
end
|
85
|
-
|
86
|
+
|
86
87
|
def log_level=(log_level)
|
87
88
|
extend Native
|
88
89
|
case log_level
|
@@ -98,42 +99,42 @@ module IdZebra
|
|
98
99
|
yaz_log_init_level(yaz_log_mask_str('all'))
|
99
100
|
end
|
100
101
|
end
|
101
|
-
|
102
|
+
|
102
103
|
end
|
103
|
-
|
104
|
+
|
104
105
|
class Repository < Struct.new(:zebra_handle)
|
105
106
|
include Native
|
106
|
-
|
107
|
+
|
107
108
|
def init
|
108
109
|
zebra_init(zebra_handle)
|
109
110
|
end
|
110
|
-
|
111
|
+
|
111
112
|
def compact
|
112
113
|
zebra_compact(zebra_handle)
|
113
114
|
end
|
114
|
-
|
115
|
+
|
115
116
|
def clean
|
116
117
|
zebra_clean(zebra_handle)
|
117
118
|
end
|
118
|
-
|
119
|
+
|
119
120
|
def commit
|
120
121
|
zebra_commit(zebra_handle)
|
121
122
|
end
|
122
|
-
|
123
|
+
|
123
124
|
def add_record(record_str)
|
124
125
|
zebra_add_record(zebra_handle, record_str, 0)
|
125
126
|
end
|
126
|
-
|
127
|
+
|
127
128
|
def update_record(record_str)
|
128
|
-
zebra_update_record(zebra_handle,
|
129
|
+
zebra_update_record(zebra_handle,
|
129
130
|
:action_update, nil, 0, nil, nil, record_str, 0)
|
130
131
|
end
|
131
|
-
|
132
|
+
|
132
133
|
def delete_record(record_str)
|
133
|
-
zebra_update_record(zebra_handle,
|
134
|
+
zebra_update_record(zebra_handle,
|
134
135
|
:action_delete, nil, 0, nil, nil, record_str, 0)
|
135
136
|
end
|
136
|
-
|
137
|
+
|
137
138
|
end
|
138
|
-
|
139
|
+
|
139
140
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: idzebra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
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: 2012-09-
|
12
|
+
date: 2012-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
version: '0'
|
106
106
|
segments:
|
107
107
|
- 0
|
108
|
-
hash:
|
108
|
+
hash: -2741384696241936114
|
109
109
|
requirements:
|
110
110
|
- idzebra-2.0
|
111
111
|
rubyforge_project:
|