taw 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +2 -2
- data/README.md +4 -1
- data/lib/taw.rb +3 -1
- data/lib/taw/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8cb03e4b5f21d3fbcbade0031ade81a7471973dd
|
4
|
+
data.tar.gz: a4192f6fc345a133d928a137e7f0ba43fafce80a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6149fe08ab8afe6c5651c8ba326fa042924ee1aaf986747476c8952845b33d77b53f405602196879a9990f26f4e11e31c50a46ac4a57e4a9f0df5eff7796f83b
|
7
|
+
data.tar.gz: c12aa898edbb02352270c60886f4d82edaf6e72af1bc28a4c3c4ee2247f1943ef1f22b31bac3d0665b080881396efc76725cb5806c9acafa263331179727b547
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/shime/taw.svg?branch=master)](https://travis-ci.org/shime/taw)
|
4
4
|
|
5
5
|
**T**ime **A**go in **W**ords helper for non Rails projects.
|
6
|
-
No dependencies. No assumptions about your codebase. Minimalistic, ~
|
6
|
+
No dependencies. No assumptions about your codebase. Minimalistic, ~90 SLOC.
|
7
7
|
|
8
8
|
## Usage
|
9
9
|
|
@@ -19,6 +19,9 @@ Taw.time_ago_in_words(Time.now - 63) + " ago"
|
|
19
19
|
Taw.time_ago_in_words(Time.now - 60 * 60 * 2 - 63) + " ago"
|
20
20
|
# => "2 hours and 1 minute and 3 seconds ago"
|
21
21
|
|
22
|
+
Taw.time_ago_in_words(Time.now - 0.5) + " ago"
|
23
|
+
# => "a moment ago"
|
24
|
+
|
22
25
|
Taw.time_ago_in_words(Time.now - 60 * 60 * 26 - 63, approx: 1) + " ago"
|
23
26
|
# => "1 day ago"
|
24
27
|
|
data/lib/taw.rb
CHANGED
@@ -88,7 +88,7 @@ module Taw
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def output_distance
|
91
|
-
[
|
91
|
+
output = [
|
92
92
|
("#{years} #{pluralize(years, "year")}" if years && years > 0),
|
93
93
|
("#{months} #{pluralize(months, "month")}" if months && months > 0),
|
94
94
|
("#{weeks} #{pluralize(weeks, "week")}" if weeks && weeks > 0),
|
@@ -97,6 +97,8 @@ module Taw
|
|
97
97
|
("#{minutes} #{pluralize(minutes, "minute")}" if minutes && minutes > 0),
|
98
98
|
("#{seconds} #{pluralize(seconds, "second")}" if seconds && seconds > 0)
|
99
99
|
].drop_while(&:nil?)[0..approx_units].compact.join(" and ")
|
100
|
+
return "a moment" if output.empty?
|
101
|
+
output
|
100
102
|
end
|
101
103
|
|
102
104
|
def pluralize(count, singular, plural = "#{singular}s")
|
data/lib/taw/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hrvoje Šimić
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.5.2.3
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Time ago in words helper for non Rails projects.
|