grizzly-rb 1.0.0 → 1.1.0

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: 24c416adb1060b6c503e854c13d11166c7d3ebaf13ec72462ef3c26ef3da24eb
4
- data.tar.gz: ca6e02092abf336a2ba350ff447500ceb438a6d21e06a17e15cea6e5e83e7ac1
3
+ metadata.gz: cbc86175e148905682a6d079cd590ec5eb194f010254de286d7e62cfdf351559
4
+ data.tar.gz: 8a6e5c787f07286a7232de7371dc997829c34ca3788cf4575f2fef1bb0d9d8f2
5
5
  SHA512:
6
- metadata.gz: dad40d7758cc00c7c1153a7ee5a68184ba1368097bc707fd1c896bd6d4c4c60a0cfe7d45d6d5585d032c2ca6283eda32997b2769539e3f07025e9f88218a0ce3
7
- data.tar.gz: 856682a5ae9346ada2725334aaaaf8e59bc85b89557f7d421963f5c7a9f54b27ebf533d0e3aeb15d3e3bbbdf7f4d81bf58c63ba20db827062bb8c1488a228fc7
6
+ metadata.gz: 1780ebc3d74d9ce4785ff95ad5d86007875c768770ce6c0ce7c2400adf644932e17c658a365f9b8174b30d5b356bd78333be9abc5dd51aff72bb985a046734f1
7
+ data.tar.gz: c341e139938bcbe89ca30030560396d6efa8be83c05e0791f58b86f8cf936b93aa00af19ee292b79589ea8e13dfca47feb44fa365c2a6a06ccf6a1a486b49ec6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grizzly-rb (1.0.0)
4
+ grizzly-rb (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,10 +1,8 @@
1
- :anger: **DISCLAIMER**: Reading this piece isn't for the faint of heart.
2
-
3
1
  # Grizzly library
4
2
 
5
- The Grizzly library is an attempt to end the predominance of the Array in Ruby by providing a Collection class that returns expected results from subgrouping methods like `Array#select, Array#partition, Array#reject`, to name a few. The work came after reading [Steve Klabnik's warning](https://steveklabnik.com/writing/beware-subclassing-ruby-core-classes) & [gist](https://gist.github.com/steveklabnik/6071687) about subclassing Ruby core classes.
3
+ The Grizzly library is an attempt to end the predominance of the Array in Ruby by providing a functional Monad for the Ruby Array. The work came after reading [Steve Klabnik's warning](https://steveklabnik.com/writing/beware-subclassing-ruby-core-classes) & [gist](https://gist.github.com/steveklabnik/6071687) about subclassing Ruby core classes.
6
4
 
7
- We're testing the library against the [Ruby/Spec](https://github.com/ruby/spec) to avoid as many side effects as possible.
5
+ We're testing the library against the [Ruby/Spec](https://github.com/ruby/spec) and covers most of the Array methods.
8
6
 
9
7
  The library provides four classes/modules:
10
8
 
@@ -13,6 +11,8 @@ The library provides four classes/modules:
13
11
  * Grizzly::Enumerator (Enumerator decorator)
14
12
  * Grizzly::LazyEnumerator (Enumerator::Lazy decorator)
15
13
 
14
+ You can find them in the lib folder.
15
+
16
16
  **The Grizzly::Collection is a subclass of Array that works; you will love to hate it.**
17
17
 
18
18
  ## Usage
@@ -4,7 +4,7 @@ gemfile do
4
4
  source 'https://rubygems.org'
5
5
  gem 'faker'
6
6
  gem 'byebug'
7
- gem 'grizzly-rb', path: '.', require: 'grizzly'
7
+ gem 'grizzly-rb', require: 'grizzly'
8
8
  end
9
9
 
10
10
  require "bigdecimal"
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.summary = "An Array subclass for Ruby"
10
10
  spec.homepage = "https://github.com/AlexB52/grizzly-rb"
11
11
  spec.license = "MIT"
12
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
13
13
 
14
14
  # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
15
15
 
@@ -1,3 +1,3 @@
1
1
  module Grizzly
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grizzly-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Barret
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-30 00:00:00.000000000 Z
11
+ date: 2023-01-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -57,7 +57,6 @@ files:
57
57
  - lib/grizzly.rb
58
58
  - lib/grizzly/collection.rb
59
59
  - lib/grizzly/enumerable.rb
60
- - lib/grizzly/enumerator-backup.rb
61
60
  - lib/grizzly/enumerator.rb
62
61
  - lib/grizzly/lazy_enumerator.rb
63
62
  - lib/grizzly/version.rb
@@ -75,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
74
  requirements:
76
75
  - - ">="
77
76
  - !ruby/object:Gem::Version
78
- version: 2.3.0
77
+ version: 2.7.0
79
78
  required_rubygems_version: !ruby/object:Gem::Requirement
80
79
  requirements:
81
80
  - - ">="
@@ -1,114 +0,0 @@
1
- require 'forwardable'
2
-
3
- module Grizzly
4
- class Enumerator
5
- extend Forwardable
6
-
7
- def_delegators :@enum, *%i{
8
- + first feed to_a
9
- next next_values
10
- peek peek_values
11
- }
12
-
13
- attr_reader :enum, :obj, :method_name, :args
14
- def initialize(obj, method_name = :each, *args, size: nil, &block)
15
- @obj = obj
16
- @args = args
17
- @size = size
18
- @method_name = method_name
19
- if block_given?
20
- @enum = ::Enumerator.new(obj, &block)
21
- else
22
- @enum = obj.to_enum(method_name, *args)
23
- end
24
- end
25
-
26
- def each(*args, &block)
27
- unless block_given?
28
- return args.any? ? new_enumerator(enum, __method__, *args) : self
29
- end
30
-
31
- enum.each(*args, &block)
32
- end
33
-
34
- def with_index(offset = 0, &block)
35
- unless block_given?
36
- return new_enumerator(self, __method__, offset)
37
- end
38
-
39
- enum.with_index(offset, &block)
40
- end
41
-
42
- def each_with_index(&block)
43
- with_index(&block)
44
- end
45
-
46
- def with_object(object, &block)
47
- unless block_given?
48
- return new_enumerator(self, __method__, object)
49
- end
50
-
51
- enum.with_object(object, &block)
52
- end
53
- alias :each_with_object :with_object
54
-
55
- def inspect
56
- enum.inspect.gsub('Enumerator', self.class.to_s)
57
- end
58
-
59
- def size
60
- return obj.call if obj.respond_to?(:call)
61
-
62
- @size || enum.size || obj.size if obj.respond_to?(:size)
63
- end
64
-
65
- def rewind
66
- enum.rewind && self
67
- end
68
-
69
- private
70
-
71
- def new_enumerator(obj, method_name, *args)
72
- self.class.new obj, method_name, *args, size: size
73
- end
74
- end
75
-
76
- # class Enumerator < Enumerator
77
- # extend Forwardable
78
-
79
- # OVERRIDE_METHODS = %i{with_index with_object each_with_index each_with_object}
80
- # ENUMERATOR_METHODS = Enumerator.public_instance_methods(false)
81
- # ENUMERABLE_METHODS = Enumerable.public_instance_methods
82
-
83
- # alias :old_enum :to_enum
84
-
85
- # def_delegators :@enum, *ENUMERATOR_METHODS
86
-
87
- # ENUMERABLE_METHODS.each do |method_name|
88
- # define_method(method_name) do |*args, &block|
89
- # return to_enum(__method__, *args) unless block
90
-
91
- # @object.send(__method__, *args, &block)
92
- # end
93
- # end
94
-
95
- # OVERRIDE_METHODS.each do |method_name|
96
- # define_method(method_name) do |*args, &block|
97
- # return to_enum(__method__, *args) unless block
98
-
99
- # @enum.send(:each, *args, &block)
100
- # end
101
- # end
102
-
103
- # attr_reader :object, :enum
104
-
105
- # def initialize(object, method_name, *args)
106
- # @object = object
107
- # @enum = object.to_enum(method_name, *args)
108
- # end
109
-
110
- # def to_enum(method_name, *args)
111
- # self.class.new @object, method_name, *args
112
- # end
113
- # end
114
- end