with_ease 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b82599593f37f0f889da475eff808db8fb46259754cd245d11ea842f6e454325
4
- data.tar.gz: 3bf87be2c1b028d522205597c7d952a055bab0907ccc8f2d805ac40902a148ba
3
+ metadata.gz: 1acaa86f823eeec13d846b6af27f39e94ec5bffa9d19fa81ce78994680efbfa5
4
+ data.tar.gz: 2c23c88589ed075d3289e27528e9d8ceb1acda6eeee0a45e6c21cae6a95240ef
5
5
  SHA512:
6
- metadata.gz: ab419bec4a95ac73a27eed1746a9c231d6c381f318449a92fdba9b77be68a8ebf42a94c855a20fcc627e11f8415f7a5889116e50fb4f1c1d2ae517018d9b5abe
7
- data.tar.gz: aea48838989fd9360f3054eea73c7aee0d5968ab43089bb612e2342656b30e81deecb530cc4ebeac2cae390cdb2111e5949c52c7cf3a8e3f1cfe50439a7028ad
6
+ metadata.gz: a6cb7b523b7481b4696242a2addd533cd08c158f6652e8e8ab11b2aa6cbeb262abfbde383a14ad51e3dda8013ff45ba431901fdcd075636aaf48d73c10aac6f8
7
+ data.tar.gz: 2f5c8b59bf12285100c0cabf7a592a55117a8b6c0e0e9d946141d14c76290c24c2770a8bc519210ac4b58cf3bf7c5b45a73292d570aec7e6f79d97a87f46937e
data/README.md CHANGED
@@ -51,6 +51,11 @@ Nothing you cannot do with `Enumerator::Lazy` but so much simpler again.
51
51
 
52
52
  [c.f for details](speculations/iterator.md)
53
53
 
54
+ #### Extend the `&:<method>` cludge from symbols to arrays with `Array#.to_proc`
55
+
56
+ My philosophy on this, is either use both or hate both
57
+
58
+ [c.f for details](speculations/array_to_proc.md)
54
59
 
55
60
  ## Quick Start
56
61
 
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'array_to_proc'
4
+ require_relative 'closed_struct'
5
+ require_relative 'forward'
6
+ require_relative 'iterator'
7
+ require_relative 'open_struct'
8
+
9
+ ClosedStruct = WithEase::ClosedStruct
10
+ Forward = WithEase::Forward
11
+ Iterator = WithEase::Iterator
12
+
13
+ require_relative 'constructor_functions'
14
+ # SPDX-License-Identifier: AGPL-3.0-or-later
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Array
4
+ def to_proc
5
+ -> { it.send(*self) }
6
+ end
7
+ end
8
+ # SPDX-License-Identifier: AGPL-3.0-or-later
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'closed_struct'
4
+ require_relative 'iterator'
5
+ require_relative 'open_struct'
6
+
7
+ def ClosedStruct(**k) = WithEase::ClosedStruct.new(**k)
8
+ def Iterator(init, &blk) = WithEase::Iterator.new(init, &blk)
9
+ def OpenStruct(**k) = WithEase::OpenStruct.new(**k)
10
+ # SPDX-License-Identifier: AGPL-3.0-or-later
@@ -6,7 +6,10 @@ module WithEase
6
6
 
7
7
  attr_reader :advancer, :value
8
8
 
9
- def advance = drop(1)
9
+ def advance = drop
10
+ def advance_fn = -> { drop }
11
+
12
+ def call = advance
10
13
 
11
14
  def drop(n=1)
12
15
  n.times do
@@ -16,14 +19,28 @@ module WithEase
16
19
  end
17
20
  def drop_fn = -> (n=1) { drop n }
18
21
 
22
+ def drop_while(&blk)
23
+ loop do
24
+ return self unless blk.(value)
25
+ advance
26
+ end
27
+ end
28
+
29
+ def map(&blk)
30
+ lazy.map(&blk)
31
+ end
19
32
 
20
33
  def each
21
34
  loop do
22
35
  yield value
23
- drop
36
+ advance
24
37
  end
25
38
  end
39
+
26
40
  def take_fn = -> (n) { take n }
41
+ def take_while_fn = -> (&blk) { take_while(&blk) }
42
+
43
+ def to_proc = ->(*) { value }
27
44
 
28
45
  private
29
46
  def initialize(value, &advancer)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WithEase
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  # SPDX-License-Identifier: AGPL-3.0-or-later
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: with_ease
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober
@@ -34,9 +34,12 @@ files:
34
34
  - LICENSE
35
35
  - README.md
36
36
  - lib/with_ease.rb
37
+ - lib/with_ease/all.rb
38
+ - lib/with_ease/array_to_proc.rb
37
39
  - lib/with_ease/base.rb
38
40
  - lib/with_ease/closed_struct.rb
39
41
  - lib/with_ease/closed_struct/hash_api.rb
42
+ - lib/with_ease/constructor_functions.rb
40
43
  - lib/with_ease/forward.rb
41
44
  - lib/with_ease/import_base.rb
42
45
  - lib/with_ease/iterator.rb