pst 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,6 +49,12 @@ class Java::ComPff::PSTFolder
49
49
  # that move the cursor out from underneith the underlying
50
50
  # java-pst library
51
51
  #
52
+ # instead do:
53
+ #
54
+ # while pe = pst_folder.getNextChild
55
+ # # ... use pe
56
+ # end
57
+ #
52
58
  # Maybe once I understand Enumerator better we can fix this.
53
59
  raise "TODO"
54
60
  Enumerator.new do |yielder|
@@ -64,6 +70,18 @@ class Java::ComPff::PSTFolder
64
70
  end
65
71
  end
66
72
 
73
+ # TODO this might suffer from the same problem as #children.
74
+ def take(n)
75
+ i = 0
76
+ results = []
77
+ while i < n && pe = self.getNextChild
78
+ results << pe
79
+ i = i + 1
80
+ end
81
+ results
82
+ end
83
+
84
+
67
85
  def filename
68
86
  self.file.filename
69
87
  end
@@ -91,7 +109,7 @@ class Java::ComPff::PSTFolder
91
109
  self.file = the_parent.file
92
110
  end
93
111
 
94
- def creation_time
112
+ def creation_trme
95
113
  t = self.getCreationTime || self.getLastModificationTime
96
114
  t.andand.to_time
97
115
  end
@@ -110,6 +128,7 @@ class Java::ComPff::PSTMessage
110
128
  alias_method :original_subject, :getOriginalSubject
111
129
  #alias_method :body, :getBody
112
130
  alias_method :html_body, :getBodyHTML
131
+ alias_method :in_reply_to_id, :getInReplyToId
113
132
 
114
133
  # things to pay attention to
115
134
  # next.getDescriptorNode().descriptorIdentifier+"";
@@ -118,6 +137,10 @@ class Java::ComPff::PSTMessage
118
137
  # next.displayTo();
119
138
  # next.getClientSubmitTime();
120
139
 
140
+ def human_sender
141
+ "%s <%s>" % [sender_name, sender_email]
142
+ end
143
+
121
144
  def human_id
122
145
  "%s:%s:%s:%s" % [ folder.human_id, self.getClientSubmitTime.to_s, self.getInternetMessageId, self.subject ]
123
146
  end
@@ -182,6 +205,25 @@ class Java::ComPff::PSTMessage
182
205
  orig
183
206
  end
184
207
  end
208
+
209
+ def headers
210
+ @headers ||= begin
211
+ hstr = self.getTransportMessageHeaders
212
+ hstr.split("\n").inject({}){|acc, line|
213
+ key,value = line.split(":", 2)
214
+ acc[key] = value.strip if value
215
+ acc
216
+ }
217
+ end
218
+ end
219
+
220
+ def thread_topic
221
+ self.headers["Thread-Topic"]
222
+ end
223
+
224
+ def thread_index
225
+ self.headers["Thread-Index"]
226
+ end
185
227
  end
186
228
 
187
229
  class Java::ComPff::PSTRecipient
@@ -200,6 +242,20 @@ class Java::ComPff::PSTRecipient
200
242
  def hash_string
201
243
  Digest::SHA1.hexdigest(human_id)
202
244
  end
245
+
246
+ def how
247
+ case getRecipientType
248
+ when Java::ComPff::PSTRecipient::MAPI_BCC then :bcc
249
+ when Java::ComPff::PSTRecipient::MAPI_CC then :cc
250
+ when Java::ComPff::PSTRecipient::MAPI_TO then :to
251
+ else
252
+ :to
253
+ end
254
+ end
255
+
256
+ def order
257
+ getRecipientOrder
258
+ end
203
259
  end
204
260
 
205
261
  class Java::ComPff::PSTAttachment
@@ -1,3 +1,3 @@
1
1
  module Pst
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -78,7 +78,8 @@ describe "PST" do
78
78
  context "PSTMessage" do
79
79
  before(:all) do
80
80
  @folder = @folders["Deleted Items"]
81
- @email = @folder.children.first
81
+ @folder.moveChildCursorTo(0)
82
+ @email = @folder.getNextChild
82
83
  end
83
84
 
84
85
  it "should have basic attributes" do
@@ -102,9 +103,11 @@ describe "PST" do
102
103
 
103
104
  it "should iterate over recipients" do
104
105
  @email.recipients.count.should eql(1)
105
- #@email.recipients.each do |r|
106
- # pp r
107
- #end
106
+ # @email.recipients.each do |r|
107
+ # pp r
108
+ # pp r.how
109
+ # pp r.order
110
+ # end
108
111
  end
109
112
 
110
113
  end
@@ -112,7 +115,7 @@ describe "PST" do
112
115
  describe "PSTRecipient" do
113
116
  before(:all) do
114
117
  @folder = @folders["Deleted Items"]
115
- @email = @folder.children.take(5).last
118
+ @email = @folder.take(8).last
116
119
 
117
120
  @recipients = @email.recipients.inject({}){|acc,r|
118
121
  acc[r.name] = r
@@ -134,6 +137,19 @@ describe "PST" do
134
137
  it "should have a hash string" do
135
138
  @recipients["Bill"].hash_string.should eql("f161dd2a45952784c440bd5879684ae89b8b0523")
136
139
  end
140
+
141
+ pending "should have an order" do
142
+ pp @recipients["Volume Management"].order
143
+ pp @recipients["Williams III"].order
144
+ pp @recipients["Bill"].order
145
+ end
146
+
147
+ it "should have a how" do
148
+ @recipients["Volume Management"].how.should eql(:to)
149
+ @recipients["Williams III"].how.should eql(:cc)
150
+ @recipients["Bill"].how.should eql(:cc)
151
+ end
152
+
137
153
  end
138
154
 
139
155
  end
metadata CHANGED
@@ -1,34 +1,44 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pst
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Nate Murray
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2011-08-27 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2011-09-10 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: andand
16
- requirement: &2153586440 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: *2153586440
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
25
32
  description: Syntactic sugar over java-libpst.
26
- email:
33
+ email:
27
34
  - nate@natemurray.com
28
35
  executables: []
36
+
29
37
  extensions: []
38
+
30
39
  extra_rdoc_files: []
31
- files:
40
+
41
+ files:
32
42
  - .gitignore
33
43
  - Gemfile
34
44
  - README.mkd
@@ -44,31 +54,37 @@ files:
44
54
  - test/data/.gitkeep
45
55
  - test/data/README
46
56
  - vendor/jars/java-libpst-1.0.0.jar
57
+ has_rdoc: true
47
58
  homepage: http://www.xcombinator.com/
48
59
  licenses: []
60
+
49
61
  post_install_message:
50
62
  rdoc_options: []
51
- require_paths:
63
+
64
+ require_paths:
52
65
  - lib
53
- required_ruby_version: !ruby/object:Gem::Requirement
54
- none: false
55
- requirements:
56
- - - ! '>='
57
- - !ruby/object:Gem::Version
58
- version: '0'
59
- required_rubygems_version: !ruby/object:Gem::Requirement
60
- none: false
61
- requirements:
62
- - - ! '>='
63
- - !ruby/object:Gem::Version
64
- version: '0'
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ segments:
78
+ - 0
79
+ version: "0"
65
80
  requirements: []
81
+
66
82
  rubyforge_project: pst.rb
67
- rubygems_version: 1.8.6
83
+ rubygems_version: 1.3.6
68
84
  signing_key:
69
85
  specification_version: 3
70
86
  summary: Syntactic sugar over java-libpst
71
- test_files:
87
+ test_files:
72
88
  - spec/pst_spec.rb
73
89
  - spec/spec_helper.rb
74
90
  - test/data/.gitkeep