totally_lazy 0.0.13 → 0.0.14

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: cfb52906262bbc2dd2e99910b5ede6e740124b89
4
- data.tar.gz: 61d1e2a40cc9a312d06a972613a4f94222bb6534
3
+ metadata.gz: 3229a338c39916c91506f35facbbfb43f2c95147
4
+ data.tar.gz: c4f0b6ffa654e6360b0dc57268b17329b1ccdfed
5
5
  SHA512:
6
- metadata.gz: f5a0e8811a004d0058a414a7ef09957ba03365db0b97c6d1e5e44c0c088ea2dd2d87159f743b7aafab230a58549b043e519f77894dab16f75c617d32d1f18140
7
- data.tar.gz: 9f4708dda0571887af33eec7a74c042dcb412a6d898fb399f35ac2acb09f58b45a485fee53dab521d1758d5a5bed2f25cae3c03d1b2503c0783c5583807ead91
6
+ metadata.gz: bea2ee197eddc5241277684ed67678c757a31256e261b5d488d876df66a54e42be56e6ec04ada9c5e414e4261ee6f0b090aa12691c1e74533e334500cd9c4541
7
+ data.tar.gz: 6dd14258d2aecb4081a33ae6fc6086144fd9d798807abed81a557ba642cf346a02ca311788bf5606b799d8152fdb0d18c22956f914be015b2bbc551805eb62df
data/README.md CHANGED
@@ -53,6 +53,11 @@ sequence(1, 2, 3, 4, 5).filter(where(is greater_than 2).and(is odd)) # lazily re
53
53
  sequence(pair(1, 2), pair(3, 4)).filter(where(key:odd)) # lazily returns 1,3
54
54
  ```
55
55
 
56
+ #### Sequences
57
+
58
+ * sequence wraps whatever is passed without modification - e.g. sequence([1,2,3]).head returns the array [1,2,3]
59
+ * sequence1 modifies what is passed if it's a single item - e.g. sequence1([1,2,3]).head returns the first element of 1
60
+
56
61
  #### Generators
57
62
 
58
63
  There are 2 types of generators:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.13
1
+ 0.0.14
data/lib/pair.rb CHANGED
@@ -48,7 +48,7 @@ module Pair
48
48
  end
49
49
 
50
50
  def self.from_map(a_map)
51
- from_single(a_map).map { |k, v| Pair.new(k, v) }
51
+ sequence1(a_map).map { |k, v| Pair.new(k, v) }
52
52
  end
53
53
 
54
54
  def to_s
data/lib/sequence.rb CHANGED
@@ -44,7 +44,7 @@ module Sequences
44
44
  # end
45
45
  # end
46
46
 
47
- def from_single(*items)
47
+ def sequence1(*items)
48
48
  if items.size == 1
49
49
  if [Range, Hash, Array, Set].include?(items.first.class)
50
50
  Sequence.new(items.first)
@@ -57,7 +57,7 @@ module Sequences
57
57
  Sequence.new(items)
58
58
  end
59
59
  end
60
- module_function :from_single
60
+ module_function :sequence1
61
61
 
62
62
  def sequence(*items)
63
63
  if items.first.nil?
@@ -82,7 +82,7 @@ module Sequences
82
82
  end
83
83
 
84
84
  def deserialize(data)
85
- from_single(data).deserialize
85
+ sequence1(data).deserialize
86
86
  end
87
87
 
88
88
  class Sequence < Enumerator
@@ -42,7 +42,7 @@ describe 'Sequence' do
42
42
  end
43
43
 
44
44
  it 'should lazily shuffle the elements - throws NoSuchElementException if empty' do
45
- expect(from_single(1..50).shuffle.entries).not_to eq(from_single(1..50).entries)
45
+ expect(sequence1(1..50).shuffle.entries).not_to eq(sequence1(1..50).entries)
46
46
  expect { empty.shuffle.first }.to raise_error(NoSuchElementException)
47
47
  end
48
48
 
@@ -214,7 +214,7 @@ describe 'Sequence' do
214
214
  end
215
215
 
216
216
  it 'should convert sequence to a map' do
217
- expect(from_single(oops('apple',1,'pear',2)).to_map).to eq({apple:1,pear:2})
217
+ expect(sequence1(oops('apple',1,'pear',2)).to_map).to eq({apple:1,pear:2})
218
218
  end
219
219
 
220
220
  def oops(*values)
data/totally_lazy.gemspec CHANGED
@@ -2,11 +2,11 @@
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.13 ruby lib
5
+ # stub: totally_lazy 0.0.14 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "totally_lazy"
9
- s.version = "0.0.13"
9
+ s.version = "0.0.14"
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"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: totally_lazy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kingsley Hendrickse