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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 364a15751f2a8c3b37feea682f21de9d9c04294eb34d85ac107b50dfc7dde66c
4
- data.tar.gz: 664902eedba625517ef65244b895ecf40ca5bb80373a04fb69a6bb28f483c742
2
+ SHA1:
3
+ metadata.gz: 8cb03e4b5f21d3fbcbade0031ade81a7471973dd
4
+ data.tar.gz: a4192f6fc345a133d928a137e7f0ba43fafce80a
5
5
  SHA512:
6
- metadata.gz: 7a32918bd5062bcfb3611c8478e929bbc436064507f54ea9ed6248218f1a3a2253ab41a54dd13c640adc40e3aa95fb0309f42d5e1c8ce918018276443c618132
7
- data.tar.gz: 2a050684f681d2edc17a0e57b7cd075fe71182bcb879cb1e59faa5bde437e0d6c974f37bf854cd224190a061823128aa674f14042ad09766f58953982aefd737
6
+ metadata.gz: 6149fe08ab8afe6c5651c8ba326fa042924ee1aaf986747476c8952845b33d77b53f405602196879a9990f26f4e11e31c50a46ac4a57e4a9f0df5eff7796f83b
7
+ data.tar.gz: c12aa898edbb02352270c60886f4d82edaf6e72af1bc28a4c3c4ee2247f1943ef1f22b31bac3d0665b080881396efc76725cb5806c9acafa263331179727b547
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- taw (1.1.0)
4
+ taw (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -25,4 +25,4 @@ DEPENDENCIES
25
25
  taw!
26
26
 
27
27
  BUNDLED WITH
28
- 1.16.1
28
+ 1.16.2
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, ~80 SLOC.
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")
@@ -1,3 +1,3 @@
1
1
  module Taw
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
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.1.0
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-08-28 00:00:00.000000000 Z
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.7.6
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.