augmented 0.2.0 → 0.2.5

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 (34) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +11 -0
  3. data/README.md +132 -28
  4. data/augmented.gemspec +14 -8
  5. data/lib/augmented.rb +4 -0
  6. data/lib/augmented/arrays/tieable.rb +1 -1
  7. data/lib/augmented/enumerators/indexing.rb +3 -1
  8. data/lib/augmented/exceptions.rb +11 -0
  9. data/lib/augmented/exceptions/chain.rb +16 -0
  10. data/lib/augmented/exceptions/detailed.rb +22 -0
  11. data/lib/augmented/exceptions/serializable.rb +25 -0
  12. data/lib/augmented/objects/pickable.rb +2 -2
  13. data/lib/augmented/procs.rb +2 -2
  14. data/lib/augmented/procs/rescuable.rb +3 -3
  15. data/lib/augmented/strings.rb +9 -0
  16. data/lib/augmented/strings/blank.rb +15 -0
  17. data/lib/augmented/strings/truncatable.rb +20 -0
  18. data/lib/augmented/version.rb +1 -1
  19. metadata +26 -47
  20. data/test/augmented/arrays/tieable_test.rb +0 -66
  21. data/test/augmented/enumerators/indexing_test.rb +0 -15
  22. data/test/augmented/hashes/mappable_test.rb +0 -37
  23. data/test/augmented/hashes/polymorphable_test.rb +0 -45
  24. data/test/augmented/hashes/transformable_test.rb +0 -87
  25. data/test/augmented/modules/refined_test.rb +0 -27
  26. data/test/augmented/objects/iffy_test.rb +0 -69
  27. data/test/augmented/objects/pickable_test.rb +0 -39
  28. data/test/augmented/objects/tackable_test.rb +0 -25
  29. data/test/augmented/objects/tappable_test.rb +0 -141
  30. data/test/augmented/objects/thru_test.rb +0 -98
  31. data/test/augmented/procs/chainable_test.rb +0 -22
  32. data/test/augmented/procs/rescuable_test.rb +0 -38
  33. data/test/augmented/symbols/arguable_test.rb +0 -51
  34. data/test/augmented/symbols/comparing_test.rb +0 -131
@@ -1,51 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'augmented/symbols/arguable'
3
-
4
- describe Augmented::Symbols::Arguable do
5
- using Augmented::Symbols::Arguable
6
-
7
- describe '#with' do
8
-
9
- before do
10
- @eleven = Class.new do
11
- def add other_number
12
- 11 + other_number
13
- end
14
-
15
- def add_many one_number, another_number, *many_numbers
16
- 11 + one_number + another_number + many_numbers.reduce(0, :+)
17
- end
18
-
19
- def do_whatever
20
- yield 11
21
- end
22
- end.new
23
- end
24
-
25
- it 'returns a function that calls the method named <symbol> while also passing the arguments supplied' do
26
- :add.with(9).call(@eleven).must_equal 20
27
- :add_many.with(3, 6, 10, 20, 50).call(@eleven).must_equal 100
28
- end
29
-
30
- describe 'the returned function' do
31
-
32
- it "it preserves Symbol's `to_proc` behavior of passing extra arguments, if supplied" do
33
- :add.to_proc.call(@eleven, 4).must_equal 15
34
- :add.with().call(@eleven, 4).must_equal 15
35
-
36
- :add_many.with(10, 20).call(@eleven, 4, 5).must_equal 50
37
- end
38
-
39
- it 'passes along the block supplied to `with`, if any' do
40
- result = nil
41
- set_result = -> i { result = i }
42
-
43
- :do_whatever.with(&set_result).call(@eleven)
44
-
45
- result.must_equal 11
46
- end
47
-
48
- end
49
-
50
- end
51
- end
@@ -1,131 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'augmented/symbols/comparing'
3
-
4
- describe Augmented::Symbols::Comparing do
5
- using Augmented::Symbols::Comparing
6
-
7
- let(:dummy) { Struct.new :lorem_ipsum }
8
-
9
- let(:thing_A) { dummy.new 123 }
10
- let(:thing_B) { dummy.new 123 }
11
- let(:thing_C) { dummy.new 987 }
12
- let(:thing_D) { dummy.new 0 }
13
-
14
- describe '#eq' do
15
-
16
- it 'returns a function that sends <symbol> to two objects and compares the results with `==`' do
17
- comparator = :lorem_ipsum.eq
18
-
19
- comparator.call(thing_A, thing_B).must_equal true
20
- comparator.call(thing_A, thing_C).must_equal false
21
- end
22
-
23
- it 'if you give it a value, it returns a function that sends <symbol> to an object and compares the result to a given value using `==`' do
24
- comparator = :lorem_ipsum.eq(123)
25
-
26
- comparator.call(thing_A).must_equal true
27
- comparator.call(thing_C).must_equal false
28
- end
29
-
30
- end
31
-
32
- describe '#neq' do
33
-
34
- it 'returns a function that sends <symbol> to two objects and compares the results with `!=`' do
35
- comparator = :lorem_ipsum.neq
36
-
37
- comparator.call(thing_A, thing_B).must_equal false
38
- comparator.call(thing_A, thing_C).must_equal true
39
- end
40
-
41
- it 'if you give it a value, it returns a function that sends <symbol> to an object and compares the result to a given value using `!=`' do
42
- comparator = :lorem_ipsum.neq(123)
43
-
44
- comparator.call(thing_A).must_equal false
45
- comparator.call(thing_C).must_equal true
46
- end
47
-
48
- end
49
-
50
- describe '#lt' do
51
-
52
- it 'returns a function that sends <symbol> to two objects and compares the results with `<`' do
53
- comparator = :lorem_ipsum.lt
54
-
55
- comparator.call(thing_A, thing_B).must_equal false
56
- comparator.call(thing_A, thing_C).must_equal true
57
- comparator.call(thing_C, thing_B).must_equal false
58
- end
59
-
60
- it 'if you give it a value, it returns a function that sends <symbol> to an object and compares the result to a given value using `<`' do
61
- comparator = :lorem_ipsum.lt(123)
62
-
63
- comparator.call(thing_A).must_equal false
64
- comparator.call(thing_C).must_equal false
65
- comparator.call(thing_D).must_equal true
66
- end
67
-
68
- end
69
-
70
- describe '#lte' do
71
-
72
- it 'returns a function that sends <symbol> to two objects and compares the results with `<=`' do
73
- comparator = :lorem_ipsum.lte
74
-
75
- comparator.call(thing_A, thing_B).must_equal true
76
- comparator.call(thing_A, thing_C).must_equal true
77
- comparator.call(thing_C, thing_B).must_equal false
78
- end
79
-
80
- it 'if you give it a value, it returns a function that sends <symbol> to an object and compares the result to a given value using `<=`' do
81
- comparator = :lorem_ipsum.lte(123)
82
-
83
- comparator.call(thing_A).must_equal true
84
- comparator.call(thing_C).must_equal false
85
- comparator.call(thing_D).must_equal true
86
- end
87
-
88
- end
89
-
90
- describe '#gt' do
91
-
92
- it 'returns a function that sends <symbol> to two objects and compares the results with `>`' do
93
- comparator = :lorem_ipsum.gt
94
-
95
- comparator.call(thing_A, thing_B).must_equal false
96
- comparator.call(thing_A, thing_C).must_equal false
97
- comparator.call(thing_C, thing_B).must_equal true
98
- end
99
-
100
- it 'if you give it a value, it returns a function that sends <symbol> to an object and compares the result to a given value using `>`' do
101
- comparator = :lorem_ipsum.gt(123)
102
-
103
- comparator.call(thing_A).must_equal false
104
- comparator.call(thing_C).must_equal true
105
- comparator.call(thing_D).must_equal false
106
- end
107
-
108
- end
109
-
110
- describe '#gte' do
111
-
112
- it 'returns a function that sends <symbol> to two objects and compares the results with `>=`' do
113
- comparator = :lorem_ipsum.gte
114
-
115
- comparator.call(thing_A, thing_B).must_equal true
116
- comparator.call(thing_A, thing_C).must_equal false
117
- comparator.call(thing_C, thing_B).must_equal true
118
- end
119
-
120
- it 'if you give it a value, it returns a function that sends <symbol> to an object and compares the result to a given value using `>=`' do
121
- comparator = :lorem_ipsum.gte(123)
122
-
123
- comparator.call(thing_A).must_equal true
124
- comparator.call(thing_C).must_equal true
125
- comparator.call(thing_D).must_equal false
126
- end
127
-
128
- end
129
-
130
-
131
- end