actionview 5.1.2 → 5.1.3.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionview might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed2636cdf141f22a4d1f7b47fe3d12dc9cfdef3b
4
- data.tar.gz: ca598be919cd46422703c2c96d22d139097faa41
3
+ metadata.gz: 6ff1b3ad9dcd88c717fd81042f1b03daf9a3965c
4
+ data.tar.gz: b9efd032901b9db13f40bec45b7a507315553da3
5
5
  SHA512:
6
- metadata.gz: 9edd512f3a863eea3a506c4f197c3f21dea5a0b3f87d71f750c557eeae4808b631f12962aa1e806eea3acc01d57ce9b1d99d19a3b0bd3afb1a1943e740a0c67c
7
- data.tar.gz: e558a901aa46f8d1ebe4fbe17075602f4a23e49bf4b56c8a4015eee015dc16a2cd02e855fd78d5b8d084fdb8d105d0f4953f9514274a60453a6c85fcd1c9a427
6
+ metadata.gz: e03f3b50e1c7c02565dce006c6075554bf0fb62a360e72368ced1da530ce934f64818519bdd68b5df3b4c9b10019a275e785186625682c99c3b81d66dc1edd34
7
+ data.tar.gz: d3c30e2b319df6e3d92d8120aea93117068d5173abecfe82840803c4fc949bc18227dc11b5112bf9b33bc990d0b9acd5c7c780599c9600832fd03159464fd6f5
@@ -1,3 +1,8 @@
1
+ ## Rails 5.1.3.rc1 (July 19, 2017) ##
2
+
3
+ * No changes.
4
+
5
+
1
6
  ## Rails 5.1.2 (June 26, 2017) ##
2
7
 
3
8
  * Fix issues with scopes and engine on `current_page?` method.
@@ -14,6 +19,11 @@
14
19
 
15
20
  *Yuji Yaginuma*
16
21
 
22
+ * Update distance_of_time_in_words helper to display better error messages
23
+ for bad input.
24
+
25
+ *Jay Hayes*
26
+
17
27
 
18
28
  ## Rails 5.1.1 (May 12, 2017) ##
19
29
 
@@ -7,8 +7,8 @@ module ActionView
7
7
  module VERSION
8
8
  MAJOR = 5
9
9
  MINOR = 1
10
- TINY = 2
11
- PRE = nil
10
+ TINY = 3
11
+ PRE = "rc1"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -95,8 +95,8 @@ module ActionView
95
95
  scope: :'datetime.distance_in_words'
96
96
  }.merge!(options)
97
97
 
98
- from_time = from_time.to_time if from_time.respond_to?(:to_time)
99
- to_time = to_time.to_time if to_time.respond_to?(:to_time)
98
+ from_time = normalize_distance_of_time_argument_to_time(from_time)
99
+ to_time = normalize_distance_of_time_argument_to_time(to_time)
100
100
  from_time, to_time = to_time, from_time if from_time > to_time
101
101
  distance_in_minutes = ((to_time - from_time) / 60.0).round
102
102
  distance_in_seconds = (to_time - from_time).round
@@ -130,22 +130,18 @@ module ActionView
130
130
  # 60 days up to 365 days
131
131
  when 86400...525600 then locale.t :x_months, count: (distance_in_minutes.to_f / 43200.0).round
132
132
  else
133
- if from_time.acts_like?(:time) && to_time.acts_like?(:time)
134
- fyear = from_time.year
135
- fyear += 1 if from_time.month >= 3
136
- tyear = to_time.year
137
- tyear -= 1 if to_time.month < 3
138
- leap_years = (fyear > tyear) ? 0 : (fyear..tyear).count { |x| Date.leap?(x) }
139
- minute_offset_for_leap_year = leap_years * 1440
140
- # Discount the leap year days when calculating year distance.
141
- # e.g. if there are 20 leap year days between 2 dates having the same day
142
- # and month then the based on 365 days calculation
143
- # the distance in years will come out to over 80 years when in written
144
- # English it would read better as about 80 years.
145
- minutes_with_offset = distance_in_minutes - minute_offset_for_leap_year
146
- else
147
- minutes_with_offset = distance_in_minutes
148
- end
133
+ from_year = from_time.year
134
+ from_year += 1 if from_time.month >= 3
135
+ to_year = to_time.year
136
+ to_year -= 1 if to_time.month < 3
137
+ leap_years = (from_year > to_year) ? 0 : (from_year..to_year).count { |x| Date.leap?(x) }
138
+ minute_offset_for_leap_year = leap_years * 1440
139
+ # Discount the leap year days when calculating year distance.
140
+ # e.g. if there are 20 leap year days between 2 dates having the same day
141
+ # and month then the based on 365 days calculation
142
+ # the distance in years will come out to over 80 years when in written
143
+ # English it would read better as about 80 years.
144
+ minutes_with_offset = distance_in_minutes - minute_offset_for_leap_year
149
145
  remainder = (minutes_with_offset % MINUTES_IN_YEAR)
150
146
  distance_in_years = (minutes_with_offset.div MINUTES_IN_YEAR)
151
147
  if remainder < MINUTES_IN_QUARTER_YEAR
@@ -687,6 +683,18 @@ module ActionView
687
683
 
688
684
  content_tag("time".freeze, content, options.reverse_merge(datetime: datetime), &block)
689
685
  end
686
+
687
+ private
688
+
689
+ def normalize_distance_of_time_argument_to_time(value)
690
+ if value.is_a?(Numeric)
691
+ Time.at(value)
692
+ elsif value.respond_to?(:to_time)
693
+ value.to_time
694
+ else
695
+ raise ArgumentError, "#{value.inspect} can't be converted to a Time value"
696
+ end
697
+ end
690
698
  end
691
699
 
692
700
  class DateTimeSelector #:nodoc:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionview
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.2
4
+ version: 5.1.3.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-26 00:00:00.000000000 Z
11
+ date: 2017-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.1.2
19
+ version: 5.1.3.rc1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.1.2
26
+ version: 5.1.3.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -92,28 +92,28 @@ dependencies:
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 5.1.2
95
+ version: 5.1.3.rc1
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 5.1.2
102
+ version: 5.1.3.rc1
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: activemodel
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 5.1.2
109
+ version: 5.1.3.rc1
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - '='
115
115
  - !ruby/object:Gem::Version
116
- version: 5.1.2
116
+ version: 5.1.3.rc1
117
117
  description: Simple, battle-tested conventions and helpers for building web pages.
118
118
  email: david@loudthinking.com
119
119
  executables: []
@@ -242,9 +242,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
242
242
  version: 2.2.2
243
243
  required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  requirements:
245
- - - ">="
245
+ - - ">"
246
246
  - !ruby/object:Gem::Version
247
- version: '0'
247
+ version: 1.3.1
248
248
  requirements:
249
249
  - none
250
250
  rubyforge_project: