<commit_before>require 'optparse'
require File.expand_path(File.dirname(__FILE__) + '/../jammit')

module Jammit

  # The @CommandLine@ is able to compress, pre-package, and pre-gzip all the
  # assets specified in the configuration file, in order to avoid an initial
  # round of slow requests after a fresh deployment.
  class CommandLine

    BANNER = <<-EOS

Usage: jammit OPTIONS

Run jammit inside a Rails application to compresses all JS, CSS,
and JST according to config/assets.yml, saving the packaged
files and corresponding gzipped versions.

If you're using "embed_assets", and you wish to precompile the
MHTML stylesheet variants, you must specify the "base-url".

Options:
    EOS

    # The @Jammit::CommandLine@ runs from the contents of @ARGV@.
    def initialize
      parse_options
      ensure_configuration_file
      Jammit.load_configuration(@options[:config_path])
      Jammit.packager.force = @options[:force]
      Jammit.packager.precache_all(@options[:output_folder], @options[:base_url])
    end


    private

    # Make sure that we have a readable configuration file. The @jammit@
    # command can't run without one.
    def ensure_configuration_file
      config = @options[:config_path]
      return true if File.exists?(config) && File.readable?(config)
      puts "Could not find the asset configuration file \"#{config}\""<commit_msg>Reuse package! helper within CommandLine tool<commit_after>require 'optparse'
require File.expand_path(File.dirname(__FILE__) + '/../jammit')

module Jammit

  # The @CommandLine@ is able to compress, pre-package, and pre-gzip all the
  # assets specified in the configuration file, in order to avoid an initial
  # round of slow requests after a fresh deployment.
  class CommandLine

    BANNER = <<-EOS

Usage: jammit OPTIONS

Run jammit inside a Rails application to compresses all JS, CSS,
and JST according to config/assets.yml, saving the packaged
files and corresponding gzipped versions.

If you're using "embed_assets", and you wish to precompile the
MHTML stylesheet variants, you must specify the "base-url".

Options:
    EOS

    # The @Jammit::CommandLine@ runs from the contents of @ARGV@.
    def initialize
      parse_options
      ensure_configuration_file
      Jammit.package!(@options)
    end


    private

    # Make sure that we have a readable configuration file. The @jammit@
    # command can't run without one.
    def ensure_configuration_file
      config = @options[:config_path]
      return true if File.exists?(config) && File.readable?(config)
      puts "Could not find the asset configuration file \"#{config}\""
{'fraction_non_alphanumeric': 0.08038095238095239, 'fraction_numerical': 0.0, 'mean_word_length': 3.783242258652095, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1974077', 'n_tokens_mistral': 751, 'n_tokens_neox': 722, 'n_words': 284}