README.adoc in relaton-index-0.1.2 vs README.adoc in relaton-index-0.1.3
- old
+ new
@@ -26,11 +26,11 @@
- indexing documents' files in GitHub repositories
- searching a document by a reference when the Relaton library fetches a document
=== Indexing
-In this case, the Relaton library should create an index object and add documents' files to it. The index object should be saved to the `index.yaml` file in the root of the repository.
+In this case, the Relaton library creates an index object and adds documents' files to it. By default, the index object is saved to the `index.yaml` file in the root of the repository. The filename can be changed using the `filename` setting
[source,ruby]
----
require 'relaton/index'
@@ -50,11 +50,11 @@
[source,ruby]
----
require 'relaton/index'
-# Create a new index object or fetch an existing one. URL should be specified. If the index file is not found or is older than 24 hours, it will be downloaded from the URL. By default, the index file is saved to the `/[HOME]/.relaton/[TYPE]/index.yaml` file.
+# Create a new index object or fetch an existing one. URL should be specified. If the index file is not found or is older than 24 hours, it will be downloaded from the URL. By default, the index file is saved to the `/[HOME]/.relaton/iho/index.yaml` file.
index = Relaton::Index.find_or_create :IHO, url: "https://raw.githubusercontent.com/relaton/relaton-data-iho/master/index.zip"
# Search for a document by reference
index.search "B-4"
@@ -67,9 +67,26 @@
end
# => [{ id: "B-4 2.19.0", file: "data/b-4_2_19_0.xml" }]
# Remove the index from the pool.
Relaton::Index.close :IHO
+----
+
+=== Configuration
+
+The gem can be configured by using the `Relaton::Index.config` method. The following settings are available:
+
+- `filename` - the name of the index file. By default, it is `index.yaml`.
+- `storage` - the storage class or module. By default, it is `FileStorage` module. It can be any class or module that implements the `ctime`, `read`, and `write` class methods.
+- `storage_dir` - the directory where the `.relaton/[TYPE]` folder is created. By default, it's a user's home dir. This setting works only when the gem is used for searching. When indexing, the index is always saved in a current folder.
+
+[source,ruby]
+----
+Relaton::Index.config do |config|
+ config.filename = "index-new.yaml"
+ config.storage = S3Storage
+ config.storage_dir = "/"
+end
----
== Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.