humane 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/README.md +8 -7
- data/lib/humane/time_formatter.rb +2 -2
- data/lib/humane/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 69b5f7271b78dcda7542ff765d7b10ee4ed7fd74b37416c9a0654c2d29ee2e26
|
|
4
|
+
data.tar.gz: bb6f7d13fb51171c3721f43739253019483510df40b3515d656c1adab0180e73
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b259b53ee06c2868de3f30cb1e0adef2094e49e5c9096d4bfb68c591578792d42fb813e3457aac686f020041c5d4425b334fc1fe6131ce1bd2e43b08fc30528
|
|
7
|
+
data.tar.gz: 74f6c96c9bdb1c1f16430cf0698572db5473ef328e56282b7b006365006616475035a5e9218724f5893b9972bf0bf62adf7d5d08badc0dfa3a69f1cf324fc11c
|
data/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# humane-ruby
|
|
2
2
|
|
|
3
|
+
[](https://rubygems.org/gems/humane)
|
|
3
4
|
[](https://www.ruby-lang.org/)
|
|
4
5
|
[](https://github.com/woodie/humane-ruby/actions/workflows/ci.yml)
|
|
5
6
|
[](https://github.com/woodie/humane-ruby/releases/latest)
|
|
@@ -7,7 +8,7 @@
|
|
|
7
8
|
|
|
8
9
|
Swift's file sizes and relative dates for Ruby
|
|
9
10
|
|
|
10
|
-
Finder-accurate file sizes and relative dates for Ruby, modeled on Swift's [`ByteCountFormatter`](https://developer.apple.com/documentation/foundation/bytecountformatter) and [`RelativeDateTimeFormatter`](https://developer.apple.com/documentation/foundation/relativedatetimeformatter) -- not literal ports (both are closed-source,
|
|
11
|
+
Finder-accurate file sizes and relative dates for Ruby, modeled on Swift's [`ByteCountFormatter`](https://developer.apple.com/documentation/foundation/bytecountformatter) and [`RelativeDateTimeFormatter`](https://developer.apple.com/documentation/foundation/relativedatetimeformatter) -- not literal ports (both are closed-source), but the same idea and the same wording: a small, configurable formatter object instead of a bare helper method.
|
|
11
12
|
|
|
12
13
|
## Install
|
|
13
14
|
|
|
@@ -28,14 +29,14 @@ require "humane"
|
|
|
28
29
|
|
|
29
30
|
size_formatter = Humane::SizeFormatter.new
|
|
30
31
|
size_formatter.string(from_byte_count: 225_935) # "226 KB" -- 1000-based math,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
# capitalized units, matching
|
|
33
|
+
# Finder, not Rails'
|
|
34
|
+
# number_to_human_size (1024-
|
|
35
|
+
# based despite the same label)
|
|
35
36
|
|
|
36
|
-
time_formatter = Humane::TimeFormatter.new
|
|
37
|
+
time_formatter = Humane::TimeFormatter.new # collapse_minute: true
|
|
37
38
|
time_formatter.string(at: scanned_at, relative_to: Time.now)
|
|
38
|
-
# "3 minutes ago" / "3 minutes
|
|
39
|
+
# "3 minutes ago" / "in 3 minutes" / "less than a minute ago"
|
|
39
40
|
```
|
|
40
41
|
|
|
41
42
|
`Humane::TimeFormatter.new` uses `at:`, not `for:` -- Ruby's `for` is a
|
|
@@ -15,7 +15,7 @@ module Humane
|
|
|
15
15
|
seconds = seconds.abs
|
|
16
16
|
|
|
17
17
|
if @collapse_minute && seconds < 60
|
|
18
|
-
return future ? "less than a minute
|
|
18
|
+
return future ? "in less than a minute" : "less than a minute ago"
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
text =
|
|
@@ -29,7 +29,7 @@ module Humane
|
|
|
29
29
|
pluralize((seconds / 86_400.0).round, "day")
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
future ? "#{text}
|
|
32
|
+
future ? "in #{text}" : "#{text} ago"
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
private
|
data/lib/humane/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: humane
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Woodell
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
12
|
description: Finder-accurate file sizes and relative dates for Ruby, modeled on Swift's
|
|
14
13
|
ByteCountFormatter and RelativeDateTimeFormatter.
|
|
@@ -30,7 +29,6 @@ licenses:
|
|
|
30
29
|
metadata:
|
|
31
30
|
homepage_uri: https://github.com/woodie/humane-ruby
|
|
32
31
|
source_code_uri: https://github.com/woodie/humane-ruby
|
|
33
|
-
post_install_message:
|
|
34
32
|
rdoc_options: []
|
|
35
33
|
require_paths:
|
|
36
34
|
- lib
|
|
@@ -45,8 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
45
43
|
- !ruby/object:Gem::Version
|
|
46
44
|
version: '0'
|
|
47
45
|
requirements: []
|
|
48
|
-
rubygems_version: 3.
|
|
49
|
-
signing_key:
|
|
46
|
+
rubygems_version: 3.6.9
|
|
50
47
|
specification_version: 4
|
|
51
48
|
summary: Swift's file sizes and relative dates for Ruby
|
|
52
49
|
test_files: []
|