Skip to content

Commit

Permalink
Update formatting on README and CHANGELOG
Browse files Browse the repository at this point in the history
Update automatically applied with:

`npx prettier . --write`

Also, add instructions for testing and releasing new version of this gem
to README.
  • Loading branch information
pdobb committed Nov 21, 2024
1 parent 0b46a11 commit 2f861b6
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 16 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,59 @@
## [Unreleased]

- Update minimum Ruby version from 2.7 -> 3.1

### 0.7.0 - 2023-11-21

- Internal refactoring for more Object-Oriented goodness.
- Internal refactoring for less brittle tests.

#### BREAKING

- Change method signature of ObjectIdentifier FormatterClass initialization to expect `parameters` as a keyword argument.
- Add ObjectIdentifier::BaseFormatter as a superclass for Formatter objects to help define the above, plus whatever else it means to be an ObjectIdentifier Formatter.

### 0.6.0 - 2023-01-09

- Internal refactoring for more Object-Oriented goodness.

#### BREAKING

- Refactor `ObjectIdentifier::Identifier` to just `ObjectIdentifier`. This has no effect on instance method usage (e.g. `<my_object>.identify(...)`). But if any manual invocations were made (e.g. `ObjectIdentifier::Identifier.call(...)`) then they will need to be updated to `ObjectIdentifier.call(...)` (or just `ObjectIdentifier.(...)`, per your own style guide).

### 0.5.0 - 2023-01-04

- Add support for defining customer Formatters.
- Add ObjectInspector::Configuration#formatter_class setting for overriding the default Formatter. See the README for more.
- Add a benchmarking script for comparing performance of formatters. See the README for more.

### 0.4.1 - 2022-12-30

- Make compatible with Ruby 3.2 (and likely Ruby 3.0 and 3.1 as well).
- Update development dependencies.

### 0.4.0 - 2020-09-01

- [#4](https://github.com/pdobb/object_identifier/pull/4) Only show attribute names if identifying more than one attribute.
- Update development dependencies.

#### BREAKING

- Drop support for Ruby 2.3.

### 0.3.0 - 2019-06-27

- Fix identification of objects that implement `to_a`, such as Struct.

### 0.2.1 - 2019-02-24

- Add ability to identify instance vars.

### 0.1.0 - 2018-04-14

- Revamp gem.
- Update gem dependencies.
- Now returns "[no objects]" even if given a :klass option.


### 0.0.6 - 2016-02-06

- Fix: identify method now supports private & protected methods.
46 changes: 32 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Which is the same as:
"#{some_object.class.name}[id:#{some_object.id}, name:\"#{some_object.name}\"]"
```


## Installation

Add this line to your application's Gemfile:
Expand All @@ -35,13 +34,13 @@ Or install it yourself as:

$ gem install object_identifier


## Compatibility

Tested MRI Ruby Versions:
* 3.1
* 3.2
* 3.3

- 3.1
- 3.2
- 3.3

Note: For Ruby 2.7 or 3.1 support, install object_identifier gem version 0.7.0.

Expand All @@ -65,7 +64,6 @@ ObjectIdentifier.configure do |config|
end
```


## Usage

### Defaults
Expand Down Expand Up @@ -128,15 +126,13 @@ The number of results that will be identified from a collection can be truncated
# => Movie[id:1, name:"Pi"], ... (1 more)
```


### Empty Collections

```ruby
[].identify # => [no objects]
{}.identify # => [no objects]
```


## Custom Object Identifiers

Internally, Object Identifier calls `inspect_lit` to return a "literally-inspected" string representation of an object. This works because Object, itself, is monkey-patched to define `inspect_lit` which just returns `inspect`. This is sufficient for most objects, but some objects will benefit from defining special output from `inspect_lit`.
Expand Down Expand Up @@ -167,12 +163,10 @@ OpenStruct.new(my_value: my_value_object).identify(:my_value)
# => "OpenStruct[my_value:42 Meters]"
```


## Supporting Gems

Object Identifier works great with the [Object Inspector](https://github.com/pdobb/object_inspector) gem.


### Benchmarking Formatters

Performance of Formatters can be tested by playing the [Formatters Benchmarking Scripts](https://github.com/pdobb/object_identifier/blob/master/script/benchmarking/formatters.rb) in the IRB console for this gem.
Expand All @@ -189,31 +183,55 @@ load "script/benchmarking/formatters.rb"
# ...
```


## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. Or, run `rake` to run the tests plus linters as well as `yard` (to confirm proper YARD documentation practices). You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`.

To release a new version, update the version number in `version.rb`, bump the latest ruby target versions etc. with `rake bump`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
### Testing

To test this gem (gemwork):

```bash
rake
```

#### Linters

```bash
rubocop

reek

npx prettier . --check
npx prettier . --write
```

### Releases

To release a new version of Gemwork to RubyGems:

1. Update the version number in `version.rb`
2. Update `CHANGELOG.md`
3. Run `bundle` to update Gemfile.lock with the latest version info
4. Commit the changes. e.g. `Bump to vX.Y.Z`
5. Run `rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).

### Documentation

[YARD documentation](https://yardoc.org/index.html) can be generated and viewed live:

1. Install YARD: `gem install yard`
2. Run the YARD server: `yard server --reload`
3. Open the live documentation site: `open http://localhost:8808`

While the YARD server is running, documentation in the live site will be auto-updated on source code save (and site reload).


## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/pdobb/object_identifier.


## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
3 changes: 2 additions & 1 deletion rakelib/gemwork.rake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ spec = Gem::Specification.find_by_name("gemwork")
# Load additional tasks defined by Gemwork.
Dir.glob(
Pathname.new(spec.gem_dir).
join("lib", "tasks", "{util,rubocop,reek,test}.rake")) do |task|
join("lib", "tasks", "{util,rubocop,reek,test,prettier}.rake")) do |task|
load(task)
end

Expand All @@ -15,5 +15,6 @@ task :default do
test
rubocop
reek
prettier
])
end

0 comments on commit 2f861b6

Please sign in to comment.