activesupport 5.0.0.beta4 → 5.0.0.racecar1

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

Potentially problematic release.


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

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8995c0f44dc006471b68548dc53dc51fbf52ea55
4
- data.tar.gz: 75a84a6b054b348460ac48e3d8cb50e289b7c14f
3
+ metadata.gz: 4947af52b010145edd9fca9acc2a7518e47ad89c
4
+ data.tar.gz: 94738603adc22827837faadcbc90b96e41af13b3
5
5
  SHA512:
6
- metadata.gz: 734344387c65492c8f1773bf2b08587f006b9e02d6bc30622bb66b1258a453ba96a7d36d5c4cf89f459f1ffcced68f9c315e72cbbf643e8723fea2327e602597
7
- data.tar.gz: b0798910b73a354f74c6b96f86d962910de002ef13116b1423c9a4435c1327c1cdc5846af2fb1a30065cd0531f397069dcc90e7bd33fd6a86a158692776b9759
6
+ metadata.gz: f68f376a0b9d1376762030d1b85bc1ebc5ed475124be0deaa6cba0ea8229494b1991f3ac83d375279fed9da204aba6ea55bbb1e9d0d3287b9b36d5f778a60c4b
7
+ data.tar.gz: ba794a32a3e50402208cde7d77524ace536adc05831772df895c99c3d531b120a89358e580657500c6541dedd07b389ebd515a0a9ae816ff1c41eae831e6197b
@@ -1,3 +1,25 @@
1
+ ## Rails 5.0.0.rc1 (May 06, 2016) ##
2
+
3
+ * `ActiveSupport::Duration` supports weeks and hours.
4
+
5
+ [1.hour.inspect, 1.hour.value, 1.hour.parts]
6
+ # => ["3600 seconds", 3600, [[:seconds, 3600]]] # Before
7
+ # => ["1 hour", 3600, [[:hours, 1]]] # After
8
+
9
+ [1.week.inspect, 1.week.value, 1.week.parts]
10
+ # => ["7 days", 604800, [[:days, 7]]] # Before
11
+ # => ["1 week", 604800, [[:weeks, 1]]] # After
12
+
13
+ This brings us into closer conformance with ISO8601 and relieves some
14
+ astonishment about getting `1.hour.inspect # => 3600 seconds`.
15
+
16
+ Compatibility: The duration's `value` remains the same, so apps using
17
+ durations are oblivious to the new time periods. Apps, libraries, and
18
+ plugins that work with the internal `parts` hash will need to broaden
19
+ their time period handling to cover hours & weeks.
20
+
21
+ *Andrey Novikov*
22
+
1
23
  ## Rails 5.0.0.beta4 (April 27, 2016) ##
2
24
 
3
25
  * Time zones: Ensure that the UTC offset reflects DST changes that occurred
@@ -89,24 +89,19 @@ class Array
89
89
  # [1, 2, 3, 4, 5].split(3) # => [[1, 2], [4, 5]]
90
90
  # (1..10).to_a.split { |i| i % 3 == 0 } # => [[1, 2], [4, 5], [7, 8], [10]]
91
91
  def split(value = nil)
92
+ arr = self.dup
93
+ result = []
92
94
  if block_given?
93
- inject([[]]) do |results, element|
94
- if yield(element)
95
- results << []
96
- else
97
- results.last << element
98
- end
99
-
100
- results
95
+ while (idx = arr.index { |i| yield i })
96
+ result << arr.shift(idx)
97
+ arr.shift
101
98
  end
102
99
  else
103
- arr = self.dup
104
- result = []
105
100
  while (idx = arr.index(value))
106
101
  result << arr.shift(idx)
107
102
  arr.shift
108
103
  end
109
- result << arr
110
104
  end
105
+ result << arr
111
106
  end
112
107
  end
@@ -5,7 +5,7 @@ module DateAndTime
5
5
  #
6
6
  # Time.zone = 'Hawaii' # => 'Hawaii'
7
7
  # Time.utc(2000).in_time_zone # => Fri, 31 Dec 1999 14:00:00 HST -10:00
8
- # Date.new(2000).in_time_zone # => Sat, 01 Jan 2000 00:00:00 HST -10:00
8
+ # Date.new(2000).in_time_zone # => Sat, 01 Jan 2000 00:00:00 HST -10:00
9
9
  #
10
10
  # This method is similar to Time#localtime, except that it uses <tt>Time.zone</tt> as the local zone
11
11
  # instead of the operating system's time zone.
@@ -14,7 +14,7 @@ module DateAndTime
14
14
  # and the conversion will be based on that zone instead of <tt>Time.zone</tt>.
15
15
  #
16
16
  # Time.utc(2000).in_time_zone('Alaska') # => Fri, 31 Dec 1999 15:00:00 AKST -09:00
17
- # Date.new(2000).in_time_zone('Alaska') # => Sat, 01 Jan 2000 00:00:00 AKST -09:00
17
+ # Date.new(2000).in_time_zone('Alaska') # => Sat, 01 Jan 2000 00:00:00 AKST -09:00
18
18
  def in_time_zone(zone = ::Time.zone)
19
19
  time_zone = ::Time.find_zone! zone
20
20
  time = acts_like?(:time) ? self : nil
@@ -17,11 +17,12 @@ module Enumerable
17
17
  # The default sum of an empty list is zero. You can override this default:
18
18
  #
19
19
  # [].sum(Payment.new(0)) { |i| i.amount } # => Payment.new(0)
20
- def sum(identity = 0, &block)
20
+ def sum(identity = nil, &block)
21
21
  if block_given?
22
22
  map(&block).sum(identity)
23
23
  else
24
- inject(:+) || identity
24
+ sum = identity ? inject(identity, :+) : inject(:+)
25
+ sum || identity || 0
25
26
  end
26
27
  end
27
28
 
@@ -91,15 +92,16 @@ end
91
92
  class Range #:nodoc:
92
93
  # Optimize range sum to use arithmetic progression if a block is not given and
93
94
  # we have a range of numeric values.
94
- def sum(identity = 0)
95
+ def sum(identity = nil)
95
96
  if block_given? || !(first.is_a?(Integer) && last.is_a?(Integer))
96
97
  super
97
98
  else
98
99
  actual_last = exclude_end? ? (last - 1) : last
99
100
  if actual_last >= first
100
- (actual_last - first + 1) * (actual_last + first) / 2
101
+ sum = identity || 0
102
+ sum + (actual_last - first + 1) * (actual_last + first) / 2
101
103
  else
102
- identity
104
+ identity || 0
103
105
  end
104
106
  end
105
107
  end
@@ -25,17 +25,17 @@ class Numeric
25
25
 
26
26
  # Returns a Duration instance matching the number of minutes provided.
27
27
  #
28
- # 2.minutes # => 120 seconds
28
+ # 2.minutes # => 2 minutes
29
29
  def minutes
30
- ActiveSupport::Duration.new(self * 60, [[:seconds, self * 60]])
30
+ ActiveSupport::Duration.new(self * 60, [[:minutes, self]])
31
31
  end
32
32
  alias :minute :minutes
33
33
 
34
34
  # Returns a Duration instance matching the number of hours provided.
35
35
  #
36
- # 2.hours # => 7_200 seconds
36
+ # 2.hours # => 2 hours
37
37
  def hours
38
- ActiveSupport::Duration.new(self * 3600, [[:seconds, self * 3600]])
38
+ ActiveSupport::Duration.new(self * 3600, [[:hours, self]])
39
39
  end
40
40
  alias :hour :hours
41
41
 
@@ -49,17 +49,17 @@ class Numeric
49
49
 
50
50
  # Returns a Duration instance matching the number of weeks provided.
51
51
  #
52
- # 2.weeks # => 14 days
52
+ # 2.weeks # => 2 weeks
53
53
  def weeks
54
- ActiveSupport::Duration.new(self * 7.days, [[:days, self * 7]])
54
+ ActiveSupport::Duration.new(self * 7.days, [[:weeks, self]])
55
55
  end
56
56
  alias :week :weeks
57
57
 
58
58
  # Returns a Duration instance matching the number of fortnights provided.
59
59
  #
60
- # 2.fortnights # => 28 days
60
+ # 2.fortnights # => 4 weeks
61
61
  def fortnights
62
- ActiveSupport::Duration.new(self * 2.weeks, [[:days, self * 14]])
62
+ ActiveSupport::Duration.new(self * 2.weeks, [[:weeks, self * 2]])
63
63
  end
64
64
  alias :fortnight :fortnights
65
65
 
@@ -97,6 +97,8 @@ class Hash
97
97
  end
98
98
 
99
99
  class String
100
+ BLANK_RE = /\A[[:space:]]*\z/
101
+
100
102
  # A string is blank if it's empty or contains whitespaces only:
101
103
  #
102
104
  # ''.blank? # => true
@@ -113,10 +115,7 @@ class String
113
115
  # The regexp that matches blank strings is expensive. For the case of empty
114
116
  # strings we can speed up this method (~3.5x) with an empty? call. The
115
117
  # penalty for the rest of strings is marginal.
116
- #
117
- # Double negation in the second operand is also a performance tweak, it is
118
- # faster than the positive \A[[:space:]]*\z.
119
- empty? || !(/[[:^space:]]/ === self)
118
+ empty? || BLANK_RE === self
120
119
  end
121
120
  end
122
121
 
@@ -120,7 +120,7 @@ module ActiveSupport
120
120
  def inspect #:nodoc:
121
121
  parts.
122
122
  reduce(::Hash.new(0)) { |h,(l,r)| h[l] += r; h }.
123
- sort_by {|unit, _ | [:years, :months, :days, :minutes, :seconds].index(unit)}.
123
+ sort_by {|unit, _ | [:years, :months, :weeks, :days, :hours, :minutes, :seconds].index(unit)}.
124
124
  map {|unit, val| "#{val} #{val == 1 ? unit.to_s.chop : unit.to_s}"}.
125
125
  to_sentence(locale: ::I18n.default_locale)
126
126
  end
@@ -159,6 +159,10 @@ module ActiveSupport
159
159
  if t.acts_like?(:time) || t.acts_like?(:date)
160
160
  if type == :seconds
161
161
  t.since(sign * number)
162
+ elsif type == :minutes
163
+ t.since(sign * number * 60)
164
+ elsif type == :hours
165
+ t.since(sign * number * 3600)
162
166
  else
163
167
  t.advance(type => sign * number)
164
168
  end
@@ -8,7 +8,7 @@ module ActiveSupport
8
8
  MAJOR = 5
9
9
  MINOR = 0
10
10
  TINY = 0
11
- PRE = "beta4"
11
+ PRE = "racecar1"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.beta4
4
+ version: 5.0.0.racecar1
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: 2016-04-27 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -59,6 +59,9 @@ dependencies:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.0'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 1.0.2
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
@@ -66,6 +69,9 @@ dependencies:
66
69
  - - "~>"
67
70
  - !ruby/object:Gem::Version
68
71
  version: '1.0'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 1.0.2
69
75
  description: A toolkit of support libraries and Ruby core extensions extracted from
70
76
  the Rails framework. Rich support for multibyte strings, internationalization, time
71
77
  zones, and testing.
@@ -330,7 +336,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
330
336
  version: 1.3.1
331
337
  requirements: []
332
338
  rubyforge_project:
333
- rubygems_version: 2.6.4
339
+ rubygems_version: 2.5.1
334
340
  signing_key:
335
341
  specification_version: 4
336
342
  summary: A toolkit of support libraries and Ruby core extensions extracted from the