fibber_mailman 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2@fibber_mailman
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/MIT-LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Fernando Guillen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,58 @@
1
+ = FibberMailman
2
+
3
+ http://farm5.static.flickr.com/4096/4855853753_840f16cb2b.jpg
4
+
5
+ <b>Hey Mailmal.. lie to me!</b>
6
+
7
+ Very simple library for mocking a
8
+
9
+ Net::POP3.start( ... ) do |pop|
10
+ <any code here>
11
+ end
12
+
13
+ call
14
+
15
+ == Install
16
+
17
+ $ [sudo] gem install fibber_mailman
18
+
19
+ or
20
+
21
+ $ script/plugin install git://github.com/fguillen/FibberMailman.git
22
+
23
+ == Usage
24
+ require 'fibber_mailman'
25
+
26
+ raw_mails = [
27
+ File.read( "/fixtures/mail1.raw_mail" ) ),
28
+ File.read( "/fixtures/mail2.raw_mail" ) ),
29
+ ]
30
+
31
+ FibberMailman.lie_to_me( raw_mails ) do
32
+ <your code that uses the Net::POP3.start on any point>
33
+ end
34
+
35
+ Not any real POP call will be done.
36
+
37
+ The mock will simulate that the mails received was the fake *raw_mails*.
38
+
39
+ See the *test* folder.
40
+
41
+ == TODO
42
+
43
+ Only
44
+ pop.each_mail do |m|
45
+ <code here>
46
+ end
47
+
48
+ is supported.
49
+
50
+ == Special Thanks
51
+
52
+ * To the people on this Ruby Forum Thread: http://www.ruby-forum.com/topic/214129
53
+
54
+ == Credits
55
+
56
+ Author:: Fernando Guillen: http://fernandoguillen.info
57
+ Copyright:: Copyright (c) 2010 Fernando Guillen
58
+ License:: Released under the MIT license.
data/Rakefile CHANGED
@@ -1,14 +1,17 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'echoe'
4
-
5
- Echoe.new('fibber_mailman', '0.0.3') do |p|
6
- p.description = "FibberMailman lie to you when you ask for a Net::POP3.start call."
7
- p.url = "http://github.com/fguillen/FibberMailman"
8
- p.author = "http://fernandoguillen.info"
9
- p.email = "fguillen.mail@gmail.com"
10
- p.ignore_pattern = []
11
- p.development_dependencies = [ "tmail" ]
12
- end
13
-
14
- # Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
1
+ # require 'bundler/gem_tasks'
2
+
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+ require 'bundler'
6
+
7
+ # include Rake::DSL
8
+
9
+ Bundler::GemHelper.install_tasks
10
+
11
+ task :default => :test
12
+
13
+ Rake::TestTask.new do |t|
14
+ t.libs << '.'
15
+ t.test_files = FileList['test/*_test.rb']
16
+ t.verbose = true
17
+ end
@@ -0,0 +1,246 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: FibberMailman</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">FibberMailman</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/fibber_mailman_rb.html">
59
+ lib/fibber_mailman.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+ <div id="description">
82
+ <p>
83
+ Example of use:
84
+ </p>
85
+ <pre>
86
+ raw_mails = [
87
+ File.read( &quot;/fixtures/mail1.raw_mail&quot; ) ),
88
+ File.read( &quot;/fixtures/mail2.raw_mail&quot; ) ),
89
+ ]
90
+
91
+ FibberMailman.lie_to_me( raw_mails ) do
92
+ &lt;your code that uses the Net::POP3.start on any point&gt;
93
+ end
94
+ </pre>
95
+ <p>
96
+ Not any real POP call will be done.
97
+ </p>
98
+ <p>
99
+ The mock will simulate that the <a
100
+ href="FibberMailman.html#M000003">mails</a> received was the fake
101
+ *<b>raw_mails</b>*.
102
+ </p>
103
+
104
+ </div>
105
+
106
+
107
+ </div>
108
+
109
+ <div id="method-list">
110
+ <h3 class="section-bar">Methods</h3>
111
+
112
+ <div class="name-list">
113
+ <a href="#M000001">lie_to_me</a>&nbsp;&nbsp;
114
+ <a href="#M000003">mails</a>&nbsp;&nbsp;
115
+ <a href="#M000002">start</a>&nbsp;&nbsp;
116
+ </div>
117
+ </div>
118
+
119
+ </div>
120
+
121
+
122
+ <!-- if includes -->
123
+
124
+ <div id="section">
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ <!-- if method_list -->
134
+ <div id="methods">
135
+ <h3 class="section-bar">Public Class methods</h3>
136
+
137
+ <div id="method-M000001" class="method-detail">
138
+ <a name="M000001"></a>
139
+
140
+ <div class="method-heading">
141
+ <a href="#M000001" class="method-signature">
142
+ <span class="method-name">lie_to_me</span><span class="method-args">( raw_mails ) {|| ...}</span>
143
+ </a>
144
+ </div>
145
+
146
+ <div class="method-description">
147
+ <p><a class="source-toggle" href="#"
148
+ onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
149
+ <div class="method-source-code" id="M000001-source">
150
+ <pre>
151
+ <span class="ruby-comment cmt"># File lib/fibber_mailman.rb, line 33</span>
152
+ 33: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">lie_to_me</span>( <span class="ruby-identifier">raw_mails</span> )
153
+ 34: <span class="ruby-ivar">@@raw_mails</span> = <span class="ruby-identifier">raw_mails</span>
154
+ 35:
155
+ 36: <span class="ruby-comment cmt"># mocking</span>
156
+ 37: <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">POP3</span>.<span class="ruby-identifier">class_eval</span> <span class="ruby-keyword kw">do</span>
157
+ 38: <span class="ruby-identifier">alias_method</span> <span class="ruby-identifier">:orig_start</span>, <span class="ruby-identifier">:start</span>
158
+ 39: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start</span>( <span class="ruby-operator">*</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> )
159
+ 40: <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>( <span class="ruby-keyword kw">self</span> )
160
+ 41: <span class="ruby-keyword kw">end</span>
161
+ 42:
162
+ 43: <span class="ruby-identifier">alias_method</span> <span class="ruby-identifier">:orig_mails</span>, <span class="ruby-identifier">:mails</span>
163
+ 44: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mails</span>
164
+ 45: <span class="ruby-identifier">pop_mails</span> = <span class="ruby-ivar">@@raw_mails</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">raw_mail</span><span class="ruby-operator">|</span> <span class="ruby-constant">FibberPop</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">raw_mail</span> ) }
165
+ 46: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">pop_mails</span>
166
+ 47: <span class="ruby-keyword kw">end</span>
167
+ 48: <span class="ruby-keyword kw">end</span>
168
+ 49:
169
+ 50: <span class="ruby-keyword kw">begin</span>
170
+ 51: <span class="ruby-keyword kw">yield</span>
171
+ 52: <span class="ruby-keyword kw">ensure</span>
172
+ 53:
173
+ 54: <span class="ruby-comment cmt"># unmocking</span>
174
+ 55: <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">POP3</span>.<span class="ruby-identifier">class_eval</span> <span class="ruby-keyword kw">do</span>
175
+ 56: <span class="ruby-identifier">alias_method</span> <span class="ruby-identifier">:start</span>, <span class="ruby-identifier">:orig_start</span>
176
+ 57: <span class="ruby-identifier">alias_method</span> <span class="ruby-identifier">:mails</span>, <span class="ruby-identifier">:orig_mails</span>
177
+ 58: <span class="ruby-keyword kw">end</span>
178
+ 59: <span class="ruby-keyword kw">end</span>
179
+ 60: <span class="ruby-keyword kw">end</span>
180
+ </pre>
181
+ </div>
182
+ </div>
183
+ </div>
184
+
185
+ <h3 class="section-bar">Public Instance methods</h3>
186
+
187
+ <div id="method-M000003" class="method-detail">
188
+ <a name="M000003"></a>
189
+
190
+ <div class="method-heading">
191
+ <a href="#M000003" class="method-signature">
192
+ <span class="method-name">mails</span><span class="method-args">()</span>
193
+ </a>
194
+ </div>
195
+
196
+ <div class="method-description">
197
+ <p><a class="source-toggle" href="#"
198
+ onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
199
+ <div class="method-source-code" id="M000003-source">
200
+ <pre>
201
+ <span class="ruby-comment cmt"># File lib/fibber_mailman.rb, line 44</span>
202
+ 44: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mails</span>
203
+ 45: <span class="ruby-identifier">pop_mails</span> = <span class="ruby-ivar">@@raw_mails</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">raw_mail</span><span class="ruby-operator">|</span> <span class="ruby-constant">FibberPop</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">raw_mail</span> ) }
204
+ 46: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">pop_mails</span>
205
+ 47: <span class="ruby-keyword kw">end</span>
206
+ </pre>
207
+ </div>
208
+ </div>
209
+ </div>
210
+
211
+ <div id="method-M000002" class="method-detail">
212
+ <a name="M000002"></a>
213
+
214
+ <div class="method-heading">
215
+ <a href="#M000002" class="method-signature">
216
+ <span class="method-name">start</span><span class="method-args">( *, &amp;block )</span>
217
+ </a>
218
+ </div>
219
+
220
+ <div class="method-description">
221
+ <p><a class="source-toggle" href="#"
222
+ onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
223
+ <div class="method-source-code" id="M000002-source">
224
+ <pre>
225
+ <span class="ruby-comment cmt"># File lib/fibber_mailman.rb, line 39</span>
226
+ 39: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start</span>( <span class="ruby-operator">*</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> )
227
+ 40: <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>( <span class="ruby-keyword kw">self</span> )
228
+ 41: <span class="ruby-keyword kw">end</span>
229
+ </pre>
230
+ </div>
231
+ </div>
232
+ </div>
233
+
234
+
235
+ </div>
236
+
237
+
238
+ </div>
239
+
240
+
241
+ <div id="validator-badges">
242
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
243
+ </div>
244
+
245
+ </body>
246
+ </html>
@@ -0,0 +1,196 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: FibberPop</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">FibberPop</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/fibber_mailman_rb.html">
59
+ lib/fibber_mailman.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000006">method_missing</a>&nbsp;&nbsp;
90
+ <a href="#M000004">new</a>&nbsp;&nbsp;
91
+ <a href="#M000005">pop</a>&nbsp;&nbsp;
92
+ </div>
93
+ </div>
94
+
95
+ </div>
96
+
97
+
98
+ <!-- if includes -->
99
+
100
+ <div id="section">
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ <!-- if method_list -->
110
+ <div id="methods">
111
+ <h3 class="section-bar">Public Class methods</h3>
112
+
113
+ <div id="method-M000004" class="method-detail">
114
+ <a name="M000004"></a>
115
+
116
+ <div class="method-heading">
117
+ <a href="#M000004" class="method-signature">
118
+ <span class="method-name">new</span><span class="method-args">( raw_mail)</span>
119
+ </a>
120
+ </div>
121
+
122
+ <div class="method-description">
123
+ <p><a class="source-toggle" href="#"
124
+ onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
125
+ <div class="method-source-code" id="M000004-source">
126
+ <pre>
127
+ <span class="ruby-comment cmt"># File lib/fibber_mailman.rb, line 4</span>
128
+ 4: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>( <span class="ruby-identifier">raw_mail</span>)
129
+ 5: <span class="ruby-ivar">@raw_mail</span> = <span class="ruby-identifier">raw_mail</span>
130
+ 6: <span class="ruby-keyword kw">end</span>
131
+ </pre>
132
+ </div>
133
+ </div>
134
+ </div>
135
+
136
+ <h3 class="section-bar">Public Instance methods</h3>
137
+
138
+ <div id="method-M000006" class="method-detail">
139
+ <a name="M000006"></a>
140
+
141
+ <div class="method-heading">
142
+ <a href="#M000006" class="method-signature">
143
+ <span class="method-name">method_missing</span><span class="method-args">(m, *args, &amp;block)</span>
144
+ </a>
145
+ </div>
146
+
147
+ <div class="method-description">
148
+ <p><a class="source-toggle" href="#"
149
+ onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
150
+ <div class="method-source-code" id="M000006-source">
151
+ <pre>
152
+ <span class="ruby-comment cmt"># File lib/fibber_mailman.rb, line 12</span>
153
+ 12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">m</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
154
+ 13: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;PopMock.#{m} called&quot;</span>
155
+ 14: <span class="ruby-keyword kw">end</span>
156
+ </pre>
157
+ </div>
158
+ </div>
159
+ </div>
160
+
161
+ <div id="method-M000005" class="method-detail">
162
+ <a name="M000005"></a>
163
+
164
+ <div class="method-heading">
165
+ <a href="#M000005" class="method-signature">
166
+ <span class="method-name">pop</span><span class="method-args">()</span>
167
+ </a>
168
+ </div>
169
+
170
+ <div class="method-description">
171
+ <p><a class="source-toggle" href="#"
172
+ onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
173
+ <div class="method-source-code" id="M000005-source">
174
+ <pre>
175
+ <span class="ruby-comment cmt"># File lib/fibber_mailman.rb, line 8</span>
176
+ 8: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pop</span>
177
+ 9: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@raw_mail</span>
178
+ 10: <span class="ruby-keyword kw">end</span>
179
+ </pre>
180
+ </div>
181
+ </div>
182
+ </div>
183
+
184
+
185
+ </div>
186
+
187
+
188
+ </div>
189
+
190
+
191
+ <div id="validator-badges">
192
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
193
+ </div>
194
+
195
+ </body>
196
+ </html>