sequel-reporter 0.0.3 → 0.0.4
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.md +1 -1
- data/data/Rakefile.tt +22 -2
- data/lib/sequel-reporter/application.rb +2 -0
- data/lib/sequel-reporter/helpers.rb +15 -0
- data/lib/sequel-reporter/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sequel::Reporter
|
|
2
2
|
|
|
3
|
-
`Sequel::Reporter` is a small opinionated framework for writing web-based reports using the [Sequel](http://sequel.rubyforge.org) database toolkit. It provides a simple structure and helpers for easily writing reports.
|
|
3
|
+
`Sequel::Reporter` is a small opinionated framework for writing web-based reports using the [Sequel](http://sequel.rubyforge.org) database toolkit. It provides a simple structure and helpers for easily writing reports. There's a [tiny demo](http://sequel-reporter-demo.herokuapp.com) if you want to see an example.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
data/data/Rakefile.tt
CHANGED
|
@@ -2,9 +2,29 @@ require 'rubygems'
|
|
|
2
2
|
require './application'
|
|
3
3
|
require 'sequel/extensions/migration'
|
|
4
4
|
|
|
5
|
+
task :environment do
|
|
6
|
+
APP = <%= @name.capitalize %>::Application.new
|
|
7
|
+
DB = Sequel.connect(<%= @name.capitalize %>::Application.settings.database_url)
|
|
8
|
+
end
|
|
9
|
+
|
|
5
10
|
namespace :db do
|
|
6
11
|
task :migrate => :environment do
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
Sequel::Migrator.apply(DB, 'migrate')
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
task :console do
|
|
17
|
+
IRB.setup(nil)
|
|
18
|
+
irb = IRB::Irb.new
|
|
19
|
+
IRB.conf[:MAIN_CONTEXT] = irb.context
|
|
20
|
+
irb.context.evaluate("require 'irb/completion'", 0)
|
|
21
|
+
irb.context.evaluate("APP = <%= @name.capitalize %>::Application.new", 0)
|
|
22
|
+
irb.context.evaluate("DB = Sequel.connect(<%= @name.capitalize %>::Application.settings.database_url)", 0)
|
|
23
|
+
|
|
24
|
+
trap("SIGINT") do
|
|
25
|
+
irb.signal_handle
|
|
26
|
+
end
|
|
27
|
+
catch(:IRB_EXIT) do
|
|
28
|
+
irb.eval_input
|
|
9
29
|
end
|
|
10
30
|
end
|
|
@@ -10,6 +10,7 @@ module Sequel::Reporter
|
|
|
10
10
|
|
|
11
11
|
set :render_engine, :erb
|
|
12
12
|
set :database_url, ENV['DATABASE_URL']
|
|
13
|
+
set :authorization_func, :authorized
|
|
13
14
|
|
|
14
15
|
attr_reader :db
|
|
15
16
|
|
|
@@ -30,6 +31,7 @@ module Sequel::Reporter
|
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
get '/*' do
|
|
34
|
+
protected!
|
|
33
35
|
begin
|
|
34
36
|
render settings.render_engine, params[:splat][0].to_sym
|
|
35
37
|
rescue Exception => e
|
|
@@ -48,5 +48,20 @@ module Sequel::Reporter
|
|
|
48
48
|
display_value
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
def protected!
|
|
52
|
+
unless self.send(settings.authorization_func)
|
|
53
|
+
response['WWW-Authenticate'] = %(Basic realm="Restricted Area")
|
|
54
|
+
throw(:halt, [401, "Not authorized\n"])
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def authorized
|
|
59
|
+
@auth ||= Rack::Auth::Basic::Request.new(request.env)
|
|
60
|
+
unless ENV['USERNAME'] && ENV['PASSWORD']
|
|
61
|
+
return true
|
|
62
|
+
end
|
|
63
|
+
@auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [ENV['USERNAME'], ENV['PASSWORD']]
|
|
64
|
+
end
|
|
65
|
+
|
|
51
66
|
end
|
|
52
67
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sequel-reporter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-02-
|
|
12
|
+
date: 2013-02-23 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: thor
|