rexchange 0.1.3 → 0.1.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.
- data/CHANGELOG +7 -0
- data/RAKEFILE +1 -1
- data/lib/rexchange/extensions.rb +4 -0
- data/lib/rexchange/folder.rb +5 -40
- data/lib/rexchange/message.rb +35 -0
- metadata +35 -40
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
-- 0.1.4:
|
2
|
+
* Moved Folder::normalize_folder_name to String#normalize, and added support for MixedCase sources.
|
3
|
+
* Fixed a bug where the normalized folder name was being used for the Folder#to_s result.
|
4
|
+
* Moved the meat of Folder#messages to Message::find
|
5
|
+
* Added Message#to_s
|
6
|
+
* Modified Folder#get_folders to return a hash instead of an array, providing both the original, and normalized names.
|
7
|
+
|
1
8
|
-- 0.1.3: Bugfixes
|
2
9
|
* Fixed several nasty bugs.
|
3
10
|
|
data/RAKEFILE
CHANGED
data/lib/rexchange/extensions.rb
CHANGED
data/lib/rexchange/folder.rb
CHANGED
@@ -22,8 +22,8 @@ module RExchange
|
|
22
22
|
# Used to access subfolders. If the subfolder does not
|
23
23
|
# exist, then old_method_missing is called.
|
24
24
|
def method_missing(sym, *args)
|
25
|
-
if
|
26
|
-
Folder.new(@credentials, self, sym )
|
25
|
+
if folders.has_key?(sym.to_s)
|
26
|
+
Folder.new(@credentials, self, folders[sym.to_s] )
|
27
27
|
else
|
28
28
|
old_method_missing(sym, args)
|
29
29
|
end
|
@@ -49,35 +49,8 @@ module RExchange
|
|
49
49
|
end.messages
|
50
50
|
end
|
51
51
|
|
52
|
-
# Retrieve an Array of messages in this folder
|
53
52
|
def messages
|
54
|
-
|
55
|
-
body = <<DABODY
|
56
|
-
<?xml version="1.0"?>
|
57
|
-
<D:searchrequest xmlns:D = "DAV:">
|
58
|
-
<D:sql>
|
59
|
-
SELECT "DAV:href",
|
60
|
-
"urn:schemas:httpmail:from", "urn:schemas:httpmail:to", "urn:schemas:mailheader:message-id",
|
61
|
-
"urn:schemas:httpmail:subject", "DAV:href", "urn:schemas:httpmail:date",
|
62
|
-
"urn:schemas:httpmail:importance", "urn:schemas:httpmail:hasattachment",
|
63
|
-
"urn:schemas:httpmail:textdescription", "urn:schemas:httpmail:htmldescription"
|
64
|
-
FROM SCOPE('shallow traversal of "#{to_s}"')
|
65
|
-
WHERE "DAV:ishidden" = false
|
66
|
-
AND "DAV:isfolder" = false
|
67
|
-
AND "DAV:contentclass" = 'urn:content-classes:message'
|
68
|
-
</D:sql>
|
69
|
-
</D:searchrequest>
|
70
|
-
DABODY
|
71
|
-
|
72
|
-
response = DavSearchRequest.execute(@credentials, :body => body)
|
73
|
-
|
74
|
-
mail_messages = []
|
75
|
-
xpath_query = "//a:propstat[a:status/text() = 'HTTP/1.1 200 OK']/a:prop"
|
76
|
-
Document.new(response.body).elements.each(xpath_query) do |m|
|
77
|
-
mail_messages << Message.new(@credentials, m)
|
78
|
-
end
|
79
|
-
|
80
|
-
return mail_messages
|
53
|
+
RExchange::Message::find(@credentials, to_s)
|
81
54
|
end
|
82
55
|
|
83
56
|
# Join the strings passed in with '/'s between them
|
@@ -90,20 +63,12 @@ DABODY
|
|
90
63
|
@folders ||= get_folders
|
91
64
|
end
|
92
65
|
|
93
|
-
# Check to see if a particular subfolder exists
|
94
|
-
def subfolder_exist?(folder)
|
95
|
-
folders.include? normalize_folder_name(folder)
|
96
|
-
end
|
97
|
-
|
98
66
|
# Return the absolute path to this folder (but not the full URI)
|
99
67
|
def to_s
|
100
68
|
Folder.join(@parent, @folder)
|
101
69
|
end
|
102
70
|
|
103
71
|
private
|
104
|
-
def normalize_folder_name(folder)
|
105
|
-
folder.to_s.tr('- ', '_').squeeze('_').downcase
|
106
|
-
end
|
107
72
|
|
108
73
|
def get_folders
|
109
74
|
request_body = <<DA_QUERY
|
@@ -120,12 +85,12 @@ DA_QUERY
|
|
120
85
|
|
121
86
|
response = DavSearchRequest.execute(@credentials, :body => request_body)
|
122
87
|
|
123
|
-
folders =
|
88
|
+
folders = {}
|
124
89
|
|
125
90
|
# iterate through folders query and add each normalized name to the folders array.
|
126
91
|
xpath_query = "//a:propstat[a:status/text() = 'HTTP/1.1 200 OK']/a:prop"
|
127
92
|
Document.new(response.body).elements.each(xpath_query) do |m|
|
128
|
-
folders
|
93
|
+
folders[m.elements['a:displayname'].text.normalize] = m.elements['a:displayname'].text
|
129
94
|
end
|
130
95
|
|
131
96
|
return folders
|
data/lib/rexchange/message.rb
CHANGED
@@ -9,6 +9,10 @@ module RExchange
|
|
9
9
|
|
10
10
|
attr_accessor :attributes
|
11
11
|
|
12
|
+
def to_s
|
13
|
+
"To: #{to}, From: #{from}, Subject: #{subject}"
|
14
|
+
end
|
15
|
+
|
12
16
|
# Used to access the attributes of the message as a hash.
|
13
17
|
def [](key)
|
14
18
|
return @attributes[key]
|
@@ -62,5 +66,36 @@ module RExchange
|
|
62
66
|
DavMoveRequest.execute(@session, source, destination)
|
63
67
|
end
|
64
68
|
|
69
|
+
# Retrieve an Array of messages in this folder
|
70
|
+
def Message.find(credentials, path)
|
71
|
+
|
72
|
+
body = <<DABODY
|
73
|
+
<?xml version="1.0"?>
|
74
|
+
<D:searchrequest xmlns:D = "DAV:">
|
75
|
+
<D:sql>
|
76
|
+
SELECT "DAV:href", "urn:schemas:httpmail:from", "urn:schemas:httpmail:to",
|
77
|
+
"urn:schemas:mailheader:message-id", "urn:schemas:httpmail:subject",
|
78
|
+
"urn:schemas:httpmail:date", "urn:schemas:httpmail:importance",
|
79
|
+
"urn:schemas:httpmail:hasattachment", "urn:schemas:httpmail:textdescription",
|
80
|
+
"urn:schemas:httpmail:htmldescription"
|
81
|
+
FROM SCOPE('shallow traversal of "#{path}"')
|
82
|
+
WHERE "DAV:ishidden" = false
|
83
|
+
AND "DAV:isfolder" = false
|
84
|
+
AND "DAV:contentclass" = 'urn:content-classes:message'
|
85
|
+
</D:sql>
|
86
|
+
</D:searchrequest>
|
87
|
+
DABODY
|
88
|
+
|
89
|
+
response = DavSearchRequest.execute(credentials, :body => body)
|
90
|
+
|
91
|
+
mail_messages = []
|
92
|
+
xpath_query = "//a:propstat[a:status/text() = 'HTTP/1.1 200 OK']/a:prop"
|
93
|
+
|
94
|
+
Document.new(response.body).elements.each(xpath_query) do |m|
|
95
|
+
mail_messages << Message.new(credentials, m)
|
96
|
+
end
|
97
|
+
|
98
|
+
return mail_messages
|
99
|
+
end
|
65
100
|
end
|
66
101
|
end
|
metadata
CHANGED
@@ -1,63 +1,58 @@
|
|
1
|
-
!ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.10
|
3
3
|
specification_version: 1
|
4
4
|
name: rexchange
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2006-02-01
|
8
|
-
summary: A simple wrapper around Microsoft Exchange Server's WebDAV API
|
6
|
+
version: 0.1.4
|
7
|
+
date: 2006-02-01
|
8
|
+
summary: "A simple wrapper around Microsoft Exchange Server's WebDAV API"
|
9
9
|
require_paths:
|
10
|
-
- lib
|
10
|
+
- lib
|
11
11
|
email: ssmoot@gmail.com; bauer.mail@gmail.com
|
12
12
|
homepage: http://substantiality.net
|
13
13
|
rubyforge_project: rexchange
|
14
|
-
description: Connect, browse, and iterate through folders and messages on an Exchange Server
|
14
|
+
description: "Connect, browse, and iterate through folders and messages on an Exchange Server"
|
15
15
|
autorequire: rexchange
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
18
18
|
has_rdoc: true
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
-
|
22
|
+
- ">"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.0.0
|
24
25
|
version:
|
25
26
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
27
|
authors:
|
29
|
-
- Sam Smoot
|
30
|
-
- Scott Bauer
|
28
|
+
- Sam Smoot
|
29
|
+
- Scott Bauer
|
31
30
|
files:
|
32
|
-
- README
|
33
|
-
- CHANGELOG
|
34
|
-
- RAKEFILE
|
35
|
-
- lib/rexchange.rb
|
36
|
-
- lib/rexchange/credentials.rb
|
37
|
-
- lib/rexchange/dav_move_request.rb
|
38
|
-
- lib/rexchange/dav_search_request.rb
|
39
|
-
- lib/rexchange/exchange_request.rb
|
40
|
-
- lib/rexchange/extensions.rb
|
41
|
-
- lib/rexchange/folder.rb
|
42
|
-
- lib/rexchange/message.rb
|
43
|
-
- lib/rexchange/session.rb
|
44
|
-
- test/functional.rb
|
31
|
+
- README
|
32
|
+
- CHANGELOG
|
33
|
+
- RAKEFILE
|
34
|
+
- lib/rexchange.rb
|
35
|
+
- lib/rexchange/credentials.rb
|
36
|
+
- lib/rexchange/dav_move_request.rb
|
37
|
+
- lib/rexchange/dav_search_request.rb
|
38
|
+
- lib/rexchange/exchange_request.rb
|
39
|
+
- lib/rexchange/extensions.rb
|
40
|
+
- lib/rexchange/folder.rb
|
41
|
+
- lib/rexchange/message.rb
|
42
|
+
- lib/rexchange/session.rb
|
43
|
+
- test/functional.rb
|
45
44
|
test_files: []
|
46
|
-
|
47
45
|
rdoc_options:
|
48
|
-
- --line-numbers
|
49
|
-
- --inline-source
|
50
|
-
- --main
|
51
|
-
- README
|
46
|
+
- "--line-numbers"
|
47
|
+
- "--inline-source"
|
48
|
+
- "--main"
|
49
|
+
- README
|
52
50
|
extra_rdoc_files:
|
53
|
-
- README
|
54
|
-
- CHANGELOG
|
55
|
-
- RAKEFILE
|
51
|
+
- README
|
52
|
+
- CHANGELOG
|
53
|
+
- RAKEFILE
|
56
54
|
executables: []
|
57
|
-
|
58
55
|
extensions: []
|
59
|
-
|
60
56
|
requirements:
|
61
|
-
- none
|
62
|
-
dependencies: []
|
63
|
-
|
57
|
+
- none
|
58
|
+
dependencies: []
|