rews 0.2.7 → 0.2.9
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/README.rdoc +10 -5
- data/VERSION +1 -1
- data/lib/rews/folder.rb +8 -0
- data/lib/rews/util.rb +27 -11
- data/spec/rews/util_spec.rb +21 -2
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= rews
|
2
2
|
|
3
|
-
Rews is a simple Ruby client for Exchange Web Services
|
3
|
+
Rews is a simple Ruby client for Exchange Web Services
|
4
4
|
|
5
5
|
* Find, Get and Delete of Items and Folders is supported.
|
6
6
|
* Filtering, ordering, and arbitrary property retrieval are supported.
|
@@ -10,6 +10,11 @@ Rews is a simple Ruby client for Exchange Web Services. It has been tested again
|
|
10
10
|
Method names generally follow the Exchange Web Services API
|
11
11
|
http://msdn.microsoft.com/en-us/library/bb409286(EXCHG.140).aspx
|
12
12
|
|
13
|
+
It has been tested against
|
14
|
+
|
15
|
+
* Exchange 2007 SP1 (Version 8.1, Build 240.6)
|
16
|
+
* Exchange 2010 SP1 (Version 14.1, Build 218.15)
|
17
|
+
|
13
18
|
to use :
|
14
19
|
|
15
20
|
# create a client
|
@@ -36,11 +41,11 @@ to use :
|
|
36
41
|
|
37
42
|
== Install
|
38
43
|
|
39
|
-
slightly painful :
|
40
|
-
gems with fixes
|
44
|
+
slightly painful : because of bugs in released versions of gems relating to NTLM authentication, you need
|
45
|
+
versions of httpclient and ntlm-http gems with fixes :
|
41
46
|
|
42
|
-
* httpclient branch ntlm_domain : https://github.com/mccraigmccraig/httpclient/tree/ntlm_domain
|
43
|
-
* ntlm-http branch
|
47
|
+
* httpclient v2.1.6.1.1 : branch ntlm_domain from : https://github.com/mccraigmccraig/httpclient/tree/ntlm_domain
|
48
|
+
* ntlm-http v0.1.1.1 : branch fix_ntlm_domain from: https://github.com/trampoline/ntlm-http/commits/fix_ntlm_domain
|
44
49
|
|
45
50
|
then:
|
46
51
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.9
|
data/lib/rews/folder.rb
CHANGED
@@ -70,6 +70,14 @@ module Rews
|
|
70
70
|
result[key]
|
71
71
|
end
|
72
72
|
|
73
|
+
def first
|
74
|
+
result.first
|
75
|
+
end
|
76
|
+
|
77
|
+
def last
|
78
|
+
result.last
|
79
|
+
end
|
80
|
+
|
73
81
|
def inspect
|
74
82
|
attrs = VIEW_ATTRS.map{|attr| "@#{attr}=#{self.send(attr)}"}.join(", ")
|
75
83
|
"#<#{self.class} #{attrs}, @result=#{@result.inspect}>"
|
data/lib/rews/util.rb
CHANGED
@@ -1,9 +1,19 @@
|
|
1
1
|
require 'set'
|
2
2
|
|
3
3
|
module Rews
|
4
|
+
class Error < RuntimeError
|
5
|
+
end
|
6
|
+
|
4
7
|
module Util
|
5
8
|
module_function
|
6
9
|
|
10
|
+
def tag_exception(e, tags)
|
11
|
+
tags.each do |k,v|
|
12
|
+
mc = class << e ; self ; end
|
13
|
+
mc.send(:define_method, k){v}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
7
17
|
# validates an options hash against a constraints hash
|
8
18
|
# in the constraints hash :
|
9
19
|
# * keys ending in ! indicate option is required
|
@@ -59,19 +69,25 @@ module Rews
|
|
59
69
|
def with_error_check(client, *response_msg_keys)
|
60
70
|
raise "no block" if !block_given?
|
61
71
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
72
|
+
begin
|
73
|
+
response = yield
|
74
|
+
hash_response = response.to_hash
|
75
|
+
statuses = hash_response.fetch_in(*response_msg_keys)
|
76
|
+
|
77
|
+
if statuses.is_a?(Array)
|
78
|
+
all_statuses = statuses
|
79
|
+
else
|
80
|
+
all_statuses = [statuses]
|
81
|
+
end
|
82
|
+
|
83
|
+
errors = all_statuses.map{|s| single_error_check(client, s)}.compact
|
84
|
+
rescue Exception=>e
|
85
|
+
client.log.warn(e)
|
86
|
+
tag_exception(e, :savon_response=>response)
|
87
|
+
raise e
|
70
88
|
end
|
71
89
|
|
72
|
-
|
73
|
-
raise errors.join("\n") if !errors.empty?
|
74
|
-
|
90
|
+
raise Error.new(errors.join("\n")) if !errors.empty?
|
75
91
|
statuses
|
76
92
|
end
|
77
93
|
|
data/spec/rews/util_spec.rb
CHANGED
@@ -36,7 +36,7 @@ module Rews
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
it "should raise if there are any errors" do
|
39
|
+
it "should raise a Rews::Error if there are any errors" do
|
40
40
|
client = Object.new
|
41
41
|
lambda {
|
42
42
|
Util.with_error_check(client, :foo, :bar) do
|
@@ -45,8 +45,27 @@ module Rews
|
|
45
45
|
mock(response).to_hash{response_hash}
|
46
46
|
response
|
47
47
|
end
|
48
|
-
}.should raise_error
|
48
|
+
}.should raise_error(Rews::Error)
|
49
49
|
end
|
50
|
+
|
51
|
+
it "should tag any unexpected exceptions with the savon response" do
|
52
|
+
client = Object.new
|
53
|
+
exception = RuntimeError.new("boo")
|
54
|
+
mock(client).log.mock!.warn(exception)
|
55
|
+
|
56
|
+
savon_response = Object.new
|
57
|
+
|
58
|
+
lambda {
|
59
|
+
Util.with_error_check(client, :foo, :bar) do
|
60
|
+
mock(savon_response).to_hash{raise exception}
|
61
|
+
savon_response
|
62
|
+
end
|
63
|
+
}.should raise_error{|error|
|
64
|
+
error.respond_to?(:savon_response).should == true
|
65
|
+
error.savon_response.should == savon_response
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
50
69
|
end
|
51
70
|
|
52
71
|
describe "single_error_check" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rews
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 9
|
10
|
+
version: 0.2.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Trampoline Systems Ltd
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-30 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|