dossier 2.8.0 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/app/controllers/dossier/reports_controller.rb +2 -2
- data/app/views/dossier/reports/multi.html.haml +5 -5
- data/app/views/dossier/reports/show.html.haml +1 -1
- data/lib/dossier/multi_report.rb +16 -0
- data/lib/dossier/report.rb +4 -0
- data/lib/dossier/responder.rb +11 -0
- data/lib/dossier/result.rb +16 -12
- data/lib/dossier/version.rb +1 -1
- data/spec/dossier/responder_spec.rb +1 -1
- data/spec/dossier/result_spec.rb +24 -1
- data/spec/dummy/app/reports/employee_with_custom_view_report.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +266 -46790
- data/spec/features/combination_report_spec.rb +3 -0
- data/spec/features/employee_spec.rb +8 -0
- data/spec/fixtures/db/mysql2.yml +1 -1
- data/spec/fixtures/db/mysql2.yml.example +1 -1
- metadata +3 -35
- data/spec/dummy/log/development.log +0 -4378
- data/spec/dummy/tmp/cache/assets/C35/BF0/sprockets%2F64292e0008108df585a755f2876c7869 +0 -0
- data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/CEA/5A0/sprockets%2Fc0534884cbc43494a05d9e957ea1298d +0 -0
- data/spec/dummy/tmp/cache/assets/D00/EF0/sprockets%2F4e1e8b85785ee1929c8e355c96902e9c +0 -0
- data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/D40/0D0/sprockets%2F15a6bb0a1346b6d7fe859c14bf729a49 +0 -0
- data/spec/dummy/tmp/cache/assets/D45/6A0/sprockets%2F22f3562bf7d5e640880df2a5d683f2fc +0 -0
- data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/D51/510/sprockets%2Fca0353abc266080173bbc3c13efa935a +0 -0
- data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/D6C/400/sprockets%2F7fa180a6e05c7ca4346ef58c54bb30f8 +0 -0
- data/spec/dummy/tmp/cache/assets/DCF/420/sprockets%2F9f127ea0ab7236994d1ceaa7bbea86c8 +0 -0
- data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/restart.txt +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 654b5bc958cd0b8226eb0f4048c88540fa3024db
|
4
|
+
data.tar.gz: 4dd0180bd6e67e797fc003342b13c9fbc093d138
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b53a3128c5e0042ee01621f49dc931c1f9cd5480b1b3e7a66517f8fa6b05b97797accded6927604da3e8e28ed7c3b2650b15fbab33ea120ae37c60f166985f6
|
7
|
+
data.tar.gz: a92771615847f0460bdb3fdca9e43730e9d14ccfa440b51fc73379f97964f0cf380a714620da2324a2547e11e77f0c214799397455169722e19a940a90ca3f6b
|
data/README.md
CHANGED
@@ -272,6 +272,7 @@ See the referenced gems for more documentation on using them.
|
|
272
272
|
Note: when you run the tests, Dossier will **make and/or truncate** some tables in the `dossier_test` database.
|
273
273
|
|
274
274
|
- Run `bundle`
|
275
|
+
- `RAILS_ENV=test rake db:create`
|
275
276
|
- `cp spec/dummy/config/database.yml{.example,}` and edit it so that it can connect to the test database.
|
276
277
|
- `cp spec/fixtures/db/mysql2.yml{.example,}`
|
277
278
|
- `cp spec/fixtures/db/sqlite3.yml{.example,}`
|
@@ -4,14 +4,14 @@ module Dossier
|
|
4
4
|
|
5
5
|
self.responder = Dossier::Responder
|
6
6
|
|
7
|
-
respond_to :html, :json, :csv, :xls
|
7
|
+
respond_to :html, :json, :csv, :xls
|
8
8
|
|
9
9
|
def show
|
10
10
|
respond_with(report)
|
11
11
|
end
|
12
12
|
|
13
13
|
def multi
|
14
|
-
|
14
|
+
respond_with(report)
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
@@ -1,8 +1,8 @@
|
|
1
|
-
%div{id:
|
1
|
+
%div{id: report.dom_id}
|
2
2
|
%h1.dossier-multi-header
|
3
|
-
=
|
3
|
+
= report.formatted_title
|
4
4
|
|
5
|
-
= render_options(
|
5
|
+
= render_options(report)
|
6
6
|
|
7
|
-
-
|
8
|
-
=
|
7
|
+
- report.reports.each do |r|
|
8
|
+
= r.render layout: false
|
data/lib/dossier/multi_report.rb
CHANGED
@@ -34,4 +34,20 @@ class Dossier::MultiReport
|
|
34
34
|
def dom_id
|
35
35
|
nil
|
36
36
|
end
|
37
|
+
|
38
|
+
def template
|
39
|
+
'multi'
|
40
|
+
end
|
41
|
+
|
42
|
+
def renderer
|
43
|
+
@renderer ||= Dossier::Renderer.new(self)
|
44
|
+
end
|
45
|
+
|
46
|
+
delegate :render, to: :renderer
|
47
|
+
|
48
|
+
class UnsupportedFormatError < StandardError
|
49
|
+
def initialize(format)
|
50
|
+
super "Dossier::MultiReport only supports rendering in HTML format (you tried #{format})"
|
51
|
+
end
|
52
|
+
end
|
37
53
|
end
|
data/lib/dossier/report.rb
CHANGED
data/lib/dossier/responder.rb
CHANGED
@@ -20,6 +20,11 @@ module Dossier
|
|
20
20
|
set_content_disposition!
|
21
21
|
controller.response_body = Xls.new(report.raw_results.arrays)
|
22
22
|
end
|
23
|
+
|
24
|
+
def respond
|
25
|
+
multi_report_html_only!
|
26
|
+
super
|
27
|
+
end
|
23
28
|
|
24
29
|
private
|
25
30
|
|
@@ -30,5 +35,11 @@ module Dossier
|
|
30
35
|
def filename
|
31
36
|
"#{report.class.filename}.#{format}"
|
32
37
|
end
|
38
|
+
|
39
|
+
def multi_report_html_only!
|
40
|
+
if report.is_a?(Dossier::MultiReport) and format.to_s != 'html'
|
41
|
+
raise Dossier::MultiReport::UnsupportedFormatError.new(format)
|
42
|
+
end
|
43
|
+
end
|
33
44
|
end
|
34
45
|
end
|
data/lib/dossier/result.rb
CHANGED
@@ -43,6 +43,13 @@ module Dossier
|
|
43
43
|
end
|
44
44
|
|
45
45
|
class Formatted < Result
|
46
|
+
|
47
|
+
alias :raw_headers :headers
|
48
|
+
|
49
|
+
def headers
|
50
|
+
@formatted_headers ||= super.map { |h| report.format_header(h) }
|
51
|
+
end
|
52
|
+
|
46
53
|
def each
|
47
54
|
adapter_results.rows.each { |row| yield format(row) }
|
48
55
|
end
|
@@ -52,20 +59,17 @@ module Dossier
|
|
52
59
|
raise ArgumentError.new("#{row.inspect} must be a kind of Enumerable")
|
53
60
|
end
|
54
61
|
|
55
|
-
row.each_with_index.map do |
|
56
|
-
|
57
|
-
|
58
|
-
if report.respond_to?(method_name)
|
59
|
-
|
60
|
-
# Provide the row as context if the formatter takes two arguments
|
61
|
-
if report.method(method_name).arity == 2
|
62
|
-
report.public_send(method_name, field, row_hash(row))
|
63
|
-
else
|
64
|
-
report.public_send(method_name, field)
|
65
|
-
end
|
62
|
+
row.each_with_index.map do |value, i|
|
63
|
+
column = raw_headers.at(i)
|
64
|
+
method = "format_#{column}"
|
66
65
|
|
66
|
+
if report.respond_to?(method)
|
67
|
+
args = [method, value]
|
68
|
+
# Provide the row as context if the formatter takes two arguments
|
69
|
+
args << row_hash(row) if report.method(method).arity == 2
|
70
|
+
report.public_send(*args)
|
67
71
|
else
|
68
|
-
|
72
|
+
report.format_column(column, value)
|
69
73
|
end
|
70
74
|
end
|
71
75
|
end
|
data/lib/dossier/version.rb
CHANGED
@@ -9,7 +9,7 @@ describe Dossier::Responder do
|
|
9
9
|
}
|
10
10
|
end
|
11
11
|
|
12
|
-
let(:results) {
|
12
|
+
let(:results) { double(arrays: [[]], hashes: [{}]) }
|
13
13
|
let(:report) { EmployeeReport.new }
|
14
14
|
let(:reports) { [stub_out_report_results(report)] }
|
15
15
|
let(:controller) {
|
data/spec/dossier/result_spec.rb
CHANGED
@@ -56,6 +56,13 @@ describe Dossier::Result do
|
|
56
56
|
|
57
57
|
let(:result) { Dossier::Result::Formatted.new(adapter_result, report) }
|
58
58
|
|
59
|
+
describe "headers" do
|
60
|
+
it "formats the headers by calling format_header" do
|
61
|
+
adapter_result.headers.each { |h| result.report.should_receive(:format_header).with(h) }
|
62
|
+
result.headers
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
59
66
|
describe "each" do
|
60
67
|
|
61
68
|
it "calls :each on on its adapter's results" do
|
@@ -71,11 +78,27 @@ describe Dossier::Result do
|
|
71
78
|
end
|
72
79
|
|
73
80
|
describe "format" do
|
81
|
+
let(:report) {
|
82
|
+
Class.new(Dossier::Report) {
|
83
|
+
def format_mascot(value); value.upcase; end
|
84
|
+
}.new
|
85
|
+
}
|
86
|
+
|
87
|
+
let(:row) { result_row.values }
|
74
88
|
|
75
|
-
it "
|
89
|
+
it "raises unless its argument responds to :[]" do
|
76
90
|
expect {result.format(Object.new)}.to raise_error(ArgumentError)
|
77
91
|
end
|
78
92
|
|
93
|
+
it "calls a custom formatter method if available" do
|
94
|
+
result.report.should_receive(:format_mascot).with('platapus')
|
95
|
+
result.format(row)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "calls the default format_column method otherwise" do
|
99
|
+
result.report.should_receive(:format_column).with('cheese', 'bleu')
|
100
|
+
result.format(row)
|
101
|
+
end
|
79
102
|
end
|
80
103
|
|
81
104
|
describe "footer" do
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|