README.md in tanshuku-0.0.13 vs README.md in tanshuku-0.0.14
- old
+ new
@@ -29,12 +29,14 @@
### 2. Configure Tanshuku (Optional)
**Note**: This step is optional.
-**Note**: The initializer file can be generated by `bin/rails generate tanshuku:install`. See the "[Installation](#installation)" section for more information.
+**Note**: An initializer file for configuration can be generated by `bin/rails generate tanshuku:install`. See the "[Installation](#installation)" section below for more information.
+**Note**: Mutating a `Tanshuku::Configuration` object is thread-***unsafe***. It is recommended to use `Tanshuku.configure` for configuration.
+
#### `config.default_url_options`
Tanshuku uses configured `config.default_url_options` when generating shortened URLs.
Default value is `{}`.
@@ -50,11 +52,11 @@
#### `config.exception_reporter`
If an exception occurs when shortening a URL, Tanshuku reports it with configured `config.exception_reporter` object.
-Default value is `Tanshuku::Configuration::DefaultExceptionReporter`. It logs the exception and the original URL with `Rails.logger.warn`.
+Default value is [`Tanshuku::Configuration::DefaultExceptionReporter`](https://kg8m.github.io/tanshuku/Tanshuku/Configuration/DefaultExceptionReporter.html). It logs the exception and the original URL with `Rails.logger.warn`.
Value of `config.exception_reporter` should respond to `#call` with keyword arguments `exception:` and `original_url:`.
The following example means that an exception and a URL will be reported to [Sentry](https://sentry.io/).
@@ -66,21 +68,25 @@
Sentry.capture_exception(exception, tags: { original_url: })
}
end
```
+#### More information
+
+cf. [`Tanshuku::Configuration`'s API documentation](https://kg8m.github.io/tanshuku/Tanshuku/Configuration.html)
+
### 3. Generate shortened URLs
#### Basic cases
You can generate a shortened URL with `Tanshuku::Url.shorten`. For example:
```rb
Tanshuku::Url.shorten("https://google.com/") #=> "https://example.com/t/abcdefghij0123456789"
```
-[`config.default_url_options`](#configdefault_url_options) is used for the shortened URL.
+[`config.default_url_options`](https://kg8m.github.io/tanshuku/Tanshuku/Configuration.html#default_url_options-instance_method) is used for the shortened URL.
**Note**: If a `Tanshuku::Url` record for the given URL already exists, no additional record will be created and always the existing record is used.
```rb
# When no record exists for "https://google.com/", a new record will be created.
@@ -120,9 +126,13 @@
# When the same URL and the same namespace is specified, no additional record will be created.
Tanshuku::Url.shorten("https://google.com/", namespace: "a") #=> "https://example.com/t/ab01cd23ef45gh67ij89"
Tanshuku::Url.shorten("https://google.com/", namespace: "a") #=> "https://example.com/t/ab01cd23ef45gh67ij89"
```
+
+#### More information
+
+cf. [`Tanshuku::Url.shorten`'s API documentation](https://kg8m.github.io/tanshuku/Tanshuku/Url.html#shorten-class_method)
### 4. Share the shortened URLs
You can share the shortened URLs, e.g., `https://example.com/t/abcdefghij0123456789`.