Skip to content

Commit 50f543d

Browse files
committed
Update README & LICENSE; add CONTRIBUTING
[ci skip]
1 parent 78fb071 commit 50f543d

File tree

3 files changed

+124
-69
lines changed

3 files changed

+124
-69
lines changed

CONTRIBUTING.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Contributing
2+
3+
Want to make a change to this library?
4+
Great! Here's how you do that.
5+
6+
First, create a fork of this repo,
7+
cloning it to your computer
8+
and running the following command in the resulting directory
9+
in order to install dependencies:
10+
11+
```
12+
bin/setup
13+
```
14+
15+
After this, you can run all of the tests
16+
to make sure everything is kosher:
17+
18+
```
19+
bundle exec rake
20+
```
21+
22+
Next, make changes to the code as necessary.
23+
Code is linted using Rubocop,
24+
so make sure that's set up in your editor.
25+
If you update one of the tests,
26+
you can run it like so:
27+
28+
```
29+
bin/rspec spec/integration/...
30+
bin/rspec spec/unit/...
31+
```
32+
33+
Finally, submit your PR.
34+
I'll try to respond as quickly as I can.
35+
I may have suggestions about code style or your approach,
36+
but hopefully everything looks good and your changes get merged!
37+
Now you're a contributor! 🎉

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2018 Elliot Winkler.
1+
Copyright (c) 2018-2020 Elliot Winkler.
22

33
Permission is hereby granted, free of charge, to any person
44
obtaining a copy of this software and associated documentation

README.md

Lines changed: 86 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,33 @@
77
[hound-badge]: https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg
88
[hound]: https://houndci.com
99

10-
SuperDiff is a gem that hooks into RSpec to intelligently display the
11-
differences between two data structures of any type.
10+
SuperDiff is a gem that hooks into RSpec
11+
to intelligently display the differences between two data structures of any type.
1212

1313
📢 **[See what's changed in the latest version (0.4.0)][changelog].**
1414

1515
[changelog]: CHANGELOG.md
1616

1717
## Introduction
1818

19-
The primary motivation behind this gem is to vastly improve upon RSpec's
20-
built-in diffing capabilities.
19+
The primary motivation behind this gem
20+
is to vastly improve upon RSpec's built-in diffing capabilities.
2121

22-
Sometimes, whenever you use a matcher such as `eq`, `match`, `include`, or
23-
`have_attributes`, you will get a diff of the two data structures you are trying
24-
to match against. This is great if all you want to do is compare multi-line
25-
strings. But if you want to compare other, more "real world" kinds of values
26-
nested data structures (arrays, hashes, and full-scale objects), such as what
27-
you might work with when developing API endpoints or testing methods that make
28-
database calls and return a set of model objects — then you are out of luck.
29-
Since [RSpec merely runs your `expected` and `actual` values through Ruby's
30-
PrettyPrinter library][rspec-differ-fail] and then performs a diff of these
31-
strings, the output it produces leaves much to be desired.
22+
Sometimes, whenever you use a matcher such as `eq`, `match`, `include`, or `have_attributes`,
23+
you will get a diff of the two data structures you are trying to match against.
24+
This is great if all you want to do is compare multi-line strings.
25+
But if you want to compare other, more "real world" kinds of values,
26+
such as what you might work with when developing API endpoints
27+
or testing methods that make database calls and return a set of model objects,
28+
then you are out of luck.
29+
Since [RSpec merely runs your `expected` and `actual` values through Ruby's PrettyPrinter library][rspec-differ-fail]
30+
and then performs a diff of these strings,
31+
the output it produces leaves much to be desired.
3232

3333
[rspec-differ-fail]: https://github.com/rspec/rspec-support/blob/c69a231d7369dd165ad7ce4742e1a2e21e3462b5/lib/rspec/support/differ.rb#L178
3434

35-
For instance, let's say you wanted to compare these two hashes:
35+
For instance,
36+
let's say you wanted to compare these two hashes:
3637

3738
``` ruby
3839
actual = {
@@ -86,36 +87,60 @@ You would get output that looks like this:
8687

8788
![Before super_diff](doc/before.png)
8889

89-
What this library does is to provide a diff engine that knows how to figure out
90-
the differences between any two data structures and display them in a sensible
91-
way. So, using the example above, you'd get this instead:
90+
What this library does
91+
is to provide a diff engine
92+
that knows how to figure out the differences between any two data structures
93+
and display them in a sensible way.
94+
So, using the example above,
95+
you'd get this instead:
9296

9397
![After super_diff](doc/after.png)
9498

9599
## Installation
96100

97-
Want to try out this gem for yourself? As with most development-related gems,
98-
there are a couple ways depending on your type of project:
101+
There are a few different ways to install `super_diff`
102+
depending on your type of project.
99103

100104
### Rails apps
101105

102-
If you're developing a Rails app, add the following to your Gemfile:
106+
If you're developing a Rails app,
107+
add the following to your Gemfile:
103108

104109
``` ruby
105-
gem "super_diff"
110+
group :test do
111+
gem "super_diff"
112+
end
106113
```
107114

108-
After running `bundle install`, add the following to your `rails_helper`:
115+
After running `bundle install`,
116+
add the following to your `rails_helper`:
109117

110118
``` ruby
111119
require "super_diff/rspec-rails"
112120
```
113121

114-
You're done!
122+
### Projects using some part of Rails (e.g. ActiveModel)
115123

116-
### Libraries
124+
If you're developing an app using Hanami or Sinatra,
125+
or merely using a part of Rails such as ActiveModel,
126+
add the following to your Gemfile where appropriate:
117127

118-
If you're developing a library, add the following to your gemspec:
128+
``` ruby
129+
gem "super_diff"
130+
```
131+
132+
After running `bundle install`,
133+
add the following to your `spec_helper`:
134+
135+
``` ruby
136+
require "super_diff/rspec"
137+
require "super_diff/active_support"
138+
```
139+
140+
### Gems
141+
142+
If you're developing a gem,
143+
add the following to your gemspec:
119144

120145
``` ruby
121146
spec.add_development_dependency "super_diff"
@@ -127,14 +152,16 @@ Now add the following to your `spec_helper`:
127152
require "super_diff/rspec"
128153
```
129154

130-
You're done!
131-
132155
## Configuration
133156

134-
As capable as this library is, it doesn't know how to deal with every kind of
135-
object out there. You might find it necessary to instruct the gem on how to diff
136-
your object. To do this, you can use a configuration block. Simply add this to
137-
your test helper file (`rails_helper` or `spec_helper`):
157+
As capable as this library is,
158+
it doesn't know how to deal with every kind of object out there.
159+
If you have a custom class,
160+
and instances of your class aren't appearing in diffs like you like,
161+
you might find it necessary to instruct the gem on how to handle them.
162+
In that case
163+
you would add something like this to your test helper file
164+
(`rails_helper` or `spec_helper`):
138165

139166
``` ruby
140167
SuperDiff::RSpec.configure do |config|
@@ -144,62 +171,53 @@ SuperDiff::RSpec.configure do |config|
144171
end
145172
```
146173

147-
*(More info here in the future on adding a custom differ, operational sequencer,
148-
and diff formatter. Also explanations on what these are.)*
174+
*(More info here in the future on adding a custom differ, operational sequencer, and diff formatter.
175+
Also explanations on what these are.)*
149176

150-
## Contributing
151-
152-
If you encounter a bug or have an idea for how this could be better, feel free
153-
to [create an issue](https://github.com/mcmire/super_diff/issues).
154-
155-
If you'd like to submit a PR instead, here's how to get started. First, fork
156-
this repo. Then, when you've cloned your fork, run:
157-
158-
```
159-
bin/setup
160-
```
177+
## Support
161178

162-
This will install various dependencies. After this, you can run all of the
163-
tests:
179+
My goal for this library is to improve your development experience.
180+
If this is not the case,
181+
and you encounter a bug or have a suggestion,
182+
feel free to [create an issue][issues-list].
183+
I'll try to respond to it as soon as I can!
164184

165-
```
166-
bundle exec rake
167-
```
168-
169-
If you update one of the tests, you can run it like so:
185+
[issues-list]: https://github.com/mcmire/super_diff/issues
170186

171-
```
172-
bin/rspec spec/integration/...
173-
bin/rspec spec/unit/...
174-
```
187+
## Contributing
175188

176-
Finally, submit your PR and I'll take a look at it when I get a chance.
189+
Any contributions to improve this library are welcome!
190+
Please see the [contributing](./CONTRIBUTING.md) document for more on how to do that.
177191

178192
## Compatibility
179193

180-
`super_diff` is [tested][travis] to work with Ruby >= 2.4.x, RSpec 3.x, and
181-
Rails >= 5.x.
194+
`super_diff` is [tested][travis] to work with
195+
Ruby >= 2.4.x,
196+
RSpec 3.x,
197+
and Rails >= 5.x.
182198

183199
[travis]: http://travis-ci.org/mcmire/super_diff
184200

185201
## Inspiration/Thanks
186202

187-
In developing this gem I made use of or was heavily inspired by these libraries:
203+
In developing this gem
204+
I made use of or was heavily inspired by these libraries:
188205

189-
* [Diff::LCS][diff-lcs], the library I started with in the [original version of
190-
this gem][original-version] (made in 2011!)
191-
* The pretty-printing algorithms and API within [PrettyPrinter][pretty-printer]
192-
and [AwesomePrint][awesome-print], from which I borrowed ideas to develop
193-
the [inspectors][inspection-tree].
206+
* [Diff::LCS][diff-lcs],
207+
the library I started with in the [original version of this gem][original-version]
208+
(made in 2011!)
209+
* The pretty-printing algorithms and API within [PrettyPrinter][pretty-printer] and [AwesomePrint][awesome-print],
210+
from which I borrowed ideas to develop the [inspectors][inspection-tree].
194211

195-
Thank you so much!
212+
Thank you to the authors of these libraries!
196213

197214
[original-version]: https://github.com/mcmire/super_diff/tree/old-master
198215
[diff-lcs]: https://github.com/halostatue/diff-lcs
199216
[pretty-printer]: https://github.com/ruby/ruby/tree/master/lib/prettyprint.rb
200217
[awesome-print]: https://github.com/awesome-print/awesome_print
201218
[inspection-tree]: https://github.com/mcmire/super_diff/blob/master/lib/super_diff/object_inspection/inspection_tree.rb
202219

203-
## Copyright/License
220+
## Author/License
204221

205-
© 2018-2019 Elliot Winkler, released under the [MIT license](LICENSE).
222+
`super_diff` was created and is maintained by Elliot Winkler.
223+
It is released under the [MIT license](LICENSE).

0 commit comments

Comments
 (0)