patrol 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/patrol.rb +7 -0
- data/lib/patrol/railtie.rb +13 -0
- data/lib/patrol_mailer.rb +23 -0
- data/lib/smtp_api_header.rb +65 -0
- data/lib/tasks/patrol.rake +29 -0
- data/patrol.gemspec +64 -0
- data/rails/init.rb +4 -0
- metadata +17 -11
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/patrol.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
require "smtp_api_header"
|
3
|
+
|
4
|
+
class PatrolMailer < ActionMailer::Base
|
5
|
+
default :from => "from@example.com"
|
6
|
+
|
7
|
+
def report(content)
|
8
|
+
@content = content
|
9
|
+
|
10
|
+
hdr = SmtpApiHeader.new()
|
11
|
+
hdr.setCategory("initial")
|
12
|
+
hdr.addFilterSetting("subscriptiontrack", "enable", 0)
|
13
|
+
headers["X-SMTPAPI"] = hdr.asJSON
|
14
|
+
timestamp = Time.now.strftime("%Y-%m-%d %H:%M")
|
15
|
+
|
16
|
+
mail(:to => "bc@billetto.dk", :subject => "Patrol report (#{timestamp})") do |format|
|
17
|
+
format.html { render :text => content }
|
18
|
+
format.text { render :text => content }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# Version 1.0
|
4
|
+
# Last Updated 6/22/2009
|
5
|
+
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
class SmtpApiHeader
|
9
|
+
|
10
|
+
def initialize()
|
11
|
+
@data = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def addTo(to)
|
15
|
+
@data['to'] ||= []
|
16
|
+
@data['to'] += to.kind_of?(Array) ? to : [to]
|
17
|
+
end
|
18
|
+
|
19
|
+
def addSubVal(var, val)
|
20
|
+
if not @data['sub']
|
21
|
+
@data['sub'] = {}
|
22
|
+
end
|
23
|
+
if val.instance_of?(Array)
|
24
|
+
@data['sub'][var] = val
|
25
|
+
else
|
26
|
+
@data['sub'][var] = [val]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def setUniqueArgs(val)
|
31
|
+
if val.instance_of?(Hash)
|
32
|
+
@data['unique_args'] = val
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def setCategory(cat)
|
37
|
+
@data['category'] = cat
|
38
|
+
end
|
39
|
+
|
40
|
+
def addFilterSetting(fltr, setting, val)
|
41
|
+
if not @data['filters']
|
42
|
+
@data['filters'] = {}
|
43
|
+
end
|
44
|
+
if not @data['filters'][fltr]
|
45
|
+
@data['filters'][fltr] = {}
|
46
|
+
end
|
47
|
+
if not @data['filters'][fltr]['settings']
|
48
|
+
@data['filters'][fltr]['settings'] = {}
|
49
|
+
end
|
50
|
+
@data['filters'][fltr]['settings'][setting] = val
|
51
|
+
end
|
52
|
+
|
53
|
+
def asJSON()
|
54
|
+
json = JSON.generate @data
|
55
|
+
return json.gsub(/(["\]}])([,:])(["\[{])/, '\\1\\2 \\3')
|
56
|
+
end
|
57
|
+
|
58
|
+
def as_string()
|
59
|
+
json = asJSON()
|
60
|
+
str = 'X-SMTPAPI: %s' % json.gsub(/(.{1,72})( +|$\n?)|(.{1,72})/,"\\1\\3\n")
|
61
|
+
return str
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
puts "patrol tasks"
|
3
|
+
|
4
|
+
namespace :ppatrol do
|
5
|
+
|
6
|
+
desc "Launch the patrol"
|
7
|
+
task :gooooooooooooooooooooooo => :environment do
|
8
|
+
log = Logger.new("/tmp/patrol.log")
|
9
|
+
output = ""
|
10
|
+
timestamp = Time.now.strftime("%Y-%m-%d %H:%M")
|
11
|
+
output << "[#{timestamp}] Launch the patrol "
|
12
|
+
output << "\n"
|
13
|
+
|
14
|
+
roadmap = YAML.load_file File.join(RAILS_ROOT, "config", "patrol.yml")
|
15
|
+
roadmap.values.each do |rule|
|
16
|
+
output << rule["title"]
|
17
|
+
output << "\n"
|
18
|
+
output << "=> #{eval(rule["request"])}"
|
19
|
+
output << "\n"
|
20
|
+
end
|
21
|
+
|
22
|
+
puts output
|
23
|
+
log.info(output)
|
24
|
+
|
25
|
+
PatrolMailer.report(output).deliver
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/patrol.gemspec
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "patrol"
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Caccinolo Benoit"]
|
12
|
+
s.date = "2011-12-13"
|
13
|
+
s.description = "patrol through your DB to ckeck data correctness"
|
14
|
+
s.email = "benoit.caccinolo@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"lib/patrol.rb",
|
28
|
+
"lib/patrol/railtie.rb",
|
29
|
+
"lib/patrol_mailer.rb",
|
30
|
+
"lib/smtp_api_header.rb",
|
31
|
+
"lib/tasks/patrol.rake",
|
32
|
+
"patrol.gemspec",
|
33
|
+
"rails/init.rb",
|
34
|
+
"test/helper.rb",
|
35
|
+
"test/test_patrol.rb"
|
36
|
+
]
|
37
|
+
s.homepage = "http://github.com/bcaccinolo/patrol"
|
38
|
+
s.licenses = ["MIT"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = "1.8.10"
|
41
|
+
s.summary = "patrol through your DB to ckeck data correctness"
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
s.specification_version = 3
|
45
|
+
|
46
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
48
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
49
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
50
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
53
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
54
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
55
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
56
|
+
end
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
59
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
60
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
61
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
data/rails/init.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patrol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-13 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: shoulda
|
16
|
-
requirement: &
|
16
|
+
requirement: &2158192540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2158192540
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &2158191260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2158191260
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &2158190080 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.6.4
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2158190080
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rcov
|
49
|
-
requirement: &
|
49
|
+
requirement: &2158189160 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2158189160
|
58
58
|
description: patrol through your DB to ckeck data correctness
|
59
59
|
email: benoit.caccinolo@gmail.com
|
60
60
|
executables: []
|
@@ -71,6 +71,12 @@ files:
|
|
71
71
|
- Rakefile
|
72
72
|
- VERSION
|
73
73
|
- lib/patrol.rb
|
74
|
+
- lib/patrol/railtie.rb
|
75
|
+
- lib/patrol_mailer.rb
|
76
|
+
- lib/smtp_api_header.rb
|
77
|
+
- lib/tasks/patrol.rake
|
78
|
+
- patrol.gemspec
|
79
|
+
- rails/init.rb
|
74
80
|
- test/helper.rb
|
75
81
|
- test/test_patrol.rb
|
76
82
|
homepage: http://github.com/bcaccinolo/patrol
|
@@ -88,7 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
94
|
version: '0'
|
89
95
|
segments:
|
90
96
|
- 0
|
91
|
-
hash:
|
97
|
+
hash: 2473816605805805005
|
92
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
99
|
none: false
|
94
100
|
requirements:
|