lib/rake/funnel/support/version_info.rb in rake-funnel-0.18.0 vs lib/rake/funnel/support/version_info.rb in rake-funnel-0.19.0

- old
+ new

@@ -14,28 +14,27 @@ each_pair(&block) end class << self def parse(context) - VersionInfo.new({ - assembly_version: assembly_version(context), - assembly_file_version: assembly_file_version(context), - assembly_informational_version: assembly_informational_version(context) - }) + VersionInfo.new(assembly_version: assembly_version(context), + assembly_file_version: assembly_file_version(context), + assembly_informational_version: assembly_informational_version(context)) end def read_version_from(file) File.open(file, &:readline).strip end private + def default_version(context) context[:version].to_s || '0' end def pad(version, parts) - numerics = version.split('.').take(parts).map { |part| part.to_i } + numerics = version.split('.').take(parts).map(&:to_i) template = Array.new(parts) { 0 }.map.with_index do |part, index| numerics[index] || part end template.join('.') @@ -56,11 +55,11 @@ def numeric(str) return str if str.to_s =~ /^\d+$/ nil end - def assembly_informational_version(context) + def assembly_informational_version(context) # rubocop:disable Metrics/MethodLength version = default_version(context) numeric_version = pad(version, 3) alpha_version = version.sub(/^[\d\.]*/, '') semver = [ @@ -83,12 +82,12 @@ end def metadata(context) metadata = context.fetch(:metadata, {}).reject { |k, _| k == :pre } - metadata = metadata.map { |key, value| + metadata = metadata.map do |key, value| [key.to_s, value.to_s] if value - }.compact + end.compact return nil if metadata.empty? metadata.join('.') end end