endeavour 0.0.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +37 -6
  3. data/lib/endeavour/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a247511ed96daa25a143673af303f47e6dad0d9
4
- data.tar.gz: 7e14681ad51366c31fbef445faa738dccbbf5c4d
3
+ metadata.gz: 9efb61a646f24ddb802b9fe4b472fee135780745
4
+ data.tar.gz: 944e69df23747c928288cf0c09d84838b0be2043
5
5
  SHA512:
6
- metadata.gz: a09dc4bb8a15575009bd387b129cb95ef8fe1cf45e8aa289e33d59392b3c697666edd86e803dd1b52bce93ce6777c4b4a2be64e46f2cb9459ec31bf15f9d2043
7
- data.tar.gz: d6e94953bb2b226499fcd415787e08dde684c79a896be482d80b3a6a56524e2fa4adaa74405c5b9845458e5bb90da6132f3b13c3ddd64522262bf256dd03ade5
6
+ metadata.gz: e8da32b5f6bb5a501524643683808f1fac116bbba09d55fb56a10f9c1a36a250e9caa54bf786624f2badaeea2a472b8ea2885daeafceff67d78ba7493a83d9ca
7
+ data.tar.gz: 807220a7c68ac07de4b0b47928d02fcf6c79b16dcbe629a10fc84da5ad73df59b9684f189f9b0a0fdc288f6ddf1477efc6f90596963f8f17345051a4ae9dc048
data/README.md CHANGED
@@ -1,6 +1,29 @@
1
1
  # Endeavour
2
2
 
3
- [Try](http://api.rubyonrails.org/classes/Object.html#method-i-try), but better.
3
+ Endeavour is a simple gem that adds a `try` method to `Object` and `NilClass`
4
+ instances. `try` permits calling a method on an object and returning `nil`
5
+ rather than `NoMethodError` if the object is `nil` or does not respond to
6
+ the method.
7
+
8
+ ## Usage
9
+
10
+ There are two ways to use `try`:
11
+
12
+ ### 1. Call-based syntax (similar to Rails' [Object#try](http://api.rubyonrails.org/classes/Object.html#method-i-try))
13
+
14
+ ```ruby
15
+ car.try(:drive)
16
+
17
+ colors.try(:[], :red)
18
+ ```
19
+
20
+ ### 1. Delegate syntax (inspired by [HoboSupport](http://www.hobocentral.net/manual/hobo_support))
21
+
22
+ ```ruby
23
+ car.try.drive
24
+
25
+ colors.try[:red]
26
+ ```
4
27
 
5
28
  ## Installation
6
29
 
@@ -18,12 +41,20 @@ Or install it yourself as:
18
41
 
19
42
  $ gem install endeavour
20
43
 
21
- ## Usage
44
+ ### Rails applications
22
45
 
23
- ```ruby
24
- car = nil
25
- car.try.drive # => nil
26
- ```
46
+ Endeavour uses a
47
+ [Railtie](http://api.rubyonrails.org/classes/Rails/Railtie.html) and can be
48
+ used after initialization without additional configuration.
49
+
50
+ ### Non-Rails applications
51
+
52
+ Call `Endeavour.hook!` early in your application.
53
+
54
+ ### Remove Endeavour
55
+
56
+ In some cases, you may want to remove Endeavour (say, if a naughty gem requires
57
+ it). You can do so with `Endeavour.remove_hook!`
27
58
 
28
59
  ## Contributing
29
60
 
@@ -1,3 +1,3 @@
1
1
  class Endeavour
2
- VERSION = '0.0.4'
2
+ VERSION = '1.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: endeavour
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cory Kaufman-Schofield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-20 00:00:00.000000000 Z
11
+ date: 2016-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest-reporters