jreport 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +110 -2
  3. data/lib/jreport/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13a854b04a3b9240cd9fc051d785141d262386ab
4
- data.tar.gz: e6738161d7360bc1acef6fb891e933a216dc2a33
3
+ metadata.gz: 7fd100b4fe07ebef2ac618b7d30ee9b7ef774001
4
+ data.tar.gz: 544b7008fdb377868d44dedb374c3994dd1a4ace
5
5
  SHA512:
6
- metadata.gz: 2ddeb812ef9797b66b43403024cb23ec16228ec20a6f33967af0b5bc9b95fa823a414d3ebedebbeb5c3a03acbee62367d6a1b2845632a2c5c892cdbfe700b2f5
7
- data.tar.gz: 898ddbe8aa50a6f69b4f708cd569aea8ee9967610b86efcf992dbec0e71eea738340529bbebcd051153e38cf2c501438488bf183a07d9f960337c7d8f3606140
6
+ metadata.gz: 72af3b3590020e478a4cde999a3e446efbbf4ad310c4c7a9b90659d5e2d90caadb990ee8cc6042bd3a48c2653aea4eafefd149c2b932f31d1498da8f1b04ce80
7
+ data.tar.gz: dcfb92b92147206d2ca0c2660900611e5f710c5d98988d48bb92825bf2793d5e3f34bca3db5c731c6d4eed92656d94da7070c945aa92d96036676a3886d9bf38
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Jreport
2
2
 
3
- TODO: Write a gem description
3
+ Jreport is used for the scenerio: collect and sort data, then make a report and send to someone. With jreport, you can focus on how to collect and sort data, and jreort would merge the data to the html template you design, then it will send the report to someoen you specfic. If you're a rails developer, you would get started quickly.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,115 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ ### Create a jreport project
22
+
23
+ jreport new example
24
+
25
+ The project looks like:
26
+
27
+ example
28
+ ├── Gemfile
29
+ ├── boot.rb
30
+ ├── collectors
31
+ ├── config
32
+ ├── controllers
33
+ ├── db
34
+ │   ├── connection.rb
35
+ │   ├── database.yml
36
+ │   └── migrate
37
+ ├── helpers
38
+ ├── models
39
+ ├── rakefile
40
+ └── views
41
+
42
+ ### Create a jreport scaffold
43
+
44
+ jreport generate scaffold weather daily weekly
45
+
46
+ Command above means we will collect some weather data, then we would use this data to produce two report: a daily report and a weekly report.
47
+
48
+ #### Collector
49
+
50
+ Check the project folder, this command create weather_collector.rb in collectors folder, the WeatherCollector class contains a method fetch_data.
51
+ You'd better return the data with the method.
52
+ For example:
53
+
54
+ class WeatherCollector
55
+ def fetch_data
56
+ #TODO: add code here
57
+ [1,2,3,4]
58
+ end
59
+ end
60
+
61
+ You can return any ruby object, only if you know what it is.
62
+ Besides, if you use active-record to store the data you get, you can even return nothing here.
63
+
64
+ #### Controller
65
+
66
+ Below the controllers folder, jreport create weather_controller.rb, with the last two arguments of 'jreport generate scaffold' command, WeatherController has two methods: daily_report and weekly_report. In this method, you can filter the data as you like(with data and data= method).
67
+
68
+ But it's important to specify email configurations(from,to,subject). You can use options to cover this.
69
+
70
+ And you can save final html string to 'save_to'.
71
+
72
+ class WeatherController
73
+ # The method looks like xxx_report would be used to generate report
74
+ def daily_report
75
+ # TODO: add code here
76
+ self.data=self.data.first
77
+ self.options['from']='from@example.com'
78
+ self.options['to']='to@example.com'
79
+ self.options['subject']='example daily report'
80
+ end
81
+ def weekly_report
82
+ # TODO: add code here
83
+ self.options['from']='from@example.com'
84
+ self.options['to']='to@example.com'
85
+ self.options['subject']='example weekly report'
86
+
87
+ self.save_to='/home/jreport/example_w.html'
88
+ end
89
+ end
90
+
91
+ #### View
92
+
93
+ In views folder, there is a folder weather contains 4 files. File daily_report.eruby and daily_report.css for the daily report, the other two are for weekly report.
94
+
95
+ You can complete a beautiful template accroding to erubis grammar, and the css code should be put into *.css file.
96
+
97
+ This is a simple weekly report template:
98
+
99
+ <h1>weekly</h1>
100
+ <%= data %>
101
+
102
+ Note: in the template you can use helper method that is defined in helpers folder. You can access the active record classes, too.
103
+ ### Gnerate report
104
+
105
+ jreport make weather
106
+
107
+ Then jreport would send two email: daily report and weekly report.
108
+
109
+ ### Use active record
110
+
111
+ Create active record is similar to rails:
112
+
113
+ jreport generate model man name:string
114
+
115
+ That create a migration file under db/migrate and a class file under models.
116
+
117
+ You can migrate db changes:
118
+
119
+ rake db:migrate
120
+
121
+ P.S. See all available rake command:
122
+
123
+ rake -T
124
+
125
+
126
+ ### Others
127
+
128
+ * Email detail configurations, please check [mail](https://github.com/mikel/mail).
129
+ * View template details, please check [erubis](https://github.com/genki/erubis).
22
130
 
23
131
  ## Contributing
24
132
 
@@ -1,3 +1,3 @@
1
1
  module Jreport
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jreport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - qjpcpu