notesgrip 0.0.4
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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.rdoc +135 -0
- data/Rakefile +2 -0
- data/Sample/sample_NotesDatabase.rb +77 -0
- data/Sample/sample_NotesSession.rb +17 -0
- data/Sample/sample_NotesView.rb +63 -0
- data/lib/notesgrip/DocCollection.rb +53 -0
- data/lib/notesgrip/GripWrapper.rb +43 -0
- data/lib/notesgrip/NotesDatabase.rb +468 -0
- data/lib/notesgrip/NotesDocument.rb +258 -0
- data/lib/notesgrip/NotesItem.rb +172 -0
- data/lib/notesgrip/NotesRichTextItem.rb +256 -0
- data/lib/notesgrip/NotesSession.rb +317 -0
- data/lib/notesgrip/NotesView.rb +447 -0
- data/lib/notesgrip/version.rb +3 -0
- data/lib/notesgrip.rb +17 -0
- data/notesgrip.gemspec +23 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b676a1689361bfcebe0f0338b221ac5cbb4e73f6
|
4
|
+
data.tar.gz: 9427cc161f8ca57ed443cfa121255fdd42121814
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3546f023c13c764a1be6af9dc906671b1e26edce7e4066bd4b293e3cc80cc1d4e2b6c1cb7b7aea7d927d7ed742f64b9345e342f0c3a8d29acc746d6b8efabe1e
|
7
|
+
data.tar.gz: 52e46c40e4702d5841fa0cded02eb4416dfa39f8e42ad642351ca3daf37d8f1d510ffbca30e712deec77d5692e5512f2036d2a3510a31349d73f759d63675f48
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 yac4423
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 yac4423
|
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.rdoc
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
= NotesGrip
|
2
|
+
Notesgrip is Ruby library to handle all Notes classes.
|
3
|
+
* Windows Only
|
4
|
+
* Necessary Notes Clinet(all version OK. R4.6-R9)
|
5
|
+
|
6
|
+
= Installation
|
7
|
+
# gem install notesgrip
|
8
|
+
|
9
|
+
= Usage
|
10
|
+
require 'notesgrip'
|
11
|
+
ns = Notesgrip::NotesSession.new
|
12
|
+
db = ns.database("myserver", "mydb.nsf")
|
13
|
+
db.each_document {|doc|
|
14
|
+
p doc
|
15
|
+
}
|
16
|
+
|
17
|
+
= Documentation
|
18
|
+
== Notesgrip::Notes_Wrapper
|
19
|
+
Base class of all Notesgrip classes.
|
20
|
+
This class wraps a various Notes objects.
|
21
|
+
=== Methods
|
22
|
+
[raw]
|
23
|
+
Return raw Notes object which is wrapped by Notesgrip object.
|
24
|
+
|
25
|
+
== Notesgrip::NotesSession class
|
26
|
+
Wrap NotesSession object to use all properties and methods of NotesSession class.
|
27
|
+
ns = NotesGrip::NotesSession.new
|
28
|
+
p ns.NotesVersion # -> "Release 9.0|March 08, 2013 "
|
29
|
+
db = ns.getDatabase("servername", "dbname.nsf")
|
30
|
+
|
31
|
+
=== Additional Methods
|
32
|
+
[database(server, dbfilename, createonfail=false)]
|
33
|
+
Alias of GetDatabse().
|
34
|
+
[each_database(server) {|database| block}]
|
35
|
+
Calls the given block for each database on server.
|
36
|
+
ns = NotesGrip::NotesSession.new
|
37
|
+
ns.each_database("myserver") {|db|
|
38
|
+
p db
|
39
|
+
}
|
40
|
+
|
41
|
+
== Notesgrip:NotesDatabase class
|
42
|
+
Wrap NotesDatabase object.
|
43
|
+
ns = NotesGrip::NotesSession.new
|
44
|
+
db = ns.getDatabase("servername", "dbname.nsf")
|
45
|
+
puts "Title:#{db.Title}, Size:#{db.Size}" # Title:tech's Directory, Size:23330816.0
|
46
|
+
|
47
|
+
=== Additional Methods
|
48
|
+
[CreateDocument(formName=nil)]
|
49
|
+
Create new NotesDocument and set form name. Return Notesgrip::NotesDocument.
|
50
|
+
[name()]
|
51
|
+
Alias of Title().
|
52
|
+
[open?()]
|
53
|
+
Alias of IsOpen().
|
54
|
+
[each_document {|doc| block}]
|
55
|
+
Calls the given block for each document in database.
|
56
|
+
db.each_document {|doc|
|
57
|
+
p doc
|
58
|
+
}
|
59
|
+
|
60
|
+
== Notesgrip:NotesView class
|
61
|
+
Wrap NotesView object.
|
62
|
+
ns = NotesGrip::NotesSession.new
|
63
|
+
db = ns.getDatabase("servername", "dbname.nsf")
|
64
|
+
view = db.view("All")
|
65
|
+
p view.Count
|
66
|
+
=== Additional Methods
|
67
|
+
[each_document {|doc| block}]
|
68
|
+
Calls the given block for each document in the view.
|
69
|
+
view = db.view("All")
|
70
|
+
view.each_document {|doc|
|
71
|
+
p doc
|
72
|
+
}
|
73
|
+
[[index]]
|
74
|
+
Return the document at index.
|
75
|
+
|
76
|
+
=== Notesgrip:NotesDocumentCollection class
|
77
|
+
Wrap NotesDocumentCollection object.
|
78
|
+
ns = NotesGrip::NotesSession.new
|
79
|
+
db = ns.getDatabase("servername", "dbname.nsf")
|
80
|
+
view = db.view("ByDate")
|
81
|
+
docList = view.GetAllDocumentsByKey("2014/04/20", true)
|
82
|
+
p docList.size # count of documents in NotesDocumentCollection
|
83
|
+
=== Additional Methods
|
84
|
+
[each_document {|doc| block}]
|
85
|
+
Calls the given block for each document in the view.
|
86
|
+
docList = view.GetAllDocumentsByKey("2014/04/20", true)
|
87
|
+
docList.each_document {|doc|
|
88
|
+
p doc
|
89
|
+
}
|
90
|
+
[[index]]
|
91
|
+
Return the document at index.
|
92
|
+
|
93
|
+
== Notesgrip:NotesDocument class
|
94
|
+
Wrap NotesDocument object.
|
95
|
+
ns = NotesGrip::NotesSession.new
|
96
|
+
db = ns.getDatabase("servername", "dbname.nsf")
|
97
|
+
doc = db.CreateDocument("main")
|
98
|
+
doc['subject'].text = "Sample-001"
|
99
|
+
doc.save
|
100
|
+
=== Additional Methods
|
101
|
+
[unid]
|
102
|
+
Alias of UniversalID().
|
103
|
+
[[itemname]]
|
104
|
+
Return Notesgrip::NotesItem object which is identified by itemname in the document.
|
105
|
+
[[itemname]=other_item]
|
106
|
+
Copy other NotesItem with given item name.
|
107
|
+
[each_item{|item| block}]
|
108
|
+
Calls the given block for each NotesItem in my document.
|
109
|
+
|
110
|
+
== Notesgrip:NotesItem class
|
111
|
+
Wrap NotesItem object.
|
112
|
+
ns = NotesGrip::NotesSession.new
|
113
|
+
db = ns.getDatabase("servername", "dbname.nsf")
|
114
|
+
db.each_document {|doc|
|
115
|
+
item = doc["subject"]
|
116
|
+
p item.text
|
117
|
+
}
|
118
|
+
===Additional Methods
|
119
|
+
[Values=item_value, text=item_value]
|
120
|
+
Copy item_value into my field. You can set Array into the field.
|
121
|
+
[each_value {|value| block}]
|
122
|
+
Calls the given block for each item value in the field.
|
123
|
+
[richitem_attached?]
|
124
|
+
Return true if Embeded oject in the field.
|
125
|
+
[to_s]
|
126
|
+
Return text string in the field.
|
127
|
+
|
128
|
+
|
129
|
+
= Author
|
130
|
+
notesgrip@tech-notes.dyndns.org
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
= License
|
135
|
+
MIT
|
data/Rakefile
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'notesgrip'
|
2
|
+
|
3
|
+
ns = Notesgrip::NotesSession.new
|
4
|
+
db = ns.database("technotes", "names.nsf")
|
5
|
+
p db # <Notesgrip::NotesDatabase, Name:"tech's Directory", FilePath:"names.nsf">
|
6
|
+
|
7
|
+
# Scan all documents in database
|
8
|
+
db.each_document {|doc|
|
9
|
+
p doc
|
10
|
+
}
|
11
|
+
|
12
|
+
# Scan all views in database
|
13
|
+
db.each_view {|view|
|
14
|
+
p view
|
15
|
+
}
|
16
|
+
|
17
|
+
# Get View
|
18
|
+
view = db.view("People")
|
19
|
+
p view
|
20
|
+
|
21
|
+
# Scan all form in database
|
22
|
+
db.each_form {|form|
|
23
|
+
p form
|
24
|
+
}
|
25
|
+
|
26
|
+
# Database Search
|
27
|
+
docList = db.FTSearch("[LastName] CONTAINS tech-notes")
|
28
|
+
p docList
|
29
|
+
docList.each {|doc|
|
30
|
+
puts "-----"
|
31
|
+
p doc
|
32
|
+
doc.each_item {|item|
|
33
|
+
p item
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
# Read/Unread Document Collection
|
38
|
+
readDocList = db.GetAllReadDocuments()
|
39
|
+
unreadDocList = db.GetAllUnreadDocuments()
|
40
|
+
puts "readDocList.size = #{readDocList.size}"
|
41
|
+
puts "unreadDocList.size = #{unreadDocList.size}"
|
42
|
+
|
43
|
+
# get document by ID/UNID
|
44
|
+
doc = db.GetDocumentByID("12AE")
|
45
|
+
p doc
|
46
|
+
doc = db.GetDocumentByUNID("F8B3C89EA5A15408852572E500656D34")
|
47
|
+
p doc
|
48
|
+
|
49
|
+
# Get Form
|
50
|
+
form = db.GetForm("person")
|
51
|
+
p form
|
52
|
+
|
53
|
+
# Get Option
|
54
|
+
p db.GetOption(Notesgrip::NotesDatabase::DBOPT_SOFTDELETE)
|
55
|
+
|
56
|
+
# ACL
|
57
|
+
acl = db.ACL
|
58
|
+
acl.each_entry {|entry|
|
59
|
+
p entry
|
60
|
+
}
|
61
|
+
|
62
|
+
# ACL Activity
|
63
|
+
db.ACLActivityLog.each {|log|
|
64
|
+
p log
|
65
|
+
}
|
66
|
+
|
67
|
+
# Agents
|
68
|
+
db.each_agent {|agent|
|
69
|
+
p agent
|
70
|
+
}
|
71
|
+
|
72
|
+
# Profile Collection
|
73
|
+
db.each_profile {|doc|
|
74
|
+
p doc
|
75
|
+
}
|
76
|
+
|
77
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'notesgrip'
|
2
|
+
|
3
|
+
ns = Notesgrip::NotesSession.new
|
4
|
+
p ns.UserName
|
5
|
+
p ns.AddressBooks # Array of Local names.nsf and Server names.nsf
|
6
|
+
p ns.CurrentDatabase
|
7
|
+
|
8
|
+
# Get database
|
9
|
+
db = ns.database("myServer", "names.nsf")
|
10
|
+
|
11
|
+
# Create NotesName
|
12
|
+
userName = ns.CreateName("CN=Administrator/O=tech")
|
13
|
+
|
14
|
+
# ListUp Databases on server
|
15
|
+
ns.each_database("technotes") {|db|
|
16
|
+
p db
|
17
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'notesgrip'
|
2
|
+
|
3
|
+
ns = Notesgrip::NotesSession.new
|
4
|
+
db = ns.database("technotes", "names.nsf")
|
5
|
+
|
6
|
+
view = db.view("People")
|
7
|
+
p view
|
8
|
+
p view.Aliases
|
9
|
+
|
10
|
+
# Column
|
11
|
+
view.each_column {|column|
|
12
|
+
p column
|
13
|
+
}
|
14
|
+
|
15
|
+
# ViewEntry
|
16
|
+
view.each_entry {|entry|
|
17
|
+
p entry
|
18
|
+
}
|
19
|
+
|
20
|
+
# ViewNavigator
|
21
|
+
viewNav = view.CreateViewNav()
|
22
|
+
p viewNav
|
23
|
+
|
24
|
+
# FTSearch
|
25
|
+
match_count = view.FTSearch("miwa_dankichi.tech-notes.dyndns.org")
|
26
|
+
puts "match_count = #{match_count}"
|
27
|
+
puts "After FTSearch, view.size = #{view.size}"
|
28
|
+
view.each_document {|doc|
|
29
|
+
p doc
|
30
|
+
}
|
31
|
+
view.clear
|
32
|
+
puts "After clear, view.size = #{view.size}"
|
33
|
+
|
34
|
+
# GetAllDocumentsByKey
|
35
|
+
docList = view.GetAllDocumentsByKey(["Administrator"], false)
|
36
|
+
puts "docList.size = #{docList.size}"
|
37
|
+
docList.each {|doc|
|
38
|
+
p doc
|
39
|
+
}
|
40
|
+
|
41
|
+
# GetAllEntriesByKey
|
42
|
+
entryList = view.GetAllEntriesByKey(["Administrator"], false)
|
43
|
+
puts "entryList.size = #{entryList.size}"
|
44
|
+
entryList.each {|entry|
|
45
|
+
p entry
|
46
|
+
}
|
47
|
+
|
48
|
+
# GetAllReadEntries
|
49
|
+
entryList = view.GetAllReadEntries()
|
50
|
+
puts "GetAllReadEntries, entryList.size = #{entryList.size}"
|
51
|
+
|
52
|
+
# GetDocumentByKey
|
53
|
+
doc = view.GetDocumentByKey(["Administrator"])
|
54
|
+
p doc
|
55
|
+
|
56
|
+
# GetEntryByKey
|
57
|
+
entry = view.GetEntryByKey(["Administrator"])
|
58
|
+
p entry
|
59
|
+
|
60
|
+
# GetNthDocument
|
61
|
+
doc = view.GetNthDocument(2)
|
62
|
+
p doc['FullName']
|
63
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Notesgrip
|
2
|
+
module DocCollection
|
3
|
+
def each_document
|
4
|
+
raw_doc = @raw_object.GetFirstDocument
|
5
|
+
while raw_doc
|
6
|
+
next_doc = @raw_object.GetNextDocument(raw_doc)
|
7
|
+
yield NotesDocument.new(raw_doc)
|
8
|
+
raw_doc = next_doc
|
9
|
+
end
|
10
|
+
end
|
11
|
+
alias each each_document
|
12
|
+
|
13
|
+
def [](index)
|
14
|
+
if index >= 0
|
15
|
+
raw_doc = @raw_object.GetNthDocument( index + 1) # GetNthDocument(1) is the first doc
|
16
|
+
else
|
17
|
+
docs_number = self.Count()
|
18
|
+
raw_index = docs_number - index.abs
|
19
|
+
return nil if raw_index < 0
|
20
|
+
raw_doc = @raw_object.GetNthDocument( raw_index + 1)
|
21
|
+
end
|
22
|
+
raw_doc ? NotesDocument.new(raw_doc) : nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def GetFirstDocument
|
26
|
+
self[0]
|
27
|
+
end
|
28
|
+
def GetLastDocument
|
29
|
+
raw_doc = @raw_object.GetLastDocument
|
30
|
+
raw_doc ? NotesDocument.new(raw_doc) : nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def GetNthDocument(index)
|
34
|
+
if index >= 1
|
35
|
+
self[index-1]
|
36
|
+
else
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def GetNextDocument(document)
|
42
|
+
raw_doc = toRaw(document)
|
43
|
+
raw_nextDoc = @raw_object.GetNextDocument(raw_doc)
|
44
|
+
raw_nextDoc ? NotesDocument.new(raw_nextDoc) : nil
|
45
|
+
end
|
46
|
+
|
47
|
+
def GetPrevDocument( document )
|
48
|
+
raw_doc = toRaw(document)
|
49
|
+
raw_prevDoc = @raw_object.GetPrevDocument(raw_doc)
|
50
|
+
raw_prevDoc ? NotesDocument.new(raw_prevDoc) : nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Notesgrip
|
2
|
+
class GripWrapper
|
3
|
+
def initialize(raw_object)
|
4
|
+
if raw_object.methods.include?("raw")
|
5
|
+
@raw_object = raw_object.raw
|
6
|
+
else
|
7
|
+
@raw_object = raw_object
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def raw
|
12
|
+
@raw_object
|
13
|
+
end
|
14
|
+
|
15
|
+
def inspect()
|
16
|
+
"<#{self.class}>"
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
OLE_METHODS = [:Type, :Initialize]
|
22
|
+
def method_missing(m_id, *params)
|
23
|
+
unless OLE_METHODS.include?(m_id)
|
24
|
+
missing_method_name = m_id.to_s.downcase
|
25
|
+
methods.each {|method|
|
26
|
+
if method.to_s.downcase == missing_method_name
|
27
|
+
return send(method, *params)
|
28
|
+
end
|
29
|
+
}
|
30
|
+
end
|
31
|
+
# Undefined Method is throwed to raw_object
|
32
|
+
begin
|
33
|
+
@raw_object.send(m_id, *params)
|
34
|
+
rescue
|
35
|
+
raise $!,$!.message, caller
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def toRaw(target_obj)
|
40
|
+
target_obj.respond_to?("raw") ? target_obj.raw : target_obj
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|