dotiw 3.1.1 → 5.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.
Files changed (65) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +45 -0
  3. data/.gitignore +2 -1
  4. data/.rspec +2 -0
  5. data/Appraisals +19 -0
  6. data/CHANGELOG.md +31 -6
  7. data/Gemfile +2 -0
  8. data/MIT-LICENSE +1 -1
  9. data/README.markdown +147 -62
  10. data/Rakefile +3 -1
  11. data/dotiw.gemspec +17 -17
  12. data/gemfiles/.bundle/config +2 -0
  13. data/gemfiles/rails_4.gemfile +9 -0
  14. data/gemfiles/rails_5.0.gemfile +9 -0
  15. data/gemfiles/rails_5.1.gemfile +9 -0
  16. data/gemfiles/rails_5.2.gemfile +9 -0
  17. data/gemfiles/rails_6.0.gemfile +9 -0
  18. data/lib/dotiw.rb +32 -13
  19. data/lib/dotiw/action_view/helpers/date_helper.rb +25 -0
  20. data/lib/dotiw/locale/ar.yml +104 -0
  21. data/lib/dotiw/locale/da.yml +35 -0
  22. data/lib/dotiw/locale/de.yml +36 -1
  23. data/lib/dotiw/locale/en.yml +35 -0
  24. data/lib/dotiw/locale/es.yml +36 -1
  25. data/lib/dotiw/locale/fr.yml +35 -0
  26. data/lib/dotiw/locale/id.yml +35 -0
  27. data/lib/dotiw/locale/it.yml +35 -0
  28. data/lib/dotiw/locale/ja.yml +35 -0
  29. data/lib/dotiw/locale/ko.yml +48 -0
  30. data/lib/dotiw/locale/nb.yml +36 -1
  31. data/lib/dotiw/locale/nl.yml +35 -0
  32. data/lib/dotiw/locale/pl.yml +42 -0
  33. data/lib/dotiw/locale/pt-BR.yml +35 -0
  34. data/lib/dotiw/locale/ru.yml +37 -0
  35. data/lib/dotiw/locale/sv.yml +48 -0
  36. data/lib/dotiw/locale/vi.yml +48 -0
  37. data/lib/dotiw/locale/zh-CN.yml +48 -0
  38. data/lib/dotiw/locale/zh-TW.yml +60 -0
  39. data/lib/dotiw/methods.rb +99 -0
  40. data/lib/dotiw/time_hash.rb +39 -33
  41. data/lib/dotiw/version.rb +2 -2
  42. data/spec/lib/dotiw_spec.rb +256 -157
  43. data/spec/lib/i18n/ar.yml +2 -0
  44. data/spec/lib/i18n/da.yml +2 -0
  45. data/spec/lib/i18n/de.yml +2 -0
  46. data/spec/lib/i18n/en.yml +2 -0
  47. data/spec/lib/i18n/es.yml +3 -0
  48. data/spec/lib/i18n/fr.yml +2 -0
  49. data/spec/lib/i18n/id.yml +2 -0
  50. data/spec/lib/i18n/it.yml +3 -0
  51. data/spec/lib/i18n/ja.yml +2 -0
  52. data/spec/lib/i18n/ko.yml +2 -0
  53. data/spec/lib/i18n/nb.yml +2 -0
  54. data/spec/lib/i18n/nl.yml +2 -0
  55. data/spec/lib/i18n/pl.yml +2 -0
  56. data/spec/lib/i18n/pt-BR.yml +2 -0
  57. data/spec/lib/i18n/ru.yml +5 -0
  58. data/spec/lib/i18n/sv.yml +2 -0
  59. data/spec/lib/i18n/vi.yml +22 -0
  60. data/spec/lib/i18n/zh-CN.yml +2 -0
  61. data/spec/lib/i18n/zh-TW.yml +2 -0
  62. data/spec/spec_helper.rb +2 -9
  63. metadata +98 -18
  64. data/.travis.yml +0 -11
  65. data/lib/dotiw/action_view_ext/helpers/date_helper.rb +0 -103
@@ -0,0 +1,2 @@
1
+ seconds:
2
+ 1.second: ثانية واحدة
@@ -0,0 +1,2 @@
1
+ seconds:
2
+ 1.second: 1 sekund
@@ -0,0 +1,2 @@
1
+ seconds:
2
+ 1.second: 1 Sekunde
@@ -0,0 +1,2 @@
1
+ seconds:
2
+ 1.second: 1 second
@@ -0,0 +1,3 @@
1
+ days:
2
+ 1.day: un día
3
+ 5.days: 5 días
@@ -0,0 +1,2 @@
1
+ seconds:
2
+ 1.second: 1 seconde
@@ -0,0 +1,2 @@
1
+ seconds:
2
+ 1.second: 1 detik
@@ -0,0 +1,3 @@
1
+ days:
2
+ 1.day: un giorno
3
+ 5.days: 5 giorni
@@ -0,0 +1,2 @@
1
+ seconds:
2
+ 1.second: 1秒
@@ -0,0 +1,2 @@
1
+ seconds:
2
+ 1.second: 일 초
@@ -0,0 +1,2 @@
1
+ seconds:
2
+ 1.second: 1 sekund
@@ -0,0 +1,2 @@
1
+ seconds:
2
+ 1.second: 1 seconde
@@ -0,0 +1,2 @@
1
+ seconds:
2
+ 1.second: 1 sekunda
@@ -0,0 +1,2 @@
1
+ seconds:
2
+ 1.second: 1 segundo
@@ -0,0 +1,5 @@
1
+ seconds:
2
+ 0.5.seconds: меньше, чем 1 секунда
3
+ 1.second: 1 секунда
4
+ minutes:
5
+ 1.minute: 1 минута
@@ -0,0 +1,2 @@
1
+ seconds:
2
+ 1.second: 1 sekund
@@ -0,0 +1,22 @@
1
+ seconds:
2
+ 0.5.second: ít hơn 1 giây
3
+ 1.second: 1 giây
4
+ 3.seconds: 3 giây
5
+ minutes:
6
+ 1.minute: 1 phút
7
+ 10.minutes: 10 phút
8
+ hours:
9
+ 1.hour: 1 giờ
10
+ 2.hours: 2 giờ
11
+ days:
12
+ 1.day: 1 ngày
13
+ 2.days: 2 ngày
14
+ weeks:
15
+ 1.week: 1 tuần
16
+ 2.weeks: 2 tuần
17
+ months:
18
+ 1.month: 1 tháng
19
+ 2.months: 2 tháng
20
+ years:
21
+ 1.year: 1 năm
22
+ 2.years: 2 năm
@@ -0,0 +1,2 @@
1
+ seconds:
2
+ 1.second: 1 秒
@@ -0,0 +1,2 @@
1
+ seconds:
2
+ 1.second: 1 秒
@@ -1,17 +1,10 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  ROOT_PATH = File.join(File.dirname(__FILE__), '..')
4
- $:.unshift ROOT_PATH unless $:.include? ROOT_PATH
5
-
6
- # Files that are usually required by Rails, but in a testing context will not be.
7
- require 'erb'
8
-
9
- require 'active_support/all'
10
- require 'action_view'
4
+ $LOAD_PATH.unshift ROOT_PATH unless $LOAD_PATH.include? ROOT_PATH
11
5
 
12
6
  require 'dotiw'
13
7
 
14
8
  Time.zone = 'UTC'
15
9
 
16
- I18n.load_path << Dir[File.join(File.dirname(__FILE__), 'translations', '*')]
17
10
  I18n.locale = :en
metadata CHANGED
@@ -1,30 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotiw
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bigg
8
8
  - Lauran Jansen
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-08 00:00:00.000000000 Z
12
+ date: 2020-10-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: actionpack
15
+ name: activesupport
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '3'
20
+ version: '0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '3'
27
+ version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: i18n
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -40,7 +40,7 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: rake
43
+ name: appraisal
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="
@@ -67,6 +67,34 @@ dependencies:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: pry
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rake
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
70
98
  - !ruby/object:Gem::Dependency
71
99
  name: rspec
72
100
  requirement: !ruby/object:Gem::Requirement
@@ -85,16 +113,16 @@ dependencies:
85
113
  name: tzinfo
86
114
  requirement: !ruby/object:Gem::Requirement
87
115
  requirements:
88
- - - ">="
116
+ - - "~>"
89
117
  - !ruby/object:Gem::Version
90
- version: '0'
118
+ version: 1.2.7
91
119
  type: :development
92
120
  prerelease: false
93
121
  version_requirements: !ruby/object:Gem::Requirement
94
122
  requirements:
95
- - - ">="
123
+ - - "~>"
96
124
  - !ruby/object:Gem::Version
97
- version: '0'
125
+ version: 1.2.7
98
126
  description: |-
99
127
  dotiw is a gem for Rails that overrides the
100
128
  default distance_of_time_in_words and provides
@@ -108,8 +136,10 @@ executables: []
108
136
  extensions: []
109
137
  extra_rdoc_files: []
110
138
  files:
139
+ - ".github/workflows/ruby.yml"
111
140
  - ".gitignore"
112
- - ".travis.yml"
141
+ - ".rspec"
142
+ - Appraisals
113
143
  - CHANGELOG.md
114
144
  - CONTRIBUTING.md
115
145
  - Gemfile
@@ -117,8 +147,15 @@ files:
117
147
  - README.markdown
118
148
  - Rakefile
119
149
  - dotiw.gemspec
150
+ - gemfiles/.bundle/config
151
+ - gemfiles/rails_4.gemfile
152
+ - gemfiles/rails_5.0.gemfile
153
+ - gemfiles/rails_5.1.gemfile
154
+ - gemfiles/rails_5.2.gemfile
155
+ - gemfiles/rails_6.0.gemfile
120
156
  - lib/dotiw.rb
121
- - lib/dotiw/action_view_ext/helpers/date_helper.rb
157
+ - lib/dotiw/action_view/helpers/date_helper.rb
158
+ - lib/dotiw/locale/ar.yml
122
159
  - lib/dotiw/locale/da.yml
123
160
  - lib/dotiw/locale/de.yml
124
161
  - lib/dotiw/locale/en.yml
@@ -127,20 +164,45 @@ files:
127
164
  - lib/dotiw/locale/id.yml
128
165
  - lib/dotiw/locale/it.yml
129
166
  - lib/dotiw/locale/ja.yml
167
+ - lib/dotiw/locale/ko.yml
130
168
  - lib/dotiw/locale/nb.yml
131
169
  - lib/dotiw/locale/nl.yml
132
170
  - lib/dotiw/locale/pl.yml
133
171
  - lib/dotiw/locale/pt-BR.yml
134
172
  - lib/dotiw/locale/ru.yml
173
+ - lib/dotiw/locale/sv.yml
174
+ - lib/dotiw/locale/vi.yml
175
+ - lib/dotiw/locale/zh-CN.yml
176
+ - lib/dotiw/locale/zh-TW.yml
177
+ - lib/dotiw/methods.rb
135
178
  - lib/dotiw/time_hash.rb
136
179
  - lib/dotiw/version.rb
137
180
  - spec/lib/dotiw_spec.rb
181
+ - spec/lib/i18n/ar.yml
182
+ - spec/lib/i18n/da.yml
183
+ - spec/lib/i18n/de.yml
184
+ - spec/lib/i18n/en.yml
185
+ - spec/lib/i18n/es.yml
186
+ - spec/lib/i18n/fr.yml
187
+ - spec/lib/i18n/id.yml
188
+ - spec/lib/i18n/it.yml
189
+ - spec/lib/i18n/ja.yml
190
+ - spec/lib/i18n/ko.yml
191
+ - spec/lib/i18n/nb.yml
192
+ - spec/lib/i18n/nl.yml
193
+ - spec/lib/i18n/pl.yml
194
+ - spec/lib/i18n/pt-BR.yml
195
+ - spec/lib/i18n/ru.yml
196
+ - spec/lib/i18n/sv.yml
197
+ - spec/lib/i18n/vi.yml
198
+ - spec/lib/i18n/zh-CN.yml
199
+ - spec/lib/i18n/zh-TW.yml
138
200
  - spec/spec_helper.rb
139
- homepage: https://github.com/radar/dotiw
201
+ homepage: https://github.com/radar/distance_of_time_in_words
140
202
  licenses:
141
203
  - MIT
142
204
  metadata: {}
143
- post_install_message:
205
+ post_install_message:
144
206
  rdoc_options: []
145
207
  require_paths:
146
208
  - lib
@@ -155,11 +217,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
217
  - !ruby/object:Gem::Version
156
218
  version: '0'
157
219
  requirements: []
158
- rubyforge_project:
159
- rubygems_version: 2.5.1
160
- signing_key:
220
+ rubygems_version: 3.1.2
221
+ signing_key:
161
222
  specification_version: 4
162
223
  summary: Better distance_of_time_in_words for Rails
163
224
  test_files:
164
225
  - spec/lib/dotiw_spec.rb
226
+ - spec/lib/i18n/ar.yml
227
+ - spec/lib/i18n/da.yml
228
+ - spec/lib/i18n/de.yml
229
+ - spec/lib/i18n/en.yml
230
+ - spec/lib/i18n/es.yml
231
+ - spec/lib/i18n/fr.yml
232
+ - spec/lib/i18n/id.yml
233
+ - spec/lib/i18n/it.yml
234
+ - spec/lib/i18n/ja.yml
235
+ - spec/lib/i18n/ko.yml
236
+ - spec/lib/i18n/nb.yml
237
+ - spec/lib/i18n/nl.yml
238
+ - spec/lib/i18n/pl.yml
239
+ - spec/lib/i18n/pt-BR.yml
240
+ - spec/lib/i18n/ru.yml
241
+ - spec/lib/i18n/sv.yml
242
+ - spec/lib/i18n/vi.yml
243
+ - spec/lib/i18n/zh-CN.yml
244
+ - spec/lib/i18n/zh-TW.yml
165
245
  - spec/spec_helper.rb
@@ -1,11 +0,0 @@
1
- rvm:
2
- - 2.3.0
3
- - 2.2.4
4
- - 2.1.8
5
- - 2.0.0
6
- - 1.9.3
7
- - jruby-19mode
8
- before_install:
9
- - gem update --system
10
- - gem update bundler
11
- install: "bundle install"
@@ -1,103 +0,0 @@
1
- module ActionView
2
- module Helpers
3
- module DateHelper
4
- alias_method :old_distance_of_time_in_words, :distance_of_time_in_words
5
-
6
- def distance_of_time_in_words_hash(from_time, to_time, options = {})
7
- from_time = from_time.to_time if !from_time.is_a?(Time) && from_time.respond_to?(:to_time)
8
- to_time = to_time.to_time if !to_time.is_a?(Time) && to_time.respond_to?(:to_time)
9
-
10
- DOTIW::TimeHash.new(nil, from_time, to_time, options).to_hash
11
- end
12
-
13
- def distance_of_time(seconds, options = {})
14
- options[:include_seconds] ||= true
15
- display_time_in_words DOTIW::TimeHash.new(seconds, nil, nil, options).to_hash, options
16
- end
17
-
18
- def distance_of_time_in_words(from_time, to_time = 0, include_seconds_or_options = {}, options = {})
19
- if include_seconds_or_options.is_a?(Hash)
20
- options = include_seconds_or_options
21
- else
22
- options[:include_seconds] ||= !!include_seconds_or_options
23
- end
24
- return distance_of_time(from_time, options) if to_time == 0
25
- return old_distance_of_time_in_words(from_time, to_time, options) if options.delete(:vague)
26
- hash = distance_of_time_in_words_hash(from_time, to_time, options)
27
- display_time_in_words(hash, options)
28
- end
29
-
30
- def distance_of_time_in_percent(from_time, current_time, to_time, options = {})
31
- options[:precision] ||= 0
32
- distance = to_time - from_time
33
- result = ((current_time - from_time) / distance) * 100
34
- number_with_precision(result, options).to_s + "%"
35
- end
36
-
37
- alias_method :old_time_ago_in_words, :time_ago_in_words
38
-
39
- def time_ago_in_words(from_time, include_seconds_or_options = {})
40
- distance_of_time_in_words(from_time, Time.current, include_seconds_or_options)
41
- end
42
-
43
- private
44
- def display_time_in_words(hash, options = {})
45
- options.reverse_merge!(
46
- :include_seconds => false
47
- ).symbolize_keys!
48
-
49
- include_seconds = options.delete(:include_seconds)
50
- hash.delete(:seconds) if !include_seconds && hash[:minutes]
51
-
52
- options[:except] = Array.wrap(options[:except]).map!(&:to_sym) if options[:except]
53
- options[:only] = Array.wrap(options[:only]).map!(&:to_sym) if options[:only]
54
-
55
- # Remove all the values that are nil or excluded. Keep the required ones.
56
- hash.delete_if do |key, value|
57
- value.nil? || value.zero? ||
58
- (options[:except] && options[:except].include?(key)) ||
59
- (options[:only] && !options[:only].include?(key))
60
- end
61
-
62
- i18n_scope = options.delete(:scope) || DOTIW::DEFAULT_I18N_SCOPE
63
- if hash.empty?
64
- fractions = DOTIW::TimeHash::TIME_FRACTIONS
65
- fractions = fractions & options[:only] if options[:only]
66
- fractions = fractions - options[:except] if options[:except]
67
-
68
- I18n.with_options :locale => options[:locale], :scope => i18n_scope do |locale|
69
- # e.g. try to format 'less than 1 days', fallback to '0 days'
70
- return locale.translate :less_than_x,
71
- :distance => locale.translate(fractions.first, :count => 1),
72
- :default => locale.translate(fractions.first, :count => 0)
73
- end
74
- end
75
-
76
- output = []
77
- I18n.with_options :locale => options[:locale], :scope => i18n_scope do |locale|
78
- output = hash.map { |key, value| locale.t(key, :count => value) }
79
- end
80
-
81
- options.delete(:except)
82
- options.delete(:only)
83
- highest_measures = options.delete(:highest_measures)
84
- highest_measures = 1 if options.delete(:highest_measure_only)
85
- if highest_measures
86
- output = output[0...highest_measures]
87
- end
88
-
89
- options[:words_connector] ||= I18n.translate :'datetime.dotiw.words_connector',
90
- :default => :'support.array.words_connector',
91
- :locale => options[:locale]
92
- options[:two_words_connector] ||= I18n.translate :'datetime.dotiw.two_words_connector',
93
- :default => :'support.array.two_words_connector',
94
- :locale => options[:locale]
95
- options[:last_word_connector] ||= I18n.translate :'datetime.dotiw.last_word_connector',
96
- :default => :'support.array.last_word_connector',
97
- :locale => options[:locale]
98
-
99
- output.to_sentence(options)
100
- end
101
- end # DateHelper
102
- end # Helpers
103
- end # ActionView