Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Remove whitespace

  • Loading branch information...
commit 17d2a6de0c795bae8b6deb2f079e5271dd181e22 1 parent bf9d038
Piotr Zolnierek authored
4 examples/validation.rb
@@ -5,7 +5,7 @@ class AgeTooHighError < ArgumentError; end
5 5
6 6 valid_age = ->(age_expr) {
7 7 age = age_expr.to_i
8   - case
  8 + case
9 9 when age <= 0; Failure(AgeTooLowError.new(age_expr))
10 10 when age > 130; Failure(AgeTooHighError.new(age_expr))
11 11 else Success(age)
@@ -13,7 +13,7 @@ class AgeTooHighError < ArgumentError; end
13 13 }
14 14
15 15 valid_name = ->(name) {
16   - case
  16 + case
17 17 when name =~ /\w{3,99}/i; Success(name)
18 18 else Failure('Invalid name')
19 19 end
16 spec/either_spec.rb
@@ -16,7 +16,7 @@
16 16 it 'Failure.new and Failure.unit and Failure() return the same' do
17 17 Failure(1).should == Failure.unit(1)
18 18 Failure.new(1).should == Failure.unit(1)
19   -
  19 +
20 20 Failure(nil).should == Failure.unit(nil)
21 21 Failure.new(nil).should == Failure.unit(nil)
22 22 end
@@ -64,7 +64,7 @@
64 64 class User
65 65 attr :age, :gender, :sobriety
66 66 def self.find(id)
67   - case id
  67 + case id
68 68 when -1; raise 'invalid user id'
69 69 when 0; nil
70 70 else User.new(id)
@@ -149,7 +149,7 @@ def initialize(id)
149 149
150 150 it 'passes the result value from the previous call to the next' do
151 151 either = Success(1).
152   - >= {|prev| Success(prev + 1) }. # a block
  152 + >= {|prev| Success(prev + 1) }. # a block
153 153 >= -> prev { Success(prev + 100) } # lambda/proc
154 154
155 155 either.should == Success(102)
@@ -160,7 +160,7 @@ def initialize(id)
160 160 end
161 161
162 162 it 'allows you to use parameterless lambdas (#arity == 0)' do
163   - (Success(0) >=
  163 + (Success(0) >=
164 164 -> { Success(1) }
165 165 ).should == Success(1)
166 166 end
@@ -198,12 +198,12 @@ def initialize(id)
198 198 end
199 199
200 200 it 'supports Either.chain' do
201   - Either.chain do
  201 + Either.chain do
202 202 bind -> { Success(1) }
203 203 bind -> { Success(2) }
204 204 end.should == Success(2)
205 205
206   - Either.chain do
  206 + Either.chain do
207 207 bind -> { Success(1) }
208 208 bind ->(p) { Success(p + 1) }
209 209 end.should == Success(2)
@@ -215,9 +215,9 @@ def initialize(id)
215 215
216 216 it 'README example' do
217 217 params = { :path => 'foo' }
218   - def load_file(path);
  218 + def load_file(path);
219 219 fail "invalid path" unless path
220   - Success("bar");
  220 + Success("bar");
221 221 end
222 222 def process_content(content); content.start_with?('b') ? Success(content.upcase) : Failure('invalid content'); end
223 223
6 spec/validation_spec.rb
@@ -8,7 +8,7 @@
8 8 def validate(person)
9 9 check_age = ->(age_expr) {
10 10 age = age_expr.to_i
11   - case
  11 + case
12 12 when age <= 0; Failure('Age must be > 0')
13 13 when age > 130; Failure('Age must be < 130')
14 14 else Success(age)
@@ -20,13 +20,13 @@ def validate(person)
20 20 when :sober, :tipsy; Success(sobriety)
21 21 when :drunk ; Failure('No drunks allowed')
22 22 else Failure("Sobriety state '#{sobriety}' is not allowed")
23   - end
  23 + end
24 24 }
25 25
26 26 check_gender = ->(gender) {
27 27 gender == :male || gender == :female ? Success(gender) : Failure("Invalid gender #{gender}")
28 28 }
29   -
  29 +
30 30 Validation() do
31 31 check { check_age.(person.age); }
32 32 check { check_sobriety.(person.sobriety) }

0 comments on commit 17d2a6d

Please sign in to comment.
Something went wrong with that request. Please try again.