activesupport 5.0.7.2 → 5.1.0.beta1

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.

Files changed (210) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +215 -820
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/lib/active_support.rb +8 -4
  6. data/lib/active_support/all.rb +3 -3
  7. data/lib/active_support/array_inquirer.rb +7 -5
  8. data/lib/active_support/backtrace_cleaner.rb +4 -4
  9. data/lib/active_support/benchmarkable.rb +3 -3
  10. data/lib/active_support/builder.rb +1 -1
  11. data/lib/active_support/cache.rb +42 -49
  12. data/lib/active_support/cache/file_store.rb +12 -21
  13. data/lib/active_support/cache/mem_cache_store.rb +30 -40
  14. data/lib/active_support/cache/memory_store.rb +11 -13
  15. data/lib/active_support/cache/null_store.rb +4 -4
  16. data/lib/active_support/cache/strategy/local_cache.rb +16 -25
  17. data/lib/active_support/cache/strategy/local_cache_middleware.rb +8 -9
  18. data/lib/active_support/callbacks.rb +647 -584
  19. data/lib/active_support/concurrency/share_lock.rb +20 -21
  20. data/lib/active_support/configurable.rb +5 -5
  21. data/lib/active_support/core_ext.rb +1 -2
  22. data/lib/active_support/core_ext/array.rb +7 -7
  23. data/lib/active_support/core_ext/array/access.rb +1 -1
  24. data/lib/active_support/core_ext/array/conversions.rb +15 -15
  25. data/lib/active_support/core_ext/array/grouping.rb +1 -1
  26. data/lib/active_support/core_ext/array/inquiry.rb +1 -1
  27. data/lib/active_support/core_ext/array/prepend_and_append.rb +1 -1
  28. data/lib/active_support/core_ext/benchmark.rb +1 -1
  29. data/lib/active_support/core_ext/big_decimal.rb +1 -1
  30. data/lib/active_support/core_ext/big_decimal/conversions.rb +4 -6
  31. data/lib/active_support/core_ext/class.rb +2 -2
  32. data/lib/active_support/core_ext/class/attribute.rb +5 -5
  33. data/lib/active_support/core_ext/class/attribute_accessors.rb +1 -1
  34. data/lib/active_support/core_ext/class/subclasses.rb +18 -4
  35. data/lib/active_support/core_ext/date.rb +5 -5
  36. data/lib/active_support/core_ext/date/acts_like.rb +1 -1
  37. data/lib/active_support/core_ext/date/blank.rb +1 -1
  38. data/lib/active_support/core_ext/date/calculations.rb +8 -8
  39. data/lib/active_support/core_ext/date/conversions.rb +12 -12
  40. data/lib/active_support/core_ext/date/zones.rb +2 -2
  41. data/lib/active_support/core_ext/date_and_time/calculations.rb +27 -22
  42. data/lib/active_support/core_ext/date_and_time/compatibility.rb +9 -1
  43. data/lib/active_support/core_ext/date_and_time/zones.rb +7 -8
  44. data/lib/active_support/core_ext/date_time.rb +5 -5
  45. data/lib/active_support/core_ext/date_time/acts_like.rb +2 -2
  46. data/lib/active_support/core_ext/date_time/blank.rb +1 -1
  47. data/lib/active_support/core_ext/date_time/calculations.rb +9 -9
  48. data/lib/active_support/core_ext/date_time/compatibility.rb +2 -13
  49. data/lib/active_support/core_ext/date_time/conversions.rb +12 -12
  50. data/lib/active_support/core_ext/digest/uuid.rb +4 -4
  51. data/lib/active_support/core_ext/enumerable.rb +46 -57
  52. data/lib/active_support/core_ext/file.rb +1 -1
  53. data/lib/active_support/core_ext/file/atomic.rb +4 -4
  54. data/lib/active_support/core_ext/hash.rb +9 -9
  55. data/lib/active_support/core_ext/hash/compact.rb +12 -9
  56. data/lib/active_support/core_ext/hash/conversions.rb +36 -37
  57. data/lib/active_support/core_ext/hash/indifferent_access.rb +1 -2
  58. data/lib/active_support/core_ext/hash/keys.rb +8 -8
  59. data/lib/active_support/core_ext/hash/reverse_merge.rb +1 -1
  60. data/lib/active_support/core_ext/hash/slice.rb +4 -4
  61. data/lib/active_support/core_ext/hash/transform_values.rb +1 -0
  62. data/lib/active_support/core_ext/integer.rb +3 -3
  63. data/lib/active_support/core_ext/integer/inflections.rb +1 -1
  64. data/lib/active_support/core_ext/integer/time.rb +2 -2
  65. data/lib/active_support/core_ext/kernel.rb +4 -4
  66. data/lib/active_support/core_ext/kernel/concern.rb +1 -1
  67. data/lib/active_support/core_ext/kernel/reporting.rb +1 -1
  68. data/lib/active_support/core_ext/load_error.rb +1 -18
  69. data/lib/active_support/core_ext/marshal.rb +2 -2
  70. data/lib/active_support/core_ext/module.rb +11 -12
  71. data/lib/active_support/core_ext/module/aliasing.rb +3 -48
  72. data/lib/active_support/core_ext/module/attr_internal.rb +4 -4
  73. data/lib/active_support/core_ext/module/attribute_accessors.rb +11 -5
  74. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +20 -13
  75. data/lib/active_support/core_ext/module/concerning.rb +1 -1
  76. data/lib/active_support/core_ext/module/delegation.rb +82 -16
  77. data/lib/active_support/core_ext/module/introspection.rb +3 -11
  78. data/lib/active_support/core_ext/module/reachable.rb +2 -2
  79. data/lib/active_support/core_ext/numeric.rb +4 -4
  80. data/lib/active_support/core_ext/numeric/conversions.rb +3 -9
  81. data/lib/active_support/core_ext/numeric/inquiry.rb +21 -21
  82. data/lib/active_support/core_ext/numeric/time.rb +5 -5
  83. data/lib/active_support/core_ext/object.rb +12 -12
  84. data/lib/active_support/core_ext/object/blank.rb +3 -1
  85. data/lib/active_support/core_ext/object/conversions.rb +4 -4
  86. data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
  87. data/lib/active_support/core_ext/object/duplicable.rb +24 -4
  88. data/lib/active_support/core_ext/object/inclusion.rb +1 -1
  89. data/lib/active_support/core_ext/object/json.rb +26 -12
  90. data/lib/active_support/core_ext/object/to_param.rb +1 -1
  91. data/lib/active_support/core_ext/object/to_query.rb +4 -4
  92. data/lib/active_support/core_ext/object/try.rb +1 -1
  93. data/lib/active_support/core_ext/object/with_options.rb +1 -1
  94. data/lib/active_support/core_ext/range.rb +4 -4
  95. data/lib/active_support/core_ext/range/conversions.rb +1 -1
  96. data/lib/active_support/core_ext/regexp.rb +4 -0
  97. data/lib/active_support/core_ext/securerandom.rb +3 -3
  98. data/lib/active_support/core_ext/string.rb +13 -13
  99. data/lib/active_support/core_ext/string/access.rb +6 -6
  100. data/lib/active_support/core_ext/string/conversions.rb +2 -2
  101. data/lib/active_support/core_ext/string/filters.rb +3 -3
  102. data/lib/active_support/core_ext/string/indent.rb +4 -4
  103. data/lib/active_support/core_ext/string/inflections.rb +10 -14
  104. data/lib/active_support/core_ext/string/inquiry.rb +1 -1
  105. data/lib/active_support/core_ext/string/multibyte.rb +1 -1
  106. data/lib/active_support/core_ext/string/output_safety.rb +19 -20
  107. data/lib/active_support/core_ext/string/strip.rb +1 -1
  108. data/lib/active_support/core_ext/string/zones.rb +2 -2
  109. data/lib/active_support/core_ext/time.rb +5 -5
  110. data/lib/active_support/core_ext/time/acts_like.rb +1 -1
  111. data/lib/active_support/core_ext/time/calculations.rb +23 -29
  112. data/lib/active_support/core_ext/time/compatibility.rb +1 -10
  113. data/lib/active_support/core_ext/time/conversions.rb +12 -12
  114. data/lib/active_support/core_ext/time/zones.rb +3 -3
  115. data/lib/active_support/core_ext/uri.rb +2 -2
  116. data/lib/active_support/dependencies.rb +45 -47
  117. data/lib/active_support/dependencies/interlock.rb +1 -1
  118. data/lib/active_support/deprecation.rb +8 -8
  119. data/lib/active_support/deprecation/behaviors.rb +3 -3
  120. data/lib/active_support/deprecation/instance_delegator.rb +2 -2
  121. data/lib/active_support/deprecation/method_wrappers.rb +3 -3
  122. data/lib/active_support/deprecation/proxy_wrappers.rb +6 -4
  123. data/lib/active_support/deprecation/reporting.rb +7 -7
  124. data/lib/active_support/duration.rb +30 -26
  125. data/lib/active_support/duration/iso8601_parser.rb +66 -65
  126. data/lib/active_support/duration/iso8601_serializer.rb +11 -9
  127. data/lib/active_support/evented_file_update_checker.rb +59 -60
  128. data/lib/active_support/execution_wrapper.rb +3 -3
  129. data/lib/active_support/executor.rb +1 -1
  130. data/lib/active_support/file_update_checker.rb +54 -50
  131. data/lib/active_support/gem_version.rb +3 -3
  132. data/lib/active_support/gzip.rb +5 -5
  133. data/lib/active_support/hash_with_indifferent_access.rb +10 -20
  134. data/lib/active_support/i18n.rb +5 -5
  135. data/lib/active_support/i18n_railtie.rb +11 -10
  136. data/lib/active_support/inflections.rb +11 -11
  137. data/lib/active_support/inflector.rb +5 -5
  138. data/lib/active_support/inflector/inflections.rb +11 -9
  139. data/lib/active_support/inflector/methods.rb +51 -50
  140. data/lib/active_support/inflector/transliterate.rb +8 -11
  141. data/lib/active_support/json.rb +2 -2
  142. data/lib/active_support/json/decoding.rb +3 -3
  143. data/lib/active_support/json/encoding.rb +8 -7
  144. data/lib/active_support/key_generator.rb +17 -17
  145. data/lib/active_support/lazy_load_hooks.rb +12 -30
  146. data/lib/active_support/log_subscriber.rb +5 -5
  147. data/lib/active_support/log_subscriber/test_helper.rb +9 -9
  148. data/lib/active_support/logger.rb +3 -3
  149. data/lib/active_support/logger_silence.rb +3 -3
  150. data/lib/active_support/logger_thread_safe_level.rb +1 -1
  151. data/lib/active_support/message_encryptor.rb +72 -35
  152. data/lib/active_support/message_verifier.rb +7 -7
  153. data/lib/active_support/multibyte.rb +2 -2
  154. data/lib/active_support/multibyte/chars.rb +23 -21
  155. data/lib/active_support/multibyte/unicode.rb +68 -89
  156. data/lib/active_support/notifications.rb +5 -5
  157. data/lib/active_support/notifications/fanout.rb +3 -3
  158. data/lib/active_support/notifications/instrumenter.rb +5 -5
  159. data/lib/active_support/number_helper.rb +4 -4
  160. data/lib/active_support/number_helper/number_converter.rb +11 -11
  161. data/lib/active_support/number_helper/number_to_currency_converter.rb +3 -3
  162. data/lib/active_support/number_helper/number_to_delimited_converter.rb +1 -2
  163. data/lib/active_support/number_helper/number_to_human_converter.rb +6 -6
  164. data/lib/active_support/number_helper/number_to_human_size_converter.rb +6 -11
  165. data/lib/active_support/number_helper/number_to_percentage_converter.rb +1 -1
  166. data/lib/active_support/number_helper/number_to_phone_converter.rb +1 -3
  167. data/lib/active_support/number_helper/number_to_rounded_converter.rb +6 -6
  168. data/lib/active_support/option_merger.rb +1 -1
  169. data/lib/active_support/ordered_hash.rb +3 -3
  170. data/lib/active_support/ordered_options.rb +6 -4
  171. data/lib/active_support/per_thread_registry.rb +5 -5
  172. data/lib/active_support/rails.rb +12 -6
  173. data/lib/active_support/railtie.rb +3 -3
  174. data/lib/active_support/reloader.rb +1 -1
  175. data/lib/active_support/rescuable.rb +8 -14
  176. data/lib/active_support/security_utils.rb +1 -1
  177. data/lib/active_support/string_inquirer.rb +8 -2
  178. data/lib/active_support/subscriber.rb +9 -5
  179. data/lib/active_support/tagged_logging.rb +4 -4
  180. data/lib/active_support/test_case.rb +12 -29
  181. data/lib/active_support/testing/assertions.rb +100 -2
  182. data/lib/active_support/testing/autorun.rb +6 -2
  183. data/lib/active_support/testing/constant_lookup.rb +0 -1
  184. data/lib/active_support/testing/declarative.rb +1 -1
  185. data/lib/active_support/testing/deprecation.rb +3 -2
  186. data/lib/active_support/testing/isolation.rb +13 -22
  187. data/lib/active_support/testing/method_call_assertions.rb +1 -1
  188. data/lib/active_support/testing/setup_and_teardown.rb +2 -2
  189. data/lib/active_support/testing/stream.rb +28 -28
  190. data/lib/active_support/testing/tagged_logging.rb +1 -1
  191. data/lib/active_support/testing/time_helpers.rb +45 -12
  192. data/lib/active_support/time.rb +12 -12
  193. data/lib/active_support/time_with_zone.rb +16 -26
  194. data/lib/active_support/values/time_zone.rb +40 -46
  195. data/lib/active_support/values/unicode_tables.dat +0 -0
  196. data/lib/active_support/version.rb +1 -1
  197. data/lib/active_support/xml_mini.rb +34 -36
  198. data/lib/active_support/xml_mini/jdom.rb +112 -112
  199. data/lib/active_support/xml_mini/libxml.rb +15 -12
  200. data/lib/active_support/xml_mini/libxmlsax.rb +17 -15
  201. data/lib/active_support/xml_mini/nokogiri.rb +13 -11
  202. data/lib/active_support/xml_mini/nokogirisax.rb +15 -14
  203. data/lib/active_support/xml_mini/rexml.rb +9 -9
  204. metadata +8 -19
  205. data/lib/active_support/concurrency/latch.rb +0 -26
  206. data/lib/active_support/core_ext/kernel/debugger.rb +0 -3
  207. data/lib/active_support/core_ext/module/method_transplanting.rb +0 -3
  208. data/lib/active_support/core_ext/module/qualified_const.rb +0 -70
  209. data/lib/active_support/core_ext/struct.rb +0 -3
  210. data/lib/active_support/core_ext/time/marshal.rb +0 -3
@@ -1,7 +1,6 @@
1
1
  module ActiveSupport
2
2
  module Multibyte
3
3
  module Unicode
4
-
5
4
  extend self
6
5
 
7
6
  # A list of all available normalization forms.
@@ -10,7 +9,7 @@ module ActiveSupport
10
9
  NORMALIZATION_FORMS = [:c, :kc, :d, :kd]
11
10
 
12
11
  # The Unicode version that is supported by the implementation
13
- UNICODE_VERSION = '8.0.0'
12
+ UNICODE_VERSION = "9.0.0"
14
13
 
15
14
  # The default normalization used for operations that require
16
15
  # normalization. It can be set to any of the normalizations
@@ -31,36 +30,6 @@ module ActiveSupport
31
30
  HANGUL_NCOUNT = HANGUL_VCOUNT * HANGUL_TCOUNT
32
31
  HANGUL_SCOUNT = 11172
33
32
  HANGUL_SLAST = HANGUL_SBASE + HANGUL_SCOUNT
34
- HANGUL_JAMO_FIRST = 0x1100
35
- HANGUL_JAMO_LAST = 0x11FF
36
-
37
- # All the unicode whitespace
38
- WHITESPACE = [
39
- (0x0009..0x000D).to_a, # White_Space # Cc [5] <control-0009>..<control-000D>
40
- 0x0020, # White_Space # Zs SPACE
41
- 0x0085, # White_Space # Cc <control-0085>
42
- 0x00A0, # White_Space # Zs NO-BREAK SPACE
43
- 0x1680, # White_Space # Zs OGHAM SPACE MARK
44
- (0x2000..0x200A).to_a, # White_Space # Zs [11] EN QUAD..HAIR SPACE
45
- 0x2028, # White_Space # Zl LINE SEPARATOR
46
- 0x2029, # White_Space # Zp PARAGRAPH SEPARATOR
47
- 0x202F, # White_Space # Zs NARROW NO-BREAK SPACE
48
- 0x205F, # White_Space # Zs MEDIUM MATHEMATICAL SPACE
49
- 0x3000, # White_Space # Zs IDEOGRAPHIC SPACE
50
- ].flatten.freeze
51
-
52
- # BOM (byte order mark) can also be seen as whitespace, it's a
53
- # non-rendering character used to distinguish between little and big
54
- # endian. This is not an issue in utf-8, so it must be ignored.
55
- LEADERS_AND_TRAILERS = WHITESPACE + [65279] # ZERO-WIDTH NO-BREAK SPACE aka BOM
56
-
57
- # Returns a regular expression pattern that matches the passed Unicode
58
- # codepoints.
59
- def self.codepoints_to_pattern(array_of_codepoints) #:nodoc:
60
- array_of_codepoints.collect{ |e| [e].pack 'U*'.freeze }.join('|'.freeze)
61
- end
62
- TRAILERS_PAT = /(#{codepoints_to_pattern(LEADERS_AND_TRAILERS)})+\Z/u
63
- LEADERS_PAT = /\A(#{codepoints_to_pattern(LEADERS_AND_TRAILERS)})+/u
64
33
 
65
34
  # Detect whether the codepoint is in a certain character class. Returns
66
35
  # +true+ when it's in the specified character class and +false+ otherwise.
@@ -83,35 +52,35 @@ module ActiveSupport
83
52
  pos = 0
84
53
  marker = 0
85
54
  eoc = codepoints.length
86
- while(pos < eoc)
55
+ while (pos < eoc)
87
56
  pos += 1
88
- previous = codepoints[pos-1]
57
+ previous = codepoints[pos - 1]
89
58
  current = codepoints[pos]
90
59
 
60
+ # See http://unicode.org/reports/tr29/#Grapheme_Cluster_Boundary_Rules
91
61
  should_break =
62
+ if pos == eoc
63
+ true
92
64
  # GB3. CR X LF
93
- if previous == database.boundary[:cr] and current == database.boundary[:lf]
65
+ elsif previous == database.boundary[:cr] && current == database.boundary[:lf]
94
66
  false
95
67
  # GB4. (Control|CR|LF) ÷
96
- elsif previous and in_char_class?(previous, [:control,:cr,:lf])
68
+ elsif previous && in_char_class?(previous, [:control, :cr, :lf])
97
69
  true
98
70
  # GB5. ÷ (Control|CR|LF)
99
- elsif in_char_class?(current, [:control,:cr,:lf])
71
+ elsif in_char_class?(current, [:control, :cr, :lf])
100
72
  true
101
73
  # GB6. L X (L|V|LV|LVT)
102
- elsif database.boundary[:l] === previous and in_char_class?(current, [:l,:v,:lv,:lvt])
74
+ elsif database.boundary[:l] === previous && in_char_class?(current, [:l, :v, :lv, :lvt])
103
75
  false
104
76
  # GB7. (LV|V) X (V|T)
105
- elsif in_char_class?(previous, [:lv,:v]) and in_char_class?(current, [:v,:t])
77
+ elsif in_char_class?(previous, [:lv, :v]) && in_char_class?(current, [:v, :t])
106
78
  false
107
79
  # GB8. (LVT|T) X (T)
108
- elsif in_char_class?(previous, [:lvt,:t]) and database.boundary[:t] === current
80
+ elsif in_char_class?(previous, [:lvt, :t]) && database.boundary[:t] === current
109
81
  false
110
- # GB8a. Regional_Indicator X Regional_Indicator
111
- elsif database.boundary[:regional_indicator] === previous and database.boundary[:regional_indicator] === current
112
- false
113
- # GB9. X Extend
114
- elsif database.boundary[:extend] === current
82
+ # GB9. X (Extend | ZWJ)
83
+ elsif in_char_class?(current, [:extend, :zwj])
115
84
  false
116
85
  # GB9a. X SpacingMark
117
86
  elsif database.boundary[:spacingmark] === current
@@ -119,13 +88,23 @@ module ActiveSupport
119
88
  # GB9b. Prepend X
120
89
  elsif database.boundary[:prepend] === previous
121
90
  false
122
- # GB10. Any ÷ Any
91
+ # GB10. (E_Base | EBG) Extend* X E_Modifier
92
+ elsif (marker...pos).any? { |i| in_char_class?(codepoints[i], [:e_base, :e_base_gaz]) && codepoints[i + 1...pos].all? { |c| database.boundary[:extend] === c } } && database.boundary[:e_modifier] === current
93
+ false
94
+ # GB11. ZWJ X (Glue_After_Zwj | EBG)
95
+ elsif database.boundary[:zwj] === previous && in_char_class?(current, [:glue_after_zwj, :e_base_gaz])
96
+ false
97
+ # GB12. ^ (RI RI)* RI X RI
98
+ # GB13. [^RI] (RI RI)* RI X RI
99
+ elsif codepoints[marker..pos].all? { |c| database.boundary[:regional_indicator] === c } && codepoints[marker..pos].count { |c| database.boundary[:regional_indicator] === c }.even?
100
+ false
101
+ # GB999. Any ÷ Any
123
102
  else
124
103
  true
125
104
  end
126
105
 
127
106
  if should_break
128
- unpacked << codepoints[marker..pos-1]
107
+ unpacked << codepoints[marker..pos - 1]
129
108
  marker = pos
130
109
  end
131
110
  end
@@ -136,17 +115,17 @@ module ActiveSupport
136
115
  #
137
116
  # Unicode.pack_graphemes(Unicode.unpack_graphemes('क्षि')) # => 'क्षि'
138
117
  def pack_graphemes(unpacked)
139
- unpacked.flatten.pack('U*')
118
+ unpacked.flatten.pack("U*")
140
119
  end
141
120
 
142
121
  # Re-order codepoints so the string becomes canonical.
143
122
  def reorder_characters(codepoints)
144
- length = codepoints.length- 1
123
+ length = codepoints.length - 1
145
124
  pos = 0
146
125
  while pos < length do
147
- cp1, cp2 = database.codepoints[codepoints[pos]], database.codepoints[codepoints[pos+1]]
126
+ cp1, cp2 = database.codepoints[codepoints[pos]], database.codepoints[codepoints[pos + 1]]
148
127
  if (cp1.combining_class > cp2.combining_class) && (cp2.combining_class > 0)
149
- codepoints[pos..pos+1] = cp2.code, cp1.code
128
+ codepoints[pos..pos + 1] = cp2.code, cp1.code
150
129
  pos += (pos > 0 ? -1 : 1)
151
130
  else
152
131
  pos += 1
@@ -159,7 +138,7 @@ module ActiveSupport
159
138
  def decompose(type, codepoints)
160
139
  codepoints.inject([]) do |decomposed, cp|
161
140
  # if it's a hangul syllable starter character
162
- if HANGUL_SBASE <= cp and cp < HANGUL_SLAST
141
+ if HANGUL_SBASE <= cp && cp < HANGUL_SLAST
163
142
  sindex = cp - HANGUL_SBASE
164
143
  ncp = [] # new codepoints
165
144
  ncp << HANGUL_LBASE + sindex / HANGUL_NCOUNT
@@ -168,7 +147,7 @@ module ActiveSupport
168
147
  ncp << (HANGUL_TBASE + tindex) unless tindex == 0
169
148
  decomposed.concat ncp
170
149
  # if the codepoint is decomposable in with the current decomposition type
171
- elsif (ncp = database.codepoints[cp].decomp_mapping) and (!database.codepoints[cp].decomp_type || type == :compatibility)
150
+ elsif (ncp = database.codepoints[cp].decomp_mapping) && (!database.codepoints[cp].decomp_type || type == :compatibility)
172
151
  decomposed.concat decompose(type, ncp.dup)
173
152
  else
174
153
  decomposed << cp
@@ -187,11 +166,11 @@ module ActiveSupport
187
166
  pos += 1
188
167
  lindex = starter_char - HANGUL_LBASE
189
168
  # -- Hangul
190
- if 0 <= lindex and lindex < HANGUL_LCOUNT
191
- vindex = codepoints[starter_pos+1] - HANGUL_VBASE rescue vindex = -1
192
- if 0 <= vindex and vindex < HANGUL_VCOUNT
193
- tindex = codepoints[starter_pos+2] - HANGUL_TBASE rescue tindex = -1
194
- if 0 <= tindex and tindex < HANGUL_TCOUNT
169
+ if 0 <= lindex && lindex < HANGUL_LCOUNT
170
+ vindex = codepoints[starter_pos + 1] - HANGUL_VBASE rescue vindex = -1
171
+ if 0 <= vindex && vindex < HANGUL_VCOUNT
172
+ tindex = codepoints[starter_pos + 2] - HANGUL_TBASE rescue tindex = -1
173
+ if 0 <= tindex && tindex < HANGUL_TCOUNT
195
174
  j = starter_pos + 2
196
175
  eoa -= 2
197
176
  else
@@ -259,7 +238,7 @@ module ActiveSupport
259
238
  reader = Encoding::Converter.new(Encoding::UTF_8, Encoding::UTF_16LE)
260
239
 
261
240
  source = string.dup
262
- out = ''.force_encoding(Encoding::UTF_16LE)
241
+ out = "".force_encoding(Encoding::UTF_16LE)
263
242
 
264
243
  loop do
265
244
  reader.primitive_convert(source, out)
@@ -282,22 +261,22 @@ module ActiveSupport
282
261
  # * <tt>form</tt> - The form you want to normalize in. Should be one of
283
262
  # the following: <tt>:c</tt>, <tt>:kc</tt>, <tt>:d</tt>, or <tt>:kd</tt>.
284
263
  # Default is ActiveSupport::Multibyte::Unicode.default_normalization_form.
285
- def normalize(string, form=nil)
264
+ def normalize(string, form = nil)
286
265
  form ||= @default_normalization_form
287
266
  # See http://www.unicode.org/reports/tr15, Table 1
288
267
  codepoints = string.codepoints.to_a
289
268
  case form
290
- when :d
291
- reorder_characters(decompose(:canonical, codepoints))
292
- when :c
293
- compose(reorder_characters(decompose(:canonical, codepoints)))
294
- when :kd
295
- reorder_characters(decompose(:compatibility, codepoints))
296
- when :kc
297
- compose(reorder_characters(decompose(:compatibility, codepoints)))
269
+ when :d
270
+ reorder_characters(decompose(:canonical, codepoints))
271
+ when :c
272
+ compose(reorder_characters(decompose(:canonical, codepoints)))
273
+ when :kd
274
+ reorder_characters(decompose(:compatibility, codepoints))
275
+ when :kc
276
+ compose(reorder_characters(decompose(:compatibility, codepoints)))
298
277
  else
299
- raise ArgumentError, "#{form} is not a valid normalization variant", caller
300
- end.pack('U*'.freeze)
278
+ raise ArgumentError, "#{form} is not a valid normalization variant", caller
279
+ end.pack("U*".freeze)
301
280
  end
302
281
 
303
282
  def downcase(string)
@@ -356,7 +335,7 @@ module ActiveSupport
356
335
  # UnicodeDatabase.
357
336
  def load
358
337
  begin
359
- @codepoints, @composition_exclusion, @composition_map, @boundary, @cp1252 = File.open(self.class.filename, 'rb') { |f| Marshal.load f.read }
338
+ @codepoints, @composition_exclusion, @composition_map, @boundary, @cp1252 = File.open(self.class.filename, "rb") { |f| Marshal.load f.read }
360
339
  rescue => e
361
340
  raise IOError.new("Couldn't load the Unicode tables for UTF8Handler (#{e.message}), ActiveSupport::Multibyte is unusable")
362
341
  end
@@ -378,7 +357,7 @@ module ActiveSupport
378
357
 
379
358
  # Returns the directory in which the data files are stored.
380
359
  def self.dirname
381
- File.dirname(__FILE__) + '/../values/'
360
+ File.dirname(__FILE__) + "/../values/"
382
361
  end
383
362
 
384
363
  # Returns the filename for the data file for this version.
@@ -389,25 +368,25 @@ module ActiveSupport
389
368
 
390
369
  private
391
370
 
392
- def apply_mapping(string, mapping) #:nodoc:
393
- database.codepoints
394
- string.each_codepoint.map do |codepoint|
395
- cp = database.codepoints[codepoint]
396
- if cp and (ncp = cp.send(mapping)) and ncp > 0
397
- ncp
398
- else
399
- codepoint
400
- end
401
- end.pack('U*')
402
- end
371
+ def apply_mapping(string, mapping)
372
+ database.codepoints
373
+ string.each_codepoint.map do |codepoint|
374
+ cp = database.codepoints[codepoint]
375
+ if cp && (ncp = cp.send(mapping)) && ncp > 0
376
+ ncp
377
+ else
378
+ codepoint
379
+ end
380
+ end.pack("U*")
381
+ end
403
382
 
404
- def recode_windows1252_chars(string)
405
- string.encode(Encoding::UTF_8, Encoding::Windows_1252, invalid: :replace, undef: :replace)
406
- end
383
+ def recode_windows1252_chars(string)
384
+ string.encode(Encoding::UTF_8, Encoding::Windows_1252, invalid: :replace, undef: :replace)
385
+ end
407
386
 
408
- def database
409
- @database ||= UnicodeDatabase.new
410
- end
387
+ def database
388
+ @database ||= UnicodeDatabase.new
389
+ end
411
390
  end
412
391
  end
413
392
  end
@@ -1,6 +1,6 @@
1
- require 'active_support/notifications/instrumenter'
2
- require 'active_support/notifications/fanout'
3
- require 'active_support/per_thread_registry'
1
+ require "active_support/notifications/instrumenter"
2
+ require "active_support/notifications/fanout"
3
+ require "active_support/per_thread_registry"
4
4
 
5
5
  module ActiveSupport
6
6
  # = Notifications
@@ -13,7 +13,7 @@ module ActiveSupport
13
13
  # To instrument an event you just need to do:
14
14
  #
15
15
  # ActiveSupport::Notifications.instrument('render', extra: :information) do
16
- # render text: 'Foo'
16
+ # render plain: 'Foo'
17
17
  # end
18
18
  #
19
19
  # That first executes the block and then notifies all subscribers once done.
@@ -48,7 +48,7 @@ module ActiveSupport
48
48
  # The block is saved and will be called whenever someone instruments "render":
49
49
  #
50
50
  # ActiveSupport::Notifications.instrument('render', extra: :information) do
51
- # render text: 'Foo'
51
+ # render plain: 'Foo'
52
52
  # end
53
53
  #
54
54
  # event = events.first
@@ -1,5 +1,5 @@
1
- require 'mutex_m'
2
- require 'concurrent/map'
1
+ require "mutex_m"
2
+ require "concurrent/map"
3
3
 
4
4
  module ActiveSupport
5
5
  module Notifications
@@ -68,7 +68,7 @@ module ActiveSupport
68
68
 
69
69
  module Subscribers # :nodoc:
70
70
  def self.new(pattern, listener)
71
- if listener.respond_to?(:start) and listener.respond_to?(:finish)
71
+ if listener.respond_to?(:start) && listener.respond_to?(:finish)
72
72
  subscriber = Evented.new pattern, listener
73
73
  else
74
74
  subscriber = Timed.new pattern, listener
@@ -1,4 +1,4 @@
1
- require 'securerandom'
1
+ require "securerandom"
2
2
 
3
3
  module ActiveSupport
4
4
  module Notifications
@@ -14,7 +14,7 @@ module ActiveSupport
14
14
  # Instrument the given block by measuring the time taken to execute it
15
15
  # and publish it. Notice that events get sent even if an error occurs
16
16
  # in the passed-in block.
17
- def instrument(name, payload={})
17
+ def instrument(name, payload = {})
18
18
  # some of the listeners might have state
19
19
  listeners_state = start name, payload
20
20
  begin
@@ -44,9 +44,9 @@ module ActiveSupport
44
44
 
45
45
  private
46
46
 
47
- def unique_id
48
- SecureRandom.hex(10)
49
- end
47
+ def unique_id
48
+ SecureRandom.hex(10)
49
+ end
50
50
  end
51
51
 
52
52
  class Event
@@ -45,7 +45,7 @@ module ActiveSupport
45
45
  #
46
46
  # number_to_phone(75561234567, pattern: /(\d{1,4})(\d{4})(\d{4})$/, area_code: true)
47
47
  # # => "(755) 6123-4567"
48
- # number_to_phone(13312345678, pattern: /(\d{3})(\d{4})(\d{4})$/))
48
+ # number_to_phone(13312345678, pattern: /(\d{3})(\d{4})(\d{4})$/)
49
49
  # # => "133-1234-5678"
50
50
  def number_to_phone(number, options = {})
51
51
  NumberToPhoneConverter.convert(number, options)
@@ -78,7 +78,7 @@ module ActiveSupport
78
78
  # (defaults to "%u%n"). Fields are <tt>%u</tt> for the
79
79
  # currency, and <tt>%n</tt> for the number.
80
80
  # * <tt>:negative_format</tt> - Sets the format for negative
81
- # numbers (defaults to prepending an hyphen to the formatted
81
+ # numbers (defaults to prepending a hyphen to the formatted
82
82
  # number given by <tt>:format</tt>). Accepts the same fields
83
83
  # than <tt>:format</tt>, except <tt>%n</tt> is here the
84
84
  # absolute value of the number.
@@ -109,7 +109,7 @@ module ActiveSupport
109
109
  # * <tt>:locale</tt> - Sets the locale to be used for formatting
110
110
  # (defaults to current locale).
111
111
  # * <tt>:precision</tt> - Sets the precision of the number
112
- # (defaults to 3). Keeps the number's precision if nil.
112
+ # (defaults to 3). Keeps the number's precision if +nil+.
113
113
  # * <tt>:significant</tt> - If +true+, precision will be the number
114
114
  # of significant_digits. If +false+, the number of fractional
115
115
  # digits (defaults to +false+).
@@ -183,7 +183,7 @@ module ActiveSupport
183
183
  # * <tt>:locale</tt> - Sets the locale to be used for formatting
184
184
  # (defaults to current locale).
185
185
  # * <tt>:precision</tt> - Sets the precision of the number
186
- # (defaults to 3). Keeps the number's precision if nil.
186
+ # (defaults to 3). Keeps the number's precision if +nil+.
187
187
  # * <tt>:significant</tt> - If +true+, precision will be the number
188
188
  # of significant_digits. If +false+, the number of fractional
189
189
  # digits (defaults to +false+).
@@ -1,8 +1,8 @@
1
- require 'active_support/core_ext/big_decimal/conversions'
2
- require 'active_support/core_ext/object/blank'
3
- require 'active_support/core_ext/hash/keys'
4
- require 'active_support/i18n'
5
- require 'active_support/core_ext/class/attribute'
1
+ require "active_support/core_ext/big_decimal/conversions"
2
+ require "active_support/core_ext/object/blank"
3
+ require "active_support/core_ext/hash/keys"
4
+ require "active_support/i18n"
5
+ require "active_support/core_ext/class/attribute"
6
6
 
7
7
  module ActiveSupport
8
8
  module NumberHelper
@@ -139,17 +139,17 @@ module ActiveSupport
139
139
  @options ||= format_options.merge(opts)
140
140
  end
141
141
 
142
- def format_options #:nodoc:
142
+ def format_options
143
143
  default_format_options.merge!(i18n_format_options)
144
144
  end
145
145
 
146
- def default_format_options #:nodoc:
146
+ def default_format_options
147
147
  options = DEFAULTS[:format].dup
148
148
  options.merge!(DEFAULTS[namespace][:format]) if namespace
149
149
  options
150
150
  end
151
151
 
152
- def i18n_format_options #:nodoc:
152
+ def i18n_format_options
153
153
  locale = opts[:locale]
154
154
  options = I18n.translate(:'number.format', locale: locale, default: {}).dup
155
155
 
@@ -160,7 +160,7 @@ module ActiveSupport
160
160
  options
161
161
  end
162
162
 
163
- def translate_number_value_with_default(key, i18n_options = {}) #:nodoc:
163
+ def translate_number_value_with_default(key, i18n_options = {})
164
164
  I18n.translate(key, { default: default_value(key), scope: :number }.merge!(i18n_options))
165
165
  end
166
166
 
@@ -169,10 +169,10 @@ module ActiveSupport
169
169
  end
170
170
 
171
171
  def default_value(key)
172
- key.split('.').reduce(DEFAULTS) { |defaults, k| defaults[k.to_sym] }
172
+ key.split(".").reduce(DEFAULTS) { |defaults, k| defaults[k.to_sym] }
173
173
  end
174
174
 
175
- def valid_float? #:nodoc:
175
+ def valid_float?
176
176
  Float(number)
177
177
  rescue ArgumentError, TypeError
178
178
  false
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/numeric/inquiry'
1
+ require "active_support/core_ext/numeric/inquiry"
2
2
 
3
3
  module ActiveSupport
4
4
  module NumberHelper
@@ -15,13 +15,13 @@ module ActiveSupport
15
15
  end
16
16
 
17
17
  rounded_number = NumberToRoundedConverter.convert(number, options)
18
- format.gsub('%n'.freeze, rounded_number).gsub('%u'.freeze, options[:unit])
18
+ format.gsub("%n".freeze, rounded_number).gsub("%u".freeze, options[:unit])
19
19
  end
20
20
 
21
21
  private
22
22
 
23
23
  def absolute_value(number)
24
- number.respond_to?(:abs) ? number.abs : number.sub(/\A-/, '')
24
+ number.respond_to?(:abs) ? number.abs : number.sub(/\A-/, "")
25
25
  end
26
26
 
27
27
  def options