meta_reports 0.0.5 → 0.1.0
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.
- checksums.yaml +4 -4
- data/README.md +26 -68
- data/app/models/meta_reports/color.rb +16 -0
- data/{lib/generators/meta_reports/templates/views/templates → app/views/meta_reports}/_default.html.erb +1 -1
- data/{lib/generators/meta_reports/templates/views/templates → app/views/meta_reports}/_default_footer.pdf.prawn +0 -0
- data/{lib/generators/meta_reports/templates/views/templates → app/views/meta_reports}/_default_header.pdf.prawn +0 -0
- data/{lib/generators/meta_reports/templates/views/templates → app/views/meta_reports}/_default_header.xlsx.axlsx +0 -0
- data/{spec/dummy/app/views/meta_reports/reports/templates → app/views/meta_reports}/_default_table.html.erb +3 -3
- data/{lib/generators/meta_reports/templates/views/templates → app/views/meta_reports}/_default_table.pdf.prawn +0 -0
- data/app/views/meta_reports/default.html.erb +1 -0
- data/app/views/meta_reports/default.pdf.prawn +37 -0
- data/{lib/generators/meta_reports/templates/views/templates → app/views/meta_reports}/default.xlsx.axlsx +1 -1
- data/lib/generators/meta_reports/install_templates_generator.rb +1 -6
- data/lib/meta_reports.rb +7 -1
- data/{app/models → lib}/meta_reports/data.rb +9 -0
- data/{app/helpers/meta_reports/reports_helper.rb → lib/meta_reports/helper.rb} +7 -6
- data/lib/meta_reports/railtie.rb +7 -0
- data/{app/models → lib}/meta_reports/table.rb +4 -0
- data/lib/meta_reports/version.rb +1 -1
- data/lib/tasks/meta_reports_tasks.rake +2 -2
- data/spec/ci.sh +1 -1
- data/spec/dummy/Rakefile +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +0 -0
- data/spec/dummy/app/controllers/application_controller.rb +0 -0
- data/spec/dummy/app/controllers/home_controller.rb +0 -0
- data/spec/dummy/app/controllers/reports_controller.rb +87 -0
- data/spec/dummy/app/helpers/application_helper.rb +0 -0
- data/spec/dummy/app/models/meta_reports/color.rb +16 -0
- data/{app/models/meta_reports/base.rb → spec/dummy/app/models/report.rb} +15 -26
- data/spec/dummy/app/views/home/index.html.erb +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +0 -0
- data/spec/dummy/app/views/meta_reports/{reports/templates/_default.html.erb → _default.html.erb} +2 -2
- data/spec/dummy/app/views/meta_reports/{reports/templates/_default_footer.pdf.prawn → _default_footer.pdf.prawn} +0 -0
- data/spec/dummy/app/views/meta_reports/{reports/templates/_default_header.pdf.prawn → _default_header.pdf.prawn} +0 -0
- data/spec/dummy/app/views/meta_reports/{reports/templates/_default_header.xlsx.axlsx → _default_header.xlsx.axlsx} +0 -0
- data/{lib/generators/meta_reports/templates/views/templates → spec/dummy/app/views/meta_reports}/_default_table.html.erb +3 -3
- data/spec/dummy/app/views/meta_reports/{reports/templates/_default_table.pdf.prawn → _default_table.pdf.prawn} +0 -0
- data/spec/dummy/app/views/meta_reports/default.html.erb +1 -0
- data/spec/dummy/app/views/meta_reports/default.pdf.prawn +37 -0
- data/spec/dummy/app/views/meta_reports/{reports/templates/default.xlsx.axlsx → default.xlsx.axlsx} +1 -1
- data/{lib/generators/meta_reports/templates/views → spec/dummy/app/views/reports}/_form.html.erb +1 -1
- data/{lib/generators/meta_reports/templates/views → spec/dummy/app/views/reports}/edit.html.erb +1 -1
- data/spec/dummy/app/views/{meta_reports/reports → reports}/forms/_form_moo.html.erb +0 -0
- data/{lib/generators/meta_reports/templates/views → spec/dummy/app/views/reports}/forms/form.html.erb +0 -0
- data/{lib/generators/meta_reports/templates/views → spec/dummy/app/views/reports}/index.html.erb +0 -0
- data/{lib/generators/meta_reports/templates/views → spec/dummy/app/views/reports}/new.html.erb +0 -0
- data/spec/dummy/config.ru +0 -0
- data/spec/dummy/config/application.rb +0 -0
- data/spec/dummy/config/boot.rb +0 -0
- data/spec/dummy/config/database.yml +0 -0
- data/spec/dummy/config/environment.rb +0 -0
- data/spec/dummy/config/environments/development.rb +0 -0
- data/spec/dummy/config/environments/production.rb +0 -0
- data/spec/dummy/config/environments/test.rb +0 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/dummy/config/initializers/inflections.rb +0 -0
- data/spec/dummy/config/initializers/mime_types.rb +0 -0
- data/spec/dummy/config/initializers/secret_token.rb +0 -0
- data/spec/dummy/config/initializers/session_store.rb +0 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/spec/dummy/config/locales/en.yml +0 -0
- data/spec/dummy/config/routes.rb +2 -1
- data/spec/dummy/config/routes_empty.rb +0 -0
- data/spec/dummy/config/routes_original.rb +0 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20130801071213_for_testing_only.rb +1 -2
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +5 -24939
- data/spec/dummy/log/test.log +3029 -0
- data/spec/dummy/public/404.html +0 -0
- data/spec/dummy/public/422.html +0 -0
- data/spec/dummy/public/500.html +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/assets/C9B/140/sprockets%2F805babf865ce32228222420a522c7b36 +0 -0
- data/spec/dummy/tmp/cache/assets/CBD/2B0/sprockets%2F9e22e937dd267c81a146665f15471b8e +0 -0
- data/spec/dummy/tmp/cache/assets/CD0/810/sprockets%2Fe858c95fa595e319dac0065d49982967 +0 -0
- data/spec/dummy/tmp/cache/assets/CD0/AC0/sprockets%2F1d341d7a2fc1328567d4b23e0809b2e2 +0 -0
- data/spec/dummy/tmp/cache/assets/CD1/A80/sprockets%2F25be813f3840b407d514e03973fbac40 +0 -0
- data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/CDC/FB0/sprockets%2F16b037c6f739184fc67a82dc140a3b83 +0 -0
- data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/D3D/EB0/sprockets%2F2d47bd3108d9abbb12c0497e36d9674d +0 -0
- data/spec/dummy/tmp/cache/assets/D40/8F0/sprockets%2F290aea2004dfecfc76f42e48970f1484 +0 -0
- data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/D61/310/sprockets%2Fc168b1c9be3e38ac1c8403a3074b5b8c +0 -0
- data/spec/dummy/tmp/cache/assets/D74/AE0/sprockets%2F9ad0425db5cfa16a9426f7b1a7958d7d +0 -0
- data/spec/dummy/tmp/cache/assets/D98/270/sprockets%2F0b7ba158ff62bbbb378d6bea80680c63 +0 -0
- data/spec/dummy/tmp/cache/assets/DDC/340/sprockets%2F8ad88a197ff3462ea8dd3ad7b1e2b7e9 +0 -0
- data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/DF1/CD0/sprockets%2F3b66bd14b91d4fb176ce0a30ab5fd9bf +0 -0
- data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/E5A/EF0/sprockets%2Fb0d5af721ea37c98fd4bccd8e1e5c6ab +0 -0
- data/spec/dummy/tmp/cache/assets/test/sass/cd99a83fa417594c8715ee09005855a11886141c/metareports_color_variables.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sass/cd99a83fa417594c8715ee09005855a11886141c/metareports_colors.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0b7ba158ff62bbbb378d6bea80680c63 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/16b037c6f739184fc67a82dc140a3b83 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1d341d7a2fc1328567d4b23e0809b2e2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/25be813f3840b407d514e03973fbac40 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/290aea2004dfecfc76f42e48970f1484 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2d47bd3108d9abbb12c0497e36d9674d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2e7ca7e84b7c22471bbca0e4504a2597 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/34d1d79bff5dc36e7f78550df20eec85 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/366f779b10b9268d7594b4833cac1629 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3b66bd14b91d4fb176ce0a30ab5fd9bf +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3f5939c6c02f0f902d77ac93858eaa55 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/76da4521ccd2724b5e04ce969514f6f7 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7d10cf1420e7efe789dd0a850b92fe72 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7f26f47a9eab416ae0e730d60088b9ef +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/805babf865ce32228222420a522c7b36 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/89b49044c6f7d85bbb660b73a9a4e181 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8ad88a197ff3462ea8dd3ad7b1e2b7e9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/9e22e937dd267c81a146665f15471b8e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b0d5af721ea37c98fd4bccd8e1e5c6ab +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e858c95fa595e319dac0065d49982967 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/capybara/capybara-201310282335386823859116.html +0 -0
- data/spec/dummy/tmp/capybara/capybara-201310282336101820292402.html +0 -0
- data/spec/dummy/tmp/capybara/capybara-201310282338439674392250.html +0 -0
- data/spec/dummy/tmp/capybara/capybara-201310282350595445887206.html +0 -0
- data/spec/dummy/tmp/capybara/capybara-201310282351429822980920.html +0 -0
- data/spec/dummy/tmp/capybara/capybara-201310282354523302677005.html +0 -0
- data/spec/features/dummy_spec.rb +8 -8
- data/spec/generators/install_templates_spec.rb +14 -14
- data/spec/models/data_spec.rb +0 -0
- data/spec/models/table_spec.rb +0 -0
- data/spec/spec_helper.rb +0 -0
- data/spec/support/utilities.rb +0 -0
- data/spec/tasks/meta_reports_rake_spec.rb +0 -1
- metadata +82 -76
- data/app/assets/images/meta_reports/print.png +0 -0
- data/app/assets/images/meta_reports/spreadsheet.png +0 -0
- data/app/assets/javascripts/meta_reports/reports.js +0 -2
- data/app/controllers/meta_reports/application_controller.rb +0 -4
- data/config/routes.rb +0 -11
- data/db/migrate/20130801071213_create_meta_reports_reports.rb +0 -17
- data/lib/generators/meta_reports/install_engine_generator.rb +0 -44
- data/lib/generators/meta_reports/templates/controllers/reports_controller.rb +0 -91
- data/lib/generators/meta_reports/templates/models/report.rb +0 -35
- data/lib/generators/meta_reports/templates/models/report_non_activerecord.rb +0 -35
- data/lib/generators/meta_reports/templates/views/forms/_form_example.html.erb +0 -1
- data/lib/generators/meta_reports/templates/views/templates/default.html.erb +0 -1
- data/lib/generators/meta_reports/templates/views/templates/default.pdf.prawn +0 -28
- data/lib/meta_reports/engine.rb +0 -15
- data/spec/dummy/app/controllers/meta_reports/reports_controller.rb +0 -91
- data/spec/dummy/app/models/meta_reports/report.rb +0 -34
- data/spec/dummy/app/views/meta_reports/reports/_form.html.erb +0 -61
- data/spec/dummy/app/views/meta_reports/reports/edit.html.erb +0 -6
- data/spec/dummy/app/views/meta_reports/reports/forms/form.html.erb +0 -17
- data/spec/dummy/app/views/meta_reports/reports/index.html.erb +0 -36
- data/spec/dummy/app/views/meta_reports/reports/new.html.erb +0 -5
- data/spec/dummy/app/views/meta_reports/reports/templates/default.html.erb +0 -1
- data/spec/dummy/app/views/meta_reports/reports/templates/default.pdf.prawn +0 -26
- data/spec/generators/install_engine_spec.rb +0 -61
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2db489ddaeda429073c17f55d72bbbaa8c8cdda5
|
|
4
|
+
data.tar.gz: 72dc2ba6d4bc8d0408e2521190ff11eceb46148e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 24af0db7ad1a94e4c8d713979bd86296c4eeb7cdf4773db2aab413cb19e44d63e55353f258e1ac185b1ac93a6c59849e85c65e0a13bc63411fa01a326bd909f3
|
|
7
|
+
data.tar.gz: 6c5f63fc7c69e6faf7c7b6fd6f12b7d5c5ba92efe7e85ed923b06798f101a0292da82fd66e18881ec583236ef1e90e0be72530c8e95409821c39035a2b1fb26a
|
data/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
##Description
|
|
10
10
|
|
|
11
|
-
**MetaReports**
|
|
11
|
+
**MetaReports** provides [Rails](https://github.com/rails/rails) classes and templates for reports. It provides a common metadata structure that can be passed to the desired template format. If your report does not fit within the metadata convention it is very easy to create specific templates.
|
|
12
12
|
|
|
13
13
|
MetaReports exports to HTML, PDF, and XLSX formats. [More are to come](#todo).
|
|
14
14
|
|
|
@@ -16,26 +16,11 @@ MetaReports exports to HTML, PDF, and XLSX formats. [More are to come](#todo).
|
|
|
16
16
|
|
|
17
17
|
##Provides
|
|
18
18
|
|
|
19
|
-
-
|
|
19
|
+
- Data models for holding template data.
|
|
20
20
|
- Default views for all formats, that expect a title, subtitle, description, and one or more tables of data.
|
|
21
|
-
-
|
|
21
|
+
- Provides a [common color mechanism](#colors) to style rows and cells
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
###Templates / data structures only
|
|
26
|
-
|
|
27
|
-
There is a generator that [installs templates only](#install-templates-only). Then you can use the data structures and templates in whatever way you see fit as you write your own controllers / reports.
|
|
28
|
-
|
|
29
|
-
###Rails engine
|
|
30
|
-
|
|
31
|
-
The MetaReports engine is avowedly fat model. It is also ActiveRecord based. This could change if a better way makes sense.
|
|
32
|
-
|
|
33
|
-
- **Fat model:** All reports are class methods in the MetaReports::Report class. This allows one to generate reports in various contexts without creating an instance (e.g. a mailer.) The reports themselves are meant to be pure data without formatting, except for class names, and html cell content if that is needed.
|
|
34
|
-
- **ActiveRecord:** Right now a database record is required in addition to the class method. So far this is for convenience in listing available reports and handling permissions. Someday, the code for a report might also be stored in a database, or an abstract description of a report with a web based query builder could be implemented.
|
|
35
|
-
|
|
36
|
-
###Thoughts on REST
|
|
37
|
-
|
|
38
|
-
The class names / html content may broken out into helpers or a decorator pattern or something else in the future. It is difficult to think of a useful generic way to specify HTML content (e.g. an HTML link within a paragraph of text) outside of the report method itself. A reports controller already breaks strict REST ideology (where does a report belong that combines 5 models?) and unnecessary work for an ideology does not help create a useful tool.
|
|
23
|
+
*Note:* Before 0.1.0 MetaReports provided an engine that served reports. The engine has been dropped. Look at the rspec/dummy app for one approach to serving reports.
|
|
39
24
|
|
|
40
25
|
##Usage
|
|
41
26
|
|
|
@@ -45,59 +30,26 @@ Add meta_reports your Gemfile:
|
|
|
45
30
|
|
|
46
31
|
```ruby
|
|
47
32
|
gem 'meta_reports'
|
|
33
|
+
gem 'prawn-table' # if you are using the latest prawn, table is not included
|
|
48
34
|
```
|
|
49
35
|
|
|
50
36
|
Run the `bundle` command to install it.
|
|
51
37
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
1. Install the templates, partials, helpers, and models only. No ActiveRecord is used.
|
|
55
|
-
2. Install and mount the engine. In addition to the above, you will have a controller,
|
|
56
|
-
additional templates for creating forms, and an ActiveRecord model.
|
|
57
|
-
|
|
58
|
-
####Install templates only
|
|
59
|
-
|
|
60
|
-
After installing the gem, run the generator:
|
|
38
|
+
Install the templates:
|
|
61
39
|
|
|
62
|
-
rails generate meta_reports:install_templates
|
|
40
|
+
bundle exec rails generate meta_reports:install_templates
|
|
63
41
|
|
|
64
|
-
This copies over the meta_reports
|
|
42
|
+
This copies over the meta_reports color model and the templates:
|
|
65
43
|
|
|
66
|
-
- `app/models/meta_reports/
|
|
67
|
-
- `app/
|
|
68
|
-
- `app/models/meta_reports/table.rb`: The MetaReports::Table model for storing options and table data.
|
|
69
|
-
- `app/models/meta_reports/report.rb`: The MetaReports::Report model for storing colors and, if you wish, report methods.
|
|
70
|
-
- `app/helpers/meta_reports/reports_helper.rb`: MetaReports helper methods.
|
|
71
|
-
- `app/views/meta_reports/reports/templates/*`: All templates.
|
|
44
|
+
- `app/models/meta_reports/color.rb`: The MetaReports::Color model for storing colors.
|
|
45
|
+
- `app/views/meta_reports/*`: All templates.
|
|
72
46
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
After installing the gem, run the generator:
|
|
76
|
-
|
|
77
|
-
rails generate meta_reports:install_engine
|
|
78
|
-
|
|
79
|
-
This copies over the meta_reports migration, model, views, and controller:
|
|
80
|
-
|
|
81
|
-
- `db/migrate/<timestamp>_create_meta_reports_reports.rb`
|
|
82
|
-
- `app/models/meta_reports/report.rb`
|
|
83
|
-
- `app/controllers/meta_reports/reports_controller.rb`
|
|
84
|
-
- `app/views/meta_reports/reports/*`
|
|
85
|
-
|
|
86
|
-
Run the migration:
|
|
87
|
-
|
|
88
|
-
rake db:migrate
|
|
89
|
-
|
|
90
|
-
Add authentication/authorization to the reports controller if desired.
|
|
47
|
+
Now create a data structure using MetaReports::Data and MetaReports::Table, and pass it off to the default templates.
|
|
91
48
|
|
|
92
49
|
###Writing a report
|
|
93
50
|
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
- Render it using the default templates, or any template of your own.
|
|
97
|
-
- With the engine installed:
|
|
98
|
-
- Write the data method using a static method in the `app/models/meta_reports/report.rb` model. The method should accept the params hash as its single argument. It should return the data in the form of a MetaReports::Data object or a hash.
|
|
99
|
-
- Create a new report record using the reports page. The name must match the data method name.
|
|
100
|
-
- If not using the default templates, write your own templates.
|
|
51
|
+
- Use the models and helper methods to create report data.
|
|
52
|
+
- Render it using the default templates, or any template of your own.
|
|
101
53
|
|
|
102
54
|
###MetaData
|
|
103
55
|
|
|
@@ -112,6 +64,8 @@ The key component of MetaReports is the metadata format. This allows you to writ
|
|
|
112
64
|
- **page_orientation:** :landscape or :portrait. Used on PDF and XLSX formats.
|
|
113
65
|
- **page_margin:** The page margin in pixels (72/inch), in single number or four value array format (top, right, bottom, left.) Used on PDF and XLSX formats. Specify XLSX header/footer margins by specifying a 5th and 6th value respectively.
|
|
114
66
|
- **page_size:** The page size. Used on the PDF format. See the [Prawn documentation](http://prawn.majesticseacreature.com/docs/0.11.1/Prawn/Document/PageGeometry.html).
|
|
67
|
+
- **tables_blank:** What to display if the report has no tables. Defaults to 'No data found'.
|
|
68
|
+
- **conclusion:** Text to display below all tables.
|
|
115
69
|
|
|
116
70
|
- **Table:** A MetaReports::Table instance, which is a thinly wrapped two dimensional array of cells.
|
|
117
71
|
- **options:** The options for the whole table. If you are using a plain array, this hash must be the last item in the table.
|
|
@@ -151,11 +105,11 @@ Here is a simple example. See the [example class](spec/dummy/app/models/meta_rep
|
|
|
151
105
|
|
|
152
106
|
###Colors
|
|
153
107
|
|
|
154
|
-
There is currently an incomplete implementation of shared colors.
|
|
108
|
+
There is currently an incomplete implementation of shared colors. Define your colors by name in the MetaReports::Color class in the COLORS hash constant. If a table row or cell contains a corresponding class name it will have that color in HTML and PDF. XLSX support is planned. It is also intended to implement a means of specifying cell text color.
|
|
155
109
|
|
|
156
110
|
#### Declaring Colors
|
|
157
111
|
|
|
158
|
-
Specify colors using the COLORS hash
|
|
112
|
+
Specify colors using the COLORS hash constant in your MetaReports::Report class. An example COLORS hash is below:
|
|
159
113
|
|
|
160
114
|
```ruby
|
|
161
115
|
COLORS = {
|
|
@@ -185,10 +139,16 @@ Note the row number begins with zero, and excludes the header if enabled.
|
|
|
185
139
|
|
|
186
140
|
#### Inline CSS
|
|
187
141
|
|
|
188
|
-
MetaReports defaults to inline styling for HTML.
|
|
142
|
+
MetaReports defaults to inline styling for HTML. You can use the rake task to create a CSS stylesheet with corresponding colors and class names. Each table must have inline_css set to false for this to occur:
|
|
189
143
|
|
|
190
144
|
```ruby
|
|
191
|
-
MetaReports::
|
|
145
|
+
MetaReports::Data.new do |d|
|
|
146
|
+
d.title = 'Class based row/cell background colors'
|
|
147
|
+
d.tables["Table 1"] = MetaReports::Table.new do |t|
|
|
148
|
+
t << %w{One simple row}
|
|
149
|
+
t.inline_css = false
|
|
150
|
+
end
|
|
151
|
+
end
|
|
192
152
|
```
|
|
193
153
|
|
|
194
154
|
#### Export SCSS / CSS
|
|
@@ -239,11 +199,11 @@ To export only the colors file, use the `meta_reports:export_colors_only` Rake t
|
|
|
239
199
|
- Expand common colors to spreadsheets, and enable coloring of text / individual cells
|
|
240
200
|
- Charts based on table data
|
|
241
201
|
- More formats (e.g. csv, json, text)
|
|
242
|
-
- Direct to email / print (using IPP) / fax
|
|
243
202
|
- Improved metadata conventions
|
|
244
203
|
|
|
245
204
|
##Changelog
|
|
246
205
|
|
|
206
|
+
- **0.1.0:** (09/08/14) Drop engine. Just models / templates. Breaking change if you were using the engine.
|
|
247
207
|
- **0.0.5:** (11/16/13) Simplify color handling, color individual cells
|
|
248
208
|
- **0.0.4:** (10/7/13) Colors rake task
|
|
249
209
|
- **0.0.3:** (10/7/13) Template/model/helper generator
|
|
@@ -254,8 +214,6 @@ To export only the colors file, use the `meta_reports:export_colors_only` Rake t
|
|
|
254
214
|
|
|
255
215
|
Fork the project on [github](https://github.com/straydogstudio/meta_reports 'straydogstudio / MetaReports on Github'), edit away, and pull.
|
|
256
216
|
|
|
257
|
-
### Rspec, and generator testing
|
|
258
|
-
|
|
259
217
|
##Authors, License and Stuff
|
|
260
218
|
|
|
261
219
|
Code by [Noel Peden](http://straydogstudio.com) and released under [MIT license](http://www.opensource.org/licenses/mit-license.php).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class MetaReports::Color
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Shared colors. The key is the class name, value is RGB in hex format
|
|
5
|
+
#
|
|
6
|
+
# Example: "highlight: 'ffcccc'" is 'tr.highlight {background: #ffcccc}' in CSS, and "$highlight: #ffcccc;"" as a SASS variable.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
COLORS = {
|
|
10
|
+
even: 'efefef',
|
|
11
|
+
odd: 'ffffff',
|
|
12
|
+
yellow: ['ffffaa', 'ffffcc', 'f9f9a4', 'f9f9c6'],
|
|
13
|
+
highlight: '$yellow_1 !important',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
end
|
|
@@ -17,7 +17,7 @@ report = @report if defined?(report).nil?
|
|
|
17
17
|
<%
|
|
18
18
|
table_names = report[:table_order] || report[:tables].keys.sort_by {|k| k.to_s}
|
|
19
19
|
table_names.each do |table_name| %>
|
|
20
|
-
<%= render partial: 'meta_reports/
|
|
20
|
+
<%= render partial: 'meta_reports/default_table', locals: {table_name: table_name, table: report[:tables][table_name]} %>
|
|
21
21
|
<% end %>
|
|
22
22
|
<% end %>
|
|
23
23
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -6,12 +6,12 @@ table_class = table.options[:table_class].to_s if !defined?(table_class) || tabl
|
|
|
6
6
|
<div class='list_container'>
|
|
7
7
|
<%= content_tag(:table, :class => "table table-condensed #{table_class}") do %>
|
|
8
8
|
<% unless @report[:table_header] == false %>
|
|
9
|
-
<%= content_tag(:thead, content_tag(:tr, table.to_a.shift.map { |h| html_cell(h, :th)}.join.html_safe ) ) %>
|
|
9
|
+
<%= content_tag(:thead, content_tag(:tr, table.to_a.shift.map { |h| html_cell(h, tag: :th, inline_css: table.options[:inline_css])}.join.html_safe ) ) %>
|
|
10
10
|
<% end %>
|
|
11
11
|
<tbody>
|
|
12
12
|
<% table.to_a.each_with_index do |row, i|
|
|
13
13
|
style = nil
|
|
14
|
-
if
|
|
14
|
+
if table[:inline_css] && row_classes[i]
|
|
15
15
|
color = nil
|
|
16
16
|
row_classes[i].split(/\s+/).each do |token|
|
|
17
17
|
if color = meta_report_color(token)
|
|
@@ -24,7 +24,7 @@ table_class = table.options[:table_class].to_s if !defined?(table_class) || tabl
|
|
|
24
24
|
%>
|
|
25
25
|
<%= content_tag(:tr, class: row_classes[i], style: style) do
|
|
26
26
|
row.each do |cell|
|
|
27
|
-
%><%= html_cell(cell) %><%
|
|
27
|
+
%><%= html_cell(cell, inline_css: table.options[:inline_css]) %><%
|
|
28
28
|
end
|
|
29
29
|
end %>
|
|
30
30
|
<% end %>
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= render 'meta_reports/default', report: (defined?(report).nil? ? @report : report) %>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
@reports ||= [@report]
|
|
2
|
+
@report ||= @reports.first
|
|
3
|
+
margin = @report[:page_margin] && [*@report[:page_margin]][0,4] || nil
|
|
4
|
+
prawn_document(page_layout: @report[:page_orientation] || :portrait, page_size: @report[:page_size] || 'LETTER', margin: margin) do |pdf|
|
|
5
|
+
|
|
6
|
+
@reports.each do |report|
|
|
7
|
+
unless report == @report
|
|
8
|
+
margin = report[:page_margin] && [*report[:page_margin]][0,4] || nil
|
|
9
|
+
pdf.start_new_page layout: report[:page_orientation] || :portrait, size: report[:page_size] || 'LETTER', margin: margin
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
render :partial => "meta_reports/default_header", :locals => { :pdf => pdf, :title => report[:title], :subtitle => report[:subtitle] }
|
|
13
|
+
pdf.font_size = report[:font_size] || 8
|
|
14
|
+
if report[:description]
|
|
15
|
+
pdf.move_up 5
|
|
16
|
+
pdf.text strip_tags(report[:description]), align: :center
|
|
17
|
+
pdf.move_down 15
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
table_names = report[:table_order] || report[:tables].keys.sort_by {|k| k.to_s}
|
|
21
|
+
table_names.each do |table_name|
|
|
22
|
+
table = report[:tables][table_name]
|
|
23
|
+
pdf.pad_bottom(25) do
|
|
24
|
+
if table[:group]
|
|
25
|
+
pdf.group do #if the table is larger than a page this will throw an error
|
|
26
|
+
render :partial => 'meta_reports/default_table', :locals => {:pdf => pdf, :title => table_name, :table => table}
|
|
27
|
+
end
|
|
28
|
+
else
|
|
29
|
+
render :partial => 'meta_reports/default_table', :locals => {:pdf => pdf, :title => table_name, :table => table}
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
render partial: "meta_reports/default_footer", locals: { pdf: pdf }
|
|
35
|
+
|
|
36
|
+
end #each report
|
|
37
|
+
end #prawn document
|
|
@@ -12,7 +12,7 @@ wb.add_worksheet(name: @report[:title][0,31].gsub(/[:\/]/,'-'), page_margins: co
|
|
|
12
12
|
columns = first_table.blank? ? 12 : first_table.first.length
|
|
13
13
|
last_column = to_xls_col(columns)
|
|
14
14
|
|
|
15
|
-
render :partial => "meta_reports/
|
|
15
|
+
render :partial => "meta_reports/default_header", :locals => { :sheet => sheet, :title => @report[:title], :subtitle => @report[:subtitle], :columns => columns, :styles => styles }
|
|
16
16
|
if @report[:description]
|
|
17
17
|
sheet.add_row [@report[:description]]
|
|
18
18
|
this_rows = sheet.rows.length
|
|
@@ -9,15 +9,10 @@ module MetaReports
|
|
|
9
9
|
|
|
10
10
|
def install_models
|
|
11
11
|
directory "app/models/meta_reports", "app/models/meta_reports"
|
|
12
|
-
copy_file "lib/generators/meta_reports/templates/models/report_non_activerecord.rb", "app/models/meta_reports/report.rb"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def install_helper
|
|
16
|
-
copy_file "app/helpers/meta_reports/reports_helper.rb", "app/helpers/meta_reports/reports_helper.rb"
|
|
17
12
|
end
|
|
18
13
|
|
|
19
14
|
def install_views
|
|
20
|
-
directory "
|
|
15
|
+
directory "app/views/meta_reports", "app/views/meta_reports"
|
|
21
16
|
end
|
|
22
17
|
end
|
|
23
18
|
end
|
data/lib/meta_reports.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
class MetaReports::Data
|
|
2
2
|
def initialize
|
|
3
3
|
@hash = {tables: {}}
|
|
4
|
+
@id = rand(10000)
|
|
4
5
|
yield self if block_given?
|
|
5
6
|
self
|
|
6
7
|
end
|
|
@@ -24,10 +25,18 @@ class MetaReports::Data
|
|
|
24
25
|
@hash[key] = value
|
|
25
26
|
end
|
|
26
27
|
|
|
28
|
+
def id
|
|
29
|
+
@hash[:id] || @hash[:title].to_s.downcase.gsub(/[^a-z]/,'_') || @id
|
|
30
|
+
end
|
|
31
|
+
|
|
27
32
|
def tables
|
|
28
33
|
@hash[:tables]
|
|
29
34
|
end
|
|
30
35
|
|
|
36
|
+
def tables=(value)
|
|
37
|
+
@hash[:tables] = value
|
|
38
|
+
end
|
|
39
|
+
|
|
31
40
|
def to_h
|
|
32
41
|
@hash
|
|
33
42
|
end
|
|
@@ -3,7 +3,6 @@ module MetaReports
|
|
|
3
3
|
def meta_report_color(klass, row = 0)
|
|
4
4
|
@meta_reports_colors ||= {}
|
|
5
5
|
@meta_reports_colors[klass.to_sym] ||= begin
|
|
6
|
-
Rails.logger.info "getting color"
|
|
7
6
|
color = MetaReports::Report::COLORS[klass.to_sym]
|
|
8
7
|
return nil unless color
|
|
9
8
|
if color.is_a? Array
|
|
@@ -33,11 +32,13 @@ module MetaReports
|
|
|
33
32
|
page_margins
|
|
34
33
|
end
|
|
35
34
|
|
|
36
|
-
def html_cell(cell,
|
|
35
|
+
def html_cell(cell, options = {})
|
|
36
|
+
tag = options[:tag] || :td
|
|
37
|
+
options[:inline_css].nil? && options[:inline_css] = true
|
|
37
38
|
if cell.is_a? Hash
|
|
38
39
|
tags = cell.reject {|k,v| k == :content || k == :html}
|
|
39
|
-
tags[:class] ||=
|
|
40
|
-
if
|
|
40
|
+
tags[:class] ||= options[:default_class]
|
|
41
|
+
if options[:inline_css]
|
|
41
42
|
color = nil
|
|
42
43
|
tags[:class].split(/\s+/).each do |token|
|
|
43
44
|
if color = meta_report_color(token)
|
|
@@ -49,7 +50,7 @@ module MetaReports
|
|
|
49
50
|
content_tag tag, (cell[:html] || cell[:content]).to_s.html_safe, tags
|
|
50
51
|
elsif cell.is_a? Array
|
|
51
52
|
else
|
|
52
|
-
content_tag
|
|
53
|
+
content_tag(tag, cell, :class => options[:default_class])
|
|
53
54
|
end
|
|
54
55
|
end
|
|
55
56
|
|
|
@@ -143,7 +144,7 @@ module MetaReports
|
|
|
143
144
|
end
|
|
144
145
|
else
|
|
145
146
|
content_tag :span do
|
|
146
|
-
link_to title,
|
|
147
|
+
link_to title, report
|
|
147
148
|
end
|
|
148
149
|
end
|
|
149
150
|
end
|
data/lib/meta_reports/version.rb
CHANGED
|
@@ -17,7 +17,7 @@ namespace :meta_reports do
|
|
|
17
17
|
FileUtils.mkdir_p "app/assets/stylesheets/lib"
|
|
18
18
|
File.open("app/assets/stylesheets/lib/metareports_color_variables.scss", "w") do |f|
|
|
19
19
|
printfl "\tVariables: "
|
|
20
|
-
MetaReports::
|
|
20
|
+
MetaReports::Color::COLORS.each do |klass, value|
|
|
21
21
|
printfl "."
|
|
22
22
|
klass = klass.to_s
|
|
23
23
|
if value.is_a? Array
|
|
@@ -38,7 +38,7 @@ namespace :meta_reports do
|
|
|
38
38
|
File.open("app/assets/stylesheets/lib/metareports_colors.scss", "w") do |f|
|
|
39
39
|
f.puts "@import 'metareports_color_variables.scss';"
|
|
40
40
|
print "\tCSS classes: "
|
|
41
|
-
MetaReports::
|
|
41
|
+
MetaReports::Color::COLORS.each do |klass, color|
|
|
42
42
|
printfl "."
|
|
43
43
|
#for now, colors are simply row colors
|
|
44
44
|
#css_klass = klass.to_s.gsub(/___/,' ').gsub(/__/,'#').gsub(/_/,'.').gsub(/--/,':')
|
data/spec/ci.sh
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env sh
|
|
2
|
-
cd spec/dummy && bundle install --without debug && bundle exec rake db:create && bundle exec rake db:migrate && cd ../../ && bundle exec rspec spec
|
|
2
|
+
cd spec/dummy && echo "bundle install" && bundle install --without debug && echo "rake db:create" && bundle exec rake db:create && echo "rake db:migrate" && bundle exec rake db:migrate && rm -rf app/models/meta_reports/color.rb app/views/meta_reports && bundle exec rails g meta_reports:install_templates && cd ../../ && echo "rspec spec" && bundle exec rspec spec
|
data/spec/dummy/Rakefile
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|