dominus 0.0.1
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/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +42 -0
- data/Rakefile +2 -0
- data/dominus.gemspec +17 -0
- data/jars/NCSO.jar +0 -0
- data/lib/dominus.rb +6 -0
- data/lib/dominus/client.rb +39 -0
- data/lib/dominus/database.rb +33 -0
- data/lib/dominus/document.rb +32 -0
- data/lib/dominus/document_collection.rb +36 -0
- data/lib/dominus/version.rb +3 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Håkon Lerring
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Dominus
|
2
|
+
|
3
|
+
Adds an easy to use wrapper around the domino diiop database api.
|
4
|
+
Memory management (recycling the domino objects) is handled by ruby.
|
5
|
+
|
6
|
+
*Warning*: This gem lacks tests. I hope to get around adding some tests soon.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'dominus'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install dominus
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Make sure NCSO.jar is in the ruby load path. ($LOAD_PATH)
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
require "dominus"
|
28
|
+
|
29
|
+
client = Dominus::Client.new("domino.example.com:63148", "username", "password")
|
30
|
+
documents = client.find_database("database.nsf").where("attribute", "value")
|
31
|
+
documents.each do |document|
|
32
|
+
puts document["attribute"] # => value
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
1. Fork it
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/dominus.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/dominus/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Håkon Lerring"]
|
6
|
+
gem.email = ["hakon@powow.no"]
|
7
|
+
gem.description = %q{An easy to use wrapper around the domino diiop database api.}
|
8
|
+
gem.summary = %q{Adds an easy to use wrapper around the domino diiop database api.\n Memory management (recycling the domino objects) is handled by ruby.}
|
9
|
+
gem.homepage = "http://github.com/Hakon/dominus"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "dominus"
|
15
|
+
gem.require_paths = ["lib", "jars"]
|
16
|
+
gem.version = Dominus::VERSION
|
17
|
+
end
|
data/jars/NCSO.jar
ADDED
Binary file
|
data/lib/dominus.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require "java"
|
2
|
+
require "NCSO.jar"
|
3
|
+
|
4
|
+
require "dominus/database"
|
5
|
+
|
6
|
+
module Dominus
|
7
|
+
|
8
|
+
def self.lotus
|
9
|
+
Java::Lotus
|
10
|
+
end
|
11
|
+
|
12
|
+
java_import lotus.domino.NotesFactory
|
13
|
+
|
14
|
+
class Client
|
15
|
+
|
16
|
+
def self.connect_to(*args)
|
17
|
+
self.new(NotesFactory.createSession(*args))
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.connect_to_local
|
21
|
+
self.connect_to
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.cleanup(session)
|
25
|
+
proc { session.recycle }
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(session)
|
29
|
+
@session = session
|
30
|
+
ObjectSpace.define_finalizer(self, self.class.cleanup(session))
|
31
|
+
end
|
32
|
+
|
33
|
+
def find_database(database_name)
|
34
|
+
Database.new(database_name, @session)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "dominus/document_collection"
|
2
|
+
|
3
|
+
module Dominus
|
4
|
+
class Database < SimpleDelegator
|
5
|
+
|
6
|
+
attr_reader :database
|
7
|
+
|
8
|
+
def initialize(database_name, session)
|
9
|
+
@session = session
|
10
|
+
super(session.getDatabase("", database_name))
|
11
|
+
ObjectSpace.define_finalizer(self, proc { __getobj__.recycle })
|
12
|
+
end
|
13
|
+
|
14
|
+
def documents
|
15
|
+
document_collection_source.call(self.all_documents, @session)
|
16
|
+
end
|
17
|
+
|
18
|
+
def where(a, b = nil)
|
19
|
+
if(b)
|
20
|
+
document_collection_source.call(self.search("#{a} = \"#{b}\""))
|
21
|
+
else
|
22
|
+
document_collection_source.call(self.search(a))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def document_collection_source
|
29
|
+
DocumentCollection.public_method(:new)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "delegate"
|
2
|
+
|
3
|
+
module Dominus
|
4
|
+
class Document < SimpleDelegator
|
5
|
+
|
6
|
+
def self.cleanup(doc)
|
7
|
+
proc { doc.recycle }
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(doc)
|
11
|
+
super(doc)
|
12
|
+
ObjectSpace.define_finalizer(self, self.class.cleanup(doc))
|
13
|
+
end
|
14
|
+
|
15
|
+
def [](key)
|
16
|
+
values = get_item_value(key)
|
17
|
+
if(values.length < 2)
|
18
|
+
values.first
|
19
|
+
else
|
20
|
+
values.to_a
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def items
|
25
|
+
@items ||= super.each_with_object({}) do |item, hash|
|
26
|
+
hash[item.name] = item.values.to_a
|
27
|
+
item.recycle
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "dominus/document"
|
2
|
+
module Dominus
|
3
|
+
class DocumentCollection
|
4
|
+
include Enumerable
|
5
|
+
attr_reader :documents
|
6
|
+
|
7
|
+
def self.cleanup(collection)
|
8
|
+
proc { collection.recycle }
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(collection)
|
12
|
+
@collection = collection
|
13
|
+
|
14
|
+
ObjectSpace.define_finalizer(self, self.class.cleanup(collection))
|
15
|
+
end
|
16
|
+
|
17
|
+
def each
|
18
|
+
doc = all.getFirstDocument
|
19
|
+
|
20
|
+
while doc
|
21
|
+
yield Document.new(doc)
|
22
|
+
doc = all.getNextDocument
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def all
|
28
|
+
@collection
|
29
|
+
end
|
30
|
+
|
31
|
+
def count
|
32
|
+
@count ||= all.count
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dominus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Håkon Lerring
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-13 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: An easy to use wrapper around the domino diiop database api.
|
15
|
+
email:
|
16
|
+
- hakon@powow.no
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- !binary |-
|
22
|
+
LmdpdGlnbm9yZQ==
|
23
|
+
- !binary |-
|
24
|
+
R2VtZmlsZQ==
|
25
|
+
- !binary |-
|
26
|
+
TElDRU5TRQ==
|
27
|
+
- !binary |-
|
28
|
+
UkVBRE1FLm1k
|
29
|
+
- !binary |-
|
30
|
+
UmFrZWZpbGU=
|
31
|
+
- !binary |-
|
32
|
+
ZG9taW51cy5nZW1zcGVj
|
33
|
+
- !binary |-
|
34
|
+
amFycy9OQ1NPLmphcg==
|
35
|
+
- !binary |-
|
36
|
+
bGliL2RvbWludXMucmI=
|
37
|
+
- !binary |-
|
38
|
+
bGliL2RvbWludXMvY2xpZW50LnJi
|
39
|
+
- !binary |-
|
40
|
+
bGliL2RvbWludXMvZGF0YWJhc2UucmI=
|
41
|
+
- !binary |-
|
42
|
+
bGliL2RvbWludXMvZG9jdW1lbnQucmI=
|
43
|
+
- !binary |-
|
44
|
+
bGliL2RvbWludXMvZG9jdW1lbnRfY29sbGVjdGlvbi5yYg==
|
45
|
+
- !binary |-
|
46
|
+
bGliL2RvbWludXMvdmVyc2lvbi5yYg==
|
47
|
+
homepage: http://github.com/Hakon/dominus
|
48
|
+
licenses: []
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
- jars
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: !binary |-
|
59
|
+
MA==
|
60
|
+
none: false
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: !binary |-
|
66
|
+
MA==
|
67
|
+
none: false
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.8.24
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: Adds an easy to use wrapper around the domino diiop database api.\n Memory management (recycling the domino objects) is handled by ruby.
|
74
|
+
test_files: []
|
75
|
+
has_rdoc:
|
76
|
+
...
|