sinatra-frank 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/sinatra/frank.rb CHANGED
@@ -3,48 +3,57 @@ require "sinatra/base"
3
3
 
4
4
  module Sinatra
5
5
  module Frank
6
- def render_with(template, opts={})
7
- erb(:"#{template}", { layout: :layout }.merge(opts))
8
- end
6
+ module Helpers
7
+ def render_with(template, opts={})
8
+ erb(:"#{template}", { layout: :layout }.merge(opts))
9
+ end
9
10
 
10
- def partial(template, opts={})
11
- parts = template.split('/')
12
- last = "_#{parts.pop}"
13
- erb([parts, last].flatten.join('/').to_sym, {layout: false}.merge(opts))
14
- end
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
- def url_for(*models)
17
- '/' + models.map do |m|
18
- [m.class.name.pluralize.downcase, m.to_param]
19
- end.join('/')
20
- end
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
- def time_in_words(time)
23
- s = Time.now.to_i - time.to_i
24
-
25
- x = if s > 29030400
26
- [(s/29030400), 'years']
27
- elsif s > 2419200
28
- [(s/2419200), 'months']
29
- elsif s > 604800
30
- [(s/604800), 'weeks']
31
- elsif s > 86400
32
- [(s/86400), 'days']
33
- elsif s > 3600
34
- [(s/3600), 'hours']
35
- elsif s > 60
36
- [(s/60), 'minutes']
37
- else
38
- [s, 'seconds']
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
- if x[0] == 1
42
- x.join(' ')[0...-1]
43
- else
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
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module Frank
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  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.1
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-17 00:00:00.000000000 Z
12
+ date: 2013-10-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler