query_report 1.0.24 → 1.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -34
- data/app/views/query_report/_records.html.erb +2 -3
- data/config/locales/query_report.yml +2 -1
- data/lib/query_report/column.rb +13 -1
- data/lib/query_report/filter.rb +4 -2
- data/lib/query_report/record.rb +6 -4
- data/lib/query_report/report_pdf.rb +13 -2
- data/lib/query_report/version.rb +1 -1
- metadata +45 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f68b878d9f9684f1177070150ff83b775f92be8f
|
4
|
+
data.tar.gz: bbf996f42c71bdb634d5b6e7d1dff8aa0b7987df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36ede71bbff6683aafef0af8044363445736a9e115064e0009062b6c032549a4d53a94fff86c015a75a15066b2bcb32c33dffe023228aed51d38d6c29dd1d6cd
|
7
|
+
data.tar.gz: 9732143800a552f9e5a83fbeb4d2c14fef50c55e99002908b7f5903d7a95d9af0fcec747e9943ced46275ef189a0b59247d1f77d7fdd06241240aca0b074bd80
|
data/Rakefile
CHANGED
@@ -11,43 +11,10 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
11
11
|
spec.pattern = FileList['spec/**/*_spec.rb']
|
12
12
|
end
|
13
13
|
|
14
|
-
# task :default => "spec:all"
|
15
|
-
#
|
16
|
-
# namespace :spec do
|
17
|
-
# desc "Run Tests against all ORMs"
|
18
|
-
# task :all do
|
19
|
-
# sh "bundle --quiet"
|
20
|
-
# sh "bundle exec rake spec"
|
21
|
-
# end
|
22
|
-
# end
|
23
|
-
#
|
24
|
-
# begin
|
25
|
-
# require 'rdoc/task'
|
26
|
-
#
|
27
|
-
# Rake::RDocTask.new do |rdoc|
|
28
|
-
# require 'query_report/version'
|
29
|
-
#
|
30
|
-
# rdoc.rdoc_dir = 'rdoc'
|
31
|
-
# rdoc.title = "query report #{QueryReport::VERSION}"
|
32
|
-
# rdoc.rdoc_files.include('README*')
|
33
|
-
# rdoc.rdoc_files.include('lib/**/*.rb')
|
34
|
-
# end
|
35
|
-
# rescue LoadError
|
36
|
-
# puts 'RDocTask is not supported on this VM and platform combination.'
|
37
|
-
# end
|
38
|
-
|
39
14
|
task :default => "spec:all"
|
40
|
-
gemfiles = %w(active_record_32 active_record_4)
|
15
|
+
gemfiles = %w(active_record_32 active_record_4 active_record_4_1_1)
|
41
16
|
|
42
17
|
namespace :spec do
|
43
|
-
gemfiles.each do |gemfile|
|
44
|
-
desc "Run Tests against #{gemfile}"
|
45
|
-
task gemfile do
|
46
|
-
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
|
47
|
-
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake -t spec"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
18
|
desc "Run Tests against all ORMs"
|
52
19
|
task :all do
|
53
20
|
gemfiles.each do |gemfile|
|
@@ -7,8 +7,7 @@
|
|
7
7
|
</thead>
|
8
8
|
|
9
9
|
<tbody>
|
10
|
-
<%
|
11
|
-
<% records.each do |record| %>
|
10
|
+
<% report.records_to_render.each do |record| %>
|
12
11
|
<tr>
|
13
12
|
<% report.columns.each do |column| %>
|
14
13
|
<% value = record[column.humanize]
|
@@ -27,5 +26,5 @@
|
|
27
26
|
</tbody>
|
28
27
|
</table>
|
29
28
|
<% else %>
|
30
|
-
<p
|
29
|
+
<p><%= t('query_report.no_record_found') %></p>
|
31
30
|
<% end %>
|
data/lib/query_report/column.rb
CHANGED
@@ -15,6 +15,7 @@ module QueryReport
|
|
15
15
|
# @option options [Boolean] :only_on_web the column will appear on the web and not appear in PDF, CSV or JSON if set to true
|
16
16
|
# @option options [Boolean] :sortable if set to true then sorts on that column, but if the sorting has to be on a joint table then you have to specify the column on which the sorting will happen
|
17
17
|
# @option options :rowspan the rows with same values in the same column will span if set to true
|
18
|
+
# @option options :pdf[:width] pass width of the column in the pdf
|
18
19
|
#
|
19
20
|
# @example Row span
|
20
21
|
# column :invoiced_to_name, rowspan: true
|
@@ -45,6 +46,7 @@ module QueryReport
|
|
45
46
|
# ├───────────┴────────────┼─────────────────┤
|
46
47
|
# │ Total │ 300 │
|
47
48
|
# └────────────────────────┴─────────────────┘
|
49
|
+
# The translation key used for total is 'query_report.total'
|
48
50
|
#
|
49
51
|
# @example Sorting
|
50
52
|
# column :invoice_date, sortable: true
|
@@ -54,10 +56,16 @@ module QueryReport
|
|
54
56
|
# then just set true to make the column sortable.
|
55
57
|
# If the column is from another table then you have to specify the column name.
|
56
58
|
#
|
59
|
+
# @example Pdf options
|
60
|
+
# column :invoice_date, pdf: {width: 20}
|
61
|
+
# This is how you can control the width of the column in the pdf
|
57
62
|
def column(name, options={}, &block)
|
58
63
|
@columns << Column.new(self, name, options, block)
|
59
64
|
end
|
60
65
|
|
66
|
+
# @return [Array<Hash>] the footer for the table with total with appropriate colspan and content
|
67
|
+
# Sample output
|
68
|
+
# [{content: "Total", colspan: '2'}, 200, 300]
|
61
69
|
def column_total_with_colspan
|
62
70
|
total_with_colspan = []
|
63
71
|
colspan = 0
|
@@ -108,6 +116,10 @@ module QueryReport
|
|
108
116
|
@options[:rowspan] == true || @options[:rowspan].kind_of?(Symbol)
|
109
117
|
end
|
110
118
|
|
119
|
+
def pdf_options
|
120
|
+
@options[:pdf] || {}
|
121
|
+
end
|
122
|
+
|
111
123
|
def rowspan_column_humanized
|
112
124
|
return @rowspan_column_humanized if @rowspan_column_humanized
|
113
125
|
rowspan_column_name = @options[:rowspan].kind_of?(Symbol) ? @options[:rowspan] : self.name
|
@@ -140,7 +152,7 @@ module QueryReport
|
|
140
152
|
def total
|
141
153
|
@total ||= begin
|
142
154
|
if has_total?
|
143
|
-
report.
|
155
|
+
report.records_to_render.inject(0) do |sum, r|
|
144
156
|
r = report.content_from_element(r[humanize])
|
145
157
|
r = strip_tags(r) if r.kind_of? String
|
146
158
|
sum + r.to_f
|
data/lib/query_report/filter.rb
CHANGED
@@ -55,8 +55,10 @@ module QueryReport
|
|
55
55
|
attr_reader :params, :column, :type, :comparators, :block, :options
|
56
56
|
|
57
57
|
# Initializes filter with the proper parameters
|
58
|
-
#
|
59
|
-
#
|
58
|
+
# @param params [Hash] The params from the http request
|
59
|
+
# @param column [Symbol] the name of the filter or the column name for the filter to be applied on
|
60
|
+
# @param block The block is passed for a manual query, The first param the block will receive is the query chain, and the rest is the values for that particular filter.
|
61
|
+
# @see FilterModule#filter options
|
60
62
|
def initialize(params, column, options, &block)
|
61
63
|
@params, @column, @options, @comparators, @block = params, column, options, [], block
|
62
64
|
@type = options.kind_of?(String) ? options : options[:type]
|
data/lib/query_report/record.rb
CHANGED
@@ -48,15 +48,17 @@ module QueryReport
|
|
48
48
|
@has_any_rowspan
|
49
49
|
end
|
50
50
|
|
51
|
-
def
|
52
|
-
@
|
51
|
+
def records_to_render
|
52
|
+
@records_to_render ||= map_rowspan(records)
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
56
|
-
@
|
55
|
+
def all_records_to_render
|
56
|
+
@all_records_to_render ||= map_rowspan(all_records)
|
57
57
|
end
|
58
58
|
|
59
59
|
def map_rowspan(recs)
|
60
|
+
return recs unless has_any_rowspan?
|
61
|
+
|
60
62
|
last_reset_index = @columns.select(&:rowspan?).inject({}) { |hash, column| hash[column.humanize] = 0; hash }
|
61
63
|
rowspan_column_hash = @columns.select(&:rowspan?).inject({}) { |hash, column| hash[column.humanize] = column.rowspan_column_humanized; hash }
|
62
64
|
|
@@ -60,7 +60,7 @@ module QueryReport
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def table_content_for(report)
|
63
|
-
table_items = report.
|
63
|
+
table_items = report.all_records_to_render
|
64
64
|
|
65
65
|
items = table_items.map do |item|
|
66
66
|
item_values = []
|
@@ -104,7 +104,18 @@ module QueryReport
|
|
104
104
|
font_size = options[:font_size]
|
105
105
|
header_font_size = options[:table][:header][:font_size]
|
106
106
|
pdf.move_down 10
|
107
|
-
|
107
|
+
|
108
|
+
table_options = {:row_colors => alternate_row_bg_color, :header => true, :cell_style => {:inline_format => true, :size => font_size}}
|
109
|
+
|
110
|
+
report.columns.each_with_index do |report_column, index|
|
111
|
+
width = report_column.pdf_options[:width]
|
112
|
+
if width
|
113
|
+
table_options[:column_widths] ||= {}
|
114
|
+
table_options[:column_widths].merge! index => width
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
pdf.table(items, table_options) do
|
108
119
|
row(0).style(:font_style => :bold, :background_color => header_bg_color, :size => header_font_size)
|
109
120
|
end
|
110
121
|
end
|
data/lib/query_report/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: query_report
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- A.K.M. Ashrafuzzaman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,160 +27,163 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '3'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: ransack
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0
|
39
|
+
version: '1.0'
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- - "
|
44
|
+
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0
|
46
|
+
version: '1.0'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: google_visualr
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
51
|
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
53
|
+
version: '2.0'
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
58
|
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
60
|
+
version: '2.0'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: rmagick
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.13
|
67
|
+
version: '2.13'
|
62
68
|
type: :runtime
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
72
|
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.13
|
74
|
+
version: '2.13'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: gruff
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
79
|
- - "~>"
|
74
80
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.5
|
81
|
+
version: '0.5'
|
76
82
|
type: :runtime
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
86
|
- - "~>"
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.5
|
88
|
+
version: '0.5'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: kaminari
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
86
92
|
requirements:
|
87
|
-
- - "
|
93
|
+
- - "~>"
|
88
94
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.14
|
95
|
+
version: '0.14'
|
90
96
|
type: :runtime
|
91
97
|
prerelease: false
|
92
98
|
version_requirements: !ruby/object:Gem::Requirement
|
93
99
|
requirements:
|
94
|
-
- - "
|
100
|
+
- - "~>"
|
95
101
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.14
|
102
|
+
version: '0.14'
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: prawn
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
100
106
|
requirements:
|
101
|
-
- - "
|
107
|
+
- - "~>"
|
102
108
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
109
|
+
version: '1.0'
|
104
110
|
type: :runtime
|
105
111
|
prerelease: false
|
106
112
|
version_requirements: !ruby/object:Gem::Requirement
|
107
113
|
requirements:
|
108
|
-
- - "
|
114
|
+
- - "~>"
|
109
115
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
116
|
+
version: '1.0'
|
111
117
|
- !ruby/object:Gem::Dependency
|
112
118
|
name: rake
|
113
119
|
requirement: !ruby/object:Gem::Requirement
|
114
120
|
requirements:
|
115
|
-
- - "
|
121
|
+
- - "~>"
|
116
122
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
123
|
+
version: '10.3'
|
118
124
|
type: :development
|
119
125
|
prerelease: false
|
120
126
|
version_requirements: !ruby/object:Gem::Requirement
|
121
127
|
requirements:
|
122
|
-
- - "
|
128
|
+
- - "~>"
|
123
129
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
130
|
+
version: '10.3'
|
125
131
|
- !ruby/object:Gem::Dependency
|
126
132
|
name: rspec
|
127
133
|
requirement: !ruby/object:Gem::Requirement
|
128
134
|
requirements:
|
129
|
-
- - "
|
135
|
+
- - "~>"
|
130
136
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
137
|
+
version: '2.14'
|
132
138
|
type: :development
|
133
139
|
prerelease: false
|
134
140
|
version_requirements: !ruby/object:Gem::Requirement
|
135
141
|
requirements:
|
136
|
-
- - "
|
142
|
+
- - "~>"
|
137
143
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
144
|
+
version: '2.14'
|
139
145
|
- !ruby/object:Gem::Dependency
|
140
146
|
name: rspec-mocks
|
141
147
|
requirement: !ruby/object:Gem::Requirement
|
142
148
|
requirements:
|
143
|
-
- - "
|
149
|
+
- - "~>"
|
144
150
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
151
|
+
version: '2.14'
|
146
152
|
type: :development
|
147
153
|
prerelease: false
|
148
154
|
version_requirements: !ruby/object:Gem::Requirement
|
149
155
|
requirements:
|
150
|
-
- - "
|
156
|
+
- - "~>"
|
151
157
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
158
|
+
version: '2.14'
|
153
159
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
160
|
+
name: sqlite3
|
155
161
|
requirement: !ruby/object:Gem::Requirement
|
156
162
|
requirements:
|
157
|
-
- - "
|
163
|
+
- - "~>"
|
158
164
|
- !ruby/object:Gem::Version
|
159
165
|
version: '0'
|
160
166
|
type: :development
|
161
167
|
prerelease: false
|
162
168
|
version_requirements: !ruby/object:Gem::Requirement
|
163
169
|
requirements:
|
164
|
-
- - "
|
170
|
+
- - "~>"
|
165
171
|
- !ruby/object:Gem::Version
|
166
172
|
version: '0'
|
167
173
|
- !ruby/object:Gem::Dependency
|
168
174
|
name: database_cleaner
|
169
175
|
requirement: !ruby/object:Gem::Requirement
|
170
176
|
requirements:
|
171
|
-
- - "
|
177
|
+
- - "~>"
|
172
178
|
- !ruby/object:Gem::Version
|
173
|
-
version: 1.2
|
179
|
+
version: '1.2'
|
174
180
|
type: :development
|
175
181
|
prerelease: false
|
176
182
|
version_requirements: !ruby/object:Gem::Requirement
|
177
183
|
requirements:
|
178
|
-
- - "
|
184
|
+
- - "~>"
|
179
185
|
- !ruby/object:Gem::Version
|
180
|
-
version: 1.2
|
186
|
+
version: '1.2'
|
181
187
|
description: This is a gem to help you to structure common reports of you application
|
182
188
|
just by writing in the controller
|
183
189
|
email:
|
@@ -252,4 +258,3 @@ signing_key:
|
|
252
258
|
specification_version: 4
|
253
259
|
summary: Structure you reports
|
254
260
|
test_files: []
|
255
|
-
has_rdoc:
|