totally_lazy 0.0.15 → 0.0.16

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: 76f6d260b177c8aa5b64578b0091377494ce839b
4
- data.tar.gz: 312fa25893fa88b9d4cdc32222da221c57151e1d
3
+ metadata.gz: 359852636f3453d43e493fb7294d4ff1aae3c290
4
+ data.tar.gz: e90a9cb5312f5bb6f96233ba6b7ede106a265ef6
5
5
  SHA512:
6
- metadata.gz: b70457704551cdc3892eb34f9a02fb089d5fa4c0f39e2d5f10705536db1cf03f3bd2a080b52e31ef02ab9d2413342764a61fba413da77fdb86cee6b7de2e4370
7
- data.tar.gz: 518b3ef257b1825686154c90e6a541ef207012fba8443b2fd18b42805c3be849891aba64924a885126a388b47c343cc565b268dd2a7932053696882c568b217f
6
+ metadata.gz: dc8fa64092c0487056ab2074188daffcb1ebe44da6554cc18a65f12c8efb0c95f5f200e08cb7d9dde54b526c3711ff2c5b01a3067d5a6cf2a218c298c00e7399
7
+ data.tar.gz: 788d696acf110d53defb2095567e7d2a78121111e1d817ba2c4d7cf12803fdf454d4564970c42506497416aa1017614a3824d80e3b0dafa1e2403e8f37534e2e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.15
1
+ 0.0.16
data/lib/option.rb CHANGED
@@ -85,49 +85,49 @@ module Option
85
85
 
86
86
  def each(&block)
87
87
  @content.each(&block)
88
- end
88
+ end
89
89
 
90
90
  def map(predicate=nil, &block)
91
- sequence(@content).map(predicate, &block)
91
+ as_option(sequence(@content).map(predicate, &block))
92
92
  end
93
93
 
94
94
  alias collect map
95
95
 
96
96
  def select(predicate=nil, &block)
97
- sequence(@content).select(predicate, &block)
97
+ as_option(sequence(@content).select(predicate, &block))
98
98
  end
99
99
 
100
100
  alias find_all select
101
101
  alias filter select
102
102
 
103
103
  def reject(predicate=nil, &block)
104
- sequence(@content).reject(predicate, &block)
104
+ as_option(sequence(@content).reject(predicate, &block))
105
105
  end
106
106
 
107
107
  alias unfilter reject
108
108
 
109
109
  def grep(pattern)
110
- sequence(@content).grep(pattern)
110
+ as_option(sequence(@content).grep(pattern))
111
111
  end
112
112
 
113
113
  def drop(n)
114
- sequence(@content).drop(n)
114
+ as_option(sequence(@content).drop(n))
115
115
  end
116
116
 
117
117
  def drop_while(&block)
118
- @content.drop_while(&block)
118
+ as_option(@content.drop_while(&block))
119
119
  end
120
120
 
121
121
  def take(n)
122
- sequence(@content).take(n)
122
+ as_option(sequence(@content).take(n))
123
123
  end
124
124
 
125
125
  def take_while(&block)
126
- sequence(@content).take_while(&block)
126
+ as_option(@content.take_while(&block))
127
127
  end
128
128
 
129
129
  def flat_map(&block)
130
- sequence(@content).flat_map(&block)
130
+ as_option(sequence(@content).flat_map(&block))
131
131
  end
132
132
 
133
133
  alias collect_concat flat_map
@@ -233,46 +233,46 @@ module Option
233
233
  alias << join
234
234
 
235
235
  def map(predicate=nil, &block)
236
- empty
236
+ none
237
237
  end
238
238
 
239
239
  alias collect map
240
240
 
241
241
  def select(predicate=nil, &block)
242
- empty
242
+ none
243
243
  end
244
244
 
245
245
  alias find_all select
246
246
  alias filter select
247
247
 
248
248
  def reject(predicate=nil, &block)
249
- empty
249
+ none
250
250
  end
251
251
 
252
252
  alias unfilter reject
253
253
 
254
254
  def grep(pattern)
255
- empty
255
+ none
256
256
  end
257
257
 
258
258
  def drop(n)
259
- empty
259
+ none
260
260
  end
261
261
 
262
262
  def drop_while(&block)
263
- empty
263
+ none
264
264
  end
265
265
 
266
266
  def take(n)
267
- empty
267
+ none
268
268
  end
269
269
 
270
270
  def take_while(&block)
271
- empty
271
+ none
272
272
  end
273
273
 
274
274
  def flat_map(&block)
275
- empty
275
+ none
276
276
  end
277
277
 
278
278
  alias collect_concat flat_map
data/spec/option_spec.rb CHANGED
@@ -64,7 +64,7 @@ describe 'Option' do
64
64
  end
65
65
 
66
66
  it 'should convert to sequence' do
67
- expect(option(1).to_seq.to_a).to eq(sequence(1).to_a)
67
+ expect(option(1).to_seq).to eq(sequence(1))
68
68
  expect(none.to_seq).to eq(empty)
69
69
  end
70
70
 
@@ -127,57 +127,58 @@ describe 'Option' do
127
127
  end
128
128
 
129
129
  it 'should support select' do
130
- expect(option(2).filter(even)).to eq(sequence(2))
131
- expect(option(2).find_all(even)).to eq(sequence(2))
132
- expect(option(2).select(even)).to eq(sequence(2))
133
- expect(option(2).filter(&:even?)).to eq(sequence(2))
134
- expect(option(2).filter{|v| v == 2}).to eq(sequence(2))
135
- expect(option(nil).filter(even)).to eq(empty)
130
+ expect(option(2).filter(even)).to eq(some(2))
131
+ expect(option(2).find_all(even)).to eq(some(2))
132
+ expect(option(2).select(even)).to eq(some(2))
133
+ expect(option(2).filter(&:even?)).to eq(some(2))
134
+ expect(option(2).filter{|v| v == 2}).to eq(some(2))
135
+ expect(option(nil).filter(even)).to eq(none)
136
136
  end
137
137
 
138
138
  it 'should support map' do
139
- expect(option([{apple:1,pear:2},{melon:3}]).map{|h| h}).to eq([{apple:1,pear:2},{melon:3}])
140
- expect(option(1).map(as_string)).to eq(sequence('1'))
141
- expect(option(1).collect(as_string)).to eq(sequence('1'))
142
- expect(option(sequence(1, 2, 3)).map { |s| s.entries }.to_a).to eq([[1, 2, 3]])
143
- expect(option(1).map{|v| v+1}).to eq(sequence(2))
144
- expect(option(nil).map(as_string)).to eq(empty)
139
+ expect(option([{apple:1,pear:2},{melon:3}]).map{|h| h}).to eq(some([{apple:1,pear:2},{melon:3}]))
140
+ expect(option({apple:1,pear:2})).to eq(some({apple:1,pear:2}))
141
+ expect(option(1).map(as_string)).to eq(some('1'))
142
+ expect(option(1).collect(as_string)).to eq(some('1'))
143
+ expect(option(sequence(1, 2, 3)).map { |s| s.entries }).to eq(some([1, 2, 3]))
144
+ expect(option(nil).map(as_string)).to eq(none)
145
145
  end
146
146
 
147
147
  it 'should support reject' do
148
- expect(option(2).reject(odd)).to eq(sequence(2))
149
- expect(option(2).unfilter(odd)).to eq(sequence(2))
150
- expect(option(2).reject(&:odd?)).to eq(sequence(2))
151
- expect(option(2).reject{|v| v == 1}).to eq(sequence(2))
152
- expect(option(nil).reject(odd)).to eq(empty)
148
+ expect(option(2).reject(odd)).to eq(some(2))
149
+ expect(option(2).unfilter(odd)).to eq(some(2))
150
+ expect(option(2).reject(&:odd?)).to eq(some(2))
151
+ expect(option(2).reject{|v| v == 1}).to eq(some(2))
152
+ expect(option(nil).reject(odd)).to eq(none)
153
153
  end
154
154
 
155
155
  it 'should support grep' do
156
- expect(option('apple').grep(/p/)).to eq(sequence('apple'))
157
- expect(option(nil).grep(/p/)).to eq(empty)
156
+ expect(option('apple').grep(/p/)).to eq(some('apple'))
157
+ expect(option(nil).grep(/p/)).to eq(none)
158
158
  end
159
159
 
160
160
  it 'should support drop' do
161
- expect(option(1).drop(1)).to eq(empty)
162
- expect(option(nil).drop(1)).to eq(empty)
161
+ expect(option(1).drop(1)).to eq(none)
162
+ expect(option(nil).drop(1)).to eq(none)
163
163
  end
164
164
 
165
165
  it 'should support drop_while' do
166
- expect(option(sequence(1,7)).drop_while { |n| n < 5 }).to eq(sequence(7))
167
- expect(option(nil).drop_while { |n| n < 5 }).to eq(empty)
166
+ expect(option(sequence(1,7)).drop_while { |n| n < 5 }).to eq(some(1))
167
+ expect(option(nil).drop_while { |n| n < 5 }).to eq(none)
168
168
  end
169
169
 
170
170
  it 'should support take' do
171
- expect(option(1).take(2)).to eq(sequence(1))
172
- expect(option(nil).take(2)).to eq(empty)
171
+ expect(option(1).take(2)).to eq(some(1))
172
+ expect(option(nil).take(2)).to eq(none)
173
173
  end
174
174
 
175
175
  it 'should support take_while' do
176
- expect(option(nil).take_while { |n| n < 5 }).to eq(empty)
176
+ expect(option(sequence(1,7)).take_while { |n| n < 5 }).to eq(some(1))
177
+ expect(option(nil).take_while { |n| n < 5 }).to eq(none)
177
178
  end
178
179
 
179
180
  it 'should support flat_map' do
180
- expect(option(nil).flat_map{|v| v.first}).to eq(empty)
181
+ expect(option(nil).flat_map{|v| v.first}).to eq(none)
181
182
  end
182
183
 
183
184
  end
data/totally_lazy.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: totally_lazy 0.0.15 ruby lib
5
+ # stub: totally_lazy 0.0.16 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "totally_lazy"
9
- s.version = "0.0.15"
9
+ s.version = "0.0.16"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Kingsley Hendrickse"]
14
- s.date = "2015-11-01"
14
+ s.date = "2015-11-03"
15
15
  s.description = "Port of java functional library totally lazy to ruby"
16
16
  s.email = "kingsleyhendrickse@me.com"
17
17
  s.extra_rdoc_files = [
@@ -59,7 +59,7 @@ Gem::Specification.new do |s|
59
59
  ]
60
60
  s.homepage = "http://github.com/kingsleyh/totally_lazy"
61
61
  s.licenses = ["MIT"]
62
- s.rubygems_version = "2.2.2"
62
+ s.rubygems_version = "2.4.5.1"
63
63
  s.summary = "Port of java functional library totally lazy to ruby"
64
64
 
65
65
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: totally_lazy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kingsley Hendrickse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-01 00:00:00.000000000 Z
11
+ date: 2015-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  version: '0'
202
202
  requirements: []
203
203
  rubyforge_project:
204
- rubygems_version: 2.2.2
204
+ rubygems_version: 2.4.5.1
205
205
  signing_key:
206
206
  specification_version: 4
207
207
  summary: Port of java functional library totally lazy to ruby