<commit_before># @Author: <NAME>
# @Date:   2015-08-20 08:40:28
# @Last Modified by:   <NAME>
# @Last Modified time: 2015-10-08 17:35:46

module TerminalVis

  require_relative '../data/data_repository'
  require_relative '../output/data_output'
  require_relative '../output/help_output'
  require_relative '../output/timeline_output'
  require_relative '../parameter/parameter_handler'
  require_relative '../math/interpolation'
  require_relative '../math/dataset_statistics'
  require_relative '../math/time_line'
  require_relative '../output/range_output'

  # Dummy class to get access to the instance variables
  class << self
    attr_reader :data_repo, :parameter_handler
  end

  # singleton method to initialize the required repositories
  # @param [Array] arguments the input values from the terminal input ARGV
  def self.initialize_repositories(arguments)
      @parameter_handler = ParameterHandler.new(arguments)
      @data_repo = DataRepository.new()
  end

  # creates the meta data based on the provided parameters
  def self.create_metadata
    begin
      if (@parameter_handler.repository.parameters[:meta])
        @data_repo.add_data(@parameter_handler.repository.parameters[:file])
      else
        @data_repo.add_data_with_default_meta(
                       @parameter_handler.repository.parameters[:file])
      end
    rescue Exception => e
      print_error(' Error while creating metadata: '.concat(e.message))
    end
  end

  # call to print the help text
  def self.print_help
    HelpOutput.print_help_for(@parameter_handler.repository.parameters[:help])
    exit(0)
  end

  # call to print version number and author
  def self.print_version
    puts 'terminal_visualization version 0.6.0'
    puts 'Created by <NAME> (June 2015)'
    exit(0)
  end

  # call for standard error output
  # @param [String] message message string with error message
  def self.print_error(message)
    STDERR.puts "#{message}"
    STDERR.puts 'For help type: ruby <script> --help'
    exit(0)
  end

  # checks if option -i was used, determines if a valid parameter was entered
  # and returns the index on success
  # @param [MetaData] meta_data the meta_data which should be checked for the
  #  corresponding index
  # @return [Integer] the index from the parameter, default return is 0
  def self.get_and_check_index(meta_data)
    index = 0   # default data set if -i not set or only one data set
    if (@parameter_handler.repository.parameters[:index])
      begin   # make sure that parameter of -i is an integer
        index = Integer(@parameter_handler.repository.parameters[:index]) - 1
      rescue ArgumentError
        message = " Error: argument of -i is not a number:" \
                  "#{@parameter_handler.repository.parameters[:index]}"
        print_error(message)
      end

      check_index(meta_data, index)
    end

    return index
  end

  # method to check if provided integer index lies in range of dataseries
  # @param [MetaData] meta_data the meta_data which should be checked for the
  #  corresponding index
  # @param [Integer] index the given index from the input
  def self.check_index(meta_data, index)
    if (index < 0 ||
      index >= @data_repo.repository[meta_data].series.size)
      text_index = @parameter_handler.repository.parameters[:index]
      data_size = @data_repo.repository[meta_data].series.size
      message = " Error: input #{text_index} for -i is not valid" \
                " for dataset with length #{data_size}"
      print_error(message)
    end
  end
  private_class_method :check_index

end

require_relative '../output/output'
require_relative '../math/interpolation'
<commit_msg>introduced configuration_handler added configuration_handler to main module to use the options<commit_after># @Author: <NAME>
# @Date:   2015-08-20 08:40:28
# @Last Modified by:   <NAME>
# @Last Modified time: 2015-10-15 19:04:04

module TerminalVis

  require_relative '../data/data_repository'
  require_relative '../output/data_output'
  require_relative '../output/help_output'
  require_relative '../output/timeline_output'
  require_relative '../parameter/parameter_handler'
  require_relative '../math/interpolation'
  require_relative '../math/dataset_statistics'
  require_relative '../math/time_line'
  require_relative '../output/range_output'
  require_relative '../configuration/configuration_handler'

  # Dummy class to get access to the instance variables
  class << self
    # @return [DataRepository] the repository storing the datasets
    attr_reader :data_repo
    # @return [ParameterHandler] the handler controlling the parameters
    attr_reader :parameter_handler
    # @return [Configuration_Handler] the handler controlling the
    #   configuration parameter
    attr_reader :option_handler
  end

  # singleton method to initialize the required repositories
  # @param [Array] arguments the input values from the terminal input ARGV
  def self.initialize_repositories(arguments)
      @parameter_handler = ParameterHandler.new(arguments)
      @data_repo = DataRepository.new()
      @option_handler = ConfigurationHandler.new()
  end

  # creates the meta data based on the provided parameters
  def self.create_metadata
    begin
      if (@parameter_handler.repository.parameters[:meta])
        @data_repo.add_data(@parameter_handler.repository.parameters[:file])
      else
        @data_repo.add_data_with_default_meta(
                       @parameter_handler.repository.parameters[:file])
      end
    rescue Exception => e
      print_error(' Error while creating metadata: '.concat(e.message))
    end
  end

  # call to print the help text
  def self.print_help
    HelpOutput.print_help_for(@parameter_handler.repository.parameters[:help])
    exit(0)
  end

  # call to print version number and author
  def self.print_version
    puts 'terminal_visualization version 0.6.0'
    puts 'Created by <NAME> (June 2015)'
    exit(0)
  end

  # call for standard error output
  # @param [String] message message string with error message
  def self.print_error(message)
    STDERR.puts "#{message}"
    STDERR.puts 'For help type: ruby <script> --help'
    exit(0)
  end

  # checks if option -i was used, determines if a valid parameter was entered
  # and returns the index on success
  # @param [MetaData] meta_data the meta_data which should be checked for the
  #  corresponding index
  # @return [Integer] the index from the parameter, default return is 0
  def self.get_and_check_index(meta_data)
    index = 0   # default data set if -i not set or only one data set
    if (@parameter_handler.repository.parameters[:index])
      begin   # make sure that parameter of -i is an integer
        index = Integer(@parameter_handler.repository.parameters[:index]) - 1
      rescue ArgumentError
        message = " Error: argument of -i is not a number:" \
                  "#{@parameter_handler.repository.parameters[:index]}"
        print_error(message)
      end

      check_index(meta_data, index)
    end

    return index
  end

  # method to check if provided integer index lies in range of dataseries
  # @param [MetaData] meta_data the meta_data which should be checked for the
  #  corresponding index
  # @param [Integer] index the given index from the input
  def self.check_index(meta_data, index)
    if (index < 0 ||
      index >= @data_repo.repository[meta_data].series.size)
      text_index = @parameter_handler.repository.parameters[:index]
      data_size = @data_repo.repository[meta_data].series.size
      message = " Error: input #{text_index} for -i is not valid" \
                " for dataset with length #{data_size}"
      print_error(message)
    end
  end
  private_class_method :check_index

end

require_relative '../output/output'
require_relative '../math/interpolation'

{'fraction_non_alphanumeric': 0.08737864077669903, 'fraction_numerical': 0.010730710270822688, 'mean_word_length': 3.4635119726339796, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, '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': '1349941', 'n_tokens_mistral': 2259, 'n_tokens_neox': 2160, 'n_words': 693}