report_card 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/report_card/reports_controller.rb +10 -4
- data/app/mailers/report_card/mailer.rb +7 -5
- data/app/views/report_card/mailer/report.html.erb +1 -1
- data/app/workers/report_card/runner.rb +4 -3
- data/lib/report_card.rb +11 -1
- data/lib/report_card/engine.rb +2 -0
- data/lib/report_card/report.rb +6 -0
- data/lib/report_card/version.rb +1 -1
- data/test/dummy/{log/development.log → db/test.sqlite3} +0 -0
- data/test/dummy/log/test.log +15 -0
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6cda23ee0f23eed670cc68f5a6e3746645c37d4
|
4
|
+
data.tar.gz: 4681b0afd0731b14e7bc2a25e84692a0216d1529
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eace107781ddb632f40f1f04406bd5fb7c6b83cb677965a3aebbb5873953905c0f318603f4d7901b5afaf8d2c0e5011e590f06d4709cfb95ba6591c2141c777f
|
7
|
+
data.tar.gz: 15c5ec29812edd3c7b976adf5aedee497a634746d6b7181db1c0a97e00074bc928363482af71d21114e9a3d4f0469354bd80092f07febd80fe38b1c3469b7f9d
|
@@ -6,11 +6,17 @@ module ReportCard
|
|
6
6
|
|
7
7
|
def create
|
8
8
|
if ReportCard::Report.exists?(params[:report_name])
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
|
10
|
+
unless params.key?(:email_options)
|
11
|
+
params[:email_options] = {}
|
12
|
+
params[:email_options][:recipient_email] = instance_eval(&ReportCard.recipient_email)
|
13
|
+
end
|
14
|
+
|
15
|
+
flash_success = params[:flash_success] || instance_eval(&ReportCard.flash_success)
|
16
|
+
ReportCard::Runner.perform_async(params)
|
17
|
+
redirect_to :back, flash: { success: flash_success }
|
12
18
|
else
|
13
|
-
redirect_to
|
19
|
+
redirect_to :back, flash: { error: 'Could not find report' }
|
14
20
|
end
|
15
21
|
end
|
16
22
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
module ReportCard
|
2
2
|
class Mailer < ActionMailer::Base
|
3
|
-
def report(url,
|
3
|
+
def report(url, email_options)
|
4
4
|
@url = url
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
@body = email_options['body'] || ReportCard.body
|
6
|
+
# email_options['recipient_email'] doesn't have default option here
|
7
|
+
# because it is a proc that is evaluated in ReportsController.
|
8
|
+
mail to: email_options['recipient_email'],
|
9
|
+
from: email_options['from_email'] || ReportCard.from_email,
|
10
|
+
subject: email_options['subject'] || ReportCard.subject
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
<%= @body %> <%= link_to @url, @url %>
|
@@ -4,8 +4,9 @@ module ReportCard
|
|
4
4
|
class Runner
|
5
5
|
include Sidekiq::Worker
|
6
6
|
|
7
|
-
def perform(
|
8
|
-
report = ReportCard::Report.find(
|
7
|
+
def perform(params)
|
8
|
+
report = ReportCard::Report.find(params['report_name']).new(params)
|
9
|
+
email_options = params['email_options']
|
9
10
|
|
10
11
|
tempfile = Tempfile.new(['report_card', '.csv'])
|
11
12
|
csv = CSV.open(tempfile, 'wb')
|
@@ -15,7 +16,7 @@ module ReportCard
|
|
15
16
|
uploader = ReportCard::Uploader.new
|
16
17
|
uploader.store!(csv)
|
17
18
|
|
18
|
-
ReportCard::Mailer.report(uploader.url,
|
19
|
+
ReportCard::Mailer.report(uploader.url, email_options).deliver
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
data/lib/report_card.rb
CHANGED
@@ -7,8 +7,18 @@ module ReportCard
|
|
7
7
|
self.parent_controller = 'ApplicationController'
|
8
8
|
|
9
9
|
mattr_accessor :recipient_email
|
10
|
-
self.recipient_email =
|
10
|
+
self.recipient_email = proc { 'change-me@example.com' }
|
11
11
|
|
12
12
|
mattr_accessor :from_email
|
13
13
|
self.from_email = 'change-me@example.com'
|
14
|
+
|
15
|
+
mattr_accessor :subject
|
16
|
+
self.subject = 'Your report is ready'
|
17
|
+
|
18
|
+
mattr_accessor :body
|
19
|
+
self.body = 'Download your report: '
|
20
|
+
|
21
|
+
mattr_accessor :flash_success
|
22
|
+
self.flash_success = proc { 'Generating report. It will be emailed to you.' }
|
23
|
+
|
14
24
|
end
|
data/lib/report_card/engine.rb
CHANGED
data/lib/report_card/report.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module ReportCard
|
2
2
|
class Report
|
3
|
+
attr_accessor :params
|
4
|
+
|
3
5
|
class ReportNotFound < StandardError; end
|
4
6
|
|
5
7
|
def self.all
|
@@ -18,5 +20,9 @@ module ReportCard
|
|
18
20
|
def self.exists?(name)
|
19
21
|
all.any? { |r| r.name == name }
|
20
22
|
end
|
23
|
+
|
24
|
+
def initialize(params)
|
25
|
+
self.params = params
|
26
|
+
end
|
21
27
|
end
|
22
28
|
end
|
data/lib/report_card/version.rb
CHANGED
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
2
|
+
--------------------------
|
3
|
+
ReportCardTest: test_truth
|
4
|
+
--------------------------
|
5
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
6
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
7
|
+
--------------------------
|
8
|
+
ReportCardTest: test_truth
|
9
|
+
--------------------------
|
10
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
11
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
12
|
+
--------------------------
|
13
|
+
ReportCardTest: test_truth
|
14
|
+
--------------------------
|
15
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: report_card
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Giancola
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -123,7 +123,8 @@ files:
|
|
123
123
|
- test/dummy/config/locales/en.yml
|
124
124
|
- test/dummy/config/routes.rb
|
125
125
|
- test/dummy/config/secrets.yml
|
126
|
-
- test/dummy/
|
126
|
+
- test/dummy/db/test.sqlite3
|
127
|
+
- test/dummy/log/test.log
|
127
128
|
- test/dummy/public/404.html
|
128
129
|
- test/dummy/public/422.html
|
129
130
|
- test/dummy/public/500.html
|
@@ -151,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
152
|
version: '0'
|
152
153
|
requirements: []
|
153
154
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.
|
155
|
+
rubygems_version: 2.4.5
|
155
156
|
signing_key:
|
156
157
|
specification_version: 4
|
157
158
|
summary: Write your domain-specific reporting code and let Report Card take care of
|
@@ -184,7 +185,8 @@ test_files:
|
|
184
185
|
- test/dummy/config/routes.rb
|
185
186
|
- test/dummy/config/secrets.yml
|
186
187
|
- test/dummy/config.ru
|
187
|
-
- test/dummy/
|
188
|
+
- test/dummy/db/test.sqlite3
|
189
|
+
- test/dummy/log/test.log
|
188
190
|
- test/dummy/public/404.html
|
189
191
|
- test/dummy/public/422.html
|
190
192
|
- test/dummy/public/500.html
|