uniq_logger 0.1.0

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/.gitignore ADDED
@@ -0,0 +1,31 @@
1
+ *.rbc
2
+ capybara-*.html
3
+ .rspec
4
+ /log
5
+ /tmp
6
+ /db/*.sqlite3
7
+ /public/system
8
+ /coverage/
9
+ /spec/tmp
10
+ **.orig
11
+ rerun.txt
12
+ pickle-email-*.html
13
+
14
+ # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
15
+ config/initializers/secret_token.rb
16
+ config/secrets.yml
17
+
18
+ ## Environment normalisation:
19
+ /.bundle
20
+ /vendor/bundle
21
+
22
+ # these should all be checked in to normalise the environment:
23
+ # Gemfile.lock, .ruby-version, .ruby-gemset
24
+
25
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
26
+ .rvmrc
27
+
28
+ # if using bower-rails ignore default bower_components path bower.json files
29
+ /vendor/assets/bower_components
30
+ *.bowerrc
31
+ bower.json
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in uniq_logger.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,67 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ uniq_logger (0.0.2)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ celluloid (0.16.0)
10
+ timers (~> 4.0.0)
11
+ coderay (1.1.0)
12
+ diff-lcs (1.2.5)
13
+ ffi (1.9.6)
14
+ formatador (0.2.5)
15
+ guard (2.8.2)
16
+ formatador (>= 0.2.4)
17
+ listen (~> 2.7)
18
+ lumberjack (~> 1.0)
19
+ pry (>= 0.9.12)
20
+ thor (>= 0.18.1)
21
+ guard-compat (1.2.1)
22
+ guard-rspec (4.5.0)
23
+ guard (~> 2.1)
24
+ guard-compat (~> 1.1)
25
+ rspec (>= 2.99.0, < 4.0)
26
+ hitimes (1.2.2)
27
+ listen (2.7.11)
28
+ celluloid (>= 0.15.2)
29
+ rb-fsevent (>= 0.9.3)
30
+ rb-inotify (>= 0.9)
31
+ lumberjack (1.0.9)
32
+ method_source (0.8.2)
33
+ pry (0.10.1)
34
+ coderay (~> 1.1.0)
35
+ method_source (~> 0.8.1)
36
+ slop (~> 3.4)
37
+ rake (10.4.2)
38
+ rb-fsevent (0.9.4)
39
+ rb-inotify (0.9.5)
40
+ ffi (>= 0.5.0)
41
+ rspec (3.1.0)
42
+ rspec-core (~> 3.1.0)
43
+ rspec-expectations (~> 3.1.0)
44
+ rspec-mocks (~> 3.1.0)
45
+ rspec-core (3.1.7)
46
+ rspec-support (~> 3.1.0)
47
+ rspec-expectations (3.1.2)
48
+ diff-lcs (>= 1.2.0, < 2.0)
49
+ rspec-support (~> 3.1.0)
50
+ rspec-mocks (3.1.3)
51
+ rspec-support (~> 3.1.0)
52
+ rspec-support (3.1.2)
53
+ slop (3.6.0)
54
+ thor (0.19.1)
55
+ timers (4.0.1)
56
+ hitimes
57
+
58
+ PLATFORMS
59
+ ruby
60
+
61
+ DEPENDENCIES
62
+ bundler (~> 1.7)
63
+ guard
64
+ guard-rspec
65
+ rake (~> 10.0)
66
+ rspec
67
+ uniq_logger!
data/Guardfile ADDED
@@ -0,0 +1,56 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+
5
+ # Note: The cmd option is now required due to the increasing number of ways
6
+ # rspec may be run, below are examples of the most common uses.
7
+ # * bundler: 'bundle exec rspec'
8
+ # * bundler binstubs: 'bin/rspec'
9
+ # * spring: 'bin/rspec' (This will use spring if running and you have
10
+ # installed the spring binstubs per the docs)
11
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
12
+ # * 'just' rspec: 'rspec'
13
+
14
+ guard :rspec, cmd: "bundle exec rspec" do
15
+ require "guard/rspec/dsl"
16
+ dsl = Guard::RSpec::Dsl.new(self)
17
+
18
+ # Feel free to open issues for suggestions and improvements
19
+
20
+ # RSpec files
21
+ rspec = dsl.rspec
22
+ watch(rspec.spec_helper) { rspec.spec_dir }
23
+ watch(rspec.spec_support) { rspec.spec_dir }
24
+ watch(rspec.spec_files)
25
+
26
+ # Ruby files
27
+ ruby = dsl.ruby
28
+ dsl.watch_spec_files_for(ruby.lib_files)
29
+
30
+ # Rails files
31
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
32
+ dsl.watch_spec_files_for(rails.app_files)
33
+ dsl.watch_spec_files_for(rails.views)
34
+
35
+ watch(rails.controllers) do |m|
36
+ [
37
+ rspec.spec.("routing/#{m[1]}_routing"),
38
+ rspec.spec.("controllers/#{m[1]}_controller"),
39
+ rspec.spec.("acceptance/#{m[1]}")
40
+ ]
41
+ end
42
+
43
+ # Rails config changes
44
+ watch(rails.spec_helper) { rspec.spec_dir }
45
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
46
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
47
+
48
+ # Capybara features specs
49
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
50
+
51
+ # Turnip features and steps
52
+ watch(%r{^spec/acceptance/(.+)\.feature$})
53
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
54
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
55
+ end
56
+ end
data/LICENSE ADDED
@@ -0,0 +1,340 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ {description}
294
+ Copyright (C) {year} {fullname}
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ {signature of Ty Coon}, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
340
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Marco Metz
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # UniqLogger
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'uniq_logger'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install uniq_logger
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/uniq_logger/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,103 @@
1
+ module UniqLogger
2
+ class Base
3
+ def initialize(opts={}, &block)
4
+ Configuration.configure_with_path
5
+ end
6
+
7
+ def config
8
+ Configuration.config
9
+ end
10
+
11
+ def create(uniq_id, data_to_save=[])
12
+ if config[:logfile_destination] == "local"
13
+ create_local_log_entry(uniq_id, data_to_save)
14
+ elsif config[:logfile_destination] == "remote"
15
+ create_remote_log_entry(uniq_id, data_to_save)
16
+ else
17
+ puts "logfile_destination is not set to [local,ftp]"
18
+ return false
19
+ end
20
+ end
21
+
22
+
23
+ def create_local_log_entry(uniq_id, data_to_save)
24
+ #Use global Logger
25
+ if config[:global_logger] == true
26
+ raise "Directory of 'path_to_local_logfiles' '#{config[:path_to_local_logfiles]}' does not exist!" unless File.directory?(config[:path_to_local_logfiles])
27
+ logfilename = File.join(config[:path_to_local_logfiles], config[:global_log_file_name])
28
+ logfile = File.open( File.expand_path(logfilename), "a" )
29
+
30
+ if is_uniq_id_in_log_hostory?(uniq_id,logfile)
31
+ return false
32
+ end
33
+
34
+ #write Data to Logfile File
35
+ logfile.puts [uniq_id,data_to_save].flatten.join(config[:csv][:col_sep])
36
+ logfile.close
37
+ end
38
+
39
+ #Use Log Rotator?
40
+ if ['day','month','year'].include?(config[:global_logger])
41
+ logger_prefix = get_current_logger_prefix()
42
+ rotator_logfilename = File.join(config[:path_to_local_logfiles], "#{config[:log_rotator_prefix]}#{logger_prefix}.log")
43
+ rotator_logfile = File.open( File.expand_path(rotator_logfilename), "a" )
44
+ rotator_logfile.puts [uniq_id,data_to_save].flatten.join(config[:csv][:col_sep])
45
+ rotator_logfile.close
46
+ end
47
+
48
+ return true
49
+ end
50
+
51
+
52
+ def is_uniq_id_in_log_hostory?(uniq_id,logfile)
53
+ if config[:validates_uniqness_of_id] == true
54
+ data = CSV.read(logfile, {:col_sep => config[:csv][:col_sep], :encoding => config[:csv][:encoding] })
55
+ list_of_ids = data.map{ |a| a[0]}
56
+ #puts data
57
+ if list_of_ids.include?(uniq_id)
58
+ return true
59
+ end
60
+ end
61
+ return false
62
+ end
63
+
64
+ def get_current_logger_prefix
65
+ case config[:global_logger]
66
+ when "day"
67
+ filename_prefix = Time.now.strftime("%d-%m-%Y")
68
+ when "month"
69
+ filename_prefix = Time.now.strftime("%m-%Y")
70
+ when "year"
71
+ filename_prefix = Time.now.strftime("%Y")
72
+ else
73
+ filename_prefix = ""
74
+ end
75
+ return filename_prefix
76
+ end
77
+
78
+
79
+ def create_remote_log_entry(uniq_id, data_to_save)
80
+ begin
81
+ auth_token = config[:remote][:auth_token]
82
+ server_name = config[:remote][:server]
83
+ endpoint = config[:remote][:endpoint]
84
+ param_id = config[:remote][:url_param_for_id]
85
+ param_data = config[:remote][:url_param_for_data]
86
+ uri = URI.parse("#{server_name}#{endpoint}?auth_token=#{auth_token}&#{param_id}=#{uniq_id}&#{param_data}=#{data_to_save}")
87
+ http = Net::HTTP.new(uri.host, 80)
88
+ request = Net::HTTP::Post.new(uri.request_uri)
89
+ response = http.request(request)
90
+ json = JSON.parse response.body
91
+ if json['response'] == "true"
92
+ return true
93
+ else
94
+ return false
95
+ end
96
+ rescue
97
+ puts "Connetion to Server failed"
98
+ return false
99
+ end
100
+ end
101
+
102
+ end
103
+ end
@@ -0,0 +1,55 @@
1
+ module UniqLogger
2
+ class Configuration
3
+ @config = {
4
+ :log_rotator => "none",
5
+ :log_rotator_prefix => "uniq_logger-",
6
+ :global_logger => true,
7
+ :global_log_file_name => "uniq_logger.log",
8
+ :validates_uniqness_of_id => true,
9
+ :logfile_destination => "local",
10
+ :path_to_local_logfiles => "log",
11
+ :remote => {
12
+ :auth_token => "xyz123abc",
13
+ :server => "http://www.server.de",
14
+ :endpoint => "/api/v1/logger",
15
+ :url_param_for_id => "id",
16
+ :url_param_for_data => "data"
17
+ },
18
+ :csv => {
19
+ :encoding => "UTF8",
20
+ :col_sep => ";"
21
+ }
22
+ }
23
+
24
+ @valid_config_keys = @config.keys
25
+
26
+ # Configure through hash
27
+ def self.configure(opts = {})
28
+ opts.each {|k,v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym}
29
+ end
30
+
31
+ # Configure through yaml file
32
+ def self.configure_with_path
33
+ if defined?(::Rails).nil?
34
+ path_to_yaml_file = "../config/uniq_logger.yml"
35
+ else
36
+ path_to_yaml_file = "#{::Rails.root}/config/uniq_logger.yml"
37
+ end
38
+ begin
39
+ config = YAML::load(IO.read(path_to_yaml_file))
40
+ rescue Errno::ENOENT
41
+ puts "YAML configuration file couldn't be found. Using defaults."
42
+ return
43
+ rescue Psych::SyntaxError
44
+ puts "YAML configuration file contains invalid syntax. Using defaults."
45
+ return
46
+ end
47
+
48
+ configure(config)
49
+ end
50
+
51
+ def self.config
52
+ @config
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ module UniqLogger
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,15 @@
1
+ require 'csv'
2
+ require 'yaml'
3
+ require "uniq_logger/configuration"
4
+ require "uniq_logger/version"
5
+
6
+ module UniqLogger
7
+
8
+ def self.new
9
+ UniqLogger::Base.new
10
+ end
11
+
12
+ end
13
+
14
+
15
+ require 'uniq_logger/base'
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+ require 'uniq_logger'
3
+
4
+ describe UniqLogger do
5
+ it 'has a version' do
6
+ expect(UniqLogger::VERSION).to match(/\d+\.\d+\.\d+/)
7
+ end
8
+ end
9
+
10
+ describe UniqLogger::Base do
11
+ before(:each) do
12
+ @logger = UniqLogger.new
13
+ @logger.config[:global_log_file_name] = "rspec_logger.log"
14
+ #reset local Logfile
15
+ @logfilename = File.join(@logger.config[:path_to_local_logfiles], @logger.config[:global_log_file_name])
16
+ if File.exists?(@logfilename)
17
+ File.delete( File.expand_path(@logfilename) )
18
+ end
19
+ end
20
+
21
+ it 'has a valid configuration' do
22
+ expect(@logger.config[:log_rotator]).to eq("none")
23
+ expect(@logger.config[:global_logger]).to eq(true)
24
+ expect(@logger.config[:csv][:encoding]).to eq("UTF8")
25
+ expect(@logger.config[:csv][:col_sep]).to eq(";")
26
+ expect(@logger.config[:logfile_destination]).to eq("local")
27
+ end
28
+
29
+ it 'should write a log to a logfile with validation of ID true' do
30
+ expect(@logger.create("12345", ["Vorname", "Nachname", "Strasse"])).to eq(true)
31
+ expect(@logger.create("12346", ["Vorname2", "Nachname2", "Strasse2"])).to eq(true)
32
+ expect(@logger.create("12346", ["Vorname3", "Nachname3", "Strasse3"])).to eq(false)
33
+ end
34
+
35
+ it 'should write a log to a logfile with validation of ID false' do
36
+ @logger.config[:validates_uniqness_of_id] = false
37
+ expect(@logger.create("12345", ["Vorname", "Nachname", "Strasse"])).to eq(true)
38
+ expect(@logger.create("12346", ["Vorname2", "Nachname2", "Strasse2"])).to eq(true)
39
+ expect(@logger.create("12346", ["Vorname3", "Nachname3", "Strasse3"])).to eq(true)
40
+ end
41
+
42
+ it 'should write a log rotator to a logfile per day' do
43
+ @logger.config[:global_logger] = "day"
44
+ expect(@logger.create("12345", ["Vorname", "Nachname", "Strasse"])).to eq(true)
45
+ expect(@logger.create("12346", ["Vorname2", "Nachname2", "Strasse2"])).to eq(true)
46
+ expect(@logger.create("12346", ["Vorname3", "Nachname3", "Strasse3"])).to eq(true)
47
+ end
48
+
49
+ it 'should write a log rotator to a logfile per month' do
50
+ @logger.config[:global_logger] = "month"
51
+ expect(@logger.create("12345", ["Vorname", "Nachname", "Strasse"])).to eq(true)
52
+ expect(@logger.create("12346", ["Vorname2", "Nachname2", "Strasse2"])).to eq(true)
53
+ expect(@logger.create("12346", ["Vorname3", "Nachname3", "Strasse3"])).to eq(true)
54
+ end
55
+
56
+ it 'should write a log rotator to a logfile per year' do
57
+ @logger.config[:global_logger] = "year"
58
+ expect(@logger.create("12345", ["Vorname", "Nachname", "Strasse"])).to eq(true)
59
+ expect(@logger.create("12346", ["Vorname2", "Nachname2", "Strasse2"])).to eq(true)
60
+ expect(@logger.create("12346", ["Vorname3", "Nachname3", "Strasse3"])).to eq(true)
61
+ end
62
+
63
+
64
+ end
@@ -0,0 +1,71 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, make a
10
+ # separate helper file that requires this one and then use it only in the specs
11
+ # that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ # The settings below are suggested to provide a good initial experience
19
+ # with RSpec, but feel free to customize to your heart's content.
20
+ =begin
21
+ # These two settings work together to allow you to limit a spec run
22
+ # to individual examples or groups you care about by tagging them with
23
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
24
+ # get run.
25
+ config.filter_run :focus
26
+ config.run_all_when_everything_filtered = true
27
+ # Many RSpec users commonly either run the entire suite or an individual
28
+ # file, and it's useful to allow more verbose output when running an
29
+ # individual spec file.
30
+ if config.files_to_run.one?
31
+ # Use the documentation formatter for detailed output,
32
+ # unless a formatter has already been configured
33
+ # (e.g. via a command-line flag).
34
+ config.default_formatter = 'doc'
35
+ end
36
+ # Print the 10 slowest examples and example groups at the
37
+ # end of the spec run, to help surface which specs are running
38
+ # particularly slow.
39
+ config.profile_examples = 10
40
+ # Run specs in random order to surface order dependencies. If you find an
41
+ # order dependency and want to debug it, you can fix the order by providing
42
+ # the seed, which is printed after each run.
43
+ # --seed 1234
44
+ config.order = :random
45
+ # Seed global randomization in this process using the `--seed` CLI option.
46
+ # Setting this allows you to use `--seed` to deterministically reproduce
47
+ # test failures related to randomization by passing the same `--seed` value
48
+ # as the one that triggered the failure.
49
+ Kernel.srand config.seed
50
+ # rspec-expectations config goes here. You can use an alternate
51
+ # assertion/expectation library such as wrong or the stdlib/minitest
52
+ # assertions if you prefer.
53
+ config.expect_with :rspec do |expectations|
54
+ # Enable only the newer, non-monkey-patching expect syntax.
55
+ # For more details, see:
56
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
57
+ expectations.syntax = :expect
58
+ end
59
+ # rspec-mocks config goes here. You can use an alternate test double
60
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
61
+ config.mock_with :rspec do |mocks|
62
+ # Enable only the newer, non-monkey-patching expect syntax.
63
+ # For more details, see:
64
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
65
+ mocks.syntax = :expect
66
+ # Prevents you from mocking or stubbing a method that does not exist on
67
+ # a real object. This is generally recommended.
68
+ mocks.verify_partial_doubles = true
69
+ end
70
+ =end
71
+ end
@@ -0,0 +1,38 @@
1
+ #Use a additional Log-Rotator which generates new logfiles for ['day','month','year'].
2
+ #Default 'none'
3
+ log_rotator: "month"
4
+
5
+ #If log_rotator is set, this will be the prefix for the file name
6
+ log_rotator_prefix: "uniq_logger-"
7
+
8
+
9
+ #Use a global LogFile [true,false]. Chech for existin logs only looks in global logfile
10
+ #Default true
11
+ global_logger: true
12
+
13
+ #Name of the logfile to write to
14
+ global_log_file_name: "uniq_logger.log"
15
+
16
+
17
+ #if set to true, logentry creation returns 'false' if a logentry already exists with this ID
18
+ # This is only on global Logfiles possible
19
+ validates_uniqness_of_id: true
20
+
21
+ #If a local Logfile should be created or a ftp Account ['local', 'remote']
22
+ logfile_destination: "local"
23
+
24
+ #Path where Logfiles should be saved
25
+ path_to_local_logfiles: "../log/"
26
+
27
+ #If logfile_destination is set to 'remote' use folloing api credentials
28
+ remote:
29
+ auth_token: "xyz123abc"
30
+ server: "http://www.server.de"
31
+ endpoint: "/api/v1/logger"
32
+ url_param_for_id: "id"
33
+ url_param_for_data: "data"
34
+
35
+ #CSV Export Settings: Encoding Type (default 'utf8'), Column Separator (default ';')
36
+ csv:
37
+ encoding: "UTF8"
38
+ col_sep: ";"
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'uniq_logger/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "uniq_logger"
8
+ spec.version = UniqLogger::VERSION
9
+ spec.authors = ["Marco Metz"]
10
+ spec.email = ["marco.metz@gmail.com"]
11
+ spec.summary = %q{checks for existing Logentries and adds new LogEntries}
12
+ spec.description = %q{Adds Entries to an Logfile, only if not already exist. Logfile can be on an ftp account}
13
+ spec.homepage = "https://github.com/ikuseiGmbH/uniq_logger"
14
+ spec.license = "GNU GENERAL PUBLIC LICENSE"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "guard"
25
+ spec.add_development_dependency 'guard-rspec'
26
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: uniq_logger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Marco Metz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-01-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.7'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.7'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '10.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '10.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: guard
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: guard-rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: Adds Entries to an Logfile, only if not already exist. Logfile can be
95
+ on an ftp account
96
+ email:
97
+ - marco.metz@gmail.com
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - .gitignore
103
+ - Gemfile
104
+ - Gemfile.lock
105
+ - Guardfile
106
+ - LICENSE
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - lib/uniq_logger.rb
111
+ - lib/uniq_logger/base.rb
112
+ - lib/uniq_logger/configuration.rb
113
+ - lib/uniq_logger/version.rb
114
+ - spec/lib/uniq_logger_spec.rb
115
+ - spec/spec_helper.rb
116
+ - template/uniq_logger.yml
117
+ - uniq_logger.gemspec
118
+ homepage: https://github.com/ikuseiGmbH/uniq_logger
119
+ licenses:
120
+ - GNU GENERAL PUBLIC LICENSE
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 1.8.26
140
+ signing_key:
141
+ specification_version: 3
142
+ summary: checks for existing Logentries and adds new LogEntries
143
+ test_files:
144
+ - spec/lib/uniq_logger_spec.rb
145
+ - spec/spec_helper.rb