<commit_before>require "swoop/version"
require "swoop/project"
require "swoop/entity"
require "swoop/entity_parser"
require "swoop/report"
require "swoop/time_machine"

require "swoop/renderer/renderer"
require "swoop/renderer/csv_renderer"
require "swoop/renderer/table_renderer"
require "swoop/renderer/chart_renderer"

require "thor"

module Swoop

  class Reporter < Thor
    # bundle exec bin/swoop --path /Users/ikhsanassaat/Songkick/ios-app/Songkick/Songkick.xcodeproj --dir 'Classes/Models'

    desc "report", "Create objc swift comparison report for classes from an Xcode project"
    option :path
    option :dir
    def report
      @project_path = options[:path]
      @dir_path = options[:dir]
      # @renderer_type = options[:renderer]

      renderer = renderer_class.new(summary_report, title)
      renderer.render
    end

    default_task :report

    private

    def summary_report
      @summary_report ||= begin
        project = Project.new(@project_path, @dir_path)
        delorean = TimeMachine.new(project) # { :weeks => 10 }

        reports = []
        delorean.travel do |proj, name, date|
          entities = EntityParser.parse_files(proj.filepaths)
          reports << Report.new(entities, name, date)
        end
        reports
      rescue ExceptionName
        nil
      end
    end

    def title
      "Swoop Report : '#{@dir_path}'"
    end

    def renderer_class
      # CSVRenderer
      # ChartRenderer
      TableRenderer
    end
  end

end
<commit_msg>Expose renderer option via command params<commit_after>require "swoop/version"
require "swoop/project"
require "swoop/entity"
require "swoop/entity_parser"
require "swoop/report"
require "swoop/time_machine"

require "swoop/renderer/renderer"
require "swoop/renderer/csv_renderer"
require "swoop/renderer/table_renderer"
require "swoop/renderer/chart_renderer"

require "thor"

module Swoop

  class Reporter < Thor
    # bundle exec bin/swoop --path /Users/ikhsanassaat/Songkick/ios-app/Songkick/Songkick.xcodeproj --dir 'Classes/Models'

    desc "report", "Create objc swift comparison report for classes from an Xcode project"
    option :path
    option :dir
    option :renderer
    def report
      @project_path = options[:path]
      @dir_path = options[:dir]
      @renderer_type = options[:renderer]

      renderer = renderer_class.new(summary_report, title)
      renderer.render
    end

    default_task :report

    private

    def summary_report
      @summary_report ||= begin
        project = Project.new(@project_path, @dir_path)
        delorean = TimeMachine.new(project) # { :weeks => 10 }

        reports = []
        delorean.travel do |proj, name, date|
          entities = EntityParser.parse_files(proj.filepaths)
          reports << Report.new(entities, name, date)
        end
        reports
      rescue Exception => e
        raise e
      end
    end

    def title
      "Swoop Report : '#{@dir_path}'"
    end

    def renderer_class
      case @renderer_type
      when "csv"
        CSVRenderer
      when "chart"
        ChartRenderer
      else
        TableRenderer
      end
    end
  end

end

{'fraction_non_alphanumeric': 0.0900413617562838, 'fraction_numerical': 0.0012726694241170856, 'mean_word_length': 2.7697841726618706, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '169952', 'n_tokens_mistral': 1007, 'n_tokens_neox': 986, 'n_words': 239}