whotowho 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Binary file
@@ -1,3 +1,12 @@
1
+ == 0.2.0 / 2008-01-06
2
+
3
+ * 1 major enhancement
4
+ * Add exclude system to assign another person
5
+ * 2 minors enhancement
6
+ * The verbose mode is really verbose and when you choose the
7
+ non-verbose mode, it's really non-verbose
8
+ * Changement of Licence to GPL to MIT
9
+
1
10
  == 0.1.0 / 2007-11-16
2
11
 
3
12
  * 1 major enhancement
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007 FIXME full name
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.
@@ -1,16 +1,17 @@
1
1
  History.txt
2
+ License.txt
2
3
  Manifest.txt
3
4
  README.txt
4
5
  Rakefile
5
6
  bin/whotowho
6
- conf.yaml
7
7
  conf/conf.yaml.example
8
8
  conf/data.yaml.example
9
9
  conf/mail-example.txt
10
- data.yaml
11
10
  lib/whotowho.rb
12
11
  lib/whotowho/link.rb
13
12
  lib/whotowho/parseargs.rb
14
13
  lib/whotowho/sendmail.rb
15
14
  lib/whotowho/smtp_tls.rb
15
+ lib/whotowho/version.rb
16
+ test/test_helper.rb
16
17
  test/test_whotowho.rb
data/README.txt CHANGED
@@ -29,13 +29,14 @@ send this name by email. With WhoToWho you can define several thing:
29
29
  * The configuration of smtp connection
30
30
  * Add options for SSL if your smtp connection is a Gmail account
31
31
 
32
-
33
32
  == FEATURES:
34
33
 
35
34
  * Randomize a list and choice one persone for another
36
- * Send an email where the personne know who is define to it
35
+ * Send an email who the personne know who is define to it
37
36
  * Define the subject and the content of mail with 2 places for define word
38
37
  * who and to who
38
+ * Possibility to exclude one or several person for another. With this
39
+ feature, one person can't have another person define.
39
40
 
40
41
  == SYNOPSIS:
41
42
 
@@ -81,6 +82,24 @@ This file define the list of name and email. The format of this file is YAML. It
81
82
  - - name3
82
83
  - email3
83
84
 
85
+ If you want define an exclude person to another you need had an Exclude list to the key exclude after email, like following :
86
+
87
+ - - name
88
+ - email
89
+ - :exclude: - name2
90
+ - - name2
91
+ - email2
92
+ - :exclude: - name5
93
+ - name6
94
+ - - name3
95
+ - email3
96
+ - - name4
97
+ - email4
98
+ - - name5
99
+ - email5
100
+ - - name6
101
+ - email6
102
+
84
103
  = File of mail configuration
85
104
 
86
105
  It's the same of actionmailer. But I have add a configuration of from. You need had :from:
@@ -102,163 +121,4 @@ This file is a simple text file. You have two patterns who change before the sen
102
121
 
103
122
  == LICENSE:
104
123
 
105
- (The GPLv3 License)
106
-
107
- GNU GENERAL PUBLIC LICENSE
108
-
109
- Version 3, 29 June 2007
110
-
111
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
112
-
113
- Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
114
- Preamble
115
-
116
- The GNU General Public License is a free, copyleft license for software and other kinds of works.
117
-
118
- The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
119
-
120
- When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
121
-
122
- To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
123
-
124
- For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
125
-
126
- Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
127
-
128
- For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
129
-
130
- Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
131
-
132
- Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
133
-
134
- The precise terms and conditions for copying, distribution and modification follow.
135
- TERMS AND CONDITIONS
136
- 0. Definitions.
137
-
138
- “This License” refers to version 3 of the GNU General Public License.
139
-
140
- “Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
141
-
142
- “The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
143
-
144
- To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
145
-
146
- A “covered work” means either the unmodified Program or a work based on the Program.
147
-
148
- To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
149
-
150
- To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
151
-
152
- An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
153
- 1. Source Code.
154
-
155
- The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
156
-
157
- A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
158
-
159
- The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
160
-
161
- The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
162
-
163
- The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
164
-
165
- The Corresponding Source for a work in source code form is that same work.
166
- 2. Basic Permissions.
167
-
168
- All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
169
-
170
- You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
171
-
172
- Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
173
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
174
-
175
- No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
176
-
177
- When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
178
- 4. Conveying Verbatim Copies.
179
-
180
- You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
181
-
182
- You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
183
- 5. Conveying Modified Source Versions.
184
-
185
- You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
186
-
187
- * a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
188
- * b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
189
- * c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
190
- * d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
191
-
192
- A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
193
- 6. Conveying Non-Source Forms.
194
-
195
- You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
196
-
197
- * a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
198
- * b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corre through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
199
-
200
- If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
201
-
202
- A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
203
-
204
- Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
205
- 12. No Surrender of Others' Freedom.
206
-
207
- If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
208
- 13. Use with the GNU Affero General Public License.
209
-
210
- Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
211
- 14. Revised Versions of this License.
212
-
213
- The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
214
-
215
- Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by authorizes you to choose that version for the Program.
216
-
217
- Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
218
- 15. Disclaimer of Warranty.
219
-
220
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
221
- 16. Limitation of Liability.
222
-
223
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
224
- 17. Interpretation of Sections 15 and 16.
225
-
226
- If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
227
-
228
- END OF TERMS AND CONDITIONS
229
- How to Apply These Terms to Your New Programs
230
-
231
- If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
232
-
233
- To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
234
-
235
- <one line to give the program's name and a brief idea of what it does.>
236
- Copyright (C) <year> <name of author>
237
-
238
- This program is free software: you can redistribute it and/or modify
239
- it under the terms of the GNU General Public License as published by
240
- the Free Software Foundation, either version 3 of the License, or
241
- (at your option) any later version.
242
-
243
- This program is distributed in the hope that it will be useful,
244
- but WITHOUT ANY WARRANTY; without even the implied warranty of
245
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
246
- GNU General Public License for more details.
247
-
248
- You should have received a copy of the GNU General Public License
249
- along with this program. If not, see <http://www.gnu.org/licenses/>.
250
-
251
- Also add information on how to contact you by electronic and paper mail.
252
-
253
- If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
254
-
255
- <program> Copyright (C) <year> <name of author>
256
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
257
- This is free software, and you are welcome to redistribute it
258
- under certain conditions; type `show c' for details.
259
-
260
- The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
261
-
262
- You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information ow to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.
263
-
264
- The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.
124
+ This code is free to use under the terms of the MIT license.
data/Rakefile CHANGED
@@ -1,18 +1,4 @@
1
- # -*- ruby -*-
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
2
3
 
3
- require 'rubygems'
4
- require 'hoe'
5
- require './lib/whotowho.rb'
6
-
7
- Hoe.new('whotowho', Whotowho::VERSION) do |p|
8
- p.rubyforge_name = 'whotowho'
9
- p.author = 'cyril mougel'
10
- p.email = 'cyril.mougel@gmail.com'
11
- p.summary = 'Define a person for another person and send by email Who to Who'
12
- # p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
13
- p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
14
- p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
15
- p.extra_deps << ['actionmailer', '>= 1.3.5']
16
- end
17
-
18
- # vim: syntax=Ruby
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
@@ -1,7 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $:.unshift File.dirname(__FILE__) + '/../lib'
4
+ require 'rubygems'
3
5
  require 'whotowho'
4
6
 
5
- args = ParseArgs.new
7
+ args = WhoToWho::ParseArgs.new
6
8
  args.parse ARGV, $0
7
- Whotowho.new(args).send
9
+ whotowho = WhoToWho::WhoToWho.new(args)
10
+ whotowho.send whotowho.random
@@ -6,3 +6,4 @@
6
6
  - email_trois
7
7
  - - quatre
8
8
  - email_quatre
9
+ - :exclude: deux
@@ -1,31 +1,101 @@
1
- require 'whotowho/sendmail'
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ require 'whotowho/version'
2
4
  require 'whotowho/link'
3
5
  require 'whotowho/parseargs'
6
+ require 'whotowho/sendmail'
7
+ require 'whotowho/smtp_tls'
4
8
 
5
- # Manage the separation and assign all who to who
6
- class Whotowho
7
-
8
- VERSION = "0.1.0"
9
- # init with an ParseArgs Object
10
- def initialize(args)
11
- @args = args
12
- end
13
-
14
- # made the random in list of Link and
15
- # send a mail to all person
16
- def send
17
- first = @args.put_random
18
- first_name = first.name
19
- email = first.email
20
- name_receiv = first.name
21
- list_mail = []
22
- while @args.size > 0 do
23
- tmp = @args.put_random
24
- SendMail.deliver_send_mail(tmp.name, email, name_receiv, @args)
25
- email = tmp.email
26
- name_receiv = tmp.name
9
+ module WhoToWho
10
+
11
+ # Manage the separation and assign all who to who
12
+ class WhoToWho
13
+
14
+ TIMEOUT = 5000
15
+
16
+ # init with an ParseArgs Object
17
+ def initialize(args)
18
+ @args = args
19
+ end
20
+
21
+ # Static method to made a logger in general of application
22
+ def self.log
23
+ @@log ||= Logger.new STDOUT
27
24
  end
28
25
 
29
- SendMail.deliver_send_mail(first_name, email, name_receiv, @args)
26
+ # Say if the logger is in debug level or not
27
+ # The log is in debug whith -v option
28
+ def self.logdebug?
29
+ WhoToWho.log.level == Logger::DEBUG
30
+ end
31
+
32
+ def send(list_random)
33
+ WhoToWho.log.info "Send Mail :"
34
+ list_random.each { |l|
35
+ WhoToWho.log.info "Send mail to #{l[0].name} (#{l[0].email})"
36
+ SendMail.deliver_send_mail(l[1].name, l[0].email, l[0].name, @args)
37
+ }
38
+ end
39
+
40
+ # made the random in list of Link
41
+ # and return a list of 2 links. The
42
+ # first for the second and the second
43
+ # can't be in list of exclude of first
44
+ def random
45
+ concord_list = []
46
+
47
+ first = @args.put_random
48
+
49
+ tmp = @args.put_random
50
+ while first.exclude.include? tmp.name
51
+ @args.insert tmp
52
+ tmp = @args.put_random
53
+ end
54
+ concord_list << [first, tmp]
55
+ WhoToWho.log.debug "concords : #{first} <= #{tmp}"
56
+
57
+ list_mail = []
58
+
59
+ timeout = TIMEOUT
60
+ refresh = false
61
+
62
+ while @args.size > 0 do
63
+ tmp2 = @args.put_random
64
+ while tmp.exclude.include? tmp2.name
65
+ @args.insert tmp2
66
+ tmp2 = @args.put_random
67
+ timeout -= 1
68
+ if timeout < 0
69
+ WhoToWho.log.debug 'timeout'
70
+ refresh = true
71
+ break
72
+ end
73
+ end
74
+ concord_list << [tmp, tmp2]
75
+ WhoToWho.log.debug "concords : #{tmp} <= #{tmp2}"
76
+ tmp = tmp2
77
+ end
78
+
79
+ if tmp.exclude.include? first.name
80
+ refresh = true
81
+ end
82
+
83
+ concord_list << [tmp, first]
84
+ WhoToWho.log.debug "concords : #{tmp} <= #{first}"
85
+
86
+ if refresh
87
+ @args.refresh
88
+ concord_list = random
89
+ end
90
+
91
+
92
+ concord_list.each { |c|
93
+ WhoToWho.log.debug "#{c[0]} => #{c[1]}"
94
+ }
95
+
96
+ WhoToWho.log.info "The assignement is define."
97
+ concord_list
98
+
99
+ end
30
100
  end
31
101
  end
@@ -1,12 +1,24 @@
1
+ module WhoToWho
2
+ # Class for link an email to a name
3
+ class Link
1
4
 
2
- # Class for link an email to a name
3
- class Link
5
+ attr_reader :name
6
+ attr_reader :email
7
+ attr_reader :exclude
8
+
9
+ def initialize(name, email)
10
+ @name = name
11
+ @email = email
12
+ @exclude = []
13
+ end
4
14
 
5
- attr_reader :name
6
- attr_reader :email
7
-
8
- def initialize(name, email)
9
- @name = name
10
- @email = email
15
+ def exclude=(list_exclude)
16
+ WhoToWho.log.debug "#{name} has exclude #{list_exclude[:exclude].join(',')}"
17
+ @exclude = list_exclude[:exclude]
18
+ end
19
+
20
+ def to_s
21
+ "#{name} (#{email})"
22
+ end
11
23
  end
12
24
  end
@@ -1,118 +1,169 @@
1
1
  require 'yaml'
2
2
  require 'optparse'
3
3
 
4
- # Class for parse Args and save all into
5
- class ParseArgs
6
-
7
- attr_reader :verbose
8
- attr_reader :subject
9
- attr_reader :content
10
- attr_reader :from
11
-
12
- # Parse all argument and check if required is define
13
- def parse(args, prog)
14
- options = OptionParser.new do |opts|
15
-
16
- opts.banner = "Usage: #{prog} [options]"
17
-
18
- opts.on("-v", "--verbose", "Run verbosely") do |v|
19
- @verbose = true
20
- end
21
- opts.on( '-f', '--file REQUIRED', :REQUIRED, 'File where is all data') do |f|
22
- load_file f
23
- end
24
- opts.on('-c', '--config FILE', :REQUIRED, 'File where is all config') do |f|
25
- load_config f
26
- end
27
- opts.on('-g', '--gmail', 'Define option if use a Gmail account for SMTP') do |g|
28
- require_dependency('whotowho/smtp_tls') if g
29
- end
30
- opts.on('-s', '--subject SUBJECT', :REQUIRED, 'Define the subject to send by email') do |s|
31
- @subject = s
32
- end
33
- opts.on('-m FILE', '--mail MAIL', :REQUIRED, 'Send a file where the content is with 2 params #{who} and #{towho}') do |c|
34
- @content = File.open(c).read
35
- end
36
-
37
- @full_print = opts
38
-
39
- end.parse!
40
- test_required
41
- end
42
-
43
-
44
- # Send a random Link objet from list_link save into
45
- def put_random
46
- rand_index = rand(@list_link.size)
47
- @list_link.slice!(rand_index)
48
- end
4
+ module WhoToWho
5
+ # Class for parse Args and save all into
6
+ class ParseArgs
7
+
8
+ attr_reader :subject
9
+ attr_reader :content
10
+ attr_reader :from
11
+
12
+ # Parse all argument and check if required is define
13
+ def parse(args, prog)
14
+ WhoToWho.log.level = Logger::INFO
15
+ options = OptionParser.new do |opts|
16
+
17
+ opts.banner = "Usage: #{prog} [options]"
18
+
19
+ opts.on("-v", "--verbose", "Run verbosely") do |v|
20
+ WhoToWho.log.level = Logger::DEBUG
21
+ WhoToWho.log.debug "Debug Activate"
22
+ end
23
+ opts.on( '-f', '--file REQUIRED', :REQUIRED, 'File where is all data') do |f|
24
+ load_file f
25
+ end
26
+ opts.on('-c', '--config FILE', :REQUIRED, 'File where is all config') do |f|
27
+ load_config f
28
+ end
29
+ opts.on('-g', '--gmail', 'Define option if use a Gmail account for SMTP') do |g|
30
+ require_dependency('whotowho/smtp_tls') if g
31
+ end
32
+ opts.on('-s', '--subject SUBJECT', :REQUIRED, 'Define the subject to send by email') do |s|
33
+ @subject = s
34
+ end
35
+ opts.on('-m FILE', '--mail MAIL', :REQUIRED, 'Send a file where the content is with 2 params #{who} and #{towho}') do |c|
36
+ @content = File.open(c).read
37
+ end
38
+
39
+ @full_print = opts
40
+
41
+ end.parse!
42
+ test_required
43
+ @test = 0
44
+ end
49
45
 
50
- # Size of list_link in args
51
- def size
52
- @list_link.size
53
- end
54
46
 
47
+ # Send a random Link objet from list_link save into
48
+ def put_random
49
+ rand_index = rand(@list_link.size)
50
+ @list_link.slice!(rand_index)
51
+ end
55
52
 
56
- # Send a random Link objet from list_link save into
57
- def put_random
58
- rand_index = rand(@list_link.size)
59
- @list_link.slice!(rand_index)
60
- end
53
+ # Size of list_link in args
54
+ def size
55
+ @list_link.size
56
+ end
61
57
 
62
- # Size of list_link in args
63
- def size
64
- @list_link.size
65
- end
66
58
 
67
- private
68
-
69
- # Load the file with format to YAML in list_link attribute
70
- def load_file(f)
71
- @list_link = []
72
- YAML.load_file(f).each { |e|
73
- @list_link << Link.new(e[0], e[1])
74
- }
75
- end
59
+ def insert(link)
60
+ @list_link << link
61
+ end
76
62
 
77
- # Load the file like a smtp config for actionMailer
78
- def load_config(f)
79
- conf_hash = YAML.load_file f
80
- ActionMailer::Base.smtp_settings = conf_hash
81
- @from = conf_hash[:from]
82
- end
83
-
84
- # Test if all argument required is define
85
- def test_required
86
- required = true
87
- if @subject.nil? || @subject.empty?
88
- puts 'you need define a subject'
89
- required = false
63
+ # Size of list_link in args
64
+ def size
65
+ @list_link.size
90
66
  end
91
67
 
92
- if @content.nil? || @content.empty?
93
- puts 'you need define a file or a file not empty for you mail template'
94
- required = false
68
+ def refresh
69
+ @list_link = Array.new @list_link_copy
70
+ WhoToWho.log.debug 'refresh'
71
+ @test += 1
72
+ if @test > 3
73
+ WhoToWho.log.warn 'Sorry this combinaison is hard to randomise, please report your data file in bugtracking http://rubyforge.org/tracker/?group_id=4883'
74
+ exit
75
+ end
95
76
  end
96
77
 
97
- if @list_link.nil? || @list_link.empty? || @list_link.size < 2
98
- puts 'The list of data need define by a file. This file can\'t be empty or only one data'
99
- required = false
78
+ private
79
+
80
+ # Load the file with format to YAML in list_link attribute
81
+ def load_file(f)
82
+ @list_link = []
83
+ YAML.load_file(f).each { |e|
84
+ link = Link.new e[0], e[1]
85
+ link.exclude = e[2] if e.size > 2
86
+ @list_link << link
87
+ }
88
+ check_possibility
89
+ @list_link_copy = Array.new @list_link
100
90
  end
101
91
 
102
- if ActionMailer::Base.smtp_settings.empty?
103
- puts 'The configuration of your SMTP account can\'t be empty'
104
- required = false
92
+ # Check if the @list_link it's not incorrect
93
+ # If the @list_link has no an element exclude by all
94
+ # or one element who exclude all
95
+ def check_possibility
96
+ @list_link.each { |l|
97
+
98
+ # Check if one element exclude all element
99
+ if (l.exclude.class == Array && l.exclude.size >= (@list_link.size - 1))
100
+ WhoToWho.log.warn "There are several exclude for #{l.name}. You need define less one element possible"
101
+ exit
102
+ end
103
+
104
+ # Check if one element is exclude by all element
105
+ all_exclude = false
106
+
107
+ @list_link.each { |l2|
108
+ next if l2 == l
109
+ unless l2.exclude.nil?
110
+ if l2.exclude.include? l.name
111
+ all_exclude = true
112
+ else
113
+ all_exclude = false
114
+ end
115
+ end
116
+ break unless all_exclude
117
+ }
118
+
119
+ if all_exclude
120
+ WhoToWho.log.warn "One name is exclude by all other element. This element is #{l.name}, you need fixe that"
121
+ exit
122
+ end
123
+ }
105
124
  end
106
125
 
107
- if @from.nil? || @from.empty?
108
- puts 'You need define a from in your mail settings.'
109
- required = false
126
+ # Load the file like a smtp config for actionMailer
127
+ def load_config(f)
128
+ conf_hash = YAML.load_file f
129
+ ActionMailer::Base.smtp_settings = conf_hash
130
+ ActionMailer::Base.logger = WhoToWho.log if WhoToWho.logdebug?
131
+ @from = conf_hash[:from]
110
132
  end
133
+
134
+ # Test if all argument required is define
135
+ def test_required
136
+ required = true
137
+ if @subject.nil? || @subject.empty?
138
+ WhoToWho.log.warn 'you need define a subject'
139
+ required = false
140
+ end
141
+
142
+ if @content.nil? || @content.empty?
143
+ WhoToWho.log.warn 'you need define a file or a file not empty for you mail template'
144
+ required = false
145
+ end
111
146
 
112
- unless required
113
- puts @full_print
114
- exit
147
+ if @list_link.nil? || @list_link.empty? || @list_link.size < 2
148
+ WhoToWho.log.warn 'The list of data need define by a file. This file can\'t be empty or only one data'
149
+ required = false
150
+ end
151
+
152
+ if ActionMailer::Base.smtp_settings.empty?
153
+ WhoToWho.log.warn 'The configuration of your SMTP account can\'t be empty'
154
+ required = false
155
+ end
156
+
157
+ if @from.nil? || @from.empty?
158
+ WhoToWho.log.warn 'You need define a from in your mail settings.'
159
+ required = false
160
+ end
161
+
162
+ unless required
163
+ puts @full_print
164
+ exit
165
+ end
115
166
  end
116
- end
117
167
 
168
+ end
118
169
  end
@@ -1,15 +1,17 @@
1
1
  require 'action_mailer'
2
2
 
3
- # Made the send mail
4
- class SendMail < ActionMailer::Base
3
+ module WhoToWho
4
+ # Made the send mail
5
+ class SendMail < ActionMailer::Base
5
6
 
6
- # Send a mail with information send by args
7
- # args is a ParseArgs Object
8
- def send_mail(name, email, name_receiv, args)
9
- recipients email
10
- from args.from
11
- subject args.subject
12
- body(args.content.gsub(/\#\{who\}/, name_receiv).gsub(/\#\{towho\}/, name))
7
+ # Send a mail with information send by args
8
+ # args is a ParseArgs Object
9
+ def send_mail(name, email, name_receiv, args)
10
+ recipients email
11
+ from args.from
12
+ subject args.subject
13
+ body(args.content.gsub(/\#\{who\}/, name_receiv).gsub(/\#\{towho\}/, name))
14
+ end
15
+
13
16
  end
14
-
15
17
  end
@@ -14,7 +14,7 @@ Net::SMTP.class_eval do
14
14
  sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
15
15
  @socket = Net::InternetMessageIO.new(sock)
16
16
  @socket.read_timeout = 60 #@read_timeout
17
- @socket.debug_output = STDERR #@debug_output
17
+ @socket.debug_output = STDERR if WhoToWho::WhoToWho.logdebug? #@debug_output
18
18
 
19
19
  check_response(critical { recv_response() })
20
20
  do_helo(helodomain)
@@ -26,7 +26,7 @@ Net::SMTP.class_eval do
26
26
  ssl.connect
27
27
  @socket = Net::InternetMessageIO.new(ssl)
28
28
  @socket.read_timeout = 60 #@read_timeout
29
- @socket.debug_output = STDERR #@debug_output
29
+ @socket.debug_output = STDERR if WhoToWho::WhoToWho.logdebug? #@debug_output
30
30
  do_helo(helodomain)
31
31
 
32
32
  authenticate user, secret, authtype if user
@@ -0,0 +1,9 @@
1
+ module WhoToWho #:nodoc:
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 2
5
+ TINY = 0
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/whotowho'
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestWhoToWho < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
metadata CHANGED
@@ -1,82 +1,104 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: whotowho
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.1.0
7
- date: 2007-11-22 00:00:00 +01:00
8
- summary: Define a person for another person and send by email Who to Who
9
- require_paths:
10
- - lib
11
- email: cyril.mougel@gmail.com
12
- homepage:
13
- rubyforge_project: whotowho
14
- description: The author was too lazy to write a description
4
+ version: 0.2.0
5
+ platform: ""
6
+ authors:
7
+ - Cyril Mougel
15
8
  autorequire:
16
- default_executable:
17
9
  bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
25
- platform: ruby
26
- signing_key:
27
10
  cert_chain:
28
- post_install_message:
29
- authors:
30
- - cyril mougel
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDOjCCAiKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBDMRUwEwYDVQQDDAxjeXJp
14
+ bC5tb3VnZWwxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkW
15
+ A2NvbTAeFw0wNzEyMjAyMDMwMTJaFw0wODEyMTkyMDMwMTJaMEMxFTATBgNVBAMM
16
+ DGN5cmlsLm1vdWdlbDEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPy
17
+ LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1ip1bFMI
18
+ th/IZZfzoNQH+QyHBXBCR9U+kIyom0ARhnyxJHX9fjGEtZo6DTZ+9UmcNwc5YgPn
19
+ YQAF9ELOedsEpFPeOCJF6BZKipzaapRR5W9Z2jzrQ/Pfne2W3yS3sTkc9dDyAJxX
20
+ pjeAQsZSivNLlZulX7xyLtXxWRLiEZEed+W+rNSm2BNV7giSC8IT+TXeiWm2VbWv
21
+ QOJJ3DZwudYrV9a+MsftSRmIhV9HZrUCL6GFwnN/Klf+aDD6gUGhLeI46PL/xX3P
22
+ 8aK7TyZxUY0G5RIqL802IwyXaGCLtibBbbMsvBsoGQMZlRNAQPRZ5zmENlqupUT5
23
+ dQst/+qskDw0OQIDAQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
24
+ HQ4EFgQUyf6z2lG7fsRSLbONGroAZRb3SkgwDQYJKoZIhvcNAQEFBQADggEBAByI
25
+ AUDTvZtsGByYnqU3dENRil3LEwqhXMbw/5Cn+jQg6IKhc79Os8BHXeoknZBQaUI1
26
+ yJnTGEWtScNx296kbqILj0saWb0sPrftjCowzG1YYFkubDdjxo6t0NmKkXQHykun
27
+ 0HPyPegBDxdwgU4pH3GuxQGO1BHwYM24rAHZcFs3TcOrECpSDza0MNt69JyVGJt6
28
+ r9dJdeUKC0H1QIMS0QVGaZoFENsNASmoPZIwWiR8wDXb2bLuK3ORUSZhmS/FcxIS
29
+ W7MdyKTPUPy7r0ouXKWICiAMFzDYxNdJpPVU3AHG0kWkn+b9RaSS96jbk/PXTWoC
30
+ 62bt1x7aYOMilMupj8o=
31
+ -----END CERTIFICATE-----
32
+
33
+ date: 2008-01-06 00:00:00 +01:00
34
+ default_executable:
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: actionmailer
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.3.5
44
+ version:
45
+ description: "WhoToWho is a simple script to define a name randomly in list of name. And send this name by email. With WhoToWho you can define several thing: * Subject of Mail * Format of Mail with 2 parameters (who and towho) * The configuration of smtp connection * Add options for SSL if your smtp connection is a Gmail account"
46
+ email: cyril.mougel@gmail.com
47
+ executables:
48
+ - whotowho
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - History.txt
53
+ - License.txt
54
+ - Manifest.txt
55
+ - README.txt
56
+ - conf/mail-example.txt
31
57
  files:
32
58
  - History.txt
59
+ - License.txt
33
60
  - Manifest.txt
34
61
  - README.txt
35
62
  - Rakefile
36
63
  - bin/whotowho
37
- - conf.yaml
38
64
  - conf/conf.yaml.example
39
65
  - conf/data.yaml.example
40
66
  - conf/mail-example.txt
41
- - data.yaml
42
67
  - lib/whotowho.rb
43
68
  - lib/whotowho/link.rb
44
69
  - lib/whotowho/parseargs.rb
45
70
  - lib/whotowho/sendmail.rb
46
71
  - lib/whotowho/smtp_tls.rb
72
+ - lib/whotowho/version.rb
73
+ - test/test_helper.rb
47
74
  - test/test_whotowho.rb
48
- test_files:
49
- - test/test_whotowho.rb
75
+ has_rdoc: true
76
+ homepage: http://whotowho.rubyforge.org
77
+ post_install_message:
50
78
  rdoc_options:
51
79
  - --main
52
80
  - README.txt
53
- extra_rdoc_files:
54
- - History.txt
55
- - Manifest.txt
56
- - README.txt
57
- - conf/mail-example.txt
58
- executables:
59
- - whotowho
60
- extensions: []
61
-
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: "0"
88
+ version:
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: "0"
94
+ version:
62
95
  requirements: []
63
96
 
64
- dependencies:
65
- - !ruby/object:Gem::Dependency
66
- name: actionmailer
67
- version_requirement:
68
- version_requirements: !ruby/object:Gem::Version::Requirement
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 1.3.5
73
- version:
74
- - !ruby/object:Gem::Dependency
75
- name: hoe
76
- version_requirement:
77
- version_requirements: !ruby/object:Gem::Version::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: 1.2.2
82
- version:
97
+ rubyforge_project: whotowho
98
+ rubygems_version: 0.9.5
99
+ signing_key:
100
+ specification_version: 2
101
+ summary: "WhoToWho is a simple script to define a name randomly in list of name. And send this name by email. With WhoToWho you can define several thing: * Subject of Mail * Format of Mail with 2 parameters (who and towho) * The configuration of smtp connection * Add options for SSL if your smtp connection is a Gmail account"
102
+ test_files:
103
+ - test/test_whotowho.rb
104
+ - test/test_helper.rb
Binary file
data/conf.yaml DELETED
@@ -1,7 +0,0 @@
1
- :address: "smtp.gmail.com"
2
- :port: 587
3
- :user_name: "cyril.mougel@gmail.com"
4
- :password: "c03m13e05"
5
- :authentication: :plain
6
- :from: "shingara@gmail.com"
7
-
data/data.yaml DELETED
@@ -1,8 +0,0 @@
1
- - - un
2
- - cyril.mougel@gmail.com
3
- - - deux
4
- - shingara@gmail.com
5
- - - trois
6
- - cyril.mougel@gmail.com
7
- - - quatre
8
- - shingara@gmail.com