<commit_before>require 'poster/version'
require 'poster/finder'
require 'poster/parser'
require 'poster/planter'
require 'poster/post'
require 'poster/conf'

module Poster

  DEFAULT_OPTIONS = {
      :blog => :test,
      :source_dir => Dir.pwd,
      :recursive => false,
      :overwrite => true,
      :dry_run => false,
      :files => nil
  }

  # TODO control overwriting the target
  # TODO use .erb template
  # TODO complete code block syntax in posts using either a default language or CL param

  def self.convert(options = {})
    options.merge!(DEFAULT_OPTIONS)

    if (options[:files])
      p "Would normally work on these files, but ignoring explicit file lists for now: #{options[:files]}"
    end

    wd = options[:source_dir]
    p "working in : #{wd}"

    files = Finder.find(wd, options[:recursive])
    p "found #{files.size} file(s) to convert:"
    files.each{ |f| p f}

    files.each { |f|
      posts = Parser.extract(f)
      p "extracted #{posts.size} posts from #{f}"
      Planter.post(posts, options[:blog])
    }
  end

end<commit_msg>using $stderr in Poster<commit_after>require 'poster/version'
require 'poster/finder'
require 'poster/parser'
require 'poster/planter'
require 'poster/post'
require 'poster/conf'

module Poster

  DEFAULT_OPTIONS = {
      :blog => :test,
      :source_dir => Dir.pwd,
      :recursive => false,
      :overwrite => true,
      :dry_run => false,
      :files => nil
  }

  # TODO control overwriting the target
  # TODO use .erb template
  # TODO complete code block syntax in posts using either a default language or CL param

  def self.convert(opts = {})
    options = DEFAULT_OPTIONS.merge(opts)

    if (options[:files])
      $stderr.puts "Would normally work on these files, but ignoring explicit file lists for now: #{options[:files]}"
    end

    wd = options[:source_dir]
    $stderr.puts "working in : #{wd}"

    files = Finder.find(wd, options[:recursive])
    $stderr.puts "found #{files.size} file(s) to convert:"
    files.each{ |f| p f}

    files.each { |f|
      posts = Parser.extract(f)
      $stderr.puts "extracted #{posts.size} posts from #{f}"
      Planter.post(posts, options[:blog])
    }
  end

end
{'fraction_non_alphanumeric': 0.1267605633802817, 'fraction_numerical': 0.0, 'mean_word_length': 3.092936802973978, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5952698', 'n_tokens_mistral': 724, 'n_tokens_neox': 703, 'n_words': 213}