diff --git a/Rakefile b/Rakefile index 560c34baa..e36ad0a3c 100644 --- a/Rakefile +++ b/Rakefile @@ -17,14 +17,14 @@ RSpec::Core::RakeTask.new('spec:progress') do |spec| end namespace :generate do - desc 'Generates a activedocument.yml from the template' + desc 'Generates an active_document.yml from the template' task config: :environment do require 'active_document' require 'erb' - template_path = 'lib/rails/generators/mongoid/config/templates/activedocument.yml' + template_path = 'lib/rails/generators/mongoid/config/templates/active_document.yml' config = ERB.new(File.read(template_path), trim_mode: '-').result(binding) - File.write('activedocument.yml', config) + File.write('active_document.yml', config) end end diff --git a/docs/reference/configuration.txt b/docs/reference/configuration.txt index 1d5970f71..7b2d93807 100644 --- a/docs/reference/configuration.txt +++ b/docs/reference/configuration.txt @@ -12,7 +12,7 @@ Configuration :depth: 2 :class: singlecol -ActiveDocument is customarily configured through a ``activedocument.yml`` file that specifies +ActiveDocument is customarily configured through a ``active_document.yml`` file that specifies options and clients. The simplest configuration is as follows, which configures ActiveDocument to talk to a MongoDB server at "localhost:27017" and use the database named "mongoid". @@ -43,16 +43,16 @@ configuration file for you by running the following command: rails g mongoid:config -The configuration file will be placed in ``config/activedocument.yml``. An +The configuration file will be placed in ``config/active_document.yml``. An initializer will also be created and placed in ``config/initializers/mongoid.rb``. It is recommended that all configuration -be specified in ``config/activedocument.yml``, but if you prefer, the ``mongoid.rb`` +be specified in ``config/active_document.yml``, but if you prefer, the ``mongoid.rb`` initializer may also be used to set configuration options. Note, though, that -settings in ``activedocument.yml`` always take precedence over settings in the +settings in ``active_document.yml`` always take precedence over settings in the initializer. If you are not using Ruby on Rails, you can copy the minimal configuration -given above and save it as ``config/activedocument.yml``. +given above and save it as ``config/active_document.yml``. Loading ActiveDocument Configuration @@ -78,10 +78,10 @@ the configuration file path as its argument, as follows: .. code-block:: ruby # Use automatically detected environment name - ActiveDocument.load!('path/to/your/activedocument.yml') + ActiveDocument.load!('path/to/your/active_document.yml') # Specify environment name manually - ActiveDocument.load!('path/to/your/activedocument.yml', :production) + ActiveDocument.load!('path/to/your/active_document.yml', :production) When ActiveDocument is asked to automatically detect the environment name, it does so by examining the following sources, in order: @@ -119,7 +119,7 @@ current environment - but it does support defining multiple clients. ActiveDocument Configuration Options ============================= -The following annotated example ``activedocument.yml`` demonstrates how ActiveDocument +The following annotated example ``active_document.yml`` demonstrates how ActiveDocument can be configured. ActiveDocument delegates to the Ruby driver for client configuration. Please review @@ -793,7 +793,7 @@ the Ruby driver, which implements the three algorithms that are supported by Mon requires the `zstd-ruby `_ library to be installed. -To use wire protocol compression, configure the Ruby driver options within ``activedocument.yml``: +To use wire protocol compression, configure the Ruby driver options within ``active_document.yml``: .. code-block:: yaml diff --git a/docs/reference/persistence-configuration.txt b/docs/reference/persistence-configuration.txt index f49868d3d..fe76a4d1d 100644 --- a/docs/reference/persistence-configuration.txt +++ b/docs/reference/persistence-configuration.txt @@ -115,7 +115,7 @@ database, or a different client. The following example would store the Band clas default into a collection named "artists" in the database named "music", with the client "analytics". Note that the value supplied to the ``client`` option must be configured under ``clients`` -in your activedocument.yml. +in your active_document.yml. .. code-block:: ruby diff --git a/docs/reference/rails-integration.txt b/docs/reference/rails-integration.txt index 266a9c998..7162c7cf4 100644 --- a/docs/reference/rails-integration.txt +++ b/docs/reference/rails-integration.txt @@ -23,9 +23,9 @@ You can set ActiveDocument configuration options in your ``application.rb`` alon other Rails environment specific options by accessing config.mongoid. The ``mongoid:config`` generator will create an initializer in ``config/initializers/mongoid.rb`` which can also be used for configuring -ActiveDocument. Note, though, that options set in your ``config/activedocument.yml`` will +ActiveDocument. Note, though, that options set in your ``config/active_document.yml`` will take precedence over options set elsewhere; it is recommended that whenever -possible you use ``activedocument.yml`` as the default location for ActiveDocument +possible you use ``active_document.yml`` as the default location for ActiveDocument configuration. .. code-block:: ruby diff --git a/docs/release-notes/mongoid-5.txt b/docs/release-notes/mongoid-5.txt index 3bd63e4f0..3a48d3b28 100644 --- a/docs/release-notes/mongoid-5.txt +++ b/docs/release-notes/mongoid-5.txt @@ -30,7 +30,7 @@ from Moped to the official MongoDB Ruby driver. Please see the :ref:`configuration section ` for a detailed description of all the new options. -All references to session are now replaced with client. This includes the ``activedocument.yml`` +All references to session are now replaced with client. This includes the ``active_document.yml`` configuration, ``store_in`` options, and all exceptions and modules with Session in the name. ``find_and_modify`` has been removed and replaced with 3 options: ``find_one_and_update``, diff --git a/docs/release-notes/mongoid-7.4.txt b/docs/release-notes/mongoid-7.4.txt index 7af520c99..3a5555a6f 100644 --- a/docs/release-notes/mongoid-7.4.txt +++ b/docs/release-notes/mongoid-7.4.txt @@ -44,7 +44,7 @@ introduces feature flags which are further explained in the sections below. To enable all new behavior in ActiveDocument 7.4, please use the following -:ref:`configuration options ` in your activedocument.yml file. +:ref:`configuration options ` in your active_document.yml file. We recommend newly created apps to do this as well. .. code-block:: yaml diff --git a/docs/release-notes/mongoid-7.5.txt b/docs/release-notes/mongoid-7.5.txt index 8985a3ea8..f65bfbfe0 100644 --- a/docs/release-notes/mongoid-7.5.txt +++ b/docs/release-notes/mongoid-7.5.txt @@ -34,7 +34,7 @@ introduces feature flags which are further explained in the sections below. To enable all new behavior in ActiveDocument 7.5, please use the following -:ref:`configuration options ` in your activedocument.yml file. +:ref:`configuration options ` in your active_document.yml file. We recommend newly created apps to do this as well. .. code-block:: yaml diff --git a/docs/tutorials/automatic-encryption.txt b/docs/tutorials/automatic-encryption.txt index 7e3e86267..da0a21072 100644 --- a/docs/tutorials/automatic-encryption.txt +++ b/docs/tutorials/automatic-encryption.txt @@ -79,7 +79,7 @@ The steps required are as follows: 5. Click Download. Once extracted, ensure the full path to the library is configured within your -``activedocument.yml`` as follows: +``active_document.yml`` as follows: .. code-block:: yaml @@ -142,7 +142,7 @@ Configure Clients Automatic CSFLE requires some additional configuration for the MongoDB client. Assuming that your application has just one ``default`` client, you need to -add the following to your ``activedocument.yml``: +add the following to your ``active_document.yml``: .. code-block:: yaml @@ -248,7 +248,7 @@ Now we can tell ActiveDocument what should be encrypted: .. note:: If you are developing a Rails application, it is recommended to set - ``preload_models`` to ``true`` in ``activedocument.yml``. This will ensure that + ``preload_models`` to ``true`` in ``active_document.yml``. This will ensure that ActiveDocument loads all models before the application starts, and the encryption schema is configured before any data is read or written. @@ -340,7 +340,7 @@ Data Encryption Keys can be created using the ``db:mongoid:encryption:create_data_key`` ``Rake`` task. By default they are stored on the same cluster as the database. However, it might be a good idea to store the keys separately. This can be -done by specifying a key vault client in ``activedocument.yml``: +done by specifying a key vault client in ``active_document.yml``: .. code-block:: yaml @@ -376,7 +376,7 @@ Here is an example of rotating keys using AWS KMS: # Create a key vault client key_vault_client = Mongo::Client.new('mongodb+srv://user:pass@yourcluster.mongodb.net') - # Or, if you declared the key value client in activedocument.yml, use it + # Or, if you declared the key value client in active_document.yml, use it key_vault_client = ActiveDocument.client(:key_vault) # Create the encryption object diff --git a/docs/tutorials/getting-started-rails6.txt b/docs/tutorials/getting-started-rails6.txt index 3821687b1..79bbf5d88 100644 --- a/docs/tutorials/getting-started-rails6.txt +++ b/docs/tutorials/getting-started-rails6.txt @@ -125,7 +125,7 @@ Add ActiveDocument bin/rails g mongoid:config -This generator will create the ``config/activedocument.yml`` configuration file +This generator will create the ``config/active_document.yml`` configuration file (used to configure the connection to the MongoDB deployment) and the ``config/initializers/mongoid.rb`` initializer file (which may be used for other ActiveDocument-related configuration). Note that as we are not using @@ -142,9 +142,9 @@ a MongoDB server is running locally. If you do not already have a local MongoDB server, `download and install MongoDB `_. -While the generated ``activedocument.yml`` will work without modifications, +While the generated ``active_document.yml`` will work without modifications, we recommend reducing the server selection timeout for development. -With this change, the uncommented lines of ``activedocument.yml`` should look +With this change, the uncommented lines of ``active_document.yml`` should look like this: .. code-block:: none @@ -171,11 +171,11 @@ Once the cluster is created, follow the instructions in `connect to the cluster page `_ to obtain the URI. Use the *Ruby driver 2.5 or later* format. -Paste the URI into the ``config/activedocument.yml`` file, and comment out the +Paste the URI into the ``config/active_document.yml`` file, and comment out the hosts that are defined. We recommend setting the server selection timeout to 5 seconds for development environment when using Atlas. -The uncommented contents of ``config/activedocument.yml`` should look like this: +The uncommented contents of ``config/active_document.yml`` should look like this: .. code-block:: yaml @@ -466,15 +466,15 @@ Generate the default ActiveDocument configuration: bin/rails g mongoid:config -This generator will create the ``config/activedocument.yml`` configuration file +This generator will create the ``config/active_document.yml`` configuration file (used to configure the connection to the MongoDB deployment) and the ``config/initializers/mongoid.rb`` initializer file (which may be used for other ActiveDocument-related configuration). In general, it is recommended to use -``activedocument.yml`` for all ActiveDocument configuration. +``active_document.yml`` for all ActiveDocument configuration. Review the sections :ref:`Run MongoDB Locally ` and :ref:`Use MongoDB Atlas ` to decide how you would like to deploy -MongoDB, and adjust ActiveDocument configuration (``config/activedocument.yml``) to match. +MongoDB, and adjust ActiveDocument configuration (``config/active_document.yml``) to match. Adjust Models ------------- diff --git a/docs/tutorials/getting-started-rails7.txt b/docs/tutorials/getting-started-rails7.txt index bc21d28c0..338b9e9bc 100644 --- a/docs/tutorials/getting-started-rails7.txt +++ b/docs/tutorials/getting-started-rails7.txt @@ -95,7 +95,7 @@ Setup ActiveDocument bin/rails g mongoid:config -This generator will create the ``config/activedocument.yml`` configuration file +This generator will create the ``config/active_document.yml`` configuration file (used to configure the connection to the MongoDB deployment) and the ``config/initializers/mongoid.rb`` initializer file (which may be used for other ActiveDocument-related configuration). Note that as we are not using @@ -112,9 +112,9 @@ a MongoDB server is running locally. If you do not already have a local MongoDB server, `download and install MongoDB `_. -While the generated ``activedocument.yml`` will work without modifications, +While the generated ``active_document.yml`` will work without modifications, we recommend reducing the server selection timeout for development. -With this change, the uncommented lines of ``activedocument.yml`` should look +With this change, the uncommented lines of ``active_document.yml`` should look like this: .. code-block:: yaml @@ -141,11 +141,11 @@ Once the cluster is created, follow the instructions in `connect to the cluster page `_ to obtain the URI. Use the *Ruby driver 2.5 or later* format. -Paste the URI into the ``config/activedocument.yml`` file, and comment out the +Paste the URI into the ``config/active_document.yml`` file, and comment out the hosts that are defined. We recommend setting the server selection timeout to 5 seconds for development environment when using Atlas. -The uncommented contents of ``config/activedocument.yml`` should look like this: +The uncommented contents of ``config/active_document.yml`` should look like this: .. code-block:: yaml @@ -334,16 +334,16 @@ Generate the default ActiveDocument configuration: bin/rails g mongoid:config -This generator will create the ``config/activedocument.yml`` configuration file +This generator will create the ``config/active_document.yml`` configuration file (used to configure the connection to the MongoDB deployment) and the ``config/initializers/mongoid.rb`` initializer file (which may be used for other ActiveDocument-related configuration). In general, it is recommended to use -``activedocument.yml`` for all ActiveDocument configuration. +``active_document.yml`` for all ActiveDocument configuration. Review the sections :ref:`Configure for Self Managed MongoDB ` and :ref:`Configure for MongoDB Atlas ` to decide how you would like to deploy MongoDB, and adjust the ActiveDocument configuration -(``config/activedocument.yml``) to match. +(``config/active_document.yml``) to match. Loaded Frameworks ----------------- diff --git a/docs/tutorials/getting-started-sinatra.txt b/docs/tutorials/getting-started-sinatra.txt index 3a5dae84a..7c5fd029c 100644 --- a/docs/tutorials/getting-started-sinatra.txt +++ b/docs/tutorials/getting-started-sinatra.txt @@ -69,7 +69,7 @@ Run MongoDB Locally To develop locally with MongoDB, `download and install MongoDB `_. -Once MongoDB is installed and running, create a file named ``config/activedocument.yml`` +Once MongoDB is installed and running, create a file named ``config/active_document.yml`` pointing to your deployment. For example, if you launched a standalone ``mongod`` on the default port, the following contents would be appropriate: @@ -95,7 +95,7 @@ Once the cluster is created, follow the instructions in `connect to the cluster page `_ to obtain the URI. Use the *Ruby driver 2.5 or later* format. -Create a file named ``config/activedocument.yml`` with the following +Create a file named ``config/active_document.yml`` with the following contents, replacing the URI with the actual URI for your cluster: .. code-block:: yaml @@ -126,7 +126,7 @@ with Sinatra, we need to do this ourselves: .. code-block:: ruby - ActiveDocument.load!(File.join(File.dirname(__FILE__), 'config', 'activedocument.yml')) + ActiveDocument.load!(File.join(File.dirname(__FILE__), 'config', 'active_document.yml')) Now we can define some models: @@ -213,6 +213,6 @@ To start using ActiveDocument in an existing Sinatra applications, the steps are essentially the same as the one given above for a new application: 1. Add the ``mongoid`` dependency to the ``Gemfile``. -2. Create a ``activedocument.yml`` configuration file. +2. Create a ``active_document.yml`` configuration file. 3. Load the configuration file and configure ActiveDocument in the application. 4. Define ActiveDocument models. diff --git a/lib/active_document.rb b/lib/active_document.rb index 7813746ec..d955fb159 100644 --- a/lib/active_document.rb +++ b/lib/active_document.rb @@ -46,7 +46,7 @@ module ActiveDocument extend Clients::Sessions::ClassMethods # A string added to the platform details of Ruby driver client handshake documents. - PLATFORM_DETAILS = "mongoid-#{VERSION}".freeze # rubocop:disable Style/RedundantFreeze + PLATFORM_DETAILS = "active_document-#{VERSION}".freeze # rubocop:disable Style/RedundantFreeze # The minimum MongoDB version supported. MONGODB_VERSION = '2.6.0' @@ -55,11 +55,11 @@ module ActiveDocument # # @example Set up configuration options. # ActiveDocument.configure do |config| - # config.connect_to("mongoid_test") + # config.connect_to("active_document_test") # # config.clients.default = { # hosts: ["localhost:27017"], - # database: "mongoid_test", + # database: "active_document_test", # } # end # @@ -67,7 +67,7 @@ module ActiveDocument # the block to perform variable assignment. # # ActiveDocument.configure do - # connect_to("mongoid_test") + # connect_to("active_document_test") # # config.preload_models = true # diff --git a/lib/active_document/association/accessors.rb b/lib/active_document/association/accessors.rb index 780643be1..a447258f3 100644 --- a/lib/active_document/association/accessors.rb +++ b/lib/active_document/association/accessors.rb @@ -294,7 +294,7 @@ def get_relation(name, association, object, reload = false) # rubocop:disable St if object && needs_no_database_query?(object, association) __build__(name, object, association) else - selected_fields = _mongoid_filter_selected_fields(association.key) + selected_fields = _active_document_filter_selected_fields(association.key) __build__(name, attributes[association.key], association, selected_fields) end end @@ -317,7 +317,7 @@ def get_relation(name, association, object, reload = false) # rubocop:disable St # @return [ Hash | nil ] # # @api private - def _mongoid_filter_selected_fields(assoc_key) + def _active_document_filter_selected_fields(assoc_key) return nil unless __selected_fields # If the list of fields was specified using #without instead of #only diff --git a/lib/active_document/config.rb b/lib/active_document/config.rb index 405fcedab..e3175ba46 100644 --- a/lib/active_document/config.rb +++ b/lib/active_document/config.rb @@ -185,7 +185,7 @@ def configured? # @note Use only in development or test environments for convenience. # # @example Set the database to connect to. - # config.connect_to("mongoid_test") + # config.connect_to("active_document_test") # # @param [ String ] name The database name. def connect_to(name, options = { read: { mode: :primary } }) @@ -209,11 +209,11 @@ def destructive_fields Composable.prohibited_methods end - # Load the settings from a compliant activedocument.yml file. This can be used for + # Load the settings from a compliant active_document.yml file. This can be used for # easy setup with frameworks other than Rails. # # @example Configure ActiveDocument. - # ActiveDocument.load!("/path/to/activedocument.yml") + # ActiveDocument.load!("/path/to/active_document.yml") # # @param [ String ] path The path to the file. # @param [ String | Symbol ] environment The environment to load. diff --git a/lib/active_document/config/environment.rb b/lib/active_document/config/environment.rb index 04e66909d..c1cbef06e 100644 --- a/lib/active_document/config/environment.rb +++ b/lib/active_document/config/environment.rb @@ -34,7 +34,7 @@ def env_name # specified environment, or for the current ActiveDocument environment. # # @example Load the yaml. - # Environment.load_yaml("/work/activedocument.yml") + # Environment.load_yaml("/work/active_document.yml") # # @param [ String ] path The location of the file. # @param [ String | Symbol ] environment Optional environment name to diff --git a/lib/active_document/config/introspection.rb b/lib/active_document/config/introspection.rb index 8d5229fcb..a61954985 100644 --- a/lib/active_document/config/introspection.rb +++ b/lib/active_document/config/introspection.rb @@ -6,7 +6,7 @@ module Config # This module provides a way to inspect not only the defined configuration # settings and their defaults (which are available via # `ActiveDocument::Config.settings`), but also the documentation about them. It - # does this by scraping the `mongoid/config.rb` file with a regular + # does this by scraping the `active_document/config.rb` file with a regular # expression to match comments with options. # # @api private @@ -28,7 +28,7 @@ class Option attr_reader :default # The comment that describes this option, as scraped from - # mongoid/config.rb. + # active_document/config.rb. # # @return [ String ] The (possibly multi-line) comment. Each line is # prefixed with the Ruby comment character ("#"). diff --git a/lib/active_document/criteria/modifiable.rb b/lib/active_document/criteria/modifiable.rb index c15313c29..25dec5b28 100644 --- a/lib/active_document/criteria/modifiable.rb +++ b/lib/active_document/criteria/modifiable.rb @@ -220,13 +220,13 @@ def first_or(method, attrs = {}, &block) def invalid_key?(hash, key) # @todo Change this to BSON::String::ILLEGAL_KEY when ruby driver 2.3.0 is - # released and mongoid is updated to depend on driver >= 2.3.0 + # released and active_document is updated to depend on driver >= 2.3.0 key.to_s =~ ActiveDocument::Document::ILLEGAL_KEY || hash.key?(key.to_sym) || hash.key?(key) end def invalid_embedded_doc?(value) # @todo Change this to BSON::String::ILLEGAL_KEY when ruby driver 2.3.0 is - # released and mongoid is updated to depend on driver >= 2.3.0 + # released and active_document is updated to depend on driver >= 2.3.0 value.is_a?(Hash) && value.any? do |key, v| key.to_s =~ ActiveDocument::Document::ILLEGAL_KEY || invalid_embedded_doc?(v) end diff --git a/lib/active_document/criteria/queryable/mergeable.rb b/lib/active_document/criteria/queryable/mergeable.rb index 1069d0f69..19eaba00d 100644 --- a/lib/active_document/criteria/queryable/mergeable.rb +++ b/lib/active_document/criteria/queryable/mergeable.rb @@ -164,7 +164,7 @@ def __multi__(criteria, operator) if expr.is_a?(Selectable) expr = expr.selector end - normalized = _mongoid_expand_keys(expr) + normalized = _active_document_expand_keys(expr) sel.store(operator, result_criteria.push(normalized)) end end @@ -180,7 +180,7 @@ def __multi__(criteria, operator) # - nil, in which case it is ignored # # @api private - def _mongoid_add_top_level_operation(operator, criteria) + def _active_document_add_top_level_operation(operator, criteria) # Flatten the criteria. The idea is that predicates in MongoDB # are always hashes and are never arrays. This method additionally # allows Criteria instances as predicates. @@ -189,11 +189,11 @@ def _mongoid_add_top_level_operation(operator, criteria) # flatten if needed. clone.tap do |query| sel = query.selector - _mongoid_flatten_arrays(criteria).each do |criterion| + _active_document_flatten_arrays(criteria).each do |criterion| expr = if criterion.is_a?(Selectable) - _mongoid_expand_keys(criterion.selector) + _active_document_expand_keys(criterion.selector) else - _mongoid_expand_keys(criterion) + _active_document_expand_keys(criterion) end if sel.empty? sel.store(operator, [expr]) @@ -211,7 +211,7 @@ def _mongoid_add_top_level_operation(operator, criteria) # Calling .flatten on an array which includes a Criteria instance # evaluates the criteria, which we do not want. Hence this method # explicitly only expands Array objects and Array subclasses. - def _mongoid_flatten_arrays(array) + def _active_document_flatten_arrays(array) out = [] pending = array.dup until pending.empty? @@ -254,7 +254,7 @@ def _mongoid_flatten_arrays(array) # @param [ Hash ] expr Criteria including Key instances. # # @return [ BSON::Document ] The expanded criteria. - def _mongoid_expand_keys(expr) + def _active_document_expand_keys(expr) unless expr.is_a?(Hash) raise ArgumentError.new('Argument must be a Hash') end diff --git a/lib/active_document/criteria/queryable/selectable.rb b/lib/active_document/criteria/queryable/selectable.rb index 9ab7b7115..f2ada4145 100644 --- a/lib/active_document/criteria/queryable/selectable.rb +++ b/lib/active_document/criteria/queryable/selectable.rb @@ -67,9 +67,9 @@ def all(*criteria) # # @return [ Selectable ] The new selectable. def and(*criteria) - _mongoid_flatten_arrays(criteria).inject(clone) do |c, new_s| + _active_document_flatten_arrays(criteria).inject(clone) do |c, new_s| new_s = new_s.selector if new_s.is_a?(Selectable) - normalized = _mongoid_expand_keys(new_s) + normalized = _active_document_expand_keys(new_s) normalized.each do |k, v| k = k.to_s if c.selector[k] @@ -475,7 +475,7 @@ def nin(condition) # # @return [ Selectable ] The new selectable. def nor(*criteria) - _mongoid_add_top_level_operation('$nor', criteria) + _active_document_add_top_level_operation('$nor', criteria) end # Is the current selectable negating the next selection? @@ -509,7 +509,7 @@ def not(*criteria) else criteria.compact.inject(clone) do |c, new_s| new_s = new_s.selector if new_s.is_a?(Selectable) - _mongoid_expand_keys(new_s).each do |k, v| + _active_document_expand_keys(new_s).each do |k, v| k = k.to_s if c.selector[k] || k.start_with?('$') || v.is_a?(Hash) c = c.send(:__multi__, [{ '$nor' => [{ k => v }] }], '$and') @@ -545,11 +545,11 @@ def not(*criteria) # # @return [ Selectable ] The new selectable. def none_of(*criteria) - criteria = _mongoid_flatten_arrays(criteria) + criteria = _active_document_flatten_arrays(criteria) return dup if criteria.empty? exprs = criteria.map do |criterion| - _mongoid_expand_keys( + _active_document_expand_keys( criterion.is_a?(Selectable) ? criterion.selector : criterion ) end @@ -588,7 +588,7 @@ def none_of(*criteria) # # @return [ Selectable ] The new selectable. def or(*criteria) - _mongoid_add_top_level_operation('$or', criteria) + _active_document_add_top_level_operation('$or', criteria) end # Adds a disjunction of the arguments as an additional constraint @@ -618,7 +618,7 @@ def or(*criteria) # # @return [ Selectable ] The new selectable. def any_of(*criteria) - criteria = _mongoid_flatten_arrays(criteria) + criteria = _active_document_flatten_arrays(criteria) case criteria.length when 0 clone @@ -632,7 +632,7 @@ def any_of(*criteria) # and add the result to self. exprs = criteria.map do |criterion| if criterion.is_a?(Selectable) - _mongoid_expand_keys(criterion.selector) + _active_document_expand_keys(criterion.selector) else criterion.to_h do |k, v| if k.is_a?(Symbol) @@ -800,7 +800,7 @@ def expr_query(criterion) raise Errors::InvalidQuery.new("Expression must be a Hash: #{Errors::InvalidQuery.truncate_expr(criterion)}") end - normalized = _mongoid_expand_keys(criterion) + normalized = _active_document_expand_keys(criterion) clone.tap do |query| normalized.each do |field, value| field_s = field.to_s diff --git a/lib/active_document/document.rb b/lib/active_document/document.rb index f295aca57..63641658b 100644 --- a/lib/active_document/document.rb +++ b/lib/active_document/document.rb @@ -148,7 +148,7 @@ def as_document # # @return [ ActiveDocument::Document ] An instance of the specified class. def becomes(klass) - mongoid_document_check!(klass) + active_document_document_check!(klass) became = klass.new(clone_document) became.internal_state = internal_state @@ -297,7 +297,7 @@ def add_attributes_for_relation(name, meta) # # @raise [ ArgumentError ] if the class does not include # ActiveDocument::Document. - def mongoid_document_check!(klass) + def active_document_document_check!(klass) return if klass.include?(ActiveDocument::Document) raise ArgumentError.new('A class which includes ActiveDocument::Document is expected') @@ -457,19 +457,19 @@ def _types # key/value on a class. # # @example Get the types. - # document._mongoid_clear_types + # document._active_document_clear_types # # @api private - def _mongoid_clear_types + def _active_document_clear_types @_types = nil - superclass._mongoid_clear_types if hereditary? + superclass._active_document_clear_types if hereditary? end # Set the i18n scope to overwrite ActiveModel. # - # @return [ Symbol ] :mongoid + # @return [ Symbol ] :active_document def i18n_scope - :mongoid + :active_document end # Returns the logger @@ -485,4 +485,4 @@ def logger end end -ActiveSupport.run_load_hooks(:mongoid, ActiveDocument::Document) +ActiveSupport.run_load_hooks(:active_document, ActiveDocument::Document) diff --git a/lib/active_document/errors/base_error.rb b/lib/active_document/errors/base_error.rb index 9b369bfa3..d5da60c7d 100644 --- a/lib/active_document/errors/base_error.rb +++ b/lib/active_document/errors/base_error.rb @@ -10,7 +10,7 @@ class BaseError < StandardError attr_reader :problem, :summary, :resolution - BASE_KEY = 'mongoid.errors.messages' + BASE_KEY = 'active_document.errors.messages' # Compose the message. # diff --git a/lib/active_document/extensions/string.rb b/lib/active_document/extensions/string.rb index 5a21f9031..654e842ce 100644 --- a/lib/active_document/extensions/string.rb +++ b/lib/active_document/extensions/string.rb @@ -66,14 +66,14 @@ def collectionize # Is the string a valid value for a ActiveDocument id? # # @example Is the string an id value? - # "_id".mongoid_id? + # "_id".active_document_id? # # @return [ true | false ] If the string is id or _id. # @deprecated - def mongoid_id? + def active_document_id? self =~ /\A(|_)id\z/ end - ActiveDocument.deprecate(self, :mongoid_id?) + ActiveDocument.deprecate(self, :active_document_id?) # Is the string a number? The literals "NaN", "Infinity", and "-Infinity" # are counted as numbers. diff --git a/lib/active_document/extensions/symbol.rb b/lib/active_document/extensions/symbol.rb index 68d821dfa..71ee10b92 100644 --- a/lib/active_document/extensions/symbol.rb +++ b/lib/active_document/extensions/symbol.rb @@ -9,14 +9,14 @@ module Symbol # Is the symbol a valid value for a ActiveDocument id? # # @example Is the string an id value? - # :_id.mongoid_id? + # :_id.active_document_id? # # @return [ true | false ] If the symbol is :id or :_id. # @deprecated - def mongoid_id? - to_s.mongoid_id? + def active_document_id? + to_s.active_document_id? end - ActiveDocument.deprecate(self, :mongoid_id?) + ActiveDocument.deprecate(self, :active_document_id?) module ClassMethods diff --git a/lib/active_document/interceptable.rb b/lib/active_document/interceptable.rb index 348be776d..e637a6ace 100644 --- a/lib/active_document/interceptable.rb +++ b/lib/active_document/interceptable.rb @@ -153,11 +153,11 @@ def run_callbacks(kind, with_children: true, skip_if: nil, &block) # the document. # # @api private - def _mongoid_run_child_callbacks(kind, children: nil, &block) + def _active_document_run_child_callbacks(kind, children: nil, &block) if ActiveDocument::Config.around_callbacks_for_embeds - _mongoid_run_child_callbacks_with_around(kind, children: children, &block) + _active_document_run_child_callbacks_with_around(kind, children: children, &block) else - _mongoid_run_child_callbacks_without_around(kind, children: children, &block) + _active_document_run_child_callbacks_without_around(kind, children: children, &block) end end @@ -175,7 +175,7 @@ def _mongoid_run_child_callbacks(kind, children: nil, &block) # the document. # # @api private - def _mongoid_run_child_callbacks_with_around(kind, children: nil, &block) + def _active_document_run_child_callbacks_with_around(kind, children: nil, &block) child, *tail = children || cascadable_children(kind) with_children = !ActiveDocument::Config.prevent_multiple_calls_of_embedded_callbacks if child.nil? @@ -184,7 +184,7 @@ def _mongoid_run_child_callbacks_with_around(kind, children: nil, &block) child.run_callbacks(child_callback_type(kind, child), with_children: with_children, &block) else child.run_callbacks(child_callback_type(kind, child), with_children: with_children) do - _mongoid_run_child_callbacks_with_around(kind, children: tail, &block) + _active_document_run_child_callbacks_with_around(kind, children: tail, &block) end end end @@ -198,16 +198,16 @@ def _mongoid_run_child_callbacks_with_around(kind, children: nil, &block) # the document. # # @api private - def _mongoid_run_child_callbacks_without_around(kind, children: nil, &block) + def _active_document_run_child_callbacks_without_around(kind, children: nil, &block) children ||= cascadable_children(kind) - callback_list = _mongoid_run_child_before_callbacks(kind, children: children) + callback_list = _active_document_run_child_before_callbacks(kind, children: children) return false if callback_list == false value = block&.call callback_list.each do |_next_sequence, env| # rubocop:disable Style/HashEachMethods env.value &&= value end - return false if _mongoid_run_child_after_callbacks(callback_list: callback_list) == false + return false if _active_document_run_child_after_callbacks(callback_list: callback_list) == false value end @@ -221,7 +221,7 @@ def _mongoid_run_child_callbacks_without_around(kind, children: nil, &block) # to execute after callbacks in reverse order. # # @api private - def _mongoid_run_child_before_callbacks(kind, children: [], callback_list: []) + def _active_document_run_child_before_callbacks(kind, children: [], callback_list: []) children.each do |child| chain = child.__callbacks[child_callback_type(kind, child)] env = ActiveSupport::Callbacks::Filters::Environment.new(child, false, nil) @@ -236,7 +236,7 @@ def _mongoid_run_child_before_callbacks(kind, children: [], callback_list: []) env.value = !env.halted callback_list << [next_sequence, env] if (grandchildren = child.send(:cascadable_children, kind)) - _mongoid_run_child_before_callbacks(kind, children: grandchildren, callback_list: callback_list) + _active_document_run_child_before_callbacks(kind, children: grandchildren, callback_list: callback_list) end end callback_list @@ -246,7 +246,7 @@ def _mongoid_run_child_before_callbacks(kind, children: [], callback_list: []) # # @param [ Array ] callback_list List of # pairs of callback sequence and environment. - def _mongoid_run_child_after_callbacks(callback_list: []) + def _active_document_run_child_after_callbacks(callback_list: []) callback_list.reverse_each do |next_sequence, env| next_sequence.invoke_after(env) return false if env.halted diff --git a/lib/active_document/persistable.rb b/lib/active_document/persistable.rb index 155768510..141edbe69 100644 --- a/lib/active_document/persistable.rb +++ b/lib/active_document/persistable.rb @@ -95,7 +95,7 @@ def atomically(join_context: nil) call_depth = @atomic_depth ||= 0 has_own_context = call_depth.zero? || !join_context @atomic_updates_to_execute_stack ||= [] - _mongoid_push_atomic_context if has_own_context + _active_document_push_atomic_context if has_own_context if block_given? @atomic_depth += 1 @@ -105,15 +105,15 @@ def atomically(join_context: nil) if has_own_context persist_atomic_operations @atomic_context - _mongoid_remove_atomic_context_changes + _active_document_remove_atomic_context_changes end true rescue StandardError => e - _mongoid_reset_atomic_context_changes! if has_own_context + _active_document_reset_atomic_context_changes! if has_own_context raise e ensure - _mongoid_pop_atomic_context if has_own_context + _active_document_pop_atomic_context if has_own_context if call_depth.zero? @atomic_depth = nil @@ -224,11 +224,11 @@ def process_atomic_operations(operations) # @api private # # @example Remove the current atomic context's dirty changes. - # document._mongoid_remove_atomic_context_changes - def _mongoid_remove_atomic_context_changes + # document._active_document_remove_atomic_context_changes + def _active_document_remove_atomic_context_changes return unless executing_atomically? - _mongoid_atomic_context_changed_fields.each { |f| remove_change f } + _active_document_atomic_context_changed_fields.each { |f| remove_change f } end # Reset the attributes for all fields changed in the current atomic @@ -237,11 +237,11 @@ def _mongoid_remove_atomic_context_changes # @api private # # @example Reset the current atomic context's changed attributes. - # document._mongoid_reset_atomic_context_changes! - def _mongoid_reset_atomic_context_changes! + # document._active_document_reset_atomic_context_changes! + def _active_document_reset_atomic_context_changes! return unless executing_atomically? - _mongoid_atomic_context_changed_fields.each { |f| reset_attribute! f } + _active_document_atomic_context_changed_fields.each { |f| reset_attribute! f } end # Push a new atomic context onto the stack. @@ -249,8 +249,8 @@ def _mongoid_reset_atomic_context_changes! # @api private # # @example Push a new atomic context onto the stack. - # document._mongoid_push_atomic_context - def _mongoid_push_atomic_context + # document._active_document_push_atomic_context + def _active_document_push_atomic_context return unless executing_atomically? @atomic_context = {} @@ -262,8 +262,8 @@ def _mongoid_push_atomic_context # @api private # # @example Pop an atomic context off the stack. - # document._mongoid_pop_atomic_context - def _mongoid_pop_atomic_context + # document._active_document_pop_atomic_context + def _active_document_pop_atomic_context return unless executing_atomically? @atomic_updates_to_execute_stack.pop @@ -275,10 +275,10 @@ def _mongoid_pop_atomic_context # @api private # # @example Return the current atomic context's changed fields. - # document._mongoid_atomic_context_changed_fields + # document._active_document_atomic_context_changed_fields # # @return [ Array ] The changed fields. - def _mongoid_atomic_context_changed_fields + def _active_document_atomic_context_changed_fields @atomic_context.values.flat_map(&:keys) end diff --git a/lib/active_document/persistable/creatable.rb b/lib/active_document/persistable/creatable.rb index 466ce4b97..6fcfed0b3 100644 --- a/lib/active_document/persistable/creatable.rb +++ b/lib/active_document/persistable/creatable.rb @@ -112,8 +112,8 @@ def prepare_insert(options = {}) run_callbacks(:save, with_children: false) do run_callbacks(:create, with_children: false) do run_callbacks(:persist_parent, with_children: false) do - _mongoid_run_child_callbacks(:save) do - _mongoid_run_child_callbacks(:create) do + _active_document_run_child_callbacks(:save) do + _active_document_run_child_callbacks(:create) do result = yield(self) if !result.is_a?(Document) || result.errors.empty? post_process_insert diff --git a/lib/active_document/persistable/updatable.rb b/lib/active_document/persistable/updatable.rb index 1aab2064d..8bd01281f 100644 --- a/lib/active_document/persistable/updatable.rb +++ b/lib/active_document/persistable/updatable.rb @@ -217,8 +217,8 @@ def run_all_callbacks_for_update(update_children, &block) run_callbacks(:save, with_children: false) do run_callbacks(:update, with_children: false) do run_callbacks(:persist_parent, with_children: false) do - _mongoid_run_child_callbacks(:save) do - _mongoid_run_child_callbacks(:update, children: update_children, &block) + _active_document_run_child_callbacks(:save) do + _active_document_run_child_callbacks(:update, children: update_children, &block) end end end diff --git a/lib/active_document/persistence_context.rb b/lib/active_document/persistence_context.rb index a4df9fc36..b4001123d 100644 --- a/lib/active_document/persistence_context.rb +++ b/lib/active_document/persistence_context.rb @@ -152,7 +152,7 @@ def ==(other) # not be closed. # # If the persistence context is requested with :client option only, it means - # that the context should use a client configured in activedocument.yml. + # that the context should use a client configured in active_document.yml. # Such clients should not be closed when the context is cleared since they # will be reused later. # @@ -276,7 +276,7 @@ def clear(object, cluster = nil, original_context = nil) # Key to store persistence contexts in the thread local storage. # # @api private - PERSISTENCE_CONTEXT_KEY = :'[mongoid]:persistence_context' + PERSISTENCE_CONTEXT_KEY = :'[active_document]:persistence_context' # Get the persistence context for a given object from the thread local # storage. diff --git a/lib/active_document/railtie.rb b/lib/active_document/railtie.rb index 3e7d5800d..79393746b 100644 --- a/lib/active_document/railtie.rb +++ b/lib/active_document/railtie.rb @@ -29,12 +29,12 @@ def self.rescue_responses } end - config.app_generators.orm :mongoid, migration: false + config.app_generators.orm :active_document, migration: false config.action_dispatch.rescue_responses&.merge!(rescue_responses) rake_tasks do - load 'mongoid/railties/database.rake' + load 'active_document/railties/database.rake' end # Exposes ActiveDocument's configuration to the Rails application configuration. @@ -42,19 +42,19 @@ def self.rescue_responses # @example Set up configuration in the Rails app. # module MyApplication # class Application < Rails::Application - # config.mongoid.logger = Logger.new(STDERR, :warn) + # config.active_document.logger = Logger.new(STDERR, :warn) # end # end - config.mongoid = ::ActiveDocument::Config + config.active_document = ::ActiveDocument::Config - # Initialize ActiveDocument. This will look for a activedocument.yml in the config - # directory and configure mongoid appropriately. + # Initialize ActiveDocument. This will look for a active_document.yml in the config + # directory and configure active_document appropriately. # # It runs after all config/initializers have loaded, so that the YAML # options can override options specified in - # (e.g.) config/initializers/mongoid.rb. - initializer 'mongoid.load-config', after: :load_config_initializers do - config_file = Rails.root.join('config/activedocument.yml') + # (e.g.) config/initializers/active_document.rb. + initializer 'active_document.load-config', after: :load_config_initializers do + config_file = Rails.root.join('config/active_document.yml') if config_file.file? begin ::ActiveDocument.load!(config_file) @@ -81,7 +81,7 @@ def self.rescue_responses # # This will happen for every request in development, once in other # environments. - initializer 'mongoid.preload-models' do |app| + initializer 'active_document.preload-models' do |app| config.to_prepare do ::Rails::ActiveDocument.preload_models(app) end @@ -89,10 +89,10 @@ def self.rescue_responses # Rails runs all initializers first before getting into any generator # code, so we have no way in the initializer to know if we are - # generating a activedocument.yml. So instead of failing, we catch all the + # generating a active_document.yml. So instead of failing, we catch all the # errors and print them out. def handle_configuration_error(error) - ::ActiveDocument.logger.error 'There is a configuration error with the current activedocument.yml.' + ::ActiveDocument.logger.error 'There is a configuration error with the current active_document.yml.' ::ActiveDocument.logger.error error.message end @@ -101,7 +101,7 @@ def handle_configuration_error(error) # instrumentation event `process_action.action_controller`. # # The measurement is made via internal Mongo monitoring subscription - initializer 'mongoid.runtime-metric' do + initializer 'active_document.runtime-metric' do require 'active_document/railties/controller_runtime' ActiveSupport.on_load :action_controller do @@ -113,7 +113,7 @@ def handle_configuration_error(error) end # Add custom serializers for BSON::ObjectId - initializer 'mongoid.active_job.custom_serializers' do + initializer 'active_document.active_job.custom_serializers' do ActiveSupport.on_load :active_job do require 'active_document/railties/bson_object_id_serializer' diff --git a/lib/active_document/railties/controller_runtime.rb b/lib/active_document/railties/controller_runtime.rb index 5d067b459..35b765c79 100644 --- a/lib/active_document/railties/controller_runtime.rb +++ b/lib/active_document/railties/controller_runtime.rb @@ -6,14 +6,14 @@ module ControllerRuntime # This extension mimics the Rails' internal method to # measure ActiveRecord runtime during request processing. - # It appends MongoDB runtime value (`mongoid_runtime`) into payload + # It appends MongoDB runtime value (`active_document_runtime`) into payload # of instrumentation event `process_action.action_controller`. module ControllerExtension extend ActiveSupport::Concern protected - attr_internal :mongoid_runtime + attr_internal :active_document_runtime # Reset the runtime before each action. def process_action(action, *args) @@ -26,14 +26,14 @@ def cleanup_view_runtime mongo_rt_before_render = Collector.reset_runtime runtime = super mongo_rt_after_render = Collector.reset_runtime - self.mongoid_runtime = mongo_rt_before_render + mongo_rt_after_render + self.active_document_runtime = mongo_rt_before_render + mongo_rt_after_render runtime - mongo_rt_after_render end # Add the measurement to the instrumentation event payload. def append_info_to_payload(payload) super - payload[:mongoid_runtime] = (mongoid_runtime || 0) + Collector.reset_runtime + payload[:active_document_runtime] = (active_document_runtime || 0) + Collector.reset_runtime end module ClassMethods @@ -42,8 +42,8 @@ module ClassMethods # log message. def log_process_action(payload) messages = super - mongoid_runtime = payload[:mongoid_runtime] - messages << format('MongoDB: %.1fms', mongoid_runtime.to_f) if mongoid_runtime + active_document_runtime = payload[:active_document_runtime] + messages << format('MongoDB: %.1fms', active_document_runtime.to_f) if active_document_runtime messages end end diff --git a/lib/active_document/threaded.rb b/lib/active_document/threaded.rb index 724df3f2c..cc50d84e5 100644 --- a/lib/active_document/threaded.rb +++ b/lib/active_document/threaded.rb @@ -8,33 +8,33 @@ module ActiveDocument # on the current thread. module Threaded - DATABASE_OVERRIDE_KEY = '[mongoid]:db-override' + DATABASE_OVERRIDE_KEY = '[active_document]:db-override' # Constant for the key to store clients. - CLIENTS_KEY = '[mongoid]:clients' + CLIENTS_KEY = '[active_document]:clients' # The key to override the client. - CLIENT_OVERRIDE_KEY = '[mongoid]:client-override' + CLIENT_OVERRIDE_KEY = '[active_document]:client-override' # The key for the current thread's scope stack. - CURRENT_SCOPE_KEY = '[mongoid]:current-scope' + CURRENT_SCOPE_KEY = '[active_document]:current-scope' - AUTOSAVES_KEY = '[mongoid]:autosaves' - VALIDATIONS_KEY = '[mongoid]:validations' + AUTOSAVES_KEY = '[active_document]:autosaves' + VALIDATIONS_KEY = '[active_document]:validations' STACK_KEYS = Hash.new do |hash, key| - hash[key] = "[mongoid]:#{key}-stack" + hash[key] = "[active_document]:#{key}-stack" end # The key for the current thread's sessions. - SESSIONS_KEY = '[mongoid]:sessions' + SESSIONS_KEY = '[active_document]:sessions' # The key for storing documents modified inside transactions. - MODIFIED_DOCUMENTS_KEY = '[mongoid]:modified-documents' + MODIFIED_DOCUMENTS_KEY = '[active_document]:modified-documents' # The key storing the default value for whether or not callbacks are # executed on documents. - EXECUTE_CALLBACKS = '[mongoid]:execute-callbacks' + EXECUTE_CALLBACKS = '[active_document]:execute-callbacks' extend self diff --git a/lib/active_document/timestamps/timeless.rb b/lib/active_document/timestamps/timeless.rb index 606fdce95..ae4b2c8de 100644 --- a/lib/active_document/timestamps/timeless.rb +++ b/lib/active_document/timestamps/timeless.rb @@ -52,7 +52,7 @@ class << self # # @api private def timeless_table - Thread.current['[mongoid]:timeless'] ||= {} + Thread.current['[active_document]:timeless'] ||= {} end def_delegators :timeless_table, :[]=, :[] diff --git a/lib/active_document/touchable.rb b/lib/active_document/touchable.rb index 34f1b7dbf..4b2cdaddd 100644 --- a/lib/active_document/touchable.rb +++ b/lib/active_document/touchable.rb @@ -188,7 +188,7 @@ def touch_callbacks_suppressed?(name) private # The key to use to store the active touch callback suppression statuses - SUPPRESS_TOUCH_CALLBACKS_KEY = '[mongoid]:suppress-touch-callbacks' + SUPPRESS_TOUCH_CALLBACKS_KEY = '[active_document]:suppress-touch-callbacks' # Returns a hash to be used to store and query the various touch callback # suppression statuses for different classes. diff --git a/lib/active_document/traversable.rb b/lib/active_document/traversable.rb index 0da2cd93a..ff3774bce 100644 --- a/lib/active_document/traversable.rb +++ b/lib/active_document/traversable.rb @@ -93,7 +93,7 @@ module DiscriminatorAssignment def discriminator_key=(value) raise Errors::InvalidDiscriminatorKeyTarget.new(self, superclass) if hereditary? - _mongoid_clear_types + _active_document_clear_types if value ActiveDocument::Fields::Validators::Macro.validate_field_name(self, value) @@ -125,7 +125,7 @@ class << self # @api private def discriminator_value=(value) value ||= name - _mongoid_clear_types + _active_document_clear_types add_discriminator_mapping(value) @discriminator_value = value end diff --git a/lib/config/locales/en.yml b/lib/config/locales/en.yml index c8e921c53..16a29a36f 100644 --- a/lib/config/locales/en.yml +++ b/lib/config/locales/en.yml @@ -116,7 +116,7 @@ en: mongo shell." empty_config_file: message: "Empty configuration file: %{path}." - summary: "Your activedocument.yml configuration file appears to be empty." + summary: "Your active_document.yml configuration file appears to be empty." resolution: "Ensure your configuration file contains the correct contents. Refer to: https://www.mongodb.com/docs/mongoid/current/reference/configuration/" gem_conflict: @@ -173,14 +173,14 @@ en: \_\_https://www.mongodb.com/docs/ruby-driver/current/reference/client-side-encryption/#auto-encryption-options" invalid_config_file: message: "Invalid configuration file: %{path}." - summary: "Your activedocument.yml configuration file does not contain the + summary: "Your active_document.yml configuration file does not contain the correct file structure." resolution: "Ensure your configuration file contains the correct contents. Refer to: https://www.mongodb.com/docs/mongoid/current/reference/configuration/" invalid_config_option: message: "Invalid configuration option: %{name}." summary: "A invalid configuration option was provided in your - activedocument.yml, or a typo is potentially present. The valid configuration + active_document.yml, or a typo is potentially present. The valid configuration options are: %{options}." resolution: "Remove the invalid option or fix the typo. If you were expecting the option to be there, please consult the following page @@ -492,7 +492,7 @@ en: message: "No default client configuration is defined." summary: "The configuration provided settings for: %{keys}, but ActiveDocument requires a :default to be defined at minimum." - resolution: "If configuring via a activedocument.yml, ensure that within + resolution: "If configuring via a active_document.yml, ensure that within your :clients section a :default client is defined.\n\n Example:\n \_\_development:\n @@ -563,7 +563,7 @@ en: not find a client configuration for the name: '%{name}'. This is necessary in order to know the host, port, and options needed to connect." - resolution: "Double check your activedocument.yml to make sure under the + resolution: "Double check your active_document.yml to make sure under the clients key that a configuration exists for '%{name}'. If you have set the configuration programmatically, ensure that '%{name}' exists in the configuration hash." @@ -572,9 +572,9 @@ en: summary: "ActiveDocument's configuration requires that you provide details about each client that can be connected to, and requires in the clients config at least 1 default client to exist." - resolution: "Double check your activedocument.yml to make sure that you + resolution: "Double check your active_document.yml to make sure that you have a top-level clients key with at least 1 default client - configuration for it. You can regenerate a new activedocument.yml for + configuration for it. You can regenerate a new active_document.yml for assistance via `rails g mongoid:config`.\n\n Example:\n \_\_development:\n @@ -588,7 +588,7 @@ en: summary: "Each client configuration must provide a database so ActiveDocument knows where the default database to persist to. What was provided was: %{config}." - resolution: "If configuring via a activedocument.yml, ensure that within + resolution: "If configuring via a active_document.yml, ensure that within your :%{name} section a :database value for the client's default database is defined.\n\n Example:\n @@ -603,7 +603,7 @@ en: summary: "Each client configuration must provide hosts so ActiveDocument knows where the database server is located. What was provided was: %{config}." - resolution: "If configuring via a activedocument.yml, ensure that within + resolution: "If configuring via a active_document.yml, ensure that within your :%{name} section a :hosts value for the client hosts is defined.\n\n Example:\n diff --git a/lib/rails/generators/active_document/config/config_generator.rb b/lib/rails/generators/active_document/config/config_generator.rb index 296f9ad83..f9b829c56 100644 --- a/lib/rails/generators/active_document/config/config_generator.rb +++ b/lib/rails/generators/active_document/config/config_generator.rb @@ -32,14 +32,14 @@ def app_name # :nodoc: parent.underscore end - # Creates a +activedocument.yml+ config file from a template. + # Creates a +active_document.yml+ config file from a template. def create_config_file - template 'activedocument.yml', File.join('config', 'activedocument.yml') + template 'active_document.yml', File.join('config', 'active_document.yml') end # Creates a +active_document.rb+ initializer file from a template. def create_initializer_file - template 'mongoid.rb', File.join('config', 'initializers', 'mongoid.rb') + template 'active_document.rb', File.join('config', 'initializers', 'active_document.rb') end end end diff --git a/lib/rails/generators/active_document/config/templates/mongoid.rb b/lib/rails/generators/active_document/config/templates/mongoid.rb index 479e1110b..0c181d440 100644 --- a/lib/rails/generators/active_document/config/templates/mongoid.rb +++ b/lib/rails/generators/active_document/config/templates/mongoid.rb @@ -7,13 +7,13 @@ # features flags (refer to documentation) config.load_defaults target_version - # It is recommended to use config/activedocument.yml for most ActiveDocument-related + # It is recommended to use config/active_document.yml for most ActiveDocument-related # configuration, whenever possible, but if you prefer, you can set # configuration values here, instead: # # config.log_level = :debug # - # Note that the settings in config/activedocument.yml always take precedence, + # Note that the settings in config/active_document.yml always take precedence, # whatever else is set here. end diff --git a/perf/benchmark.rb b/perf/benchmark.rb index d0312c311..ca73a67d0 100644 --- a/perf/benchmark.rb +++ b/perf/benchmark.rb @@ -4,7 +4,7 @@ require "active_document" require "./perf/models" -ActiveDocument.connect_to("mongoid_perf_test") +ActiveDocument.connect_to("active_document_perf_test") Mongo::Logger.logger.level = ::Logger::FATAL ActiveDocument.purge! diff --git a/perf/benchmark_ips.rb b/perf/benchmark_ips.rb index ef5329d6f..b2ef93f50 100644 --- a/perf/benchmark_ips.rb +++ b/perf/benchmark_ips.rb @@ -2,18 +2,18 @@ require "benchmark/ips" require "active_document" -require "./perf/models" +require './perf/models' require './perf/gc_suite' -ActiveDocument.connect_to("mongoid_perf_test") +ActiveDocument.connect_to('active_document_perf_test') Mongo::Logger.logger.level = ::Logger::FATAL ActiveDocument.purge! -puts "Creating indexes..." +puts 'Creating indexes...' [ Person, Post, Game, Preference ].each(&:create_indexes) -puts "Starting benchmark..." +puts 'Starting benchmark...' suite = GCSuite.new diff --git a/perf/benchmark_ips_iteration_cases.rb b/perf/benchmark_ips_iteration_cases.rb index ce623587c..8e75dc420 100644 --- a/perf/benchmark_ips_iteration_cases.rb +++ b/perf/benchmark_ips_iteration_cases.rb @@ -2,10 +2,10 @@ require "benchmark/ips" require "active_document" -require "./perf/models" +require './perf/models' require './perf/gc_suite' -ActiveDocument.connect_to("mongoid_perf_test") +ActiveDocument.connect_to('active_document_perf_test') Mongo::Logger.logger.level = ::Logger::FATAL ActiveDocument.purge! diff --git a/perf/profile.rb b/perf/profile.rb index 826c6beaa..2c1b4e06e 100644 --- a/perf/profile.rb +++ b/perf/profile.rb @@ -4,7 +4,7 @@ require "active_document" require "./perf/models" -ActiveDocument.connect_to("mongoid_perf_test") +ActiveDocument.connect_to("active_document_perf_test") ActiveDocument.purge! diff --git a/spec/active_document/clients_spec.rb b/spec/active_document/clients_spec.rb index 8a44cc0ab..e50107124 100644 --- a/spec/active_document/clients_spec.rb +++ b/spec/active_document/clients_spec.rb @@ -544,7 +544,7 @@ describe '#mongo_client' do let(:file) do - File.join(File.dirname(__FILE__), '..', 'config', 'activedocument.yml') + File.join(File.dirname(__FILE__), '..', 'config', 'active_document.yml') end before do @@ -556,7 +556,7 @@ context 'when getting the default' do let(:file) do - File.join(File.dirname(__FILE__), '..', 'config', 'activedocument.yml') + File.join(File.dirname(__FILE__), '..', 'config', 'active_document.yml') end let!(:band) do Band.new @@ -656,7 +656,7 @@ describe '.mongo_client' do let(:file) do - File.join(File.dirname(__FILE__), '..', 'config', 'activedocument.yml') + File.join(File.dirname(__FILE__), '..', 'config', 'active_document.yml') end before do @@ -672,7 +672,7 @@ context 'when getting the default' do let(:file) do - File.join(File.dirname(__FILE__), '..', 'config', 'activedocument.yml') + File.join(File.dirname(__FILE__), '..', 'config', 'active_document.yml') end let!(:mongo_client) do Band.mongo_client @@ -1160,7 +1160,7 @@ class StoreChild2 < StoreParent context 'when overriding the default database' do let(:file) do - File.join(File.dirname(__FILE__), '..', 'config', 'activedocument.yml') + File.join(File.dirname(__FILE__), '..', 'config', 'active_document.yml') end before do diff --git a/spec/active_document/config/environment_spec.rb b/spec/active_document/config/environment_spec.rb index 66a9b8244..dd487b790 100644 --- a/spec/active_document/config/environment_spec.rb +++ b/spec/active_document/config/environment_spec.rb @@ -61,7 +61,7 @@ describe '#load_yaml' do subject { described_class.load_yaml(path, environment) } - let(:path) { 'activedocument.yml' } + let(:path) { 'active_document.yml' } let(:environment) {} before do @@ -77,7 +77,7 @@ context 'when file found' do before do - allow(File).to receive(:read).with('activedocument.yml').and_return(file_contents) + allow(File).to receive(:read).with('active_document.yml').and_return(file_contents) end let(:file_contents) do @@ -140,7 +140,7 @@ raise 'Expected to find some schema maps' if paths.empty? before do - allow(File).to receive(:read).with('activedocument.yml').and_return(file_contents) + allow(File).to receive(:read).with('active_document.yml').and_return(file_contents) end let(:file_contents) do diff --git a/spec/active_document/config_spec.rb b/spec/active_document/config_spec.rb index 88394f4d1..9e18bd3ad 100644 --- a/spec/active_document/config_spec.rb +++ b/spec/active_document/config_spec.rb @@ -337,7 +337,7 @@ describe '#load!' do let(:file) do - File.join(File.dirname(__FILE__), '..', 'config', 'activedocument.yml') + File.join(File.dirname(__FILE__), '..', 'config', 'active_document.yml') end context 'when existing clients exist in the configuration' do diff --git a/spec/active_document/errors/invalid_config_file_spec.rb b/spec/active_document/errors/invalid_config_file_spec.rb index 0cdabc1b6..c82dfec14 100644 --- a/spec/active_document/errors/invalid_config_file_spec.rb +++ b/spec/active_document/errors/invalid_config_file_spec.rb @@ -18,7 +18,7 @@ it 'contains the summary in the message' do expect(error.message).to include( - 'Your activedocument.yml configuration file does not contain the' + 'Your active_document.yml configuration file does not contain the' ) end diff --git a/spec/active_document/errors/invalid_config_option_spec.rb b/spec/active_document/errors/invalid_config_option_spec.rb index 5c731a89d..8b63226b3 100644 --- a/spec/active_document/errors/invalid_config_option_spec.rb +++ b/spec/active_document/errors/invalid_config_option_spec.rb @@ -18,7 +18,7 @@ it 'contains the summary in the message' do expect(error.message).to include( - 'A invalid configuration option was provided in your activedocument.yml,' + 'A invalid configuration option was provided in your active_document.yml,' ) end diff --git a/spec/active_document/errors/no_client_config_spec.rb b/spec/active_document/errors/no_client_config_spec.rb index 53ca2c6fc..e47026c31 100644 --- a/spec/active_document/errors/no_client_config_spec.rb +++ b/spec/active_document/errors/no_client_config_spec.rb @@ -24,7 +24,7 @@ it 'contains the resolution in the message' do expect(error.message).to include( - 'Double check your activedocument.yml to make sure under the clients' + 'Double check your active_document.yml to make sure under the clients' ) end end diff --git a/spec/active_document/errors/no_client_database_spec.rb b/spec/active_document/errors/no_client_database_spec.rb index 4848a1402..49d384653 100644 --- a/spec/active_document/errors/no_client_database_spec.rb +++ b/spec/active_document/errors/no_client_database_spec.rb @@ -24,7 +24,7 @@ it 'contains the resolution in the message' do expect(error.message).to include( - 'If configuring via a activedocument.yml, ensure that within your :analytics' + 'If configuring via a active_document.yml, ensure that within your :analytics' ) end end diff --git a/spec/active_document/errors/no_client_hosts_spec.rb b/spec/active_document/errors/no_client_hosts_spec.rb index 67db4b1b4..2f83cae23 100644 --- a/spec/active_document/errors/no_client_hosts_spec.rb +++ b/spec/active_document/errors/no_client_hosts_spec.rb @@ -24,7 +24,7 @@ it 'contains the resolution in the message' do expect(error.message).to include( - 'If configuring via a activedocument.yml, ensure that within your :analytics' + 'If configuring via a active_document.yml, ensure that within your :analytics' ) end end diff --git a/spec/active_document/errors/no_clients_config_spec.rb b/spec/active_document/errors/no_clients_config_spec.rb index 7bc0b3dd0..68bc7a1f8 100644 --- a/spec/active_document/errors/no_clients_config_spec.rb +++ b/spec/active_document/errors/no_clients_config_spec.rb @@ -24,7 +24,7 @@ it 'contains the resolution in the message' do expect(error.message).to include( - 'Double check your activedocument.yml to make sure that you have' + 'Double check your active_document.yml to make sure that you have' ) end end diff --git a/spec/active_document/persistence_context_spec.rb b/spec/active_document/persistence_context_spec.rb index 1b4f313e3..158fe98b1 100644 --- a/spec/active_document/persistence_context_spec.rb +++ b/spec/active_document/persistence_context_spec.rb @@ -261,7 +261,7 @@ context 'when the parent object has a client set' do let(:file) do - File.join(File.dirname(__FILE__), '..', 'config', 'activedocument.yml') + File.join(File.dirname(__FILE__), '..', 'config', 'active_document.yml') end before do diff --git a/spec/integration/app_spec.rb b/spec/integration/app_spec.rb index 0b3915266..3732a55df 100644 --- a/spec/integration/app_spec.rb +++ b/spec/integration/app_spec.rb @@ -136,7 +136,7 @@ def prepare_new_rails_app(name) it 'generates ActiveDocument config' do prepare_new_rails_app 'active_document-test-config' do - active_document_config_file = File.join(TMP_BASE, 'active_document-test-config/config/activedocument.yml') + active_document_config_file = File.join(TMP_BASE, 'active_document-test-config/config/active_document.yml') expect(File.exist?(active_document_config_file)).to be false check_call(%w[rails g active_document:config], env: clean_env) @@ -287,7 +287,7 @@ def write_active_document_yml 'uri' => uri } } } config = { 'development' => env_config, 'production' => env_config } - File.open('config/activedocument.yml', 'w') do |f| + File.open('config/active_document.yml', 'w') do |f| f << YAML.dump(config) end end diff --git a/spec/support/macros.rb b/spec/support/macros.rb index a5b8dd5e3..ff35846d8 100644 --- a/spec/support/macros.rb +++ b/spec/support/macros.rb @@ -5,7 +5,7 @@ module Macros def use_spec_active_document_config around do |example| - config_path = File.join(File.dirname(__FILE__), '..', 'config', 'activedocument.yml') + config_path = File.join(File.dirname(__FILE__), '..', 'config', 'active_document.yml') ActiveDocument::Clients.clear ActiveDocument.load!(config_path, :test)