rims-qdbm 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3348e7c899dbf6c80c802f4a370ba67b38a9914b02a23dfb1c22bbd7ad76ab98
4
+ data.tar.gz: 6b652d2eac805df84993a5c4ba8d7b624c5176f80ece73ad076abe63275c6ab2
5
+ SHA512:
6
+ metadata.gz: e0a8cb0f55fd23c17ea696b41d48ec3498215343fe9202c106335768bfbce54a918b9016a711a9f3ed8ef712de06caf066a689fcee1470e3c415335a89b4c42e
7
+ data.tar.gz: 2cfedf3fc2d3a4ed28cfb30398451601efdea43e4104badfe733b4eee8f27f4cd66f5de96eb8c24619f5d9b71b85e275ba9085c6791173549c996c619e27f360
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *~
10
+ README.html
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rims-qdbm.gemspec
6
+ gemspec
7
+
8
+ # Local Variables:
9
+ # mode: Ruby
10
+ # indent-tabs-mode: nil
11
+ # End:
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 TOKI Yoshinori
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,55 @@
1
+ RIMS::QDBM
2
+ ==========
3
+
4
+ RIMS key-value store plug-in for QDBM.
5
+ By introducing this plug-in, RIMS IMAP server will be able to store
6
+ mailboxes and messages in QDBM. QDBM is Quick Database Manager of
7
+ https://fallabs.com/qdbm/.
8
+
9
+ This gem provides 2 plug-ins (`qdbm_depot` and `qdbm_curia`).
10
+
11
+ Installation
12
+ ------------
13
+
14
+ Add this line to your application's Gemfile that includes RIMS:
15
+
16
+ ```ruby
17
+ gem 'rims-qdbm'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install rims-qdbm
27
+
28
+ Usage
29
+ -----
30
+
31
+ Add these lines to your config.yml of RIMS:
32
+
33
+ ```yaml
34
+ load_libraries:
35
+ - rims/qdbm
36
+ meta_key_value_store:
37
+ plug_in: qdbm_depot
38
+ configuration:
39
+ bnum: 1200000
40
+ text_key_value_store:
41
+ plug_in: qdbm_curia
42
+ configuration:
43
+ bnum: 50000
44
+ dnum: 8
45
+ ```
46
+
47
+ Contributing
48
+ ------------
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/y10k/rims-qdbm.
51
+
52
+ License
53
+ -------
54
+
55
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,25 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ task :default => :spec
7
+
8
+ Rake::TestTask.new do |task|
9
+ if ((ENV.key? 'RUBY_DEBUG') && (! ENV['RUBY_DEBUG'].empty?)) then
10
+ task.ruby_opts << '-d'
11
+ end
12
+ end
13
+
14
+ desc 'Build README.html from markdown source.'
15
+ task :readme => %w[ README.html ]
16
+
17
+ file 'README.html' => [ 'README.md' ] do
18
+ sh "pandoc --from=markdown --to=html5 --standalone --self-contained --css=$HOME/.pandoc/github.css --output=README.html README.md"
19
+ end
20
+ CLOBBER.include 'README.html'
21
+
22
+ # Local Variables:
23
+ # mode: Ruby
24
+ # indent-tabs-mode: nil
25
+ # End:
@@ -0,0 +1,196 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'curia'
4
+ require 'depot'
5
+ require 'fileutils'
6
+ require 'rims'
7
+ require 'rims/qdbm/version'
8
+
9
+ module RIMS
10
+ module QDBM
11
+ class Depot_KeyValueStore < KeyValueStore
12
+ def initialize(depot, path)
13
+ @db = depot
14
+ @path = path
15
+ @closed = false
16
+ end
17
+
18
+ class << self
19
+ def exist?(path)
20
+ depot_path = path + '.qdbm_depot'
21
+ File.exist? depot_path
22
+ end
23
+
24
+ def depot_open(path, *optional)
25
+ depot = Depot.new(path, Depot::OWRITER | Depot::OCREAT, *optional)
26
+ depot.silent = true
27
+ depot
28
+ end
29
+
30
+ def open(name, *optional)
31
+ depot_path = name + '.qdbm_depot'
32
+ new(depot_open(depot_path, *optional), depot_path)
33
+ end
34
+
35
+ def open_with_conf(name, config)
36
+ bnum = config['bnum']
37
+ args = []
38
+ args << bnum if bnum
39
+ open(name, *args)
40
+ end
41
+ end
42
+
43
+ def [](key)
44
+ @closed and raise 'closed'
45
+ @db[key]
46
+ end
47
+
48
+ def []=(key, value)
49
+ @closed and raise 'closed'
50
+ @db[key] = value
51
+ end
52
+
53
+ def delete(key)
54
+ @closed and raise 'closed'
55
+ ret_val = @db[key]
56
+ @db.out(key)
57
+ ret_val
58
+ end
59
+
60
+ def key?(key)
61
+ @closed and raise 'closed'
62
+ ! @db[key].nil?
63
+ end
64
+
65
+ def each_key
66
+ @closed and raise 'closed'
67
+ return enum_for(:each_key) unless block_given?
68
+ @db.each_key do |key|
69
+ yield(key)
70
+ end
71
+ self
72
+ end
73
+
74
+ def sync
75
+ @closed and raise 'closed'
76
+ @db.sync
77
+ self
78
+ end
79
+
80
+ def close
81
+ @closed and raise 'closed'
82
+ @db.close
83
+ @closed = true
84
+ self
85
+ end
86
+
87
+ def destroy
88
+ unless (@closed) then
89
+ raise "failed to destroy qdbm-depot that isn't closed: #{@path}"
90
+ end
91
+ File.delete(@path)
92
+ nil
93
+ end
94
+ end
95
+ KeyValueStore::FactoryBuilder.add_plug_in('qdbm_depot', Depot_KeyValueStore)
96
+
97
+ class Curia_KeyValueStore < KeyValueStore
98
+ def initialize(curia, path)
99
+ @db = curia
100
+ @path = path
101
+ @closed = false
102
+ end
103
+
104
+ class << self
105
+ def exist?(path)
106
+ curia_path = path + '.qdbm_curia'
107
+ File.exist? curia_path
108
+ end
109
+
110
+ def curia_open(path, *optional)
111
+ curia = Curia.new(path, Curia::OWRITER | Curia::OCREAT, *optional)
112
+ curia.silent = true
113
+ curia
114
+ end
115
+
116
+ def open(name, *optional)
117
+ curia_path = name + '.qdbm_curia'
118
+ new(curia_open(curia_path, *optional), curia_path)
119
+ end
120
+
121
+ def open_with_conf(name, config)
122
+ bnum = config['bnum']
123
+ dnum = config['dnum']
124
+
125
+ args = []
126
+ unless (dnum) then
127
+ args << bnum if bnum
128
+ else
129
+ args << bnum || -1
130
+ args << dnum
131
+ end
132
+
133
+ open(name, *args)
134
+ end
135
+ end
136
+
137
+ def [](key)
138
+ @closed and raise 'closed'
139
+ @db[key]
140
+ end
141
+
142
+ def []=(key, value)
143
+ @closed and raise 'closed'
144
+ @db[key] = value
145
+ end
146
+
147
+ def delete(key)
148
+ @closed and raise 'closed'
149
+ ret_val = @db[key]
150
+ @db.out(key)
151
+ ret_val
152
+ end
153
+
154
+ def key?(key)
155
+ @closed and raise 'closed'
156
+ ! @db[key].nil?
157
+ end
158
+
159
+ def each_key
160
+ @closed and raise 'closed'
161
+ return enum_for(:each_key) unless block_given?
162
+ @db.each_key do |key|
163
+ yield(key)
164
+ end
165
+ self
166
+ end
167
+
168
+ def sync
169
+ @closed and raise 'closed'
170
+ @db.sync
171
+ self
172
+ end
173
+
174
+ def close
175
+ @closed and raise 'closed'
176
+ @db.close
177
+ @closed = true
178
+ self
179
+ end
180
+
181
+ def destroy
182
+ unless (@closed) then
183
+ raise "failed to destroy qdbm-curia that isn't closed: #{@path}"
184
+ end
185
+ FileUtils.rm_rf(@path)
186
+ nil
187
+ end
188
+ end
189
+ KeyValueStore::FactoryBuilder.add_plug_in('qdbm_curia', Curia_KeyValueStore)
190
+ end
191
+ end
192
+
193
+ # Local Variables:
194
+ # mode: Ruby
195
+ # indent-tabs-mode: nil
196
+ # End:
@@ -0,0 +1,5 @@
1
+ module RIMS
2
+ module QDBM
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,43 @@
1
+ #-*- coding: utf-8 -*-
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "rims/qdbm/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "rims-qdbm"
9
+ spec.version = RIMS::QDBM::VERSION
10
+ spec.authors = ["TOKI Yoshinori"]
11
+ spec.email = ["toki@freedom.ne.jp"]
12
+
13
+ spec.summary = %q{RIMS key-value store plug-in for QDBM}
14
+ spec.description = <<-'EOF'
15
+ RIMS key-value store plug-in for QDBM. By introducing this
16
+ plug-in, RIMS IMAP server will be able to store mailboxes and
17
+ messages in QDBM. QDBM is Quick Database Manager of
18
+ https://fallabs.com/qdbm/.
19
+ EOF
20
+ spec.homepage = "https://github.com/y10k/rims-qdbm"
21
+ spec.license = "MIT"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ end
28
+ spec.bindir = "bin"
29
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
30
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_runtime_dependency "rims", ">= 0.2.0"
34
+ spec.add_runtime_dependency "ruby-qdbm"
35
+ spec.add_development_dependency "bundler", "~> 1.16"
36
+ spec.add_development_dependency "rake", "~> 10.0"
37
+ spec.add_development_dependency "test-unit"
38
+ end
39
+
40
+ # Local Variables:
41
+ # mode: Ruby
42
+ # indent-tabs-mode: nil
43
+ # End:
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rims-qdbm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - TOKI Yoshinori
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-02-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rims
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby-qdbm
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: test-unit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: |2
84
+ RIMS key-value store plug-in for QDBM. By introducing this
85
+ plug-in, RIMS IMAP server will be able to store mailboxes and
86
+ messages in QDBM. QDBM is Quick Database Manager of
87
+ https://fallabs.com/qdbm/.
88
+ email:
89
+ - toki@freedom.ne.jp
90
+ executables: []
91
+ extensions: []
92
+ extra_rdoc_files: []
93
+ files:
94
+ - ".gitignore"
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - lib/rims/qdbm.rb
100
+ - lib/rims/qdbm/version.rb
101
+ - rims-qdbm.gemspec
102
+ homepage: https://github.com/y10k/rims-qdbm
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubygems_version: 3.0.1
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: RIMS key-value store plug-in for QDBM
125
+ test_files: []