anotifier 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/History.txt +4 -0
- data/Manifest.txt +13 -0
- data/README.rdoc +61 -0
- data/Rakefile +24 -0
- data/app/models/anotifier/resource_mailer.rb +12 -0
- data/app/models/anotifier/resource_observer.rb +12 -0
- data/app/views/anotifier/resource_mailer/new_resource.text.html.erb +12 -0
- data/lib/anotifier.rb +6 -0
- data/rails/init.rb +13 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/test_helper.rb +3 -0
- metadata +95 -0
data/.gemtest
ADDED
File without changes
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.rdoc
|
4
|
+
Rakefile
|
5
|
+
lib/anotifier.rb
|
6
|
+
script/console
|
7
|
+
script/destroy
|
8
|
+
script/generate
|
9
|
+
test/test_helper.rb
|
10
|
+
rails/init.rb
|
11
|
+
app/models/anotifier/resource_mailer.rb
|
12
|
+
app/models/anotifier/resource_observer.rb
|
13
|
+
app/views/anotifier/resource_mailer/new_resource.text.html.erb
|
data/README.rdoc
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
= notifier
|
2
|
+
|
3
|
+
* http://github.com/cmdjohnson/anotifier
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
This Rails gem will send you an email whenever a record is created. This way, you can keep a tight track of what your users are doing. When you want to stop monitoring, simply remove the gem from the Gemfile.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
Sends emails. 'nuff said.
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
Run your app. That's all there's up to it.
|
16
|
+
|
17
|
+
== REQUIREMENTS:
|
18
|
+
|
19
|
+
- Rails (tested on 2.3.12)
|
20
|
+
|
21
|
+
== INSTALL:
|
22
|
+
|
23
|
+
1. Add the anotifier gem to your gemfile
|
24
|
+
2. Create a file config/anotifier_config.rb like this:
|
25
|
+
|
26
|
+
# -*- encoding : utf-8 -*-
|
27
|
+
################################################################################
|
28
|
+
# Config file for Anotifier.
|
29
|
+
################################################################################
|
30
|
+
|
31
|
+
module Anotifier
|
32
|
+
CONFIG = {
|
33
|
+
:notifications_email_address => "joe@blow.com",
|
34
|
+
:application_name => "app.super-roundhouse.net"
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
== LICENSE:
|
39
|
+
|
40
|
+
(The MIT License)
|
41
|
+
|
42
|
+
Copyright (c) 2011 Commander Johnson <commanderjohnson@gmail.com>
|
43
|
+
|
44
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
45
|
+
a copy of this software and associated documentation files (the
|
46
|
+
'Software'), to deal in the Software without restriction, including
|
47
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
48
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
49
|
+
permit persons to whom the Software is furnished to do so, subject to
|
50
|
+
the following conditions:
|
51
|
+
|
52
|
+
The above copyright notice and this permission notice shall be
|
53
|
+
included in all copies or substantial portions of the Software.
|
54
|
+
|
55
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
56
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
57
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
58
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
59
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
60
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
61
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/anotifier'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
# Hoe.plugin :website
|
9
|
+
# Hoe.plugin :cucumberfeatures
|
10
|
+
|
11
|
+
# Generate all the Rake tasks
|
12
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
+
$hoe = Hoe.spec 'anotifier' do
|
14
|
+
self.developer 'Commander Johnson', 'commanderjohnson@gmail.com'
|
15
|
+
self.rubyforge_name = self.name # TODO this is default value
|
16
|
+
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'newgem/tasks'
|
20
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
21
|
+
|
22
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
23
|
+
# remove_task :default
|
24
|
+
# task :default => [:spec, :features]
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Anotifier
|
2
|
+
class ResourceMailer < ActionMailer::Base
|
3
|
+
def new_resource(resource, sent_at = Time.now)
|
4
|
+
subject "[#{Anotifier::CONFIG[:application_name]}] New #{resource.class} was created"
|
5
|
+
recipients Anotifier::CONFIG[:notifications_email_address]
|
6
|
+
from Anotifier::CONFIG[:notifications_email_address]
|
7
|
+
sent_on sent_at
|
8
|
+
|
9
|
+
body :resource => resource
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Anotifier
|
2
|
+
class ResourceObserver < ActiveRecord::Observer
|
3
|
+
observe ActiveRecord::Base
|
4
|
+
|
5
|
+
def after_create resource
|
6
|
+
################################################################################
|
7
|
+
# generic notification service
|
8
|
+
################################################################################
|
9
|
+
Anotifier::ResourceMailer.deliver_new_resource(resource)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<p class="note">Please note: nonexistent and nil attributes are not listed.</p>
|
2
|
+
|
3
|
+
<table class="new_resource">
|
4
|
+
<th>Attribute</th>
|
5
|
+
<th>Value</th>
|
6
|
+
<%- for attribute in @resource.attributes.keys %>
|
7
|
+
<tr>
|
8
|
+
<td><%= h attribute.to_s %></td>
|
9
|
+
<td><%= h @resource.attributes[attribute].inspect %></td>
|
10
|
+
</tr>
|
11
|
+
<%- end %>
|
12
|
+
</table>
|
data/lib/anotifier.rb
ADDED
data/rails/init.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
################################################################################
|
3
|
+
# init.rb
|
4
|
+
################################################################################
|
5
|
+
|
6
|
+
# Load the config file
|
7
|
+
require 'config/anotifier_config'
|
8
|
+
|
9
|
+
raise "anotifier: Please create a config file config/anotifier_config.rb" unless defined? Anotifier::CONFIG
|
10
|
+
|
11
|
+
config.after_initialize do
|
12
|
+
ActiveRecord::Base.observers << Anotifier::ResourceObserver
|
13
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/notifier.rb'}"
|
9
|
+
puts "Loading notifier gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: anotifier
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Commander Johnson
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-10-08 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: hoe
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 27
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 12
|
32
|
+
version: "2.12"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
description: This Rails gem will send you an email whenever a record is created. This way, you can keep a tight track of what your users are doing. When you want to stop monitoring, simply remove the gem from the Gemfile.
|
36
|
+
email:
|
37
|
+
- commanderjohnson@gmail.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- History.txt
|
44
|
+
- Manifest.txt
|
45
|
+
files:
|
46
|
+
- History.txt
|
47
|
+
- Manifest.txt
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- lib/anotifier.rb
|
51
|
+
- script/console
|
52
|
+
- script/destroy
|
53
|
+
- script/generate
|
54
|
+
- test/test_helper.rb
|
55
|
+
- rails/init.rb
|
56
|
+
- app/models/anotifier/resource_mailer.rb
|
57
|
+
- app/models/anotifier/resource_observer.rb
|
58
|
+
- app/views/anotifier/resource_mailer/new_resource.text.html.erb
|
59
|
+
- .gemtest
|
60
|
+
homepage: http://github.com/cmdjohnson/anotifier
|
61
|
+
licenses: []
|
62
|
+
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options:
|
65
|
+
- --main
|
66
|
+
- README.rdoc
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project: anotifier
|
90
|
+
rubygems_version: 1.8.10
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: This Rails gem will send you an email whenever a record is created
|
94
|
+
test_files:
|
95
|
+
- test/test_helper.rb
|