glowing-archer 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,9 @@ module BooleanHelpers
2
2
  def humanize
3
3
  self ? "yes" : "no"
4
4
  end
5
+ def yesno
6
+ self ? "Yes" : "No"
7
+ end
5
8
  end
6
9
 
7
10
  class FalseClass
@@ -11,4 +14,3 @@ end
11
14
  class TrueClass
12
15
  include BooleanHelpers
13
16
  end
14
-
@@ -11,6 +11,10 @@ String.class_eval do
11
11
  end
12
12
  return html.html_safe
13
13
  end
14
+
15
+ def to_tags
16
+ self.split(",").drop_nil
17
+ end
14
18
 
15
19
  def to_bool
16
20
  return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
@@ -68,6 +72,10 @@ String.class_eval do
68
72
  self.initial.upcase + "."
69
73
  end
70
74
 
75
+ def capitalize_first_char
76
+ self.sub(/^(.)/) { $1.capitalize }
77
+ end
78
+
71
79
  end
72
80
 
73
81
  class NilClass
@@ -0,0 +1,21 @@
1
+ module PrettyDate
2
+ def to_pretty
3
+ a = (Time.now-self).to_i
4
+
5
+ case a
6
+ when 0 then 'Just now'
7
+ when 1 then 'A second ago'
8
+ when 2..59 then a.to_s+' seconds ago'
9
+ when 60..119 then 'A minute ago' #120 = 2 minutes
10
+ when 120..3540 then (a/60).to_i.to_s+' minutes ago'
11
+ when 3541..7100 then 'An hour ago' # 3600 = 1 hour
12
+ when 7101..82800 then ((a+99)/3600).to_i.to_s+' hours ago'
13
+ when 82801..172000 then 'A day ago' # 86400 = 1 day
14
+ when 172001..518400 then ((a+800)/(60*60*24)).to_i.to_s+' days ago'
15
+ when 518400..1036800 then 'A week ago'
16
+ else ((a+180000)/(60*60*24*7)).to_i.to_s+' weeks ago'
17
+ end
18
+ end
19
+ end
20
+
21
+ Time.send :include, PrettyDate
@@ -1,5 +1,5 @@
1
1
  module Glowing
2
2
  module Archer
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glowing-archer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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-04 00:00:00.000000000 Z
12
+ date: 2013-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -46,6 +46,7 @@ files:
46
46
  - lib/glowing-archer/rails/boolean.rb
47
47
  - lib/glowing-archer/rails/numeric.rb
48
48
  - lib/glowing-archer/rails/string.rb
49
+ - lib/glowing-archer/rails/time.rb
49
50
  - lib/glowing-archer/version.rb
50
51
  homepage: https://github.com/johnantoni/glowing-archer
51
52
  licenses: []
@@ -61,7 +62,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
61
62
  version: '0'
62
63
  segments:
63
64
  - 0
64
- hash: 3315372235594486216
65
+ hash: -2867229016205579772
65
66
  required_rubygems_version: !ruby/object:Gem::Requirement
66
67
  none: false
67
68
  requirements:
@@ -70,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
71
  version: '0'
71
72
  segments:
72
73
  - 0
73
- hash: 3315372235594486216
74
+ hash: -2867229016205579772
74
75
  requirements: []
75
76
  rubyforge_project:
76
77
  rubygems_version: 1.8.23