stat_board 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 714d8cf51a57406f3e98bce6f897cdcfc0e9a9d7
4
+ data.tar.gz: fa217da108f3d63a92d3e7b952e15c5f8c060a8f
5
+ SHA512:
6
+ metadata.gz: f645fa8393b2eac0e327cf21bc684ae8fc9b2f343770c9b4d8f5bdd74e2f09916aa405228963e98b8c3d22ee72755dbbc52b7c75c678c879f7c8451ea4db6d63
7
+ data.tar.gz: 53320913aad40ed6d6d1c2a9ce4b722607bcc7cb685d38109ef39be9d84b48d3d3816421504fda343158f5d4be15a9c861cee3553785f01d3f7198080302b853
@@ -13,10 +13,9 @@ A simple dashboard of records created this week, this month, and all time, mount
13
13
 
14
14
  gem 'stat_board'
15
15
 
16
- 2. Mount engine (in `config/routes.rb`):
16
+ 2. Add initializer and route:
17
17
 
18
- YourApp::Application.routes.draw do
19
- mount StatBoard::Engine, :at => "/stats"
18
+ rails g stat_board:install
20
19
 
21
20
  3. Configure models (in `config/initializers/stat_board.rb`):
22
21
 
@@ -24,6 +23,12 @@ A simple dashboard of records created this week, this month, and all time, mount
24
23
 
25
24
  Models can also be listed as strings if you encounter any loading order issues.
26
25
 
26
+ ## Routing
27
+
28
+ You can access StatBoard like this:
29
+
30
+ stat_board.root_url
31
+
27
32
  ## Additonal Configuration
28
33
 
29
34
  In `config/initializers/stat_board.rb`:
@@ -41,6 +46,23 @@ In `config/initializers/stat_board.rb`:
41
46
 
42
47
  StatBoard.display_graph = true
43
48
 
49
+ 4. You may provide your own reports, just place they into `lib/stat_board/reports`. Name of report should be `*_report.rb`. For example:
50
+
51
+ # lib/stat_board/reports/day_report.rb
52
+ module StatBoard
53
+ module Reports
54
+ class DayReport < Report
55
+ def name(original_date = nil)
56
+ "Last day"
57
+ end
58
+
59
+ def scope(model)
60
+ super.where(["created_at > ?", 1.day.ago])
61
+ end
62
+ end
63
+ end
64
+ end
65
+
44
66
  ## Issues
45
67
 
46
68
  * Models can be specified as strings rather than constants
@@ -5,11 +5,7 @@ module StatBoard
5
5
  before_filter :basic_authenticate, :if => lambda { StatBoard.username && StatBoard.password }
6
6
 
7
7
  def index
8
- @reports = [
9
- Reports::OverallReport.new,
10
- Reports::MonthlyReport.new,
11
- Reports::WeeklyReport.new
12
- ]
8
+ @reports = ReportsFinder.all
13
9
  end
14
10
 
15
11
  private
@@ -0,0 +1,17 @@
1
+ module StatBoard
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ desc "creates an initializer file at config/initializers/stat_board.rb and adds StatBoard route to config/routes.rb"
5
+ source_root File.expand_path("../templates", __FILE__)
6
+
7
+ def generate_initialization
8
+ copy_file 'initializer.rb', 'config/initializers/stat_board.rb'
9
+ end
10
+
11
+ def generate_routing
12
+ route "mount StatBoard::Engine, at: 'stats'"
13
+ log "# You can access StatBoard url like this: stat_board.root_url #=> '/stats'"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1 @@
1
+ # StatBoard.models = [User, Post, Comment] # configure models
@@ -4,6 +4,7 @@ require "stat_board/reports/overall_report"
4
4
  require "stat_board/reports/monthly_report"
5
5
  require "stat_board/reports/weekly_report"
6
6
  require "stat_board/graph_helper"
7
+ require "stat_board/reports_finder"
7
8
 
8
9
  module StatBoard
9
10
  mattr_accessor :models, :title, :display_graph, :username, :password
@@ -0,0 +1,14 @@
1
+ module StatBoard
2
+ class ReportsFinder < Struct.new(:directory)
3
+ def reports
4
+ Dir[File.join(directory, "/*_report.rb")].map do |report|
5
+ "StatBoard::Reports::#{File.basename(report, ".rb").camelcase}".constantize.new
6
+ end
7
+ end
8
+
9
+ def self.all
10
+ self.new(File.join(StatBoard::Engine.root, "lib/stat_board/reports")).reports +
11
+ self.new(File.join(Rails.root, "lib/stat_board/reports")).reports
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module StatBoard
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
metadata CHANGED
@@ -1,100 +1,88 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stat_board
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
5
- prerelease:
4
+ version: 0.1.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - David Eisinger
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-05-20 00:00:00.000000000 Z
11
+ date: 2014-07-09 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 3.2.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 3.2.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: sqlite3
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec-rails
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: pry
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: launchy
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: capybara
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: capybara-webkit
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
@@ -126,49 +111,43 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: database_cleaner
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - '>='
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - '>='
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: appraisal
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - '>='
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0'
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - '>='
156
137
  - !ruby/object:Gem::Version
157
138
  version: '0'
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: rake
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ! '>='
143
+ - - '>='
164
144
  - !ruby/object:Gem::Version
165
145
  version: '0'
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
- - - ! '>='
150
+ - - '>='
172
151
  - !ruby/object:Gem::Version
173
152
  version: '0'
174
153
  description: Simple dashboard of records created this week, this month, and all time,
@@ -188,12 +167,15 @@ files:
188
167
  - app/views/stat_board/stats/_graph.html.erb
189
168
  - app/views/stat_board/stats/index.html.erb
190
169
  - config/routes.rb
170
+ - lib/generators/stat_board/install_generator.rb
171
+ - lib/generators/stat_board/templates/initializer.rb
191
172
  - lib/stat_board/engine.rb
192
173
  - lib/stat_board/graph_helper.rb
193
174
  - lib/stat_board/reports/monthly_report.rb
194
175
  - lib/stat_board/reports/overall_report.rb
195
176
  - lib/stat_board/reports/report.rb
196
177
  - lib/stat_board/reports/weekly_report.rb
178
+ - lib/stat_board/reports_finder.rb
197
179
  - lib/stat_board/version.rb
198
180
  - lib/stat_board.rb
199
181
  - lib/tasks/stat_board_tasks.rake
@@ -203,27 +185,26 @@ files:
203
185
  homepage: https://github.com/vigetlabs/stat_board
204
186
  licenses:
205
187
  - MIT
188
+ metadata: {}
206
189
  post_install_message:
207
190
  rdoc_options: []
208
191
  require_paths:
209
192
  - lib
210
193
  required_ruby_version: !ruby/object:Gem::Requirement
211
- none: false
212
194
  requirements:
213
- - - ! '>='
195
+ - - '>='
214
196
  - !ruby/object:Gem::Version
215
197
  version: '0'
216
198
  required_rubygems_version: !ruby/object:Gem::Requirement
217
- none: false
218
199
  requirements:
219
- - - ! '>='
200
+ - - '>='
220
201
  - !ruby/object:Gem::Version
221
202
  version: '0'
222
203
  requirements: []
223
204
  rubyforge_project:
224
- rubygems_version: 1.8.23.2
205
+ rubygems_version: 2.0.3
225
206
  signing_key:
226
- specification_version: 3
207
+ specification_version: 4
227
208
  summary: Simple dashboard of records created this week, this month, and all time,
228
209
  mountable as a Rails Engine.
229
210
  test_files: []