time_compact 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +14 -0
- data/README.md +2 -0
- data/lib/time_compact/railtie.rb +2 -2
- data/lib/time_compact/version.rb +1 -1
- data/lib/time_compact.rb +8 -15
- data/test/test_time_compact.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81ad0a9403e46694eda26d158cef5d9aa76b2ee7
|
4
|
+
data.tar.gz: fddc40df215da1c9748201616ffc610ee0450c17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fccd9c748f371cbae30d3d66913db61512ece8b54ac853f6b7429f040a106b641e0b647a51ccbb908f31a59a32c0022b34e2d1d86e3636e632e37c172d77ae4e
|
7
|
+
data.tar.gz: b511b5bdb40bf03f42c15969dcc561eb905f554716a489bded1ace4268ea513f7675493c051bcca8c6ce9032c2ca44e2bc38a38b5150496f3932ed415b567bb3
|
data/.travis.yml
ADDED
data/README.md
CHANGED
data/lib/time_compact/railtie.rb
CHANGED
data/lib/time_compact/version.rb
CHANGED
data/lib/time_compact.rb
CHANGED
@@ -4,35 +4,28 @@ require 'i18n'
|
|
4
4
|
require 'yaml'
|
5
5
|
|
6
6
|
module TimeCompact
|
7
|
-
LOCALE_DIR = File.expand_path('../../locale', __FILE__)
|
8
|
-
|
9
7
|
def time_compact(time, now = Time.now)
|
8
|
+
locale_dir = File.expand_path('../../locale', __FILE__)
|
10
9
|
I18n.enforce_available_locales = true
|
11
|
-
I18n.load_path += Dir[
|
10
|
+
I18n.load_path += Dir["#{locale_dir}/*.yml"]
|
11
|
+
messages = I18n.t('time_compact')
|
12
12
|
|
13
13
|
if time.year == now.year
|
14
14
|
if time.month == now.month
|
15
15
|
if time.day == now.day
|
16
16
|
if time.hour == now.hour
|
17
|
-
time.strftime(
|
17
|
+
time.strftime(messages[:same_hour])
|
18
18
|
else
|
19
|
-
time.strftime(
|
19
|
+
time.strftime(messages[:same_day])
|
20
20
|
end
|
21
21
|
else
|
22
|
-
time.strftime(
|
22
|
+
time.strftime(messages[:same_month])
|
23
23
|
end
|
24
24
|
else
|
25
|
-
time.strftime(
|
25
|
+
time.strftime(messages[:same_year])
|
26
26
|
end
|
27
27
|
else
|
28
|
-
time.strftime(
|
28
|
+
time.strftime(messages[:other])
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def fetch_locale(name)
|
35
|
-
yml = YAML.load_file("#{LOCALE_DIR}/#{I18n.locale}.yml")
|
36
|
-
yml[I18n.locale.to_s]['time_compact'][name]
|
37
|
-
end
|
38
31
|
end
|
data/test/test_time_compact.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_compact
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaki Komagata
|
@@ -74,6 +74,7 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
77
78
|
- Gemfile
|
78
79
|
- LICENSE.txt
|
79
80
|
- README.md
|