<commit_before>require 'faster_csv' unless defined?(FasterCSV)

module NinthBit
  module PirateShip

    module ActMethods
      #coding tyle is adopted from attachment_fu
      def has_csv_pirate_ship(options = {})
        # If you aren't using ActiveRecord (you are outside rails) then you must declare your :booty
        # If you are using ActiveRecord then you only want ot check for booty if the table exists so it won't fail pre-migration
        check_booty = defined?(ActiveRecord) && self.is_a?(ActiveRecord::Base) ? ActiveRecord::Base.connection.tables.include?(self.table_name) : true

        options[:chart]         ||= ['log','csv']
        options[:aft]           ||= '.csv'
        options[:gibbet]        ||= '.export'
        #Needs to be defined at runtime, doesn't make sense here
        #options[:chronometer]   ||= Date.today
        options[:waggoner]      ||= "#{self}"
        options[:swag]          ||= nil
        options[:swab]          ||= :counter
        options[:mop]           ||= :clean
        options[:shrouds]       ||= ','
        options[:grub]          ||= self if options[:swag].nil?
        options[:spyglasses]    ||= [:all]
        # Have to protect against model definitions pre-migration, since column names will fail if
        options[:booty]         ||= check_booty ? self.column_names : []
        options[:bury_treasure] ||= true
        options[:blackjack]     ||= {:humanize => '_'}
        options[:parlay]        ||= 1

        # if they provide both
        raise ArgumentError, "must provide either :swag or :grub, not both" if !options[:swag].blank? && !options[:grub].blank?
        # if they provide neither
        raise ArgumentError, "must provide either :swag or :grub" if options[:swag].blank? && options[:grub].blank?
        raise ArgumentError, ":swab is #{options[:swab].inspect}, but must be one of #{CsvPirate::BOOKIE.inspect}" unless CsvPirate::BOOKIE.include?(options[:swab])
        raise ArgumentError, ":mop is #{options[:mop].inspect}, but must be one of #{CsvPirate::MOP_HEADS.inspect}" unless CsvPirate::MOP_HEADS.include?(options[:mop])
        raise ArgumentError, ":gibbet is #{options[:gibbet].inspect}, and does not contain a '.' character, which is required when using iterative filenames (set :swab => :none to turn off iterative filenames)" if options[:swab] != :none && (options[:gibbet].nil? || !options[:gibbet].include?('.'))
        raise ArgumentError, ":waggoner is #{options[:waggoner].inspect}, and must be a string at least one character long" if options[:waggoner].nil? || options[:waggoner].length < 1<commit_msg>fixed typo in comment<commit_after>require 'faster_csv' unless defined?(FasterCSV)

module NinthBit
  module PirateShip

    module ActMethods
      #coding tyle is adopted from attachment_fu
      def has_csv_pirate_ship(options = {})
        # If you aren't using ActiveRecord (you are outside rails) then you must declare your :booty
        # If you are using ActiveRecord then you only want to check for booty if the table exists so it won't fail pre-migration
        check_booty = defined?(ActiveRecord) && self.is_a?(ActiveRecord::Base) ? ActiveRecord::Base.connection.tables.include?(self.table_name) : false

        options[:chart]         ||= ['log','csv']
        options[:aft]           ||= '.csv'
        options[:gibbet]        ||= '.export'
        #Needs to be defined at runtime, doesn't make sense here
        #options[:chronometer]   ||= Date.today
        options[:waggoner]      ||= "#{self}"
        options[:swag]          ||= nil
        options[:swab]          ||= :counter
        options[:mop]           ||= :clean
        options[:shrouds]       ||= ','
        options[:grub]          ||= self if options[:swag].nil?
        options[:spyglasses]    ||= [:all]
        # Have to protect against model definitions pre-migration, since column names will fail if
        options[:booty]         ||= check_booty ? self.column_names : []
        options[:bury_treasure] ||= true
        options[:blackjack]     ||= {:humanize => '_'}
        options[:parlay]        ||= 1

        # if they provide both
        raise ArgumentError, "must provide either :swag or :grub, not both" if !options[:swag].blank? && !options[:grub].blank?
        # if they provide neither
        raise ArgumentError, "must provide either :swag or :grub" if options[:swag].blank? && options[:grub].blank?
        raise ArgumentError, ":swab is #{options[:swab].inspect}, but must be one of #{CsvPirate::BOOKIE.inspect}" unless CsvPirate::BOOKIE.include?(options[:swab])
        raise ArgumentError, ":mop is #{options[:mop].inspect}, but must be one of #{CsvPirate::MOP_HEADS.inspect}" unless CsvPirate::MOP_HEADS.include?(options[:mop])
        raise ArgumentError, ":gibbet is #{options[:gibbet].inspect}, and does not contain a '.' character, which is required when using iterative filenames (set :swab => :none to turn off iterative filenames)" if options[:swab] != :none && (options[:gibbet].nil? || !options[:gibbet].include?('.'))
        raise ArgumentError, ":waggoner is #{options[:waggoner].inspect}, and must be a string at least one character long" if options[:waggoner].nil? || options[:waggoner].length < 1
{'fraction_non_alphanumeric': 0.13475854170643253, 'fraction_numerical': 0.0007635044855888528, 'mean_word_length': 3.1065830721003134, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 7, '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': '3684872', 'n_tokens_mistral': 1557, 'n_tokens_neox': 1526, 'n_words': 448}