lib/t/utils.rb in t-2.2.1 vs lib/t/utils.rb in t-2.3.0

- old
+ new

@@ -1,8 +1,8 @@ module T module Utils - private + private # https://github.com/rails/rails/blob/bd8a970/actionpack/lib/action_view/helpers/date_helper.rb def distance_of_time_in_words(from_time, to_time = Time.now) # rubocop:disable CyclomaticComplexity seconds = (to_time - from_time).abs minutes = seconds / 60 @@ -56,11 +56,11 @@ [users, users.length] end def format_users!(users, options) require 't/core_ext/string' - options['id'] ? users.map!(&:to_i) : users.map!(&:strip_ats) + options['id'] ? users.collect!(&:to_i) : users.collect!(&:strip_ats) end def extract_owner(list, options) owner, list = list.split('/') if list.nil? @@ -77,11 +77,11 @@ html.gsub(/<.+?>/, '') end def number_with_delimiter(number, delimiter = ',') digits = number.to_s.split(//) - groups = digits.reverse.each_slice(3).map { |g| g.join('') } + groups = digits.reverse.each_slice(3).collect { |g| g.join('') } groups.join(delimiter).reverse end def pluralize(count, singular, plural = nil) "#{count || 0} " + (count == 1 || count =~ /^1(\.0+)?$/ ? singular : (plural || "#{singular}s")) @@ -106,8 +106,12 @@ def open_or_print(uri, options) Launchy.open(uri, options) do say "Open: #{uri}" end + end + + def parallel_map(enumerable) + enumerable.collect { |object| Thread.new { yield object } }.collect(&:value) end end end