rexchange 0.3.3 → 0.3.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 +5 -0
- data/RAKEFILE +1 -1
- data/README +43 -35
- data/lib/rexchange.rb +1 -1
- data/lib/rexchange/credentials.rb +1 -1
- data/lib/rexchange/folder.rb +3 -6
- data/lib/rexchange/generic_item.rb +1 -1
- data/lib/rexchange/session.rb +1 -4
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
-- 0.3.4:
|
2
|
+
* Updated the README so it jives with the current version
|
3
|
+
* Removed Folder::join since it's only used by Folder#to_s, and just used a simpler
|
4
|
+
solution in Folder#to_s instead
|
5
|
+
|
1
6
|
-- 0.3.3:
|
2
7
|
* Folder objects now default to using the Message class for enumeration
|
3
8
|
if no class is associated with the content_type of the Folder.
|
data/RAKEFILE
CHANGED
data/README
CHANGED
@@ -15,53 +15,61 @@ RExchange is a pure ruby wrapper for the Microsoft Exchange Server WebDAV API
|
|
15
15
|
|
16
16
|
== Example
|
17
17
|
|
18
|
-
uri
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
# to create a RExchange::Session.
|
23
|
-
RExchange::open(uri, options) do |mailbox|
|
24
|
-
|
18
|
+
# We pass our uri (pointing directly to a mailbox), a username, and a password to RExchange::open
|
19
|
+
# to create a RExchange::Session. Notice that we escape the "\" in our username.
|
20
|
+
RExchange::open('https://example.com/exchange/admin/', 'mydomain\\admin', 'secret') do |mailbox|
|
21
|
+
|
25
22
|
# The block parameter ("mailbox" in this case) is actually the Session itself.
|
26
23
|
# You can refer to folders by chaining them as method calls. "inbox" in this case
|
27
24
|
# isn't a defined method for Session, but part of the DSL to refer to folder names.
|
28
25
|
# Each folder name returns a RExchange::Folder. The folder is Enumerable, allowing
|
29
|
-
# iteration over the
|
30
|
-
|
31
|
-
|
26
|
+
# iteration over the items in the folder, depending on the DAV:content-class of
|
27
|
+
# the folder.
|
28
|
+
mailbox.inbox.each do |message|
|
29
|
+
|
32
30
|
# The "message" block parameter is a RExchange::Message object. You have access to
|
33
|
-
# several attributes of the message, including: href, from, to,
|
34
|
-
# importance,
|
35
|
-
|
36
|
-
|
31
|
+
# several attributes of the message, including: href, from, to, message_id, date,
|
32
|
+
# importance, has_attachment? and body.
|
33
|
+
p message.subject
|
34
|
+
|
37
35
|
# The RExchange::Message#move_to method moves the message to another folder, in this
|
38
36
|
# case, an "archive" folder off of the inbox.
|
39
|
-
message.move_to mailbox.inbox.archive
|
37
|
+
message.move_to mailbox.inbox.archive
|
40
38
|
end
|
41
|
-
|
42
|
-
# You can also call the RExchange::Folder#messages method if you find calling "each"
|
43
|
-
# on a folder directly a little obscure.
|
44
|
-
mailbox.inbox.archive.messages.each do |m|
|
45
|
-
|
46
|
-
# Our previous message should show up in here now.
|
47
|
-
p m.subject
|
48
|
-
end
|
49
|
-
|
50
|
-
# The RExchange::Folder#message_in method is less expensive than the DSL folder-chaining
|
51
|
-
# methods. Since the folder-chaining is cached in the Session it's a small hit, and some
|
52
|
-
# may prefer the readability of them, but if you're looking for absolute performance
|
53
|
-
# or have really deep folder structures then this may be the method for you.
|
54
|
-
mailbox.messages_in '/inbox/' do |m|
|
55
|
-
|
56
|
-
# Since we moved all our messages to the archive earlier, this shouldn't display
|
57
|
-
# anything.
|
58
|
-
p m.from
|
59
|
-
end
|
60
|
-
|
39
|
+
|
61
40
|
# Folder names are "normalized", replacing dashes and spaces with underscores,
|
62
41
|
# squeezing out multiple underscores in a row, and downcasing the whole thing.
|
63
42
|
# So a folder name such as "My Very-long Folder Name" would look like:
|
64
43
|
mailbox.my_very_long_folder_name
|
44
|
+
|
45
|
+
# The Enumerable mixin gives us an Folder#entries method in case we just want to
|
46
|
+
# return an array.
|
47
|
+
messages = mailbox.inbox.entries
|
48
|
+
|
49
|
+
# Other methods, like Enumerable#map and Enumerable#sort_by let us manipulate
|
50
|
+
# the Folder in fun ways:
|
51
|
+
puts mailbox.contacts.sort_by { |contact| contact.first_name }.map do |contact|
|
52
|
+
<<-CONTACT
|
53
|
+
Name: #{contact.first_name} #{contact.last_name}
|
54
|
+
Email: #{contact.email}
|
55
|
+
Phone: #{contact.phone}
|
56
|
+
CONTACT
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
# We can access the Global Address Book by accessing the "/public" folder:
|
62
|
+
RExchange::open('https://example.com/public', 'mydomain\\somebody', 'secret') do |mailbox|
|
63
|
+
|
64
|
+
puts mailbox.company_contacts.each do |contact|
|
65
|
+
<<-CONTACT
|
66
|
+
Company: #{contact.company}
|
67
|
+
Name: #{contact.first_name} #{contact.last_name}
|
68
|
+
Email: #{contact.email}
|
69
|
+
Phone: #{contact.phone}
|
70
|
+
CONTACT
|
71
|
+
end
|
72
|
+
|
65
73
|
end
|
66
74
|
|
67
75
|
== Caveats
|
data/lib/rexchange.rb
CHANGED
@@ -18,7 +18,7 @@ module RExchange
|
|
18
18
|
# Use STDOUT or another stream if you'd like to capture the HTTP debug output
|
19
19
|
DEBUG_STREAM = $log
|
20
20
|
|
21
|
-
# A shortcut to RExchange::Session#new
|
21
|
+
# A shortcut to RExchange::Session#new
|
22
22
|
def self.open(uri, username = nil, password = nil)
|
23
23
|
session = RExchange::Session.new(uri, username, password)
|
24
24
|
|
@@ -7,7 +7,7 @@ module RExchange
|
|
7
7
|
class Credentials
|
8
8
|
attr_reader :user, :password, :uri
|
9
9
|
|
10
|
-
# You must pass a uri,
|
10
|
+
# You must pass a uri, a username and a password
|
11
11
|
def initialize(uri, username = nil, password = nil)
|
12
12
|
@uri = URI.parse(uri)
|
13
13
|
@use_ssl = (@uri.scheme.downcase == 'https')
|
data/lib/rexchange/folder.rb
CHANGED
@@ -40,15 +40,12 @@ module RExchange
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
# Not Implemented!
|
43
44
|
def search(conditions = {})
|
45
|
+
raise NotImplementedError.new('Bad Touch!')
|
44
46
|
@content_type::find(@credentials, to_s, conditions)
|
45
47
|
end
|
46
48
|
|
47
|
-
# Join the strings passed in with '/'s between them
|
48
|
-
def self.join(*args)
|
49
|
-
args.collect { |f| f.to_s.ensure_ends_with('/') }.to_s.squeeze('/')
|
50
|
-
end
|
51
|
-
|
52
49
|
# Return an Array of subfolders for this folder
|
53
50
|
def folders
|
54
51
|
@folders ||= begin
|
@@ -83,7 +80,7 @@ module RExchange
|
|
83
80
|
|
84
81
|
# Return the absolute path to this folder (but not the full URI)
|
85
82
|
def to_s
|
86
|
-
|
83
|
+
"#@parent/#@name/".squeeze('/')
|
87
84
|
end
|
88
85
|
end
|
89
86
|
end
|
@@ -77,7 +77,7 @@ module RExchange
|
|
77
77
|
|
78
78
|
# Defines what attributes are used in queries, and
|
79
79
|
# what methods they map to in instances. You should
|
80
|
-
# pass a Hash of method_name and namespaced-attribute-name pairs.
|
80
|
+
# pass a Hash of method_name symbols and namespaced-attribute-name pairs.
|
81
81
|
def self.attribute_mappings(mappings)
|
82
82
|
|
83
83
|
mappings.merge! :uid => 'DAV:uid',
|
data/lib/rexchange/session.rb
CHANGED
@@ -8,10 +8,7 @@ module RExchange
|
|
8
8
|
|
9
9
|
# Creates a Credentials instance to pass to subfolders
|
10
10
|
# === Example
|
11
|
-
#
|
12
|
-
# options = { :user => 'test', :password => 'random' }
|
13
|
-
#
|
14
|
-
# RExchange::Session.new(uri, 'bob', 'secret') do |mailbox|
|
11
|
+
# RExchange::Session.new('https://mydomain.com/exchange/demo', 'mydomain\\bob', 'secret') do |mailbox|
|
15
12
|
# mailbox.test.each do |message|
|
16
13
|
# puts message.subject
|
17
14
|
# end
|
metadata
CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rexchange
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.3.
|
6
|
+
version: 0.3.4
|
7
7
|
date: 2007-01-10 00:00:00 -06:00
|
8
8
|
summary: A simple wrapper around Microsoft Exchange Server's WebDAV API
|
9
9
|
require_paths:
|
@@ -34,8 +34,8 @@ files:
|
|
34
34
|
- CHANGELOG
|
35
35
|
- RAKEFILE
|
36
36
|
- MIT-LICENSE
|
37
|
-
- lib/rexchange.rb
|
38
37
|
- lib/r_exchange.rb
|
38
|
+
- lib/rexchange.rb
|
39
39
|
- lib/rexchange/appointment.rb
|
40
40
|
- lib/rexchange/contact.rb
|
41
41
|
- lib/rexchange/credentials.rb
|