lib/countless/statistics.rb in countless-1.2.0 vs lib/countless/statistics.rb in countless-1.3.0
- old
+ new
@@ -25,11 +25,11 @@
# rubocop:disable Metrics/MethodLength dito
def initialize(*dirs)
base_path = Countless.configuration.base_path
# Resolve the given directory configurations to actual files
- dirs = (dirs.presence || Countless.statistic_directories)
+ dirs = dirs.presence || Countless.statistic_directories
@dirs = dirs.each_with_object([]) do |cur, memo|
copy = cur.deep_dup
copy[:files] = Array(copy[:files])
if copy[:pattern].is_a? Regexp
@@ -67,16 +67,16 @@
# named hash.
#
# @return [Hash{String => Hash{Symbol => Mixed}}] the statistics
# per configuration
def calculate_statistics
- @dirs.map do |conf|
+ @dirs.to_h do |conf|
[
conf[:name],
conf.merge(stats: calculate_file_statistics(conf[:name],
conf[:files]))
]
- end.to_h
+ end
end
# Setup a new +Calculator+ for the given directory/pattern in order to
# extract the individual file statistics and calculate the sub-totals.
#