Skip to content

Commit 5777d3e

Browse files
committed
docs: update online yardoc links and simplify readme
1 parent f3e1bf6 commit 5777d3e

File tree

2 files changed

+33
-48
lines changed

2 files changed

+33
-48
lines changed

README.md

Lines changed: 31 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,72 +2,57 @@
22

33
[![Gem Version](https://badge.fury.io/rb/nested_objects.svg)](https://badge.fury.io/rb/nested_objects)
44
[![Build Status](https://github.com/main-branch/nested_objects/actions/workflows/continuous_integration.yml/badge.svg)](https://github.com/main-branch/nested_objects/actions/workflows/continuous_integration.yml)
5-
[![Documentation](https://img.shields.io/badge/Documentation-Latest-green)](https://rubydoc.info/gems/nested_objects/)
5+
[![Documentation](https://img.shields.io/badge/Documentation-Latest-green)](https://gemdocs.org/gems/nested_objects)
66
[![Change Log](https://img.shields.io/badge/CHANGELOG-Latest-green)](https://rubydoc.info/gems/nested_objects/file/CHANGELOG.md)
77
[![Slack](https://img.shields.io/badge/slack-main--branch/track__open__instances-yellow.svg?logo=slack)](https://main-branch.slack.com/archives/C01CHR7TMM2)
88

9-
The `NestedObjects` module provides module level methods to safely navigate and
9+
The `NestedObjects` module provides module methods to safely navigate and
1010
manage a heirarchy of Ruby POROs nested using Hashes or Arrays. Think of these
1111
nested data objects like what you would get after reading in a JSON file.
1212

13-
The key methods are:
13+
## Usage
1414

15-
* `NestedObjects.deep_copy(data)` - returns a deep copy of data including nested hash
16-
values and array elements
17-
* `NestedObjects.dig(data, path)` - returns the value at the given path
18-
* `NestedObjects.bury(data, path, value)` - sets a value within the data structure at
19-
the given path
20-
* `NestedObjects.delete(data, path)` - deletes the Hash key or Array index at the
21-
given path
22-
* `NestedObjects.path?(data, path)` - returns true if the path exists in the given
23-
data structure
15+
### Module Methods
2416

25-
These methods (prefixed with `nested_` to avoid method conflicts) can be mixed into
26-
`Object` for ease of use:
17+
These methods are exposted on the `NestedObjects` module. The key methods are:
18+
`deep_copy`, `dig`, `bury`, `delete`, and `path?`.
2719

28-
```Ruby
29-
Object.include NestedObjects::Mixin
20+
Here is an example of using the `dig` method:
3021

31-
data = { 'users' => [{ 'name' => 'John Smith'}, { 'name' => 'Jane Doe' }] }
22+
```Ruby
23+
require 'nested_objects'
3224

33-
data.nested_dig(%w[users 1 name]) #=> 'Jane Doe'
25+
data = { 'people' => [{ 'name' => 'John'}, { 'name', 'Jane' }] }
26+
path = 'people/0/name'.split('/')
27+
NestedObjects.dig(data, path) #=> 'John'
3428
```
3529

36-
If the path is malformed or does not exist, a `BadPathError` will be raised.
37-
38-
## Development
39-
40-
After checking out the repo, run `bin/setup` to install dependencies. Then, run
41-
`bundle exec rake` to run tests, static analysis, and build the gem.
42-
43-
For experimentation, you can also run `bin/console` for an interactive (IRB) prompt that
44-
automatically requires nested_objects.
30+
See documentation and examples of the full API in
31+
[the gem's YARD documentation](https://gemdocs.org/gems/nested_objects/).
4532

46-
## Contributing
47-
48-
Bug reports and pull requests are welcome on GitHub at <https://github.com/main-branch/nested_objects>.
33+
### Object Mixin
4934

50-
### Commit message guidelines
35+
As a convenience, these methods can be mixed into other classes by including the `NestedObjects::Mixin` module.
5136

52-
All commit messages must follow the [Conventional Commits
53-
standard](https://www.conventionalcommits.org/en/v1.0.0/). This helps us maintain a
54-
clear and structured commit history, automate versioning, and generate changelogs
55-
effectively.
37+
In order to reduce the possibility of method name conflicts, all methods are prefixed with `nested_`.
5638

57-
To ensure compliance, this project includes:
39+
```Ruby
40+
Object.include NestedObjects::Mixin
5841

59-
- A git commit-msg hook that validates your commit messages before they are accepted.
42+
data = { 'people' => [{ 'name' => 'John'}, { 'name', 'Jane' }] }
43+
path = 'people/0/name'.split('/')
44+
data.nested_dig(path) #=> 'John'
45+
```
6046

61-
To activate the hook, you must have node installed and run `npm install`.
47+
## Development
6248

63-
- A GitHub Actions workflow that will enforce the Conventional Commit standard as
64-
part of the continuous integration pipeline.
49+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
50+
`bundle exec rake` to run tests, static analysis, and build the gem.
6551

66-
Any commit message that does not conform to the Conventional Commits standard will
67-
cause the workflow to fail and not allow the PR to be merged.
52+
For experimentation, you can also run `bin/console` for an interactive (IRB) prompt
53+
that automatically requires nested_objects.
6854

69-
### Pull request guidelines
55+
## Contributing
7056

71-
All pull requests must be merged using rebase merges. This ensures that commit
72-
messages from the feature branch are preserved in the release branch, keeping the
73-
history clean and meaningful.
57+
See [the contributing guildlines](CONTRIBUTING.md) for guidance on how to contriute
58+
to this project.

nested_objects.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Gem::Specification.new do |spec|
2929
spec.homepage = "https://github.com/main-branch/#{spec.name}"
3030
spec.metadata['homepage_uri'] = spec.homepage
3131
spec.metadata['source_code_uri'] = spec.homepage
32-
spec.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}"
33-
spec.metadata['changelog_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}/file/CHANGELOG.md"
32+
spec.metadata['documentation_uri'] = "https://gemdocs.org/#{spec.name}/#{spec.version}"
33+
spec.metadata['changelog_uri'] = "https://gemdocs.org/#{spec.name}/#{spec.version}/file.CHANGELOG.md"
3434

3535
# Specify which files should be added to the gem when it is released.
3636
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.

0 commit comments

Comments
 (0)