sinatra-frank 0.0.1 → 0.0.2
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/lib/sinatra/frank.rb +44 -35
- data/lib/sinatra/frank/version.rb +1 -1
- metadata +2 -2
data/lib/sinatra/frank.rb
CHANGED
@@ -3,48 +3,57 @@ require "sinatra/base"
|
|
3
3
|
|
4
4
|
module Sinatra
|
5
5
|
module Frank
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
module Helpers
|
7
|
+
def render_with(template, opts={})
|
8
|
+
erb(:"#{template}", { layout: :layout }.merge(opts))
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
def partial(template, opts={})
|
12
|
+
parts = template.split('/')
|
13
|
+
last = "_#{parts.pop}"
|
14
|
+
erb([parts, last].flatten.join('/').to_sym, {layout: false}.merge(opts))
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
def url_for(*models)
|
18
|
+
'/' + models.map do |m|
|
19
|
+
[m.class.name.pluralize.downcase, m.to_param]
|
20
|
+
end.join('/')
|
21
|
+
end
|
22
|
+
|
23
|
+
def time_in_words(time)
|
24
|
+
s = Time.now.to_i - time.to_i
|
21
25
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
[
|
26
|
+
x = if s > 29030400
|
27
|
+
[(s/29030400), 'years']
|
28
|
+
elsif s > 2419200
|
29
|
+
[(s/2419200), 'months']
|
30
|
+
elsif s > 604800
|
31
|
+
[(s/604800), 'weeks']
|
32
|
+
elsif s > 86400
|
33
|
+
[(s/86400), 'days']
|
34
|
+
elsif s > 3600
|
35
|
+
[(s/3600), 'hours']
|
36
|
+
elsif s > 60
|
37
|
+
[(s/60), 'minutes']
|
38
|
+
else
|
39
|
+
[s, 'seconds']
|
40
|
+
end
|
41
|
+
|
42
|
+
if x[0] == 1
|
43
|
+
x.join(' ')[0...-1]
|
44
|
+
else
|
45
|
+
x.join(' ')
|
46
|
+
end
|
39
47
|
end
|
48
|
+
end
|
40
49
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
x.join(' ')
|
50
|
+
module HoneyPot
|
51
|
+
def honey_pot_param(param)
|
52
|
+
before { halt(403, "Something went wrong") if params && params[param] }
|
45
53
|
end
|
46
54
|
end
|
47
55
|
end
|
48
56
|
|
49
|
-
helpers Frank
|
57
|
+
helpers Frank::Helpers
|
58
|
+
register Frank::HoneyPot
|
50
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-frank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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-10-
|
12
|
+
date: 2013-10-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|