stat_board 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ module StatBoard
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,15 @@
1
+ require_dependency "stat_board/application_controller"
2
+
3
+ module StatBoard
4
+ class StatsController < ApplicationController
5
+ before_filter :basic_authenticate, :if => lambda { StatBoard.username && StatBoard.password }
6
+
7
+ private
8
+
9
+ def basic_authenticate
10
+ authenticate_or_request_with_http_basic do |name, password|
11
+ name == StatBoard.username && password == StatBoard.password
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= StatBoard.title || "StatBoard" %></title>
5
+ <%= stylesheet_link_tag "stat_board/bootstrap", :media => "all" %>
6
+ <%= csrf_meta_tags %>
7
+ </head>
8
+ <body>
9
+
10
+ <div class="container">
11
+ <div class="page-header">
12
+ <h1><%= StatBoard.title || "StatBoard" %></h1>
13
+ </div>
14
+
15
+ <%= yield %>
16
+ </div>
17
+
18
+ </body>
19
+ </html>
@@ -0,0 +1,18 @@
1
+ <div id="<%= title.downcase.gsub(" ", "-") %>" class="span4">
2
+ <table class="table table-striped">
3
+ <thead>
4
+ <tr>
5
+ <th colspan="2"><%= title %></th>
6
+ </tr>
7
+ </thead>
8
+
9
+ <tbody>
10
+ <% StatBoard.models.each do |model| %>
11
+ <tr>
12
+ <td class="span2"><%= model.to_s.pluralize %></td>
13
+ <td class="span2"><%= scope[model].count %></td>
14
+ </tr>
15
+ <% end %>
16
+ </tbody>
17
+ </table>
18
+ </div>
@@ -0,0 +1,18 @@
1
+ <% if StatBoard.models %>
2
+ <div class="row">
3
+ <%= render "chart",
4
+ :title => "Overall",
5
+ :scope => lambda { |klass| klass } %>
6
+
7
+ <%= render "chart",
8
+ :title => "This Month",
9
+ :scope => lambda { |klass| klass.where(["created_at > ?", 1.month.ago]) } %>
10
+
11
+ <%= render "chart",
12
+ :title => "This Week",
13
+ :scope => lambda { |klass| klass.where(["created_at > ?", 1.week.ago]) } %>
14
+ </div>
15
+ <% else %>
16
+ Please specify some models by setting <code>StatBoard.models</code>
17
+ (in <code>config/initializers/stat_board.rb</code>, for example).
18
+ <% end %>
@@ -0,0 +1,3 @@
1
+ StatBoard::Engine.routes.draw do
2
+ root :to => "stats#index"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "stat_board/engine"
2
+
3
+ module StatBoard
4
+ mattr_accessor :models, :title, :username, :password
5
+ end
@@ -0,0 +1,5 @@
1
+ module StatBoard
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace StatBoard
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module StatBoard
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :stat_board do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stat_board
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - David Eisinger
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.2'
30
+ - !ruby/object:Gem::Dependency
31
+ name: sqlite3
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec-rails
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: capybara
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Simple dashboard of records created this week, this month, and all time,
79
+ mountable as a Rails Engine.
80
+ email:
81
+ - david.eisinger@viget.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - app/assets/stylesheets/stat_board/bootstrap.css
87
+ - app/controllers/stat_board/application_controller.rb
88
+ - app/controllers/stat_board/stats_controller.rb
89
+ - app/views/layouts/stat_board/application.html.erb
90
+ - app/views/stat_board/stats/_chart.html.erb
91
+ - app/views/stat_board/stats/index.html.erb
92
+ - config/routes.rb
93
+ - lib/stat_board/engine.rb
94
+ - lib/stat_board/version.rb
95
+ - lib/stat_board.rb
96
+ - lib/tasks/stat_board_tasks.rake
97
+ - MIT-LICENSE
98
+ - Rakefile
99
+ - README.markdown
100
+ homepage: https://github.com/vigetlabs/stat_board
101
+ licenses: []
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 1.8.24
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: Simple dashboard of records created this week, this month, and all time,
124
+ mountable as a Rails Engine.
125
+ test_files: []