bin/fief in fief-0.0.3 vs bin/fief in fief-0.0.4

- old
+ new

@@ -55,11 +55,11 @@ o.array '--metrics', 'Names of metrics to use (all by default)' o.array '--include', 'Mask of GitHub repo to include, e.g. yegor256/*' o.array '--exclude', 'Mask of GitHub repo to exclude' end -if opts.help? || opts[:include].empty? +if opts.help? puts opts exit end if opts.verbose? @@ -87,10 +87,11 @@ repos = [ 'yegor256/fief' ] if !opts[:dry] repos = Fief::Repos.new(opts, api, loog).all end data = [] + legend = {} repos.each do |repo| Dir[File.join(__dir__, '../lib/fief/metrics/*.rb')].each do |f| name = File::basename(f).split('.')[0] if !opts[:metrics].empty? && !opts[:metrics].include?(name) loog.info("Ignoring #{user}/#{name} due to --metrics") @@ -99,29 +100,41 @@ type = "Fief::#{name.capitalize}" loog.info("Reading '#{name}' for #{repo}...") require_relative f m = type.split('::').reduce(Module, :const_get).new(api, repo, opts) if opts.dry? - measures = [{ title: 'Open Pull Requests', value: 42 }, { title: 'Open Issues', value: 42 }] + measures = [{ title: 'Pulls+', value: 42, legend: 'Open pulls' }, { title: 'Issues', value: 42 }] else measures = m.take(loog) end + measures.each do |m| + legend[m[:title]] = m[:legend] + end if data.find { |d| d[:name] == repo }.nil? data << {name: repo, metrics: []} end data.find { |d| d[:name] == repo }[:metrics] += measures + loog.info("Read from '#{name}': #{measures.map { |m| "#{m[:title]}=#{m[:value]}" }.join(', ')}") end end + p data builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| - xml.fief(time: Time.now, msec: Time.now - start) do + xml.fief(time: Time.now, sec: Time.now - start) do xml.titles do data.map { |r| r[:metrics].map { |ms| ms[:title] } }.flatten.uniq.each do |t| xml.title do xml.text t end end end + xml.legend do + legend.each do |t, text| + xml.column(title: t) do + xml.text text + end + end + end xml.repositories do data.each do |r| xml.repository(id: r[:name]) do xml.metrics do r[:metrics].each do |ms| @@ -139,9 +152,10 @@ xml = builder.to_xml loog.debug(xml) xml end begin + raise 'At least one --include is required' if opts[:include].empty? home = File.absolute_path(opts[:to]) loog.debug("All files generated will be saved to #{home}") if File.exist?(home) loog.debug("Directory #{home} exists") else