totally_lazy 0.1.54 → 0.1.55

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 (4) hide show
  1. checksums.yaml +8 -8
  2. data/lib/totally_lazy/pair.rb +8 -0
  3. data/readme.md +49 -3
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODE3OWEyZGRkZjQwZjQ5MjdjOTI5YmFkMjdiZDU1Y2FhMjc0MzAwYQ==
4
+ MGFjNjY5NzI0NjAzMDgyZThjYTA3MTUxYWI0YTBiNzk0ZmZkMDA5ZQ==
5
5
  data.tar.gz: !binary |-
6
- ZTEyZjkwNWU1ZmNjODA1NDFjOWVkOGEwNmQ4MmI3NmYyNzY5MWJmMg==
6
+ YmU1MjQ0YzVmOThmMjYzMTVlODlmODY3Yzc4OWE0OWUxMzc5YTI0Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MmU3MDY1NDBkOTg4NGFmZGE5ZDFlNTZjMDhlNjdhMGIyNjI2YzE3MDMxNjMy
10
- ZWRhNDAwNGQzMGE5ZmI2NjRlMTdkNjhhOTA1Y2M4MjYyYTZjOGNiOWYyNGI1
11
- MzZjOWRiZDQxOWI0YzY4OGQ4NGVmOTlhNWEyY2FmNGU4OWYxNzk=
9
+ M2ZiYzJjOTZlNjZlN2Y5NmJkNDM5ZmNmYTY1MThiODQyYzgyNGU0OTkwOWJk
10
+ ODk3ZjhmNDJjNGVhZmZhYTRmNGMzMjQyMjJmYjdmYzI2MDAyNTIyYzdkOTRi
11
+ MTU1ZWIxYmUxYjQwZmEzZTlmOTE2YTkyNjRjMjNkNzhkNDliNmE=
12
12
  data.tar.gz: !binary |-
13
- YzM5MmRhZjQ4NTY3ZDAzMjQ0YzgyMjA2ZGQyMmJlNzBhNmI4N2FmZTdkMjA5
14
- ZDg0ZjNkYzI2NDY1NGZiMGM1MTM5NjEwMzMwYjAwOGNjZjA2MWQ1M2RkODFk
15
- NjVhNWZjMzIxY2JlMGNkOWIyZDJjMTkyYWJkODhmOTM1NjEyOTg=
13
+ YTNkYWNmODE3OTVjY2QzZWRmM2UyMWFmZDZlODM4N2M4OTY3MTk1MTJkMDI0
14
+ ZGFhOTAxZDRjZDdiYzg5MTc3MDdmZDZkMDViOWZiNjY1ZDhhYTMwZDA3YTVk
15
+ OGNmNjhjMTZkYjA2ZjAzMWU1YmFjMmVkY2RhNGNmYTFhMDA1OTM=
@@ -3,6 +3,14 @@ module Pairs
3
3
  def pair(first, second)
4
4
  Pair.new(first, second)
5
5
  end
6
+
7
+ def first
8
+ ->(pair) { pair.first }
9
+ end
10
+
11
+ def second
12
+ ->(pair) { pair.second }
13
+ end
6
14
  end
7
15
 
8
16
  class Pair
data/readme.md CHANGED
@@ -1,4 +1,50 @@
1
- totally_lazy
2
- ============
1
+ # Totally Lazy for Ruby
3
2
 
4
- [![Build Status](https://travis-ci.org/raymanoz/totally_lazy.svg?branch=master)](https://travis-ci.org/raymanoz/totally_lazy) [![Gem Version](https://badge.fury.io/rb/totally_lazy.svg)](https://badge.fury.io/rb/totally_lazy)
3
+ This is a port of the java functional library [Totally Lazy](https://code.google.com/p/totallylazy/) to the ruby language.
4
+
5
+ ### Status
6
+ [![Build Status](https://travis-ci.org/raymanoz/totally_lazy.svg?branch=master)](https://travis-ci.org/raymanoz/totally_lazy)
7
+ [![Gem Version](https://badge.fury.io/rb/totally_lazy.svg)](https://badge.fury.io/rb/totally_lazy)
8
+
9
+ ### Summary
10
+
11
+ * Tries to be as lazy as possible
12
+ * Supports method chaining
13
+ * Is primarily based on ruby Enumerators
14
+ * For function, can use blocks or lambdas (some places require lambdas, eg. when 2 functions need to be passed in)
15
+
16
+ ### Install
17
+
18
+ This gem requires ruby >= 2.0.0
19
+
20
+ In your bundler Gemfile
21
+
22
+ ```ruby
23
+ gem totally_lazy, '~>0.1.54' (or latest)
24
+ ```
25
+
26
+ Or with rubygems
27
+
28
+ ```
29
+ gem install totally_lazy
30
+ ```
31
+
32
+ ### Examples
33
+
34
+ The following are some simple examples of the currently implemented functionality.
35
+
36
+ ```ruby
37
+ require 'totally_lazy'
38
+
39
+ sequence(1,2,3,4).filter(even) # lazily returns 2,4
40
+ sequence(1,2).map(to_string) # lazily returns "1","2"
41
+ sequence(1, 2).map_concurrently(to_string) # lazily distributes the work to background threads
42
+ sequence(1,2,3).take(2) # lazily returns 1,2
43
+ sequence(1,2,3).drop(2) # lazily returns 3
44
+ sequence(1,2,3).tail # lazily returns 2,3
45
+ sequence(1,2,3).head # eagerly returns 1
46
+ sequence(1,2,3).head_option # eagerly returns an option
47
+ some(sequence(1,2,3)).get_or_else(empty) # eagerly returns value or else empty sequence
48
+ sequence(1, 2, 3, 4, 5).filter(greater_than(2).and(odd)) # lazily returns 3,5
49
+ sequence(pair(1, 2), pair(3, 4)).filter(where(first, equal_to?(3))) # lazily returns pair(3,4)
50
+ ```
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.1.54
4
+ version: 0.1.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raymond Barlow