dynamic_reports 0.0.0 → 0.0.1

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.
data/README CHANGED
@@ -22,6 +22,8 @@
22
22
  First we define a report in app/reports/orders_report.rb, something like:
23
23
 
24
24
  class OrdersReport < DynamicReports::Report
25
+ title "Orders Report"
26
+ subtitle "All orders recorded in database"
25
27
  columns :total, :created_at
26
28
  end
27
29
 
@@ -47,39 +49,47 @@
47
49
 
48
50
  Note that erb is the default templating engine since it is available by default in Ruby.
49
51
 
50
- One may also surpress the default rendered styles you may specify that as an option as well:
51
-
52
- render :text => OrdersReport.on(@orders).to_html(:style => false), :layout => "application"
53
-
54
52
  Now let us extend our report definition to specify a template to use!
55
53
 
56
54
  class OrdersReport < DynamicReports::Report
55
+ title "Orders Report"
56
+ subtitle "All orders recorded in database"
57
57
  columns :total, :created_at
58
- template :orders_report
58
+
59
+ template :my_custom_template
59
60
  end
60
61
 
61
- This will look in app/views/reports/ for a template named "orders_report.html.erb" by default.
62
- If you specify :engine => :haml then it will look for "orders_report.html.haml"
62
+ This will look in app/views/reports/ for a template named "my_custom_template.html.erb" by default.
63
+ If you specify :engine => :haml then it will look for "my_custom_template.html.haml"
63
64
 
64
65
  If you happen to have your report templates in a different location you can specify this as follows:
65
66
 
66
67
  class OrdersReport < DynamicReports::Report
68
+ title "Orders Report"
69
+ subtitle "All orders recorded in database"
67
70
  columns :total, :created_at
68
- template :orders_report
71
+
72
+ template :my_custom_template
69
73
  views "app/views/admin/reports/"
70
74
  end
71
75
 
72
76
  And DynamicReports will look for the specified template in app/views/reports as well as app/views/admin/reports.
73
77
 
78
+ It is also worth pointing out that you can have as many dynamic reports in a view as you wish, simply include
79
+ each report render where desired within the view.
80
+
74
81
  == Charts
75
82
 
76
83
  Charts can be defined on a report easily. Let's say we wish to chart the total versus the item quantity sold for our Orders Report exmaple:
77
84
 
78
85
  class OrdersReport < DynamicReports::Report
86
+ title "Orders Report"
87
+ subtitle "All orders recorded in database"
79
88
  columns :total, :created_at
80
89
 
81
90
  chart :total_vs_quantity do
82
91
  columns :total, :quantity
92
+ label_column "created_at"
83
93
  end
84
94
  end
85
95
 
@@ -94,7 +104,40 @@
94
104
  * :bar
95
105
  * :pie
96
106
 
97
- Other chart types are planned.
107
+ Since DynamicReport's charts utilize the Google Chart API, you can easily extend each chart by passing a hash of chart options as part
108
+ of the block. The options are appended onto the request to the API so they should follow the Google's API commands (http://code.google.com/apis/chart/)
109
+
110
+ For example, to add min, max and average labels to the example chart, you would do something like this:
111
+
112
+ chart :total_vs_quantity, {:chxt => "r", :chxl => "0:|min|average|max"} do
113
+ columns :total, :quantity
114
+ label_column "created_at"
115
+ end
116
+
117
+ == Stylizing
118
+
119
+ The reports are, by default, stylized with an inline style sheet. The styles produce a nicely formatted grid with
120
+ a white on black header row and black on white columns with a gray border througout.
121
+
122
+ You can create your own styles by simply adding a class_name object to the report definition as such:
123
+
124
+ class OrdersReport < DynamicReports::Report
125
+ title "Orders Report"
126
+ subtitle "All orders recorded in database"
127
+ columns :total, :created_at
128
+
129
+ class_name "my_class_name"
130
+ end
131
+
132
+ This will cause DR to simply not include the inline style. From there you can customer the styles using the
133
+ following sub-classes for your class name, for example:
134
+
135
+ .my_class_name .report_title {}
136
+ .my_class_name .report_subtitle {}
137
+ .my_class_name table tr th {}
138
+ .my_class_name table tr td {}
139
+ .my_class_name .report_charts {} // all charts are displayed within this div
140
+ .my_class_name .report_chart {} // represents an individual chart
98
141
 
99
142
  == Rails Usage
100
143
 
data/gemspec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "rubygems"
2
2
 
3
3
  library="dynamic_reports"
4
- version="0.0.0"
4
+ version="0.0.1"
5
5
 
6
6
  Gem::Specification::new do |spec|
7
7
  $VERBOSE = nil
@@ -18,7 +18,7 @@ Gem::Specification::new do |spec|
18
18
  spec.email = "wayneeseguin@gmail.com, jlippiner@gmail.com"
19
19
  spec.homepage = "http://github.com/wayneeseguin/direct_reports"
20
20
  # spec.test_suite_file = "test/#{library}.rb" if File::directory?("test")
21
- #spec.add_dependency "gchartrb", ">= 0.8"
21
+ #spec.add_dependency "", ">= 0.0"
22
22
  spec.extensions << "extconf.rb" if File::exists?("extconf.rb")
23
23
  spec.rubyforge_project = library
24
24
  end
@@ -8,7 +8,7 @@ module DynamicReports
8
8
  class Report
9
9
  @@default_engine = "erb"
10
10
 
11
- attr_accessor :name, :title, :sub_title, :columns, :charts, :records, :template, :style_name, :styles
11
+ attr_accessor :name, :title, :sub_title, :columns, :charts, :records, :template, :class_name, :styles
12
12
 
13
13
  # views accessor, array of view paths.
14
14
  def views
@@ -79,13 +79,13 @@ module DynamicReports
79
79
  options[:styles] ||= false
80
80
  end
81
81
 
82
- def style_name(value = nil)
82
+ def class_name(value = nil)
83
83
  if value
84
- options[:style_name] = value
85
- elsif options[:style_name].empty?
86
- options[:style_name] = self.to_s
84
+ options[:class_name] = value
85
+ elsif options[:class_name].empty?
86
+ options[:class_name] = self.to_s
87
87
  else
88
- options[:style_name]
88
+ options[:class_name]
89
89
  end
90
90
  end
91
91
 
@@ -1,4 +1,4 @@
1
- <% if report.style_name.nil? %>
1
+ <% if report.class_name.nil? %>
2
2
  <style type="text/css">
3
3
  .dynamic_report .report_title {
4
4
  font-size:16pt;
@@ -29,7 +29,7 @@
29
29
  </style>
30
30
  <% end %>
31
31
 
32
- <div id="<%= report.style_name %>" class="dynamic_report">
32
+ <div id="<%= report.class_name %>" class="dynamic_report">
33
33
  <%= "<div class='report_title'>#{report.title}</div>" if report.title %>
34
34
  <%= "<div class='report_subtitle'>#{report.sub_title}</div>" if report.sub_title %>
35
35
  <table class="report" border="0" cellpadding="0" cellspacing="0">
@@ -1,4 +1,4 @@
1
- - if report.styles.nil?
1
+ - if report.class_name.nil?
2
2
  %style{type => "text/css"}
3
3
  \.dynamic_report .report_title {
4
4
  font-size:16pt;
@@ -26,7 +26,7 @@
26
26
  margin:15px;
27
27
  }
28
28
 
29
- .dynamic_report{ :id => report.style_name }
29
+ .dynamic_report{ :id => report.class_name }
30
30
  - if report.title
31
31
  %h2.report_title
32
32
  = report.title
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_reports
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wayne E. Seguin & Joshua Lippiner
@@ -36,7 +36,6 @@ files:
36
36
  - lib/dynamic_reports/vendor/google_chart/scatter_chart.rb
37
37
  - lib/dynamic_reports/vendor/google_chart/venn_diagram.rb
38
38
  - lib/dynamic_reports/vendor/google_chart.rb
39
- - lib/dynamic_reports/views/default_chart.html.erb
40
39
  - lib/dynamic_reports/views/default_layout.html.erb
41
40
  - lib/dynamic_reports/views/default_report.html.erb
42
41
  - lib/dynamic_reports/views/default_report.html.haml
File without changes