reactive_support 0.2.2.beta2 → 0.3.0.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1df366e9c83f6723e0fc634eb0028ba690051bbf
4
- data.tar.gz: fa71805317d8b4051f47a051d20e47443587580f
3
+ metadata.gz: 4e03c0b062f28792315df4ddeb261e6084d93495
4
+ data.tar.gz: 022f699675dcb56d66c9f1fd5f1c65b900d1edd2
5
5
  SHA512:
6
- metadata.gz: 0fde4b90121f00b053c5d64f694ab8e97ddc317ad2e45852c8745d9ab29a5403cb7dd0abf26f329ac656ebfd9b419bc8cdb1780e0daa52612075c06362cebe97
7
- data.tar.gz: 375a135b61ec7a6a6ea0547f92cecdff893e329b6a19215996dca4c7edf0594fae40887423b58be7498655d4b5f8ab448759974832771ff98373805621ade20b
6
+ metadata.gz: 00f6717977c36891e7df8f75f3935e9d9c0baf91618dea25415e6f8adf486168fc7ab678527b9cc6137df02358ff919bfbd40167bd2c595a00535611f7174e50
7
+ data.tar.gz: e0db1dcf183d452823e6bffb71ab33322f92c42f21882fb3ebd90c3ba9e115d51651ae7d7eb4ebd38deaa9a7447957b2ad5008d4f0f03ada7940302b8b9335ef
@@ -2,10 +2,10 @@
2
2
  # The +#blank?+ method returns +true+ if the object is undefined, blank, false,
3
3
  # empty, or nil. The +#present?+ method returns the opposite of +#blank?+
4
4
 
5
- # Ruby's core String class. See documentation for version
6
- # 2.1.3[http://ruby-doc.org/core-2.1.3/String.html],
7
- # 2.0.0[http://ruby-doc.org/core-2.1.3/String.html], or
8
- # 1.9.3[http://ruby-doc.org/core-2.0.0/String.html].
5
+ # Ruby's core Object class. See documentation for version
6
+ # 2.1.5[http://ruby-doc.org/core-2.1.5/Object.html],
7
+ # 2.0.0[http://ruby-doc.org/core-2.0.0/Object.html], or
8
+ # 1.9.3[http://ruby-doc.org/core-1.9.3/Object.html].
9
9
 
10
10
  class Object
11
11
 
@@ -30,6 +30,11 @@ class Object
30
30
  end
31
31
  end
32
32
 
33
+ # Ruby's core String class. See documentation for version
34
+ # 2.1.5[http://ruby-doc.org/core-2.1.5/String.html],
35
+ # 2.0.0[http://ruby-doc.org/core-2.0.0/String.html], or
36
+ # 1.9.3[http://ruby-doc.org/core-1.9.3/String.html].
37
+
33
38
  class String
34
39
 
35
40
  # When called on a string, the +#blank?+ method returns +true+ if the string
@@ -54,9 +59,9 @@ class String
54
59
  end
55
60
 
56
61
  # Ruby's core Array class. See documentation for version
57
- # 2.1.3[http://ruby-doc.org/core-2.1.3/FalseClass.html],
58
- # 2.0.0[http://ruby-doc.org/core-2.0.0/FalseClass.html], or
59
- # 1.9.3[http://ruby-doc.org/core-1.9.3/FalseClass.html].
62
+ # 2.1.5[http://ruby-doc.org/core-2.1.3/Array.html],
63
+ # 2.0.0[http://ruby-doc.org/core-2.0.0/Array.html], or
64
+ # 1.9.3[http://ruby-doc.org/core-1.9.3/Array.html].
60
65
 
61
66
  class Array
62
67
 
@@ -82,7 +87,7 @@ class Array
82
87
  end
83
88
 
84
89
  # Ruby's core Hash class. See documentation for version
85
- # 2.1.3[http://ruby-doc.org/core-2.1.3/Hash.html],
90
+ # 2.1.5[http://ruby-doc.org/core-2.1.5/Hash.html],
86
91
  # 2.0.0[http://ruby-doc.org/core-2.0.0/Hash.html], or
87
92
  # 1.9.3[http://ruby-doc.org/core-1.9.3/Hash.html].
88
93
 
@@ -108,7 +113,7 @@ class Hash
108
113
  end
109
114
 
110
115
  # Ruby's core NilClass (the singleton class consisting of the +nil+ object).
111
- # See documentation for version 2.1.3[http://ruby-doc.org/core-2.1.3/NilClass.html],
116
+ # See documentation for version 2.1.5[http://ruby-doc.org/core-2.1.5/NilClass.html],
112
117
  # 2.0.0[http://ruby-doc.org/core-2.0.0/NilClass.html], or
113
118
  # 1.9.3[http://ruby-doc.org/core-1.9.3/NilClass.html].
114
119
 
@@ -138,7 +143,7 @@ class NilClass
138
143
  end
139
144
 
140
145
  # Ruby's core TrueClass (the singleton class consisting of the +true+ object).
141
- # See documentation for version 2.1.3[http://ruby-doc.org/core-2.1.3/TrueClass.html],
146
+ # See documentation for version 2.1.5[http://ruby-doc.org/core-2.1.5/TrueClass.html],
142
147
  # 2.0.0[http://ruby-doc.org/core-2.0.0/TrueClass.html], or
143
148
  # 1.9.3[http://ruby-doc.org/core-1.9.3/TrueClass.html].
144
149
 
@@ -162,7 +167,7 @@ class TrueClass
162
167
  end
163
168
 
164
169
  # Ruby's core FalseClass (the singleton class consisting of the +false+ object).
165
- # See documentation for version 2.1.3[http://ruby-doc.org/core-2.1.3/FalseClass.html],
170
+ # See documentation for version 2.1.5[http://ruby-doc.org/core-2.1.5/FalseClass.html],
166
171
  # 2.0.0[http://ruby-doc.org/core-2.0.0/FalseClass.html], or
167
172
  # 1.9.3[http://ruby-doc.org/core-1.9.3/FalseClass.html].
168
173
 
@@ -186,7 +191,7 @@ class FalseClass
186
191
  end
187
192
 
188
193
  # Ruby's core Numeric class, the parent class of Integer, Fixnum, Bignum, Float,
189
- # and Rational. See documentation for version 2.1.3[http://ruby-doc.org/core-2.1.3/Numeric.html],
194
+ # and Rational. See documentation for version 2.1.5[http://ruby-doc.org/core-2.1.5/Numeric.html],
190
195
  # 2.0.0[http://ruby-doc.org/core-2.0.0/Numeric.html], or
191
196
  # 1.9.3[http://ruby-doc.org/core-1.9.3/Numeric.html].
192
197
 
@@ -0,0 +1,29 @@
1
+ # Ruby's core Proc class. See documentation for version
2
+ # 2.1.5[http://ruby-doc.org/core-2.1.5/Proc.html],
3
+ # 2.0.0[http://ruby-doc.org/core-2.0.0/Proc.html], or
4
+ # 1.9.3[http://ruby-doc.org/core-1.9.3/Proc.html].
5
+
6
+ class Proc
7
+
8
+ # The +#raises_error?+ method checks whether an exception is raised
9
+ # when the calling Proc is called with the given +*args+.
10
+ #
11
+ # The +#raises_error?+ method does not actually create lasting changes
12
+ # to objects or variables; it only checks whether an exception would be
13
+ # raised if the Proc were called with the given +*args+.
14
+ #
15
+ # Basic examples:
16
+ # proc = Proc.new {|q| 1.quo(q) }
17
+ # proc.raises_error?(2) # => false
18
+ # proc.raises_error?(0) # => true
19
+ #
20
+ # Examples with destructive proc:
21
+ # hash = {:foo => :bar}
22
+ # proc = Proc.new {|hash| hash.reject! {|k,v| k === :foo } }
23
+ # proc.raises_error?(hash) # => false
24
+ # hash # => {:foo => :bar}
25
+
26
+ def raises_error?(*args)
27
+ (!self.call(*args.deep_dup)) rescue true
28
+ end
29
+ end
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
 
9
9
  s.name = 'reactive_support'
10
10
  s.version = ReactiveSupport.gem_version
11
- s.date = '2014-11-17'
11
+ s.date = '2014-11-25'
12
12
 
13
13
  s.description = "ActiveSupport methods re-implemented independently of the Rails ecosystem"
14
14
  s.summary = "ReactiveSupport provides useful ActiveSupport methods in a gem that is simple, stable, agnostic, and transparent."
@@ -138,4 +138,31 @@ describe ReactiveExtensions do
138
138
  end
139
139
  end
140
140
  end
141
+
142
+ describe 'proc methods' do
143
+ describe 'raises_error?' do
144
+ let(:proc) { Proc.new {|quotient| 1.quo(quotient) } }
145
+
146
+ context 'when an error is raised' do
147
+ it 'returns true' do
148
+ expect(proc.raises_error?(0)).to be true
149
+ end
150
+
151
+ it 'handles the exception' do
152
+ expect{ proc.raises_error?(0) }.not_to raise_error
153
+ end
154
+ end
155
+
156
+ context 'when no error is raised' do
157
+ it 'returns false' do
158
+ expect(proc.raises_error?(2)).to be false
159
+ end
160
+
161
+ it 'doesn\'t change objects' do
162
+ h, p = {:foo => :bar}, Proc.new {|hash| hash.reject! {|k,v| k === :foo } }
163
+ expect{ p.raises_error?(h) }.not_to change(h, :length)
164
+ end
165
+ end
166
+ end
167
+ end
141
168
  end
data/version.rb CHANGED
@@ -5,9 +5,9 @@ module ReactiveSupport
5
5
 
6
6
  module Version
7
7
  MAJOR = '0'
8
- MINOR = '2'
9
- PATCH = '2'
10
- PRE = 'beta2'
8
+ MINOR = '3'
9
+ PATCH = '0'
10
+ PRE = 'beta'
11
11
 
12
12
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.').chomp('.')
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reactive_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2.beta2
4
+ version: 0.3.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dana Scheider
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-17 00:00:00.000000000 Z
11
+ date: 2014-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -86,6 +86,7 @@ files:
86
86
  - "./lib/reactive_support/core_ext/object/try.rb"
87
87
  - "./lib/reactive_support/extensions/array_extensions.rb"
88
88
  - "./lib/reactive_support/extensions/hash_extensions.rb"
89
+ - "./lib/reactive_support/extensions/proc_extensions.rb"
89
90
  - "./lib/reactive_support/extensions/reactive_extensions.rb"
90
91
  - "./spec/array_spec.rb"
91
92
  - "./spec/reactive_extensions_spec.rb"
@@ -122,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
123
  version: 1.3.1
123
124
  requirements: []
124
125
  rubyforge_project:
125
- rubygems_version: 2.2.2
126
+ rubygems_version: 2.4.3
126
127
  signing_key:
127
128
  specification_version: 1
128
129
  summary: ReactiveSupport provides useful ActiveSupport methods in a gem that is simple,