<commit_before>require 'excursion/pool/application'
require 'excursion/pool/dsl'
require 'excursion/exceptions/pool'
require 'excursion/exceptions/datastores'

module Excursion
  module Pool
    @@applications = {}

    def self.all_applications
      datastore.all_apps.each do |app|
        @@applications[app.name] = app
      end
    end

    def self.application(name)
      return @@applications[name] if @@applications.has_key?(name) && !@@applications[name].nil?
      
      @@applications[name] = datastore.app(name)
    end

    def self.register_application(app=nil, opts={}, &block)
      raise ArgumentError, "app must be an instance of Rails::Application" unless app.is_a?(Rails::Application) || block_given?
      opts = {cache: true}.merge(opts)
      
      if app.is_a?(Rails::Application)
        name = app.class.name.underscore.split("/").first
        config = {default_url_options: Excursion.configuration.default_url_options}
        routes = app.routes.named_routes
        @@applications[name] = Application.new(name, config, routes)
      end
      
      if block_given?
        if @@applications.has_key?(name)
          DSL.block_eval(@@applications[name], &block)
        else
          block_app = DSL.block_eval(&block)
          name = block_app.name
          @@applications[name] = block_app
        end
      end
      
      datastore.set(name, @@applications[name].to_cache) if opts[:cache]
      @@applications[name]
    end

    def self.register_hash(app_hash)
      raise ArgumentError, "you must provide at minimum a hash with a :name key" unless app_hash.is_a?(Hash) && app_hash.has_key?(:name)
      
      app_hash = {default_url_options: Excursion.configuration.default_url_options, routes: {}, registered_at: Time.now}.merge(app_hash)
      name = app_hash[:name]

      datastore.set(name, app_hash)
      @@applications[name] = datastore.app(name)
    end

    def self.remove_application(app)
      raise ArgumentError, "app must be an instance of Rails::Application" unless app.is_a?(Rails::Application)
      
      name = app.class.name.underscore.split("/").first
      datastore.delete(name)
      @@applications.delete(name)
    end
<commit_msg>changes :cache option to :store<commit_after>require 'excursion/pool/application'
require 'excursion/pool/dsl'
require 'excursion/exceptions/pool'
require 'excursion/exceptions/datastores'

module Excursion
  module Pool
    @@applications = {}

    def self.all_applications
      datastore.all_apps.each do |app|
        @@applications[app.name] = app
      end
    end

    def self.application(name)
      return @@applications[name] if @@applications.has_key?(name) && !@@applications[name].nil?
      
      @@applications[name] = datastore.app(name)
    end

    def self.register_application(app=nil, opts={}, &block)
      raise ArgumentError, "app must be an instance of Rails::Application" unless app.is_a?(Rails::Application) || block_given?
      opts = {store: true}.merge(opts)
      
      if app.is_a?(Rails::Application)
        name = app.class.name.underscore.split("/").first
        config = {default_url_options: Excursion.configuration.default_url_options}
        routes = app.routes.named_routes
        @@applications[name] = Application.new(name, config, routes)
      end
      
      if block_given?
        if @@applications.has_key?(name)
          DSL.block_eval(@@applications[name], &block)
        else
          block_app = DSL.block_eval(&block)
          name = block_app.name
          @@applications[name] = block_app
        end
      end
      
      datastore.set(name, @@applications[name].to_cache) if opts[:store]
      @@applications[name]
    end

    def self.register_hash(app_hash)
      raise ArgumentError, "you must provide at minimum a hash with a :name key" unless app_hash.is_a?(Hash) && app_hash.has_key?(:name)
      
      app_hash = {default_url_options: Excursion.configuration.default_url_options, routes: {}, registered_at: Time.now}.merge(app_hash)
      name = app_hash[:name]

      datastore.set(name, app_hash)
      @@applications[name] = datastore.app(name)
    end

    def self.remove_application(app)
      raise ArgumentError, "app must be an instance of Rails::Application" unless app.is_a?(Rails::Application)
      
      name = app.class.name.underscore.split("/").first
      datastore.delete(name)
      @@applications.delete(name)
    end

{'fraction_non_alphanumeric': 0.1174875734297334, 'fraction_numerical': 0.0, 'mean_word_length': 3.1104921077065923, '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': '4514567', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1384, 'n_words': 274}