<commit_before># frozen_string_literal: true

namespace :action_text do
  # Prevent migration installation task from showing up twice.
  Rake::Task["install:migrations"].clear_comments

  desc "Copy over the migration, stylesheet, and JavaScript files"
  task install: %w( environment copy_migrations copy_stylesheet copy_fixtures )

  task :copy_migrations do
    Rake::Task["active_storage:install:migrations"].invoke
    Rake::Task["railties:install:migrations"].reenable # Otherwise you can't run 2 migration copy tasks in one invocation
    Rake::Task["action_text:install:migrations"].invoke
  end

  STYLESHEET_TEMPLATE_PATH = File.expand_path("../templates/actiontext.css", __dir__)
  STYLESHEET_APP_PATH      = Rails.root.join("app/assets/stylesheets/actiontext.css")

  task :copy_stylesheet do
    unless File.exist?(STYLESHEET_APP_PATH)
      FileUtils.cp STYLESHEET_TEMPLATE_PATH, STYLESHEET_APP_PATH
    end
  end

  FIXTURE_TEMPLATE_PATH = File.expand_path("../templates/fixtures.yml", __dir__)
  FIXTURE_APP_DIR_PATH  = Rails.root.join("test/fixtures/action_text")
  FIXTURE_APP_PATH      = FIXTURE_APP_DIR_PATH.join("rich_texts.yml")

  task :copy_fixtures do
    unless File.exist?(FIXTURE_APP_PATH)
      FileUtils.mkdir FIXTURE_APP_DIR_PATH
      FileUtils.cp FIXTURE_TEMPLATE_PATH, FIXTURE_APP_PATH
    end
  end
end<commit_msg>Add via yarn in the installer<commit_after># frozen_string_literal: true

namespace :action_text do
  # Prevent migration installation task from showing up twice.
  Rake::Task["install:migrations"].clear_comments

  desc "Copy over the migration, stylesheet, and JavaScript files"
  task install: %w( environment copy_migrations copy_stylesheet copy_fixtures yarn_add )

  task :copy_migrations do
    Rake::Task["active_storage:install:migrations"].invoke
    Rake::Task["railties:install:migrations"].reenable # Otherwise you can't run 2 migration copy tasks in one invocation
    Rake::Task["action_text:install:migrations"].invoke
  end

  STYLESHEET_TEMPLATE_PATH = File.expand_path("../templates/actiontext.css", __dir__)
  STYLESHEET_APP_PATH      = Rails.root.join("app/assets/stylesheets/actiontext.css")

  task :copy_stylesheet do
    unless File.exist?(STYLESHEET_APP_PATH)
      FileUtils.cp STYLESHEET_TEMPLATE_PATH, STYLESHEET_APP_PATH
    end
  end

  FIXTURE_TEMPLATE_PATH = File.expand_path("../templates/fixtures.yml", __dir__)
  FIXTURE_APP_DIR_PATH  = Rails.root.join("test/fixtures/action_text")
  FIXTURE_APP_PATH      = FIXTURE_APP_DIR_PATH.join("rich_texts.yml")

  task :copy_fixtures do
    unless File.exist?(FIXTURE_APP_PATH)
      FileUtils.mkdir FIXTURE_APP_DIR_PATH
      FileUtils.cp FIXTURE_TEMPLATE_PATH, FIXTURE_APP_PATH
    end
  end

  task :yarn_add do
    # FIXME: Replace with release version on release
    system "yarn add https://github.com/basecamp/actiontext"
  end
end
{'fraction_non_alphanumeric': 0.08763966480446927, 'fraction_numerical': 0.0006983240223463687, 'mean_word_length': 4.981210855949896, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '2851685', 'n_tokens_mistral': 972, 'n_tokens_neox': 951, 'n_words': 188}