@@ -155,34 +155,47 @@ require "super_diff/rspec"
155
155
156
156
## Configuration
157
157
158
- ### Custom colors
158
+ You can customize the behavior of the gem
159
+ by adding a configuration block
160
+ to your test helper file
161
+ (` rails_helper ` or ` spec_helper ` )
162
+ which looks something like this:
159
163
160
- If you want to use something other than the default colors, you can
161
- configure them by adding them to your test helper file
162
- (` rails_helper ` or ` spec_helper ` ):
164
+ ``` ruby
165
+ SuperDiff .configure do |config |
166
+ # ...
167
+ end
168
+ ```
169
+
170
+ ### Customizing colors
171
+
172
+ If you don't like the colors that SuperDiff uses,
173
+ you can change them like this:
163
174
164
175
``` ruby
165
176
SuperDiff .configure do |config |
166
- config.set_actual_color( :green )
167
- config.set_expected_color( :red )
168
- config.set_border_color( :yellow )
169
- config.set_header_color( :yellow )
177
+ config.actual_color = :green
178
+ config.expected_color = :red
179
+ config.border_color = :yellow
180
+ config.header_color = :yellow
170
181
end
171
182
```
172
183
173
- See [ eight_bit_color.rb] ( lib/super_diff/csi/eight_bit_color.rb ) for the list
174
- of available colors.
184
+ See [ eight_bit_color.rb] ( lib/super_diff/csi/eight_bit_color.rb )
185
+ for the list of available colors.
175
186
176
187
### Diffing custom objects
177
188
178
- As capable as this library is,
179
- it doesn't know how to deal with every kind of object out there.
180
- If you have a custom class,
181
- and instances of your class aren't appearing in diffs like you like,
182
- you might find it necessary to instruct the gem on how to handle them.
183
- In that case
184
- you would add something like this to your test helper file
185
- (` rails_helper ` or ` spec_helper ` ):
189
+ If you are comparing two data structures
190
+ that involve a class that is specific to your project,
191
+ the resulting diff may not look as good as diffs involving native or primitive objects.
192
+ This happens because if SuperDiff doesn't recognize a class,
193
+ it will fall back to a generic representation when diffing instances of that class.
194
+ Fortunately, the gem has a pluggable interface
195
+ that allows you to insert your own implementations
196
+ of key pieces involved in the diffing process.
197
+ I'll have more about how that works soon,
198
+ but here is what such a configuration would look like:
186
199
187
200
``` ruby
188
201
SuperDiff .configure do |config |
@@ -193,12 +206,6 @@ SuperDiff.configure do |config|
193
206
end
194
207
```
195
208
196
- * (More info here in the future on adding a custom differ,
197
- operation tree builder,
198
- operation tree,
199
- and diff formatter.
200
- Also explanations on what these are.)*
201
-
202
209
## Support
203
210
204
211
My goal for this library is to improve your development experience.
@@ -252,5 +259,5 @@ Thank you to the authors of these libraries!
252
259
253
260
## Author/License
254
261
255
- ` super_diff ` was created and is maintained by Elliot Winkler.
262
+ SuperDiff was created and is maintained by Elliot Winkler.
256
263
It is released under the [ MIT license] ( LICENSE ) .
0 commit comments