Dex 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Dex.gemspec +2 -3
- data/lib/Dex.rb +5 -1
- data/lib/Dex/version.rb +1 -1
- data/spec/libs/main.rb +0 -24
- metadata +1 -51
- data/lib/Dex/Rack_App.rb +0 -96
- data/spec/Dex_Rack_App.rb +0 -92
data/Dex.gemspec
CHANGED
@@ -24,11 +24,10 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_development_dependency 'Bacon_Colored'
|
25
25
|
s.add_development_dependency 'pry'
|
26
26
|
s.add_development_dependency 'Exit_0'
|
27
|
-
|
27
|
+
|
28
28
|
|
29
29
|
# Specify any dependencies here; for example:
|
30
30
|
s.add_runtime_dependency 'sqlite3'
|
31
31
|
s.add_runtime_dependency 'sequel'
|
32
|
-
|
33
|
-
s.add_runtime_dependency 'markaby'
|
32
|
+
|
34
33
|
end
|
data/lib/Dex.rb
CHANGED
data/lib/Dex/version.rb
CHANGED
data/spec/libs/main.rb
CHANGED
@@ -19,31 +19,7 @@ require 'Bacon_Colored'
|
|
19
19
|
require 'pry'
|
20
20
|
require 'Exit_0'
|
21
21
|
|
22
|
-
ENV['RACK_ENV']='test'
|
23
|
-
require 'rack/test'
|
24
22
|
require 'Dex'
|
25
|
-
require 'Dex/Rack_App'
|
26
|
-
|
27
|
-
class Bacon::Context
|
28
|
-
include Rack::Test::Methods
|
29
|
-
|
30
|
-
def app
|
31
|
-
Dex::Rack_App
|
32
|
-
end
|
33
|
-
|
34
|
-
def should_render txt
|
35
|
-
last_response.should.be.ok
|
36
|
-
r = txt.respond_to?(:~) ? txt : %r!#{txt}!
|
37
|
-
last_response.body.should.match r
|
38
|
-
end
|
39
|
-
|
40
|
-
def should_redirect_to url, status = 303
|
41
|
-
last_response.status.should == status
|
42
|
-
last_response['Location'].sub( %r!http://(www.)?example.(com|org)!, '' )
|
43
|
-
.should == '/'
|
44
|
-
end
|
45
|
-
|
46
|
-
end # === class Bacon::Context
|
47
23
|
|
48
24
|
Exit_0 "rm /tmp/dex.test.db" if File.exists?("/tmp/dex.test.db")
|
49
25
|
Dex.db "/tmp/dex.test.db"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Dex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -91,22 +91,6 @@ dependencies:
|
|
91
91
|
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: rack-test
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ! '>='
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
94
|
- !ruby/object:Gem::Dependency
|
111
95
|
name: sqlite3
|
112
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,38 +123,6 @@ dependencies:
|
|
139
123
|
- - ! '>='
|
140
124
|
- !ruby/object:Gem::Version
|
141
125
|
version: '0'
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: sinatra
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ! '>='
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '0'
|
150
|
-
type: :runtime
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - ! '>='
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '0'
|
158
|
-
- !ruby/object:Gem::Dependency
|
159
|
-
name: markaby
|
160
|
-
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
|
-
requirements:
|
163
|
-
- - ! '>='
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: '0'
|
166
|
-
type: :runtime
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
|
-
requirements:
|
171
|
-
- - ! '>='
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
174
126
|
description: ! "\n A simple function to log errors to sqlite3.\n "
|
175
127
|
email:
|
176
128
|
- i-hate-spam-45671204@mailinator.com
|
@@ -184,10 +136,8 @@ files:
|
|
184
136
|
- README.md
|
185
137
|
- Rakefile
|
186
138
|
- lib/Dex.rb
|
187
|
-
- lib/Dex/Rack_App.rb
|
188
139
|
- lib/Dex/version.rb
|
189
140
|
- spec/Dex.rb
|
190
|
-
- spec/Dex_Rack_App.rb
|
191
141
|
- spec/bin.rb
|
192
142
|
- spec/libs/main.rb
|
193
143
|
homepage: https://github.com/da99/Dex
|
data/lib/Dex/Rack_App.rb
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'sinatra/base'
|
3
|
-
require 'Dex'
|
4
|
-
require 'markaby'
|
5
|
-
|
6
|
-
class Dex
|
7
|
-
|
8
|
-
class Rack_App < Sinatra::Base
|
9
|
-
|
10
|
-
get "/" do
|
11
|
-
recent
|
12
|
-
end
|
13
|
-
|
14
|
-
get "/recent/:num" do | num |
|
15
|
-
recent Integer(num)
|
16
|
-
end
|
17
|
-
|
18
|
-
get "/:id" do | id |
|
19
|
-
r = Dex.filter(:id=>id).first
|
20
|
-
view_record Hash[:title=>r[:message], :record=>r]
|
21
|
-
end
|
22
|
-
|
23
|
-
put "/:id/status" do |id|
|
24
|
-
Dex.filter(:id=>id).update(:status=>params[:status].to_i)
|
25
|
-
redirect to('/'), 303
|
26
|
-
end
|
27
|
-
|
28
|
-
delete "/:id" do | id |
|
29
|
-
Dex.filter(:id=>id).delete
|
30
|
-
redirect to('/'), 303
|
31
|
-
end
|
32
|
-
|
33
|
-
def recent num = 10
|
34
|
-
vars = Hash[
|
35
|
-
:title => "Dex List",
|
36
|
-
:list => Dex.recent.to_a
|
37
|
-
]
|
38
|
-
view_index vars
|
39
|
-
end
|
40
|
-
|
41
|
-
def layout vars, &b
|
42
|
-
mab = Markaby::Builder.new
|
43
|
-
mab.html do
|
44
|
-
head {
|
45
|
-
title vars[:title]
|
46
|
-
}
|
47
|
-
body {
|
48
|
-
instance_eval(&b)
|
49
|
-
}
|
50
|
-
end
|
51
|
-
|
52
|
-
mab.to_s
|
53
|
-
end
|
54
|
-
|
55
|
-
def view_index vars
|
56
|
-
layout(vars) {
|
57
|
-
if vars[:list].empty?
|
58
|
-
div.empty { p "No exceptions created." }
|
59
|
-
else
|
60
|
-
vars[:list].each { |db|
|
61
|
-
div {
|
62
|
-
p db[:message]
|
63
|
-
p db[:exception]
|
64
|
-
}
|
65
|
-
}
|
66
|
-
end
|
67
|
-
}
|
68
|
-
end
|
69
|
-
|
70
|
-
def view_record vars
|
71
|
-
r = vars[:record]
|
72
|
-
s = self
|
73
|
-
layout(vars) {
|
74
|
-
div {
|
75
|
-
p {
|
76
|
-
span "#{r[:exception]}: #{r[:message]}"
|
77
|
-
span.status s.status_to_word(r[:status])
|
78
|
-
}
|
79
|
-
pre { r[:backtrace] }
|
80
|
-
|
81
|
-
}
|
82
|
-
}
|
83
|
-
end
|
84
|
-
|
85
|
-
def status_to_word num
|
86
|
-
case num
|
87
|
-
when 0
|
88
|
-
"Unresolved"
|
89
|
-
when 1
|
90
|
-
"Resolved"
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end # === Rack_App < Sinatra::Base
|
94
|
-
|
95
|
-
end # === Dex
|
96
|
-
|
data/spec/Dex_Rack_App.rb
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
|
2
|
-
describe "get /" do
|
3
|
-
|
4
|
-
it "renders a recent list of 10" do
|
5
|
-
transact {
|
6
|
-
5.times { |i| Dex.insert except("Err: #{i}") }
|
7
|
-
|
8
|
-
get "/"
|
9
|
-
5.times { |i|
|
10
|
-
last_response.body.should.match %r!Err: #{i}!
|
11
|
-
}
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
it "renders message when there are no exceptions" do
|
16
|
-
get "/"
|
17
|
-
last_response.body.should.match %r!No exceptions!
|
18
|
-
end
|
19
|
-
|
20
|
-
end # === get /
|
21
|
-
|
22
|
-
describe "get /recent/:num" do
|
23
|
-
|
24
|
-
it "/n renders a list equal to n" do
|
25
|
-
transact {
|
26
|
-
n = rand(10) + 1
|
27
|
-
n.times { |i| Dex.insert except("N: #{i}") }
|
28
|
-
|
29
|
-
get "/recent/#{n}"
|
30
|
-
n.times { |i|
|
31
|
-
last_response.body.should.match %r!N: #{i}!
|
32
|
-
}
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
end # === get /recent/num
|
37
|
-
|
38
|
-
describe "get /:id" do
|
39
|
-
|
40
|
-
it "displays record" do
|
41
|
-
transact {
|
42
|
-
id = Dex.insert(except "rand err")
|
43
|
-
get "/#{id}"
|
44
|
-
should_render "rand err"
|
45
|
-
}
|
46
|
-
end
|
47
|
-
|
48
|
-
end # === get /:id
|
49
|
-
|
50
|
-
describe "put /:id/status" do
|
51
|
-
|
52
|
-
it "updates status of record" do
|
53
|
-
transact {
|
54
|
-
id = Dex.insert(except "rand err")
|
55
|
-
put "/#{id}/status", :status=>2
|
56
|
-
Dex.filter(:id=>id).first[:status]
|
57
|
-
.should == 2
|
58
|
-
}
|
59
|
-
end
|
60
|
-
|
61
|
-
it "redirects to /:id 303" do
|
62
|
-
transact {
|
63
|
-
id = Dex.insert(except "rand err")
|
64
|
-
put "/#{id}/status", :status=>2
|
65
|
-
should_redirect_to "/"
|
66
|
-
}
|
67
|
-
end
|
68
|
-
|
69
|
-
end # === put /:id/status
|
70
|
-
|
71
|
-
describe "delete /:id" do
|
72
|
-
|
73
|
-
it "deletes record" do
|
74
|
-
transact {
|
75
|
-
Dex.insert(except("Deleted"))
|
76
|
-
r = Dex.recent(1)
|
77
|
-
delete "/#{r[:id]}"
|
78
|
-
Dex.count.should == 0
|
79
|
-
}
|
80
|
-
end
|
81
|
-
|
82
|
-
it "redirects to / 303" do
|
83
|
-
transact {
|
84
|
-
Dex.insert(except("Deleted"))
|
85
|
-
r = Dex.recent(1)
|
86
|
-
delete "/#{r[:id]}"
|
87
|
-
should_redirect_to "/"
|
88
|
-
}
|
89
|
-
end
|
90
|
-
|
91
|
-
end # === delete /:id
|
92
|
-
|