compendium 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +9 -1
- data/app/controllers/compendium/reports_controller.rb +22 -3
- data/config/locales/en.yml +1 -0
- data/lib/compendium/engine/mount.rb +1 -1
- data/lib/compendium/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2ZlZDg2ZDkxZjRlNjc5Yzk0OTZlYWUyYTJkNDZmMTBkNTlmNDczMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWE2NmE5MGZlZjhmNzdlOTljZWQyYmQ4NDU2NzhlZmM5MzZhMjgxNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjNkMDgzYWI0OGNkZTY4NGJmMDQxMzRjMzcyODEyOWE2MGFhZDlmOWIzMzZl
|
10
|
+
ZTQ3OGViNWQ3MGY3ZTlkOGFkMzZhNmVjNmM3NmFiMjYwMzc2MmE0YTQ2ZjBm
|
11
|
+
YzY0ODFkNzlhMzBhZTEzNDkzNTQ3OTVlZmMwZDJiOWE3NWFiYWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDk4ODU0OTJmMTU4ODA2ODViZjhlNDVjZTI2YTdlMjA4ZDY2ZGFhZWI1OWQy
|
14
|
+
ZjM4MjAxNTI2NzRkYTYxNTlhNDAxNzkxYzMwNjdhNDA4MGI3N2NhZWRlOTFm
|
15
|
+
Yjc1OWQzMzVjNWZhN2QwNGQ3YTZkMTgyZTI0NjRkMmMzNjcyNjI=
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Compendium
|
1
|
+
# Compendium [![Gem Version](https://badge.fury.io/rb/compendium.svg)](http://badge.fury.io/rb/compendium)
|
2
2
|
|
3
3
|
Ruby on Rails framework for making reporting easy.
|
4
4
|
|
@@ -68,6 +68,14 @@ within your `config/routes.rb` file
|
|
68
68
|
mount_compendium at: '/report', controller: 'reports' # controller defaults to compendium/reports
|
69
69
|
```
|
70
70
|
|
71
|
+
### Rendering report results as JSON
|
72
|
+
|
73
|
+
While the default action when running a report is to render a view with the results, Compendium reports can be rendered
|
74
|
+
as JSON. If using the default routes provided by `mount_compendium` (assuming compendium was mounted at `/report`),
|
75
|
+
`POST`ing to <code>report/<i>report_name</i>.json</code> will return the report results as JSON. You can also collect
|
76
|
+
the results of a single query (instead of the entire report) by `POST`ing to
|
77
|
+
<code>report/<i>report_name</i>/<i>query_name</i>.json</code>.
|
78
|
+
|
71
79
|
### Interaction with other gems
|
72
80
|
* If [accessible_tooltip](https://github.com/dvandersluis/accessible_tooltip) is present, option notes will be rendered
|
73
81
|
in a tooltip rather than as straight text.
|
@@ -4,6 +4,7 @@ module Compendium
|
|
4
4
|
include Compendium::ReportsHelper
|
5
5
|
|
6
6
|
before_filter :find_report
|
7
|
+
before_filter :find_query
|
7
8
|
before_filter :validate_options, only: :run
|
8
9
|
before_filter :run_report, only: :run
|
9
10
|
|
@@ -12,8 +13,16 @@ module Compendium
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def run
|
15
|
-
|
16
|
-
|
16
|
+
respond_to do |format|
|
17
|
+
format.json do
|
18
|
+
render json: @query ? @query.results : @report.results
|
19
|
+
end
|
20
|
+
|
21
|
+
format.any do
|
22
|
+
template = template_exists?(@prefix, get_template_prefixes) ? @prefix : 'run'
|
23
|
+
render action: template, locals: { report: @report }
|
24
|
+
end
|
25
|
+
end
|
17
26
|
end
|
18
27
|
|
19
28
|
private
|
@@ -32,6 +41,16 @@ module Compendium
|
|
32
41
|
end
|
33
42
|
end
|
34
43
|
|
44
|
+
def find_query
|
45
|
+
return unless params[:query]
|
46
|
+
@query = @report.queries[params[:query]]
|
47
|
+
|
48
|
+
unless @query
|
49
|
+
flash[:error] = t(:invalid_report_query)
|
50
|
+
redirect_to action: :setup, report_name: params[:report_name]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
35
54
|
def render_setup(opts = {})
|
36
55
|
locals = { report: @report, prefix: @prefix }
|
37
56
|
opts.empty? ? render(action: :setup, locals: locals) : render_if_exists(opts.merge(locals: locals)) || render(action: :setup, locals: locals)
|
@@ -46,7 +65,7 @@ module Compendium
|
|
46
65
|
end
|
47
66
|
|
48
67
|
def run_report
|
49
|
-
@report.run(self)
|
68
|
+
@report.run(self, @query ? { only: @query.name } : {})
|
50
69
|
end
|
51
70
|
|
52
71
|
def get_template_prefixes
|
data/config/locales/en.yml
CHANGED
@@ -4,7 +4,7 @@ module ActionDispatch
|
|
4
4
|
def mount_compendium(options = {})
|
5
5
|
scope options[:at], controller: options.fetch(:controller, 'compendium/reports') do
|
6
6
|
get ':report_name', action: :setup, as: 'compendium_reports_setup'
|
7
|
-
post ':report_name', action: :run, as: 'compendium_reports_run'
|
7
|
+
post ':report_name(/:query)', action: :run, as: 'compendium_reports_run'
|
8
8
|
root action: :index, as: 'compendium_reports_root'
|
9
9
|
end
|
10
10
|
end
|
data/lib/compendium/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compendium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Vandersluis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03
|
11
|
+
date: 2014-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
type: :runtime
|