scan_left 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -1
- data/Gemfile.lock +6 -8
- data/lib/scan_left.rb +16 -4
- data/lib/scan_left/enumerable_with_scan_left.rb +17 -14
- data/lib/scan_left/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ada6f02fa663948a57b934fced8f69dbd24a4eface9f62fcad535d7ecc3fe6e3
|
4
|
+
data.tar.gz: 660026f96d8d1e84404043256043851012be5a0dd85fd3373641e372cce95865
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3f355a17a62e271ac8c1a5c65e07be7f2a31059a5a74db9de38ce5db7e2ad187e2bd1cb2b910d7fa20f12446905b4cf0ffa485dc813cb2a3f89d03d6868c23d
|
7
|
+
data.tar.gz: 9bb78ebd390fbb37d93c9a95e0b6d6ea02467e3d42445dfda5e546dcfb8bff754652b0c77d9d36984b509c2814a8a37181d42871ccf2548c7f4a66d63ba8b7ec
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.2.1] - 2020-05-15
|
10
|
+
### Added
|
11
|
+
- Additional documentation and examples
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
- Fixed formatting inside of YARD documentation comments
|
15
|
+
- Fixed syntax highlighting in examples in YARD doc comments
|
16
|
+
|
9
17
|
## [0.2.0] - 2020-05-14
|
10
18
|
### Added
|
11
19
|
- Optional refinement to add a `#scan_left` directly to `Enumerable`
|
@@ -33,7 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
33
41
|
- Initial gem project structure
|
34
42
|
- Initial CHANGELOG.md based on keepachangelog.com
|
35
43
|
|
36
|
-
[Unreleased]: https://github.com/panorama-ed/scan_left/compare/v0.2.
|
44
|
+
[Unreleased]: https://github.com/panorama-ed/scan_left/compare/v0.2.1...HEAD
|
45
|
+
[0.2.1]: https://github.com/panorama-ed/scan_left/compare/v0.2.0...v0.2.1
|
37
46
|
[0.2.0]: https://github.com/panorama-ed/scan_left/compare/v0.1.0...v0.2.0
|
38
47
|
[0.1.0]: https://github.com/panorama-ed/scan_left/compare/v0.0.1...v0.1.0
|
39
48
|
[0.0.1]: https://github.com/panorama-ed/scan_left/releases/tag/v0.0.1
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
GIT
|
2
2
|
remote: https://github.com/panorama-ed/panolint
|
3
|
-
revision:
|
3
|
+
revision: 145a6b9415534d5563f319798297d00e3c184fd1
|
4
4
|
specs:
|
5
5
|
panolint (0.1.2)
|
6
6
|
brakeman (~> 4.8)
|
7
|
-
rubocop (~> 0.
|
7
|
+
rubocop (~> 0.83)
|
8
8
|
rubocop-performance (~> 1.5)
|
9
9
|
rubocop-rails (~> 2.5)
|
10
|
-
rubocop-rspec (~> 1.
|
10
|
+
rubocop-rspec (~> 1.39)
|
11
11
|
|
12
12
|
PATH
|
13
13
|
remote: .
|
14
14
|
specs:
|
15
|
-
scan_left (0.2.
|
15
|
+
scan_left (0.2.1)
|
16
16
|
|
17
17
|
GEM
|
18
18
|
remote: https://rubygems.org/
|
@@ -24,12 +24,11 @@ GEM
|
|
24
24
|
tzinfo (~> 1.1)
|
25
25
|
zeitwerk (~> 2.2, >= 2.2.2)
|
26
26
|
ast (2.4.0)
|
27
|
-
brakeman (4.8.
|
27
|
+
brakeman (4.8.2)
|
28
28
|
concurrent-ruby (1.1.6)
|
29
29
|
diff-lcs (1.3)
|
30
30
|
i18n (1.8.2)
|
31
31
|
concurrent-ruby (~> 1.0)
|
32
|
-
jaro_winkler (1.5.4)
|
33
32
|
minitest (5.14.0)
|
34
33
|
parallel (1.19.1)
|
35
34
|
parser (2.7.1.2)
|
@@ -51,8 +50,7 @@ GEM
|
|
51
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
52
51
|
rspec-support (~> 3.9.0)
|
53
52
|
rspec-support (3.9.3)
|
54
|
-
rubocop (0.
|
55
|
-
jaro_winkler (~> 1.5.1)
|
53
|
+
rubocop (0.83.0)
|
56
54
|
parallel (~> 1.10)
|
57
55
|
parser (>= 2.7.0.1)
|
58
56
|
rainbow (>= 2.2.2, < 4.0)
|
data/lib/scan_left.rb
CHANGED
@@ -1,16 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Original author:
|
3
|
+
# Original author: {Marc Siegel}[https://github.com/ms-ati].
|
4
4
|
|
5
5
|
require "scan_left/enumerable_with_scan_left"
|
6
6
|
require "scan_left/version"
|
7
7
|
|
8
|
-
#
|
8
|
+
# Wraps any +Enumerable+ to provide the {#scan_left} operation.
|
9
|
+
#
|
10
|
+
# Please see {file:README.md} for details, examples, background, and further
|
11
|
+
# reading about this operation.
|
12
|
+
#
|
13
|
+
# *Note:* if you'd prefer to use the {#scan_left} method directly on any
|
14
|
+
# +Enumerable+ instance, please see the optional refinement
|
15
|
+
# {EnumerableWithScanLeft}.
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# ScanLeft.new([1, 2, 3]).scan_left(0) { |s, x| s + x } == [0, 1, 3, 6]
|
19
|
+
#
|
20
|
+
# @see EnumerableWithScanLeft
|
9
21
|
class ScanLeft
|
10
|
-
# @return [Enumerable]
|
22
|
+
# @return [Enumerable] Enumerable to transform via {#scan_left}
|
11
23
|
attr_reader :enumerable
|
12
24
|
|
13
|
-
# @param [Enumerable]
|
25
|
+
# @param enumerable [Enumerable] Enumerable to transform via {#scan_left}
|
14
26
|
def initialize(enumerable)
|
15
27
|
@enumerable = enumerable
|
16
28
|
end
|
@@ -1,27 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
3
|
+
# *Optional*
|
4
|
+
# {refinement}[https://docs.ruby-lang.org/en/2.7.0/syntax/refinements_rdoc.html]
|
5
|
+
# which refines +Enumerable+ to add a +#scan_left+ method, in order to provide
|
6
|
+
# a more natural syntax in comparison to explicitly creating instances of the
|
7
|
+
# +ScanLeft+ class.
|
6
8
|
#
|
7
|
-
# Without using this refinement:
|
8
|
-
# ScanLeft.new([1,2,3]).scan_left(0, &:+) => [0, 1, 3, 6]
|
9
|
+
# Without using this refinement, we wrap Enumerables in +ScanLeft+ instances:
|
9
10
|
#
|
10
|
-
#
|
11
|
-
# [1,2,3].scan_left(0, &:+) => [0, 1, 3, 6]
|
11
|
+
# ScanLeft.new([1,2,3]).scan_left(0, &:+) # => [0, 1, 3, 6]
|
12
12
|
#
|
13
|
+
# Using this refinement, we can call +#scan_left+ directly on any Enumerable:
|
13
14
|
#
|
14
|
-
#
|
15
|
+
# [1,2,3].scan_left(0, &:+) # => [0, 1, 3, 6]
|
15
16
|
#
|
16
|
-
#
|
17
|
-
#
|
17
|
+
# @example
|
18
|
+
# class Foo
|
19
|
+
# using EnumerableWithScanLeft
|
18
20
|
#
|
19
|
-
#
|
20
|
-
#
|
21
|
+
# def bar(x)
|
22
|
+
# [1,2,3].scan_left(x, &:+)
|
23
|
+
# end
|
21
24
|
# end
|
22
|
-
# end
|
23
25
|
#
|
24
|
-
#
|
26
|
+
# Foo.new.bar(10) # => [10, 11, 13, 16]
|
27
|
+
#
|
25
28
|
module EnumerableWithScanLeft
|
26
29
|
refine Enumerable do
|
27
30
|
def scan_left(initial, &block)
|
data/lib/scan_left/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scan_left
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Siegel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|