telewatts_sender_support 0.1.22
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 +5 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +101 -0
- data/README +3 -0
- data/Rakefile +9 -0
- data/config.ru +4 -0
- data/config/application.rb +42 -0
- data/config/boot.rb +13 -0
- data/config/database.yml +22 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +26 -0
- data/config/environments/production.rb +49 -0
- data/config/environments/test.rb +35 -0
- data/db/schema.rb +15 -0
- data/db/seeds.rb +7 -0
- data/db/test_schema.rb +3 -0
- data/lib/sample_data_support.rb +33 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/telewatts.rb +2 -0
- data/lib/telewatts/sender_support.rb +7 -0
- data/lib/telewatts/sender_support/sender_report.rb +75 -0
- data/lib/telewatts/sender_support/sender_reports_migration.rb +21 -0
- data/lib/telewatts/sender_support/version.rb +5 -0
- data/lib/telewatts_sender_support.rb +7 -0
- data/pkg/telewatts_sender_support-0.1.20.gem +0 -0
- data/pkg/telewatts_sender_support-0.1.21.gem +0 -0
- data/pkg/telewatts_sender_support-0.1.22.gem +0 -0
- data/script/rails +6 -0
- data/telewatts_sender_support.gemspec +26 -0
- data/test/test_helper.rb +23 -0
- data/test/unit/sender_report_test.rb +28 -0
- metadata +137 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
telewatts_sender_support (0.1.22)
|
|
5
|
+
assertalot
|
|
6
|
+
rails (>= 3.0.4)
|
|
7
|
+
rake
|
|
8
|
+
sqlite3-ruby
|
|
9
|
+
|
|
10
|
+
GEM
|
|
11
|
+
remote: http://rubygems.org/
|
|
12
|
+
specs:
|
|
13
|
+
abstract (1.0.0)
|
|
14
|
+
actionmailer (3.0.4)
|
|
15
|
+
actionpack (= 3.0.4)
|
|
16
|
+
mail (~> 2.2.15)
|
|
17
|
+
actionpack (3.0.4)
|
|
18
|
+
activemodel (= 3.0.4)
|
|
19
|
+
activesupport (= 3.0.4)
|
|
20
|
+
builder (~> 2.1.2)
|
|
21
|
+
erubis (~> 2.6.6)
|
|
22
|
+
i18n (~> 0.4)
|
|
23
|
+
rack (~> 1.2.1)
|
|
24
|
+
rack-mount (~> 0.6.13)
|
|
25
|
+
rack-test (~> 0.5.7)
|
|
26
|
+
tzinfo (~> 0.3.23)
|
|
27
|
+
activemodel (3.0.4)
|
|
28
|
+
activesupport (= 3.0.4)
|
|
29
|
+
builder (~> 2.1.2)
|
|
30
|
+
i18n (~> 0.4)
|
|
31
|
+
activerecord (3.0.4)
|
|
32
|
+
activemodel (= 3.0.4)
|
|
33
|
+
activesupport (= 3.0.4)
|
|
34
|
+
arel (~> 2.0.2)
|
|
35
|
+
tzinfo (~> 0.3.23)
|
|
36
|
+
activeresource (3.0.4)
|
|
37
|
+
activemodel (= 3.0.4)
|
|
38
|
+
activesupport (= 3.0.4)
|
|
39
|
+
activesupport (3.0.4)
|
|
40
|
+
archive-tar-minitar (0.5.2)
|
|
41
|
+
arel (2.0.9)
|
|
42
|
+
assertalot (0.1.0)
|
|
43
|
+
builder (2.1.2)
|
|
44
|
+
columnize (0.3.2)
|
|
45
|
+
erubis (2.6.6)
|
|
46
|
+
abstract (>= 1.0.0)
|
|
47
|
+
i18n (0.5.0)
|
|
48
|
+
linecache19 (0.5.12)
|
|
49
|
+
ruby_core_source (>= 0.1.4)
|
|
50
|
+
mail (2.2.15)
|
|
51
|
+
activesupport (>= 2.3.6)
|
|
52
|
+
i18n (>= 0.4.0)
|
|
53
|
+
mime-types (~> 1.16)
|
|
54
|
+
treetop (~> 1.4.8)
|
|
55
|
+
mime-types (1.16)
|
|
56
|
+
polyglot (0.3.1)
|
|
57
|
+
rack (1.2.1)
|
|
58
|
+
rack-mount (0.6.14)
|
|
59
|
+
rack (>= 1.0.0)
|
|
60
|
+
rack-test (0.5.7)
|
|
61
|
+
rack (>= 1.0)
|
|
62
|
+
rails (3.0.4)
|
|
63
|
+
actionmailer (= 3.0.4)
|
|
64
|
+
actionpack (= 3.0.4)
|
|
65
|
+
activerecord (= 3.0.4)
|
|
66
|
+
activeresource (= 3.0.4)
|
|
67
|
+
activesupport (= 3.0.4)
|
|
68
|
+
bundler (~> 1.0)
|
|
69
|
+
railties (= 3.0.4)
|
|
70
|
+
railties (3.0.4)
|
|
71
|
+
actionpack (= 3.0.4)
|
|
72
|
+
activesupport (= 3.0.4)
|
|
73
|
+
rake (>= 0.8.7)
|
|
74
|
+
thor (~> 0.14.4)
|
|
75
|
+
rake (0.8.7)
|
|
76
|
+
rr (1.0.2)
|
|
77
|
+
ruby-debug-base19 (0.11.25)
|
|
78
|
+
columnize (>= 0.3.1)
|
|
79
|
+
linecache19 (>= 0.5.11)
|
|
80
|
+
ruby_core_source (>= 0.1.4)
|
|
81
|
+
ruby-debug19 (0.11.6)
|
|
82
|
+
columnize (>= 0.3.1)
|
|
83
|
+
linecache19 (>= 0.5.11)
|
|
84
|
+
ruby-debug-base19 (>= 0.11.19)
|
|
85
|
+
ruby_core_source (0.1.5)
|
|
86
|
+
archive-tar-minitar (>= 0.5.2)
|
|
87
|
+
sqlite3 (1.3.3)
|
|
88
|
+
sqlite3-ruby (1.3.3)
|
|
89
|
+
sqlite3 (>= 1.3.3)
|
|
90
|
+
thor (0.14.6)
|
|
91
|
+
treetop (1.4.9)
|
|
92
|
+
polyglot (>= 0.3.1)
|
|
93
|
+
tzinfo (0.3.24)
|
|
94
|
+
|
|
95
|
+
PLATFORMS
|
|
96
|
+
ruby
|
|
97
|
+
|
|
98
|
+
DEPENDENCIES
|
|
99
|
+
rr
|
|
100
|
+
ruby-debug19
|
|
101
|
+
telewatts_sender_support!
|
data/README
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
|
3
|
+
|
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
|
5
|
+
require 'rake'
|
|
6
|
+
require 'bundler'
|
|
7
|
+
|
|
8
|
+
TelewattsSenderSupport::Application.load_tasks
|
|
9
|
+
Bundler::GemHelper.install_tasks
|
data/config.ru
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
require 'rails/all'
|
|
4
|
+
|
|
5
|
+
# If you have a Gemfile, require the gems listed there, including any gems
|
|
6
|
+
# you've limited to :test, :development, or :production.
|
|
7
|
+
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
|
8
|
+
|
|
9
|
+
module TelewattsSenderSupport
|
|
10
|
+
class Application < Rails::Application
|
|
11
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
12
|
+
# Application configuration should go into files in config/initializers
|
|
13
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
14
|
+
|
|
15
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
|
16
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
|
17
|
+
|
|
18
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
|
19
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
|
20
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
|
21
|
+
|
|
22
|
+
# Activate observers that should always be running.
|
|
23
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
|
24
|
+
|
|
25
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
26
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
27
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
|
28
|
+
|
|
29
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
30
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
31
|
+
# config.i18n.default_locale = :de
|
|
32
|
+
|
|
33
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
|
34
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
|
35
|
+
|
|
36
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
|
37
|
+
config.encoding = "utf-8"
|
|
38
|
+
|
|
39
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
|
40
|
+
config.filter_parameters += [:password]
|
|
41
|
+
end
|
|
42
|
+
end
|
data/config/boot.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
|
|
3
|
+
# Set up gems listed in the Gemfile.
|
|
4
|
+
gemfile = File.expand_path('../../Gemfile', __FILE__)
|
|
5
|
+
begin
|
|
6
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
|
7
|
+
require 'bundler'
|
|
8
|
+
Bundler.setup
|
|
9
|
+
rescue Bundler::GemNotFound => e
|
|
10
|
+
STDERR.puts e.message
|
|
11
|
+
STDERR.puts "Try running `bundle install`."
|
|
12
|
+
exit!
|
|
13
|
+
end if File.exist?(gemfile)
|
data/config/database.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# SQLite version 3.x
|
|
2
|
+
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
|
3
|
+
development:
|
|
4
|
+
adapter: sqlite3
|
|
5
|
+
database: db/development.sqlite3
|
|
6
|
+
pool: 5
|
|
7
|
+
timeout: 5000
|
|
8
|
+
|
|
9
|
+
# Warning: The database defined as "test" will be erased and
|
|
10
|
+
# re-generated from your development database when you run "rake".
|
|
11
|
+
# Do not set this db to the same as development or production.
|
|
12
|
+
test:
|
|
13
|
+
adapter: sqlite3
|
|
14
|
+
database: db/test.sqlite3
|
|
15
|
+
pool: 5
|
|
16
|
+
timeout: 5000
|
|
17
|
+
|
|
18
|
+
production:
|
|
19
|
+
adapter: sqlite3
|
|
20
|
+
database: db/production.sqlite3
|
|
21
|
+
pool: 5
|
|
22
|
+
timeout: 5000
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
TelewattsSenderSupport::Application.configure do
|
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
|
3
|
+
|
|
4
|
+
# In the development environment your application's code is reloaded on
|
|
5
|
+
# every request. This slows down response time but is perfect for development
|
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
|
7
|
+
config.cache_classes = false
|
|
8
|
+
|
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
|
10
|
+
config.whiny_nils = true
|
|
11
|
+
|
|
12
|
+
# Show full error reports and disable caching
|
|
13
|
+
config.consider_all_requests_local = true
|
|
14
|
+
config.action_view.debug_rjs = true
|
|
15
|
+
config.action_controller.perform_caching = false
|
|
16
|
+
|
|
17
|
+
# Don't care if the mailer can't send
|
|
18
|
+
config.action_mailer.raise_delivery_errors = false
|
|
19
|
+
|
|
20
|
+
# Print deprecation notices to the Rails logger
|
|
21
|
+
config.active_support.deprecation = :log
|
|
22
|
+
|
|
23
|
+
# Only use best-standards-support built into browsers
|
|
24
|
+
config.action_dispatch.best_standards_support = :builtin
|
|
25
|
+
end
|
|
26
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
TelewattsSenderSupport::Application.configure do
|
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
|
3
|
+
|
|
4
|
+
# The production environment is meant for finished, "live" apps.
|
|
5
|
+
# Code is not reloaded between requests
|
|
6
|
+
config.cache_classes = true
|
|
7
|
+
|
|
8
|
+
# Full error reports are disabled and caching is turned on
|
|
9
|
+
config.consider_all_requests_local = false
|
|
10
|
+
config.action_controller.perform_caching = true
|
|
11
|
+
|
|
12
|
+
# Specifies the header that your server uses for sending files
|
|
13
|
+
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
|
14
|
+
|
|
15
|
+
# For nginx:
|
|
16
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
|
17
|
+
|
|
18
|
+
# If you have no front-end server that supports something like X-Sendfile,
|
|
19
|
+
# just comment this out and Rails will serve the files
|
|
20
|
+
|
|
21
|
+
# See everything in the log (default is :info)
|
|
22
|
+
# config.log_level = :debug
|
|
23
|
+
|
|
24
|
+
# Use a different logger for distributed setups
|
|
25
|
+
# config.logger = SyslogLogger.new
|
|
26
|
+
|
|
27
|
+
# Use a different cache store in production
|
|
28
|
+
# config.cache_store = :mem_cache_store
|
|
29
|
+
|
|
30
|
+
# Disable Rails's static asset server
|
|
31
|
+
# In production, Apache or nginx will already do this
|
|
32
|
+
config.serve_static_assets = false
|
|
33
|
+
|
|
34
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
|
35
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
|
36
|
+
|
|
37
|
+
# Disable delivery errors, bad email addresses will be ignored
|
|
38
|
+
# config.action_mailer.raise_delivery_errors = false
|
|
39
|
+
|
|
40
|
+
# Enable threaded mode
|
|
41
|
+
# config.threadsafe!
|
|
42
|
+
|
|
43
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
|
44
|
+
# the I18n.default_locale when a translation can not be found)
|
|
45
|
+
config.i18n.fallbacks = true
|
|
46
|
+
|
|
47
|
+
# Send deprecation notices to registered listeners
|
|
48
|
+
config.active_support.deprecation = :notify
|
|
49
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
TelewattsSenderSupport::Application.configure do
|
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
|
3
|
+
|
|
4
|
+
# The test environment is used exclusively to run your application's
|
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
|
8
|
+
config.cache_classes = true
|
|
9
|
+
|
|
10
|
+
# Log error messages when you accidentally call methods on nil.
|
|
11
|
+
config.whiny_nils = true
|
|
12
|
+
|
|
13
|
+
# Show full error reports and disable caching
|
|
14
|
+
config.consider_all_requests_local = true
|
|
15
|
+
config.action_controller.perform_caching = false
|
|
16
|
+
|
|
17
|
+
# Raise exceptions instead of rendering exception templates
|
|
18
|
+
config.action_dispatch.show_exceptions = false
|
|
19
|
+
|
|
20
|
+
# Disable request forgery protection in test environment
|
|
21
|
+
config.action_controller.allow_forgery_protection = false
|
|
22
|
+
|
|
23
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
|
24
|
+
# The :test delivery method accumulates sent emails in the
|
|
25
|
+
# ActionMailer::Base.deliveries array.
|
|
26
|
+
config.action_mailer.delivery_method = :test
|
|
27
|
+
|
|
28
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
|
29
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
|
30
|
+
# like if you have constraints or database-specific column types
|
|
31
|
+
# config.active_record.schema_format = :sql
|
|
32
|
+
|
|
33
|
+
# Print deprecation notices to the stderr
|
|
34
|
+
config.active_support.deprecation = :stderr
|
|
35
|
+
end
|
data/db/schema.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
|
4
|
+
#
|
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your
|
|
6
|
+
# database schema. If you need to create the application database on another
|
|
7
|
+
# system, you should be using db:schema:load, not running all the migrations
|
|
8
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
|
9
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
|
10
|
+
#
|
|
11
|
+
# It's strongly recommended to check this file into your version control system.
|
|
12
|
+
|
|
13
|
+
ActiveRecord::Schema.define(:version => 0) do
|
|
14
|
+
Telewatts::SenderSupport::SenderReportsMigration.up
|
|
15
|
+
end
|
data/db/seeds.rb
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
|
3
|
+
#
|
|
4
|
+
# Examples:
|
|
5
|
+
#
|
|
6
|
+
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
|
|
7
|
+
# Mayor.create(:name => 'Daley', :city => cities.first)
|
data/db/test_schema.rb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module SampleDataSupport
|
|
2
|
+
|
|
3
|
+
def generate_sender_reports
|
|
4
|
+
|
|
5
|
+
begin
|
|
6
|
+
raise Exception.new "sample exception message"
|
|
7
|
+
rescue Exception => e
|
|
8
|
+
exception = e
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
reports = []
|
|
12
|
+
|
|
13
|
+
i=0;
|
|
14
|
+
SenderReport.levels.each do |level|
|
|
15
|
+
3.times do
|
|
16
|
+
reports << SenderReport.new do |e|
|
|
17
|
+
e.level=level
|
|
18
|
+
e.message = "Sample SenderReport message ##{i}"
|
|
19
|
+
e.dump_exception(exception) if level=='error'
|
|
20
|
+
end
|
|
21
|
+
i+=1
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
reports << SenderReport.new do |e|
|
|
26
|
+
e.level='report'
|
|
27
|
+
e.code='sender_active'
|
|
28
|
+
e.message = "Sample SenderReport message ##{i}"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
reports
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/tasks/.gitkeep
ADDED
|
File without changes
|
data/lib/telewatts.rb
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
module Telewatts
|
|
2
|
+
module SenderSupport
|
|
3
|
+
class SenderReport < ActiveRecord::Base
|
|
4
|
+
|
|
5
|
+
validates_presence_of :level, :message
|
|
6
|
+
|
|
7
|
+
before_validation :create_message_from_code_if_blank
|
|
8
|
+
|
|
9
|
+
protected
|
|
10
|
+
|
|
11
|
+
def create_message_from_code_if_blank
|
|
12
|
+
if !code.blank? and message.blank?
|
|
13
|
+
self.message = code.humanize
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
public
|
|
18
|
+
|
|
19
|
+
def dump_exception e
|
|
20
|
+
dump = [e.class.name, e.message]
|
|
21
|
+
dump << e.backtrace
|
|
22
|
+
self.exception_dump = ActiveSupport::JSON.encode dump
|
|
23
|
+
return self
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def encode_data data
|
|
27
|
+
self.data = ActiveSupport::JSON.encode data
|
|
28
|
+
return self
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def inspect
|
|
32
|
+
s = "#{self.created_at} #{self.level.blank? ? '': self.level.upcase} #{self.code || self.message} [id=#{self.id}]"
|
|
33
|
+
s << " [exception dump available]" unless self.exception_dump.blank?
|
|
34
|
+
s
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def marshal_exception_dump
|
|
38
|
+
|
|
39
|
+
return nil if exception_dump.blank?
|
|
40
|
+
a = ActiveSupport::JSON.decode exception_dump
|
|
41
|
+
e = Exception.new "(#{a[0]}): #{a[1]}"
|
|
42
|
+
e.set_backtrace a[2]
|
|
43
|
+
e
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def print_exception
|
|
47
|
+
return nil if exception_dump.blank?
|
|
48
|
+
a = ActiveSupport::JSON.decode exception_dump
|
|
49
|
+
puts "\nException class: #{a[0]}\n\n"
|
|
50
|
+
puts "Message: #{a[1]}\n\n"
|
|
51
|
+
puts "Backtrace:\n\n"
|
|
52
|
+
a[2].each do |line|
|
|
53
|
+
puts line
|
|
54
|
+
end
|
|
55
|
+
puts "\n\n"
|
|
56
|
+
nil
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
class << self
|
|
60
|
+
# sender report levels in increasing order of priority
|
|
61
|
+
def levels
|
|
62
|
+
%W{debug info report warn error fatal}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def lowest_priority_level
|
|
66
|
+
log_levels.first
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def highest_priority_level
|
|
70
|
+
log_levels.last
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Telewatts
|
|
2
|
+
module SenderSupport
|
|
3
|
+
class SenderReportsMigration < ActiveRecord::Migration
|
|
4
|
+
def self.up
|
|
5
|
+
create_table :sender_reports do |t|
|
|
6
|
+
t.string :level
|
|
7
|
+
t.string :code # predefined report codes such as 'sender_active'
|
|
8
|
+
t.string :message
|
|
9
|
+
t.text :data
|
|
10
|
+
t.text :exception_dump
|
|
11
|
+
|
|
12
|
+
t.timestamps
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.down
|
|
17
|
+
drop_table :sender_reports
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/script/rails
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
|
3
|
+
|
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
|
6
|
+
require 'rails/commands'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "telewatts/sender_support/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "telewatts_sender_support"
|
|
7
|
+
s.version = Telewatts::SenderSupport::VERSION
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.authors = ["Sam Taylor"]
|
|
10
|
+
s.email = ["sjltaylor@gmail.com"]
|
|
11
|
+
s.homepage = ""
|
|
12
|
+
s.summary = %q{shared models between server and client for the telewatts sender api}
|
|
13
|
+
#s.description = %q{TODO: Write a gem description}
|
|
14
|
+
|
|
15
|
+
s.add_dependency 'rails', '>= 3.0.4'
|
|
16
|
+
s.add_dependency 'sqlite3-ruby'
|
|
17
|
+
s.add_dependency 'rake'
|
|
18
|
+
s.add_dependency 'assertalot'
|
|
19
|
+
|
|
20
|
+
s.rubyforge_project = "telewatts_sender_support"
|
|
21
|
+
|
|
22
|
+
s.files = `git ls-files`.split("\n")
|
|
23
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
25
|
+
s.require_paths = ["lib"]
|
|
26
|
+
end
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
|
3
|
+
require 'rails/test_help'
|
|
4
|
+
require 'rr'
|
|
5
|
+
|
|
6
|
+
class Test::Unit::TestCase
|
|
7
|
+
include RR::Adapters::TestUnit
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class ActiveSupport::TestCase
|
|
11
|
+
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
|
12
|
+
#
|
|
13
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
|
14
|
+
# -- they do not yet inherit this setting
|
|
15
|
+
|
|
16
|
+
# fixtures will no longer be used for tr apps
|
|
17
|
+
# fixtures :all
|
|
18
|
+
|
|
19
|
+
# Add more helper methods to be used by all tests here...
|
|
20
|
+
|
|
21
|
+
include Assertalot::Assertions
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class SenderReportTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
class SenderReport < Telewatts::SenderSupport::SenderReport; end
|
|
6
|
+
|
|
7
|
+
test 'sender reports must have a message' do
|
|
8
|
+
|
|
9
|
+
e = SenderReport.new
|
|
10
|
+
assert !e.valid?
|
|
11
|
+
assert_error_on e, :message
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
test 'must have a level' do
|
|
15
|
+
e = SenderReport.new
|
|
16
|
+
assert !e.valid?
|
|
17
|
+
assert_error_on e, :level
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test 'valid data is accepted' do
|
|
21
|
+
e = SenderReport.new
|
|
22
|
+
e.level = 'info'
|
|
23
|
+
e.code = 'sender_report'
|
|
24
|
+
assert e.valid?
|
|
25
|
+
assert_no_error_on e, :level
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: telewatts_sender_support
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
prerelease:
|
|
5
|
+
version: 0.1.22
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Sam Taylor
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
|
|
13
|
+
date: 2011-04-11 00:00:00 +01:00
|
|
14
|
+
default_executable:
|
|
15
|
+
dependencies:
|
|
16
|
+
- !ruby/object:Gem::Dependency
|
|
17
|
+
name: rails
|
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
19
|
+
none: false
|
|
20
|
+
requirements:
|
|
21
|
+
- - ">="
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: 3.0.4
|
|
24
|
+
type: :runtime
|
|
25
|
+
prerelease: false
|
|
26
|
+
version_requirements: *id001
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: sqlite3-ruby
|
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
30
|
+
none: false
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: "0"
|
|
35
|
+
type: :runtime
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: *id002
|
|
38
|
+
- !ruby/object:Gem::Dependency
|
|
39
|
+
name: rake
|
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: "0"
|
|
46
|
+
type: :runtime
|
|
47
|
+
prerelease: false
|
|
48
|
+
version_requirements: *id003
|
|
49
|
+
- !ruby/object:Gem::Dependency
|
|
50
|
+
name: assertalot
|
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
52
|
+
none: false
|
|
53
|
+
requirements:
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: "0"
|
|
57
|
+
type: :runtime
|
|
58
|
+
prerelease: false
|
|
59
|
+
version_requirements: *id004
|
|
60
|
+
description:
|
|
61
|
+
email:
|
|
62
|
+
- sjltaylor@gmail.com
|
|
63
|
+
executables: []
|
|
64
|
+
|
|
65
|
+
extensions: []
|
|
66
|
+
|
|
67
|
+
extra_rdoc_files: []
|
|
68
|
+
|
|
69
|
+
files:
|
|
70
|
+
- .gitignore
|
|
71
|
+
- Gemfile
|
|
72
|
+
- Gemfile.lock
|
|
73
|
+
- README
|
|
74
|
+
- Rakefile
|
|
75
|
+
- config.ru
|
|
76
|
+
- config/application.rb
|
|
77
|
+
- config/boot.rb
|
|
78
|
+
- config/database.yml
|
|
79
|
+
- config/environment.rb
|
|
80
|
+
- config/environments/development.rb
|
|
81
|
+
- config/environments/production.rb
|
|
82
|
+
- config/environments/test.rb
|
|
83
|
+
- db/schema.rb
|
|
84
|
+
- db/seeds.rb
|
|
85
|
+
- db/test_schema.rb
|
|
86
|
+
- lib/sample_data_support.rb
|
|
87
|
+
- lib/tasks/.gitkeep
|
|
88
|
+
- lib/telewatts.rb
|
|
89
|
+
- lib/telewatts/sender_support.rb
|
|
90
|
+
- lib/telewatts/sender_support/sender_report.rb
|
|
91
|
+
- lib/telewatts/sender_support/sender_reports_migration.rb
|
|
92
|
+
- lib/telewatts/sender_support/version.rb
|
|
93
|
+
- lib/telewatts_sender_support.rb
|
|
94
|
+
- pkg/telewatts_sender_support-0.1.20.gem
|
|
95
|
+
- pkg/telewatts_sender_support-0.1.21.gem
|
|
96
|
+
- pkg/telewatts_sender_support-0.1.22.gem
|
|
97
|
+
- script/rails
|
|
98
|
+
- telewatts_sender_support.gemspec
|
|
99
|
+
- test/test_helper.rb
|
|
100
|
+
- test/unit/sender_report_test.rb
|
|
101
|
+
has_rdoc: true
|
|
102
|
+
homepage: ""
|
|
103
|
+
licenses: []
|
|
104
|
+
|
|
105
|
+
post_install_message:
|
|
106
|
+
rdoc_options: []
|
|
107
|
+
|
|
108
|
+
require_paths:
|
|
109
|
+
- lib
|
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
|
+
none: false
|
|
112
|
+
requirements:
|
|
113
|
+
- - ">="
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
hash: 130279974232091708
|
|
116
|
+
segments:
|
|
117
|
+
- 0
|
|
118
|
+
version: "0"
|
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
|
+
none: false
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
hash: 130279974232091708
|
|
125
|
+
segments:
|
|
126
|
+
- 0
|
|
127
|
+
version: "0"
|
|
128
|
+
requirements: []
|
|
129
|
+
|
|
130
|
+
rubyforge_project: telewatts_sender_support
|
|
131
|
+
rubygems_version: 1.5.0
|
|
132
|
+
signing_key:
|
|
133
|
+
specification_version: 3
|
|
134
|
+
summary: shared models between server and client for the telewatts sender api
|
|
135
|
+
test_files:
|
|
136
|
+
- test/test_helper.rb
|
|
137
|
+
- test/unit/sender_report_test.rb
|