snoopit 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +39 -0
  4. data/.idea/.name +1 -0
  5. data/.idea/.rakeTasks +7 -0
  6. data/.idea/dictionaries/rbirch.xml +9 -0
  7. data/.idea/encodings.xml +5 -0
  8. data/.idea/misc.xml +5 -0
  9. data/.idea/modules.xml +9 -0
  10. data/.idea/scopes/scope_settings.xml +5 -0
  11. data/.idea/snoopit.iml +233 -0
  12. data/.idea/vcs.xml +7 -0
  13. data/.rspec +2 -0
  14. data/.travis.yml +7 -0
  15. data/Gemfile +15 -0
  16. data/LICENSE.txt +22 -0
  17. data/README.md +411 -0
  18. data/Rakefile +1 -0
  19. data/bin/snoopit +173 -0
  20. data/lib/snoopit.rb +22 -0
  21. data/lib/snoopit/detected.rb +50 -0
  22. data/lib/snoopit/file_info.rb +104 -0
  23. data/lib/snoopit/file_tracker.rb +83 -0
  24. data/lib/snoopit/logger.rb +30 -0
  25. data/lib/snoopit/notification_manager.rb +123 -0
  26. data/lib/snoopit/notifier.rb +25 -0
  27. data/lib/snoopit/notifiers/email.rb +61 -0
  28. data/lib/snoopit/notifiers/http.rb +85 -0
  29. data/lib/snoopit/notifiers/https.rb +21 -0
  30. data/lib/snoopit/notifiers/stomp.rb +59 -0
  31. data/lib/snoopit/register.rb +69 -0
  32. data/lib/snoopit/sniffer.rb +51 -0
  33. data/lib/snoopit/snooper.rb +149 -0
  34. data/lib/snoopit/snoopy.rb +67 -0
  35. data/lib/snoopit/version.rb +3 -0
  36. data/snoopit.gemspec +27 -0
  37. data/spec/bin/snoopit_spec.rb +258 -0
  38. data/spec/file_info_spec.rb +131 -0
  39. data/spec/file_tracker_spec.rb +172 -0
  40. data/spec/notification_manager_spec.rb +103 -0
  41. data/spec/notifiers/email_spec.rb +36 -0
  42. data/spec/notifiers/http_spec.rb +37 -0
  43. data/spec/notifiers/https_spec.rb +38 -0
  44. data/spec/notifiers/stomp_spec.rb +34 -0
  45. data/spec/register_spec.rb +105 -0
  46. data/spec/snooper_spec.rb +538 -0
  47. data/spec/spec_helper.rb +24 -0
  48. data/spec/support/log/snoop_log.test +593 -0
  49. data/spec/support/log/snoop_log_2.test +593 -0
  50. data/spec/support/multiple_snoopies.json +82 -0
  51. data/spec/support/regexp_tester.rb +10 -0
  52. data/spec/support/snoopies.json +93 -0
  53. data/spec/support/snoopies_notifiers.json +66 -0
  54. data/spec/support/test_notifier.rb +18 -0
  55. data/spec/support/test_notifier_load.rb +18 -0
  56. data/support/snoopies.json +110 -0
  57. metadata +190 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 773c96a6cce42a924a16de8a09d32981180fb570
4
+ data.tar.gz: e150e7960bad252b7707abd10775fdc748226f39
5
+ SHA512:
6
+ metadata.gz: c73e43dd072abdbdef14e56ab28ae096c3beeca3d8bfc7dd9de1dbd0929b57af194882f49e2dc279d674fdf0d6d2ea70805b0756ddb3da6876656ae4217b5404
7
+ data.tar.gz: e80aa3bf4c634cfb6cd35adcec8d6009af9ecb141a04f8aa1aaac5c583dcece65b62f20dd90b14e062995132fa97362ebc6a82abe2880ab72bf86b4f9ae4b074
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,39 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .ruby-gemset
19
+ .ruby-version
20
+ spec/support/db
21
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
22
+
23
+ ## Directory-based project format
24
+ #.idea/
25
+
26
+ # if you remove the above rule, at least ignore user-specific stuff:
27
+ .idea/workspace.xml
28
+ .idea/tasks.xml
29
+ # and these sensitive or high-churn files:
30
+ .idea/dataSources.ids
31
+ .idea/dataSources.xml
32
+ .idea/sqlDataSources.xml
33
+ .idea/dynamic.xml
34
+
35
+ ## File-based project format
36
+ # *.ipr
37
+ # *.iml
38
+ # *.iws
39
+
@@ -0,0 +1 @@
1
+ snoopit
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build snoopit-0.0.1.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install snoopit-0.0.1.gem into system gems" fullCmd="install" taksId="install" /><RakeTask description="Create tag v0.0.1 and build and push snoopit-0.0.1.gem to Rubygems" fullCmd="release" taksId="release" /></RakeGroup></Settings>
@@ -0,0 +1,9 @@
1
+ <component name="ProjectDictionaryState">
2
+ <dictionary name="rbirch">
3
+ <words>
4
+ <w>snoopie</w>
5
+ <w>snoopies</w>
6
+ <w>snoopit</w>
7
+ </words>
8
+ </dictionary>
9
+ </component>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
+ </project>
5
+
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-1.9.3-p448 [sandbox]" project-jdk-type="RUBY_SDK" />
4
+ </project>
5
+
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/snoopit.iml" filepath="$PROJECT_DIR$/.idea/snoopit.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
9
+
@@ -0,0 +1,5 @@
1
+ <component name="DependencyValidationManager">
2
+ <state>
3
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,233 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="CompassSettings">
4
+ <option name="compassSupportEnabled" value="true" />
5
+ </component>
6
+ <component name="FacetManager">
7
+ <facet type="gem" name="Ruby Gem">
8
+ <configuration>
9
+ <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
10
+ <option name="GEM_APP_TEST_PATH" value="$MODULE_DIR$/test" />
11
+ <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
12
+ </configuration>
13
+ </facet>
14
+ </component>
15
+ <component name="ModuleRunConfigurationManager">
16
+ <configuration default="false" name="All specs in spec: snoopit" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
17
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
18
+ <module name="snoopit" />
19
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
20
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
21
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
22
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
23
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
24
+ <envs>
25
+ <env name="JRUBY_OPTS" value="-X+O" />
26
+ </envs>
27
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
28
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
29
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
30
+ <COVERAGE_PATTERN ENABLED="true">
31
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
32
+ </COVERAGE_PATTERN>
33
+ </EXTENSION>
34
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
35
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="$MODULE_DIR$/spec" />
36
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
37
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
38
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
39
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
40
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="ALL_IN_FOLDER" />
41
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
42
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
43
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
44
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
45
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
46
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
47
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
48
+ <RunnerSettings RunnerId="RubyCover" />
49
+ <RunnerSettings RunnerId="RubyRunner" />
50
+ <ConfigurationWrapper RunnerId="RubyCover" />
51
+ <ConfigurationWrapper RunnerId="RubyRunner" />
52
+ <method />
53
+ </configuration>
54
+ <configuration default="false" name="Snooper base functionality file tests: snoopit" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
55
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
56
+ <module name="snoopit" />
57
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
58
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
59
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
60
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
61
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
62
+ <envs>
63
+ <env name="JRUBY_OPTS" value="-X+O" />
64
+ </envs>
65
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
66
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
67
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
68
+ <COVERAGE_PATTERN ENABLED="true">
69
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
70
+ </COVERAGE_PATTERN>
71
+ </EXTENSION>
72
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
73
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
74
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/snooper_spec.rb" />
75
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
76
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
77
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="Snooper base functionality file tests" />
78
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
79
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
80
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
81
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
82
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
83
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
84
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
85
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
86
+ <RunnerSettings RunnerId="RubyRunner" />
87
+ <ConfigurationWrapper RunnerId="RubyRunner" />
88
+ <method />
89
+ </configuration>
90
+ <configuration default="false" name="Run spec 'snooper_spec': snoopit" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
91
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
92
+ <module name="snoopit" />
93
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
94
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
95
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
96
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
97
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
98
+ <envs>
99
+ <env name="JRUBY_OPTS" value="-X+O" />
100
+ </envs>
101
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
102
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
103
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
104
+ <COVERAGE_PATTERN ENABLED="true">
105
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
106
+ </COVERAGE_PATTERN>
107
+ </EXTENSION>
108
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
109
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
110
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/snooper_spec.rb" />
111
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
112
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
113
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
114
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
115
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
116
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
117
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
118
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
119
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
120
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
121
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
122
+ <RunnerSettings RunnerId="RubyRunner" />
123
+ <ConfigurationWrapper RunnerId="RubyRunner" />
124
+ <method />
125
+ </configuration>
126
+ <configuration default="false" name="Run spec 'email_spec': snoopit" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
127
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
128
+ <module name="snoopit" />
129
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
130
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
131
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
132
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
133
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
134
+ <envs>
135
+ <env name="JRUBY_OPTS" value="-X+O" />
136
+ </envs>
137
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
138
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
139
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
140
+ <COVERAGE_PATTERN ENABLED="true">
141
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
142
+ </COVERAGE_PATTERN>
143
+ </EXTENSION>
144
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
145
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
146
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/notifiers/email_spec.rb" />
147
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
148
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
149
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
150
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
151
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
152
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
153
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
154
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
155
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
156
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
157
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
158
+ <RunnerSettings RunnerId="RubyDebugRunner" />
159
+ <ConfigurationWrapper RunnerId="RubyDebugRunner" />
160
+ <method />
161
+ </configuration>
162
+ <configuration default="false" name="Snoopit: snoopit" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
163
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
164
+ <module name="snoopit" />
165
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
166
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
167
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
168
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
169
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
170
+ <envs>
171
+ <env name="JRUBY_OPTS" value="-X+O" />
172
+ </envs>
173
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
174
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
175
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
176
+ <COVERAGE_PATTERN ENABLED="true">
177
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
178
+ </COVERAGE_PATTERN>
179
+ </EXTENSION>
180
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
181
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
182
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/bin/snoopit_spec.rb" />
183
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
184
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
185
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="Snoopit" />
186
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
187
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
188
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
189
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
190
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
191
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
192
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
193
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
194
+ <RunnerSettings RunnerId="RubyRunner" />
195
+ <ConfigurationWrapper RunnerId="RubyRunner" />
196
+ <method />
197
+ </configuration>
198
+ </component>
199
+ <component name="NewModuleRootManager">
200
+ <content url="file://$MODULE_DIR$">
201
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
202
+ </content>
203
+ <orderEntry type="jdk" jdkName="RVM: ruby-2.1.2 [snoopit]" jdkType="RUBY_SDK" />
204
+ <orderEntry type="sourceFolder" forTests="false" />
205
+ <orderEntry type="library" scope="PROVIDED" name="awesome_print (v1.2.0, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
206
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.6.3, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
207
+ <orderEntry type="library" scope="PROVIDED" name="byebug (v2.7.0, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
208
+ <orderEntry type="library" scope="PROVIDED" name="coderay (v1.1.0, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
209
+ <orderEntry type="library" scope="PROVIDED" name="columnize (v0.8.9, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
210
+ <orderEntry type="library" scope="PROVIDED" name="coveralls (v0.7.0, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
211
+ <orderEntry type="library" scope="PROVIDED" name="debugger-linecache (v1.2.0, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
212
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
213
+ <orderEntry type="library" scope="PROVIDED" name="docile (v1.1.3, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
214
+ <orderEntry type="library" scope="PROVIDED" name="method_source (v0.8.2, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
215
+ <orderEntry type="library" scope="PROVIDED" name="mime-types (v2.2, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
216
+ <orderEntry type="library" scope="PROVIDED" name="multi_json (v1.10.0, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
217
+ <orderEntry type="library" scope="PROVIDED" name="pry (v0.9.12.6, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
218
+ <orderEntry type="library" scope="PROVIDED" name="pry-byebug (v1.3.2, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
219
+ <orderEntry type="library" scope="PROVIDED" name="rest-client (v1.6.7, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
220
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v2.14.0, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
221
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.14.8, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
222
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.14.5, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
223
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v2.14.6, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
224
+ <orderEntry type="library" scope="PROVIDED" name="simplecov (v0.8.2, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
225
+ <orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.8.0, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
226
+ <orderEntry type="library" scope="PROVIDED" name="slop (v3.5.0, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
227
+ <orderEntry type="library" scope="PROVIDED" name="stomp (v1.3.2, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
228
+ <orderEntry type="library" scope="PROVIDED" name="term-ansicolor (v1.3.0, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
229
+ <orderEntry type="library" scope="PROVIDED" name="thor (v0.19.1, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
230
+ <orderEntry type="library" scope="PROVIDED" name="tins (v1.1.0, RVM: ruby-2.1.2 [snoopit]) [gem]" level="application" />
231
+ </component>
232
+ </module>
233
+
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
7
+
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.0.0
5
+ - 2.1.0
6
+
7
+ script: rspec
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in snoopit.gemspec
4
+ gemspec
5
+
6
+ group :test, :development do
7
+ gem 'pry', '~> 0.9.12.6'
8
+ gem 'pry-byebug', '~> 1.3.0'
9
+ gem 'coveralls', :require => false
10
+ end
11
+
12
+ gem 'awesome_print', '~> 1.2'
13
+ gem 'stomp', '~> 1.3'
14
+
15
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Robert Birch
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.
@@ -0,0 +1,411 @@
1
+ # Snoopit
2
+
3
+ [![Gem Version][GV img]][Gem Version]
4
+ [![Build Status][BS img]][Build Status]
5
+ [![Dependency Status][DS img]][Dependency Status]
6
+ [![Coverage Status][CS img]][Coverage Status]
7
+ [![Code Climate](https://codeclimate.com/github/robdbirch/snoopit.png)](https://codeclimate.com/github/robdbirch/snoopit)
8
+
9
+ Simple tool for monitoring process log files for specified events and then generating basic notifications. This is an extensible and data driven solution. It provides a single location to manage log scraping duties.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'snoopit'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install snoopit
24
+
25
+ ## Usage
26
+ Typical use is via the command line with a JSON specification file.
27
+
28
+ Usage: snoopit [options]
29
+ -s, --snoopers snoopies.json File contains one or more regular expressions to locate a line of interest in a file
30
+ -S, --snooper snooper_name Only use the named snooper. This option can be used more than once to use several snoopers.
31
+ -t, --template Generate a template snoopies.json file to stdout
32
+ -T, --tracking Enable log file tracking using file ./snoopit_db.json
33
+ -f, --tracking-file file_name Specify a different tracking file name and location instead of the default ./snoopit_db.json
34
+ -j, --json Generate output in json
35
+ -J, --pretty-json Generate output in pretty json
36
+ -N, --no-newline Do not output new line between found items
37
+ -n, --enable-notifications Enable notifications
38
+ -l, --line-numbers show line numbers
39
+ -v, --verbose prints out file name, matched line number
40
+ -h, --help
41
+
42
+ ### Basic Snoopers specification file
43
+
44
+ `Snooper.json`
45
+
46
+ {
47
+ "snoopers" : {
48
+ "AppServer1" : {
49
+ "snoop" : "/opt/app_servers/app_server1/log/app.log",
50
+ "sniffers" : [
51
+ {
52
+ "comment" : "Failed to communicate with remote sync server",
53
+ "regexp" : "ERROR: Sync",
54
+ "lines" : {
55
+ "before" : 1,
56
+ "after" : 1
57
+ }
58
+ }
59
+ ]
60
+ }
61
+ }
62
+ }
63
+
64
+ $ snoopit -s snoopers.json
65
+ ERROR: Max sync retry count reached
66
+ ERROR: Sync error on remote server syc_server_54
67
+ ERROR: Switching to alternate server sync_server_702
68
+
69
+ ## Snooper Configuration
70
+ This is a JSON file which describes to the `Snooper` how to snoop around files and directories to find items of interest using regular expressions. It contains an array of files to snoop. Each file can be associated one or more regular expressions. Each regular expression behavior can be customized and each regular expression can be associated with zero or more event notifiers. The `Snooper` file also specifies notifier configurations and how to load custom notifiers.
71
+
72
+ "snoopers" : {
73
+ "AppServer": {
74
+ "snoop": "/opt/servers/app_server/log/my_app_server.log"
75
+ "sniffers" : [
76
+ {
77
+ "comment" : "Bad status from server",
78
+ "regexp" : "Non OK Status",
79
+ "lines" : {
80
+ "before" : 2,
81
+ "after" : 2
82
+ },
83
+ "notify" : {
84
+ "email" : {
85
+ "to" : "admin@myplace.com"
86
+ },
87
+ "http" : {
88
+ "url" : "http://localhost:3000/snoopers/snooped"
89
+ }
90
+ }
91
+ }
92
+ ]
93
+ }
94
+ },
95
+ "notifiers" :
96
+ {
97
+ "load" : {
98
+ "MyNotifier" : {
99
+ "file" : "/home/joe_code/snoopit/my_notifier",
100
+ "class" : "MyNotifier",
101
+ "config" : { "config_param" : "config_value" }
102
+ }
103
+ },
104
+ "email" : {
105
+ "smtp-server" : "smtp.gmail.com",
106
+ "port" : 587,
107
+ "tls" : true,
108
+ "user" : "someone@gmail.com",
109
+ "password" : "apassword",
110
+ "authentication" : "login"
111
+ }
112
+ }
113
+
114
+ ### Snoopers
115
+ Each `Snooper` configured in the `JSON` file is associated with either a file or a directory that will be snooped.
116
+
117
+ ##### File Snoopers
118
+ Each file `Snooper` can be associated with one file.
119
+
120
+ "snoopers": {
121
+ "AppServer": {
122
+ "snoop": "/opt/servers/app_server/log/my_app_server.log"
123
+ }
124
+ }
125
+
126
+
127
+ The above specification will snoop the file `/opt/servers/app_server/log/my_app_server.log`
128
+
129
+ ##### Directory Snoopers
130
+ Each directory `Snooper` can be associated with one directory. If the `glob` is not specified then every file in the directory is snooped. The `glob` string value is passed to Ruby's [`Dir.glob`](http://www.ruby-doc.org/core-2.1.1/Dir.html#method-c-glob)
131
+
132
+ "snoopers": {
133
+ "AppServer": {
134
+ "dir" : {
135
+ "path" : "/opt/servers/app_server/log",
136
+ "glob" : "*.log"
137
+ }
138
+ }
139
+ }
140
+
141
+ The above specification will snoop all files in directory `/opt/servers/app_server/log` with a suffix of `.log`
142
+
143
+ #### Defining Snooper Regular Expressions
144
+ Each `Snooper` has one or more regular expression specifications. This array of regular expressions are used to sniff through the files. These are identified as `Sniffers`.
145
+
146
+ ##### Sniffer Attributes
147
+
148
+ * `comment` Typically used by a `Notifier`, such as in the subject line in an email notifier.
149
+ * `regexp` The value of this string is passed to ruby's [Regexp](http://www.ruby-doc.org/core-2.1.1/Regexp.html)
150
+ * `lines`
151
+ * `before` Number of lines to print out before the matched line
152
+ * `after` Number of lines to print out after the matched line
153
+ * `notify` This is a list of event notifiers to use when a line is matched by the `regexp`
154
+
155
+ "sniffers" : [
156
+ {
157
+ "comment" : "Bad status from server",
158
+ "regexp" : "Non OK Status",
159
+ "lines" : {
160
+ "before" : 2,
161
+ "after" : 2
162
+ },
163
+ "notify" : {
164
+ "email" : {
165
+ "to": [ "watcher@something.com", "admin@something.com" ],
166
+ "from" : "snooper@something.com"
167
+ }
168
+ }
169
+ }
170
+ ]
171
+
172
+ ## Notifiers
173
+ After a file has been snooped by a `Snooper` any items matched by a `Sniffer's` regular expression can be sent to a specified notifier. Notifier's can be used to send notifications, such as an email, text messages, enqueue into a queueing system, or call a another service to take action based on the matched event.
174
+
175
+ ### Using a Notifier
176
+ Each `Sniffer` can use one or more notifiers. Notification parameters are specified for each `Sniffer` that uses a particular notifier. In the example above the `email` notifier parameters used are the `to` and `from` parameters.
177
+
178
+ ### Configuring a Notifier for the Manager
179
+ Notifiers will most likely need some minimal configuration information. These notifier configurations are specified after the `snoopers` section of the `Snooper` configuration file.
180
+
181
+ "notifiers" :
182
+ {
183
+ "email" : {
184
+ "smtp-server" : "smtp.gmail.com",
185
+ "port" : 587,
186
+ "user" : "someone@gmail.com",
187
+ "password" : "password",
188
+ "authentication" : "login"
189
+ }
190
+ }
191
+
192
+
193
+
194
+ ### Email Notifier
195
+ The email notifier is a simple `SMTP` mail notification provider.
196
+
197
+ #### Email Notifier Sniffer Parameters
198
+ The following parameters can be used with the `email` notifier
199
+
200
+ * `to` Specifies who is to receive the email notification information. This can be a single string or an array
201
+
202
+ "foo@bar.com" or [ "foo@bar.com", "bar@foo.com" ]
203
+
204
+
205
+ #### Email Notifier Configuration
206
+ The following configuration information is specified in the `notifiers` section of the `Snooper` configuration file.
207
+
208
+ * `email` Section name
209
+ * `smtp-server` SMTP sever name
210
+ * `port` SMTP port
211
+ * `user` User name
212
+ * `password` Password
213
+ * `authentication` Authentication type can be one of the following `plain`,`login`,`cram_md5`
214
+
215
+ ### Stomp Notifier
216
+ The stomp notifier is a simple `Stomp` notification provider.
217
+
218
+ #### Stomp Notifier Sniffer Parameters
219
+ The following parameters can be used with the `stomp` notifier
220
+
221
+ The destination `queue` and `headers can be specified.
222
+
223
+ "queue" : "/queue/snooped",
224
+ "headers" : {
225
+ "key-a": "a",
226
+ "key-b": "b"
227
+ }
228
+
229
+
230
+ #### Stomp Notifier Configuration
231
+ The following configuration information is specified in the `notifiers` section of the `Snooper` configuration file.
232
+
233
+ "stomp": {
234
+ "host": "localhost",
235
+ "port": "61613",
236
+ "login": "admin",
237
+ "passcode": "flintstone",
238
+ "headers": {
239
+ "accept-version": "1.1",
240
+ "host": "vhost"
241
+ }
242
+ }
243
+
244
+
245
+ ### Redis Notifier
246
+ Available soon.
247
+
248
+ ### HTTP Post Notifier
249
+ The http notifier is a simple `HTTP` notification provider. It can handle post `http` and `https`.
250
+ Basic authentication is available.
251
+
252
+ #### HTTP Post Notifier Sniffer Parameters
253
+ The following parameters can be used with the `http` notifier
254
+
255
+ * `url` Specifies where to post the notification information.
256
+
257
+ "http" : {
258
+ "url" : "http://localhost:3000/snoopers/snooped"
259
+ }
260
+
261
+ or for `https`
262
+
263
+ "https" : {
264
+ "url" : "https://localhost:3000/snoopers/snooped"
265
+ }
266
+
267
+ #### HTTP Post Notifier Configuration
268
+ The following configuration information is specified in the `notifiers` section of the `Snooper` configuration file.
269
+
270
+ * `http` Section name. Use http **not** `https`
271
+ * `api_key` The value of this parameter is placed in the header with the following format
272
+
273
+ Authorization: Token token=BR549
274
+
275
+ * `user` If a user parameter is passed then basic authentication will be performed with the given password
276
+ * `password` If a password parameter is passed then basic authentication will be performed with the given user name
277
+
278
+
279
+ "http" : {
280
+ "api-key" : "BR549",
281
+ "user" : "fred",
282
+ "password" : "flintstone"
283
+ }
284
+
285
+
286
+ ### Building Custom Notifiers
287
+ All Notifiers must inherit from the class `Snoopit::Notifier` and implement the `notify` method
288
+
289
+ def notify(found, notify_params)
290
+ raise NotImplementedError.new 'Notifier#notify'
291
+ end
292
+
293
+ #### `notify` Parameters
294
+
295
+ * `found` is a `hash` with the matched regular expression. It's what the `Snooper` sniffed out from the file.
296
+
297
+ {
298
+ comment: comment,
299
+ file: file,
300
+ before: [ lines before match ],
301
+ match: matched_line,
302
+ match_line_no: line_no_of_match,
303
+ after: [ lines after match ]
304
+ }
305
+
306
+ * `notify_params` These are the parameters defined for the notifier in the `Sniffer notifier` section (e.g. to and from parameters for the email notifier)
307
+
308
+ "sniffers" : [
309
+ {
310
+ "comment" : "Bad status from server",
311
+ "regexp" : "Non OK Status",
312
+ "lines" : {
313
+ "before" : 2,
314
+ "after" : 2
315
+ },
316
+ "notify" : {
317
+ "My Custom Notifier" : {
318
+ "param1": [ "a_value1", "a_value2" ],
319
+ "param2" : "value1"
320
+ }
321
+ }
322
+ }
323
+ ]
324
+
325
+ ### Dynamically Loading Custom Notifiers
326
+ To make a non default notifier available to the `Snooper` a notifier must be dynamically loaded. Specifying a `notifier` to be dynamically loaded is specified in the `notifiers` section of the `Snooper` configuration file.
327
+
328
+ "notifiers" {
329
+ "load" : {
330
+ "My Custom Notifier" : {
331
+ "file" : "/opt/snooper/notifiers/my_custom_notifier",
332
+ "class" : "MyCustomNotifier",
333
+ "config" : { "param1": "configure_me" }
334
+ }
335
+ }
336
+ }
337
+
338
+ In the `notifiers Hash` in the `load Hash` add the following in `Custom Notifier Hash`
339
+
340
+ * A key with a descriptive unique name `My Custom Notifier`
341
+ * `file` The path to the ruby file that contains the custom notifier class `"/opt/snooper/notifiers/my_custom_notifier"`
342
+ * `class` The class name of your notifier `MyCustomNotifier`
343
+ * `config` Any parameters needed to configure the custom notifier prior to generating notifications
344
+
345
+
346
+ ### Custom Notifier Initialization
347
+ Internally the `Snooper` will use an initializer with no arguments to create a custom notifier
348
+
349
+ MyCustomNotifier.new specified_config_params
350
+
351
+ If there are `config` items specified then the `initializer` will pass those items to the `Custom Notifier#initializer`
352
+
353
+ def initializer(config)
354
+ super config
355
+ @my_param1 = config['param1']
356
+ @my_param2 = @config['param2']
357
+ ...
358
+
359
+ **Be sure** to call **`super config`** in your initializer. One of the functions of calling `super` is to place the `config` parameter into the instance variable `@config`
360
+
361
+ ### Specifying Custom Notifier Configuration Section Names
362
+ The key used for your notification parameters for both `configuring` and `notifying` is the class name:
363
+
364
+ MyCustomNotifier.class.name
365
+
366
+ This can be changed in the `MyCustomNotifier#initializer` by passing a string to `super`
367
+
368
+ def initializer(config)
369
+ super config, 'my_custom_notifier_name'
370
+ @my_param1 = config['param1']
371
+ @my_param2 = @config['param2']
372
+ ...
373
+
374
+ ## File Tracking
375
+ Typically the `Snooper` is used for repeated invocations on a log file. This is typically done via `cron`. Enabling file tracking allows the `Snooper` to keep track of where it was in a file on it's last snoop of the file. Enabling file tracking prevents rereading the whole file and resending matched events. When file tracking is enabled using by the `-T` to `snoopit` the `Snooper` creates a `JSON` database in the directory where the `Snooper` was invoked. This file has the name `snoopit_db.json` The location of this file can be changed using the `-f` option of `snoopit`. If the `-f` option is used the `-T` is implied and does not need to be specified.
376
+
377
+
378
+ ## Cron example
379
+ `
380
+ */15 * * * * /usr/local/bin/ruby /usr/local/ruby/gems/bin/snoopit -s /opt/admin/snoopit/cron_snoopit.json -f /opt/admin/snoopit/cron_snoopit_db.json -n >> /opt/admin/snoopit/cron_snoopit.out 2>&1
381
+ `
382
+
383
+ ## History
384
+ Written this handy little utility too many times too count. From the ancient times via Rob Pikes and the gang's `sh`,`grep`, `awk`, `sed` and `mail` to Larry Wall's wonderful `perl` to the latest and best yet `ruby` from Matz.
385
+
386
+ grep -H -n -B 2 -A 2 'Look for this' ./log/some.log | awk ... | mail ...
387
+
388
+ # Versioning
389
+ This library aims to adhere to [Semantic Versioning 2.0.0](http://semver.org/). Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, that version should be immediately yanked and/or a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions. As a result of this policy, you can (and should) specify a dependency on this gem using the [Pessimistic Version Constraint](http://docs.rubygems.org/read/chapter/16#page74) with two digits of precision.
390
+
391
+
392
+ [Gem Version]: https://rubygems.org/gems/snoopit
393
+ [Build Status]: https://travis-ci.org/robdbirch/snoopit
394
+ [travis pull requests]: https://travis-ci.org/robdbirch/snoopit/pull_requests
395
+ [Dependency Status]: https://gemnasium.com/robdbirch/snoopit
396
+ [Coverage Status]: https://coveralls.io/r/robdbirch/snoopit
397
+
398
+ [GV img]: https://badge.fury.io/rb/snoopit.png
399
+ [BS img]: https://travis-ci.org/robdbirch/snoopit.png
400
+ [DS img]: https://gemnasium.com/robdbirch/snoopit.png
401
+ [CS img]: https://coveralls.io/repos/robdbirch/snoopit/badge.png?branch=master
402
+
403
+
404
+
405
+ ## Contributing
406
+
407
+ 1. Fork it
408
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
409
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
410
+ 4. Push to the branch (`git push origin my-new-feature`)
411
+ 5. Create new Pull Request