proc_extensions 0.1.0 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64b24b11314915d666312d064d8b407a806d1d52
4
- data.tar.gz: 8967295d202dd6760653a67212a693835a83f852
3
+ metadata.gz: b1d08b432029ecd32d639aeb12f69d4c86913d64
4
+ data.tar.gz: 049b0d3f0810adb03e1f9efd89556650496b7091
5
5
  SHA512:
6
- metadata.gz: 21327da9034eb81da77ba3a00834337707d70c5a8037c2e65dc53f3354aa2c624c4c814a3290123dbfbdafc9a8281265e68238afccdea1878f1e72317a836fe8
7
- data.tar.gz: 3d19d0258e4555b5de0ea378b8dd6319a8f365ff79431ce1c70e93c4624928a72ba00cd45a276294e00ddcecb6ad02fd276d1047e5bcef77e79d93f2976f59b6
6
+ metadata.gz: 0d36bc11bd7a296072c3686aec1f28669bd85d0e74c8019a89b8cd3f158fc3483e6b01ef79b9d5e0caba342809e7a838996dcfe98d0a84d9f2acc295fef3cd5c
7
+ data.tar.gz: fa298f13ac6d57f9f03fb65d89b99de0c9400c6d3878d2e596c69bf054e518634ac65de8eba173da43f7cddd7c0cbd74ebb7a3b62716c58c40ffcc04c89f1c9f
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
- - 2.0.0
4
+ - 2.0
5
5
  - 2.1
6
6
  - 2.2
7
7
  before_install: gem install bundler -v 1.10.6
data/README.md CHANGED
@@ -31,11 +31,27 @@ ps1 == ps2 # => false
31
31
  ps1.match ps2 # => true
32
32
  ```
33
33
 
34
+ You can create a `ProcSource` with no proc or with a `nil` proc and it will simply provide an empty string for `source`
35
+ `raw_source`, `to_s` and `inspect`. And two `ProcSource` objects created like this will be considered equal.
36
+
37
+ ```ruby
38
+ ps1 = ProcSource.new
39
+ ps2 = ProcSource.new nil
40
+
41
+ ps1.source # => ""
42
+ ps1.raw_source # => ""
43
+ ps1.to_s # => ""
44
+ ps1.inspect # => ""
45
+
46
+ ps1 == ps2 # => true
47
+ ps1.match ps2 # => true
48
+ ```
49
+
34
50
  # Proc Extensions
35
51
 
36
52
  Extensions to Proc support source extraction and comparison.
37
53
 
38
- Optionsally methods can be added to the `Proc` class:
54
+ Optionally methods can be added to the `Proc` class:
39
55
  * `inspect`: returns source code if it can be extracted
40
56
  * `source`, `raw_source`: returns source code
41
57
  * `==`: determines if two procs have exactly the same source code
@@ -87,6 +87,7 @@ class ProcSource
87
87
  end
88
88
 
89
89
  def extract_source(method)
90
+ return '' unless proc
90
91
  proc_source = proc.public_send(method)
91
92
  lambda? ? proc_source.sub('proc ', 'lambda ') : proc_source
92
93
  end
@@ -1,3 +1,3 @@
1
1
  module ProcExtensions
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proc_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Declan Whelan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-25 00:00:00.000000000 Z
11
+ date: 2015-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sourcify
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  version: '0'
210
210
  requirements: []
211
211
  rubyforge_project:
212
- rubygems_version: 2.4.6
212
+ rubygems_version: 2.4.5.1
213
213
  signing_key:
214
214
  specification_version: 4
215
215
  summary: Extensions to the Proc class to support source extraction and comparison.