grizzly-rb 1.0.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.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yml +58 -0
  3. data/.gitignore +13 -0
  4. data/.rubocop.yml +23 -0
  5. data/Gemfile +10 -0
  6. data/Gemfile.lock +56 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +192 -0
  9. data/Rakefile +16 -0
  10. data/benchmark.rb +59 -0
  11. data/benchmark.txt +73 -0
  12. data/bin/console +22 -0
  13. data/bin/convert +15 -0
  14. data/bin/setup +11 -0
  15. data/bin/spec/convert +27 -0
  16. data/bin/spec/reset +9 -0
  17. data/bin/spec/setup +20 -0
  18. data/bin/test +38 -0
  19. data/config/mspec_override.rb +44 -0
  20. data/config/skipped_tests.yml +104 -0
  21. data/conversion/Gemfile +7 -0
  22. data/conversion/Gemfile.lock +53 -0
  23. data/conversion/bin/rspec +27 -0
  24. data/conversion/lib/cops/array_initialization.rb +95 -0
  25. data/conversion/lib/cops/enumerator_initialization.rb +56 -0
  26. data/conversion/lib/cops/grep_implementation.rb +36 -0
  27. data/conversion/lib/cops/instance_of_array.rb +24 -0
  28. data/conversion/lib/cops/subclass_initialization.rb +47 -0
  29. data/conversion/lib/cops.rb +6 -0
  30. data/conversion/spec/.DS_Store +0 -0
  31. data/conversion/spec/cops/array_initialization_spec.rb +154 -0
  32. data/conversion/spec/cops/enumerator_initialization_spec.rb +105 -0
  33. data/conversion/spec/cops/grep_implementation_spec.rb +57 -0
  34. data/conversion/spec/cops/instance_of_array_spec.rb +38 -0
  35. data/conversion/spec/cops/subclass_initialization_spec.rb +26 -0
  36. data/conversion/spec/spec_helper.rb +104 -0
  37. data/examples/transactions.rb +278 -0
  38. data/grizzly-group.gemspec +28 -0
  39. data/lib/grizzly/collection.rb +77 -0
  40. data/lib/grizzly/enumerable.rb +120 -0
  41. data/lib/grizzly/enumerator-backup.rb +114 -0
  42. data/lib/grizzly/enumerator.rb +63 -0
  43. data/lib/grizzly/lazy_enumerator.rb +40 -0
  44. data/lib/grizzly/version.rb +3 -0
  45. data/lib/grizzly.rb +8 -0
  46. metadata +89 -0
@@ -0,0 +1,40 @@
1
+ module Grizzly
2
+ class LazyEnumerator
3
+ include ::Grizzly::Enumerable
4
+
5
+ %i[
6
+ select chunk chunk_while collect collect_concat compact drop drop_while
7
+ eager enum_for filter filter_map find_all flat_map force grep grep_v
8
+ map reject slice_after slice_before slice_when take take_while to_enum
9
+ uniq with_index zip each_with_index with_index cycle each_with_object
10
+ with_object each_slice each_entry each_cons each
11
+ ].each do |method_name|
12
+ define_method(method_name) do |*args, &block|
13
+ subgroup @obj.send(method_name, *args, &block)
14
+ end
15
+ end
16
+
17
+ attr_reader :obj, :instantiating_class
18
+ def initialize(obj, instantiating_class: Array)
19
+ @obj = obj
20
+ @instantiating_class = instantiating_class
21
+ end
22
+
23
+ def subgroup(result)
24
+ return new_lazy_enumerator(result) if result.is_a?(::Enumerator::Lazy)
25
+ super
26
+ end
27
+
28
+ def lazy
29
+ self
30
+ end
31
+
32
+ def size
33
+ @obj.size
34
+ end
35
+
36
+ def to_a(*args, &block)
37
+ @obj.to_a(*args, &block) # no subgroup?
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ module Grizzly
2
+ VERSION = "1.0.0"
3
+ end
data/lib/grizzly.rb ADDED
@@ -0,0 +1,8 @@
1
+ require_relative "grizzly/version"
2
+ require_relative "grizzly/enumerable"
3
+ require_relative "grizzly/collection"
4
+ require_relative "grizzly/enumerator"
5
+ require_relative "grizzly/lazy_enumerator"
6
+
7
+ module Grizzly
8
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: grizzly-rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexandre Barret
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-01-30 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - alexbarret@duck.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".github/workflows/ci.yml"
21
+ - ".gitignore"
22
+ - ".rubocop.yml"
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - benchmark.rb
29
+ - benchmark.txt
30
+ - bin/console
31
+ - bin/convert
32
+ - bin/setup
33
+ - bin/spec/convert
34
+ - bin/spec/reset
35
+ - bin/spec/setup
36
+ - bin/test
37
+ - config/mspec_override.rb
38
+ - config/skipped_tests.yml
39
+ - conversion/Gemfile
40
+ - conversion/Gemfile.lock
41
+ - conversion/bin/rspec
42
+ - conversion/lib/cops.rb
43
+ - conversion/lib/cops/array_initialization.rb
44
+ - conversion/lib/cops/enumerator_initialization.rb
45
+ - conversion/lib/cops/grep_implementation.rb
46
+ - conversion/lib/cops/instance_of_array.rb
47
+ - conversion/lib/cops/subclass_initialization.rb
48
+ - conversion/spec/.DS_Store
49
+ - conversion/spec/cops/array_initialization_spec.rb
50
+ - conversion/spec/cops/enumerator_initialization_spec.rb
51
+ - conversion/spec/cops/grep_implementation_spec.rb
52
+ - conversion/spec/cops/instance_of_array_spec.rb
53
+ - conversion/spec/cops/subclass_initialization_spec.rb
54
+ - conversion/spec/spec_helper.rb
55
+ - examples/transactions.rb
56
+ - grizzly-group.gemspec
57
+ - lib/grizzly.rb
58
+ - lib/grizzly/collection.rb
59
+ - lib/grizzly/enumerable.rb
60
+ - lib/grizzly/enumerator-backup.rb
61
+ - lib/grizzly/enumerator.rb
62
+ - lib/grizzly/lazy_enumerator.rb
63
+ - lib/grizzly/version.rb
64
+ homepage: https://github.com/AlexB52/grizzly-rb
65
+ licenses:
66
+ - MIT
67
+ metadata:
68
+ homepage_uri: https://github.com/AlexB52/grizzly-rb
69
+ source_code_uri: https://github.com/AlexB52/grizzly-rb
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 2.3.0
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubygems_version: 3.3.26
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: An Array subclass for Ruby
89
+ test_files: []