<commit_before>require "ordinare/version"
require "optparse"

module Ordinare
  module_function

  def hi
    "Ciao, sono Ordinare"
  end

  def parse_args
    OptionParser.new do |opts|
      opts.banner = "Usage: ordinare inside your Rails project"

      opts.on("-pFILE", "--path=FILE", "Order file") do |filename|
        Ordinare.sort(filename)
      end

      opts.on("-v", "--version", "Check gem version") do
        puts Ordinare::VERSION
      end

      opts.on("-h", "--help", "Get help") do
        puts opts
      end
    end.parse!
  end

  def sort(path = "Gemfile")
    unless File.file?(path)
      abort("No Gemfile found in the current directory, is this a Rails project with Gemfile?")
    end

    content = File.readlines(path)

    content.sort

    File.open("#{path}.ordinare", "w+") do |file|
      content.each { |line| file.puts(line) }
    end
  end
end<commit_msg>Actually sort the simple Gemfile<commit_after>require "ordinare/version"
require "optparse"

module Ordinare
  module_function

  def hi
    "Ciao, sono Ordinare"
  end

  def parse_args
    OptionParser.new do |opts|
      opts.banner = "Usage: ordinare inside your Rails project"

      opts.on("-pFILE", "--path=FILE", "Order file") do |filename|
        Ordinare.sort(filename)
      end

      opts.on("-v", "--version", "Check gem version") do
        puts Ordinare::VERSION
      end

      opts.on("-h", "--help", "Get help") do
        puts opts
      end
    end.parse!
  end

  def sort(path = "Gemfile")
    unless File.file?(path)
      abort("No Gemfile found in the current directory, is this a Rails project with Gemfile?")
    end

    content = File.readlines(path)

    content = content.sort

    File.open("#{path}.ordinare", "w+") do |file|
      content.each { |line| file.puts(line) }
    end
  end
end
{'fraction_non_alphanumeric': 0.1256171146461876, 'fraction_numerical': 0.0, 'mean_word_length': 2.583497053045187, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3254919', 'n_tokens_mistral': 607, 'n_tokens_neox': 587, 'n_words': 174}