totally_lazy 0.0.20 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/compiler.xml +22 -0
- data/.idea/encodings.xml +6 -0
- data/.idea/misc.xml +19 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vcs.xml +6 -0
- data/.travis.yml +2 -5
- data/Gemfile +6 -8
- data/Guardfile +2 -17
- data/LICENSE +202 -0
- data/Rakefile +18 -33
- data/VERSION +1 -1
- data/contributors.txt +1 -0
- data/lib/comparators.rb +9 -0
- data/lib/enumerators.rb +74 -0
- data/lib/functions.rb +66 -0
- data/lib/numbers.rb +38 -0
- data/lib/option.rb +38 -268
- data/lib/pair.rb +13 -51
- data/lib/predicates.rb +5 -0
- data/lib/sequence.rb +171 -526
- data/lib/strings.rb +13 -0
- data/lib/totally_lazy.rb +14 -165
- data/readme.md +2 -0
- data/spec/option_spec.rb +6 -182
- data/spec/sequence_spec.rb +202 -132
- data/spec/spec_helper.rb +0 -13
- data/totally_lazy.iml +74 -0
- metadata +58 -71
- data/.document +0 -5
- data/.rspec +0 -1
- data/LICENSE.txt +0 -20
- data/README.md +0 -173
- data/lib/any.rb +0 -13
- data/lib/functor.rb +0 -92
- data/lib/generators.rb +0 -161
- data/lib/parallel/parallel.rb +0 -442
- data/lib/parallel/processor_count.rb +0 -85
- data/lib/predicates/compare.rb +0 -25
- data/lib/predicates/conversions.rb +0 -22
- data/lib/predicates/numbers.rb +0 -21
- data/lib/predicates/predicates.rb +0 -141
- data/lib/predicates/where.rb +0 -34
- data/lib/predicates/where_processor.rb +0 -13
- data/lib/type_check.rb +0 -19
- data/lib/utils.rb +0 -9
- data/spec/functor_spec.rb +0 -35
- data/spec/generators_spec.rb +0 -37
- data/spec/pair_spec.rb +0 -44
- data/spec/predicate_spec.rb +0 -77
- data/spec/serialization_spec.rb +0 -56
- data/spec/type_check_spec.rb +0 -20
- data/spec/util_spec.rb +0 -10
- data/totally_lazy.gemspec +0 -101
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc3625c5e70f5f158b34cf22f9b8a8f97ccc072d
|
4
|
+
data.tar.gz: 86aa91774a32e80e59f944fe75912e195e5504b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e1a1a589d14fc1b87c2b710c0ec7ea71a38d085569d6f832190a3f53a2429ad49cbec0db11dff5c78207d48e08cc91e46cd896f8850aaa85eeeafb6d31a7387
|
7
|
+
data.tar.gz: 4125f0fa47810c96109b61ca319a3103930ae07856dc8f9ed3b54d7ba3dadb057a83c8301ead1a172dab6ae292e307c8fce68e4d179df1a5bc1480774dab66f5
|
data/.idea/.name
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
totally_lazy
|
data/.idea/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build gem into pkg/" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated file" fullCmd="clobber" taksId="clobber" /><RakeTask description="Start IRB with all runtime dependencies loaded" fullCmd="console[script]" taksId="console[script]" /><RakeGroup description="" fullCmd="" taksId="gemcutter"><RakeTask description="Release gem to Gemcutter" fullCmd="gemcutter:release" taksId="release" /></RakeGroup><RakeTask description="Generate and validate gemspec" fullCmd="gemspec" taksId="gemspec" /><RakeGroup description="" fullCmd="" taksId="gemspec"><RakeTask description="Display the gemspec for debugging purposes, as jeweler knows it (not from the filesystem)" fullCmd="gemspec:debug" taksId="debug" /><RakeTask description="Regenerate the gemspec on the filesystem" fullCmd="gemspec:generate" taksId="generate" /><RakeTask description="Regenerate and validate gemspec, and then commits and pushes to git" fullCmd="gemspec:release" taksId="release" /><RakeTask description="Validates the gemspec on the filesystem" fullCmd="gemspec:validate" taksId="validate" /></RakeGroup><RakeGroup description="" fullCmd="" taksId="git"><RakeTask description="Tag and push release to git" fullCmd="git:release" taksId="release" /></RakeGroup><RakeTask description="run rspec guard" fullCmd="guard" taksId="guard" /><RakeTask description="Build and install gem using `gem install`" fullCmd="install" taksId="install" /><RakeTask description="rebuild gem" fullCmd="re" taksId="re" /><RakeTask description="Release gem" fullCmd="release" taksId="release" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="Displays the current version" fullCmd="version" taksId="version" /><RakeGroup description="" fullCmd="" taksId="version"><RakeGroup description="" fullCmd="" taksId="bump"><RakeTask description="Bump the major version by 1" fullCmd="version:bump:major" taksId="major" /><RakeTask description="Bump the a minor version by 1" fullCmd="version:bump:minor" taksId="minor" /><RakeTask description="Bump the patch version by 1" fullCmd="version:bump:patch" taksId="patch" /></RakeGroup><RakeTask description="Writes out an explicit version" fullCmd="version:write" taksId="write" /></RakeGroup><RakeTask description="" fullCmd="console" taksId="console" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="gemspec_required" taksId="gemspec_required" /><RakeTask description="" fullCmd="version_required" taksId="version_required" /></RakeGroup></Settings>
|
data/.idea/compiler.xml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="CompilerConfiguration">
|
4
|
+
<resourceExtensions />
|
5
|
+
<wildcardResourcePatterns>
|
6
|
+
<entry name="!?*.java" />
|
7
|
+
<entry name="!?*.form" />
|
8
|
+
<entry name="!?*.class" />
|
9
|
+
<entry name="!?*.groovy" />
|
10
|
+
<entry name="!?*.scala" />
|
11
|
+
<entry name="!?*.flex" />
|
12
|
+
<entry name="!?*.kt" />
|
13
|
+
<entry name="!?*.clj" />
|
14
|
+
<entry name="!?*.aj" />
|
15
|
+
</wildcardResourcePatterns>
|
16
|
+
<annotationProcessing>
|
17
|
+
<profile default="true" name="Default" enabled="false">
|
18
|
+
<processorPath useClasspath="true" />
|
19
|
+
</profile>
|
20
|
+
</annotationProcessing>
|
21
|
+
</component>
|
22
|
+
</project>
|
data/.idea/encodings.xml
ADDED
data/.idea/misc.xml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="EntryPointsManager">
|
4
|
+
<entry_points version="2.0" />
|
5
|
+
</component>
|
6
|
+
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
7
|
+
<OptionsSetting value="true" id="Add" />
|
8
|
+
<OptionsSetting value="true" id="Remove" />
|
9
|
+
<OptionsSetting value="true" id="Checkout" />
|
10
|
+
<OptionsSetting value="true" id="Update" />
|
11
|
+
<OptionsSetting value="true" id="Status" />
|
12
|
+
<OptionsSetting value="true" id="Edit" />
|
13
|
+
<ConfirmationsSetting value="0" id="Add" />
|
14
|
+
<ConfirmationsSetting value="0" id="Remove" />
|
15
|
+
</component>
|
16
|
+
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_4" default="true" assert-keyword="true" jdk-15="false" project-jdk-name="RVM: ruby-2.1.4 [global]" project-jdk-type="RUBY_SDK">
|
17
|
+
<output url="file://$PROJECT_DIR$/out" />
|
18
|
+
</component>
|
19
|
+
</project>
|
data/.idea/modules.xml
ADDED
data/.idea/vcs.xml
ADDED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,13 +1,11 @@
|
|
1
|
-
source
|
1
|
+
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
group :development do
|
4
|
-
gem 'rspec', '~> 3.0.0'
|
5
|
-
gem 'rdoc', '~> 3.12'
|
4
|
+
gem 'rspec', '~> 3.0', '>= 3.0.0'
|
6
5
|
gem 'bundler', '~> 1.0'
|
7
|
-
gem 'jeweler', '~> 2.0.1'
|
6
|
+
gem 'jeweler', '~> 2.0', '>= 2.0.1'
|
8
7
|
gem 'rspec_html_formatter', '~> 0.3.0'
|
9
|
-
gem 'rake', '~> 10.3.2'
|
10
|
-
gem '
|
11
|
-
gem '
|
12
|
-
gem 'guard-rspec', require: false
|
8
|
+
gem 'rake', '~> 10.3', '>= 10.3.2'
|
9
|
+
gem 'guard-rspec', '~> 4.6', '>= 4.6.4', require: false
|
10
|
+
gem 'concurrent-ruby-edge', '~> 0', require: 'concurrent-edge'
|
13
11
|
end
|
data/Guardfile
CHANGED
@@ -1,24 +1,9 @@
|
|
1
1
|
# A sample Guardfile
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
|
4
|
-
guard :rspec do
|
4
|
+
guard :rspec, cmd: 'rspec' do
|
5
5
|
watch(%r{^spec/.+_spec\.rb$})
|
6
|
-
watch(%r{^lib/(.+)\.rb$}) {
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { "spec" }
|
7
7
|
watch('spec/spec_helper.rb') { "spec" }
|
8
|
-
|
9
|
-
# # Rails example
|
10
|
-
# watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
-
# watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
-
# watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
-
# watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
-
# watch('config/routes.rb') { "spec/routing" }
|
15
|
-
# watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
-
#
|
17
|
-
# # Capybara features specs
|
18
|
-
# watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
19
|
-
#
|
20
|
-
# # Turnip features and steps
|
21
|
-
# watch(%r{^spec/acceptance/(.+)\.feature$})
|
22
|
-
# watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
23
8
|
end
|
24
9
|
|
data/LICENSE
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright 2015 Bodar Ltd
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
202
|
+
|
data/Rakefile
CHANGED
@@ -6,57 +6,42 @@ begin
|
|
6
6
|
Bundler.setup(:default, :development)
|
7
7
|
rescue Bundler::BundlerError => e
|
8
8
|
$stderr.puts e.message
|
9
|
-
$stderr.puts
|
9
|
+
$stderr.puts 'Run `bundle install` to install missing gems'
|
10
10
|
exit e.status_code
|
11
11
|
end
|
12
12
|
require 'rake'
|
13
13
|
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
-
gem.name = "totally_lazy"
|
18
|
-
gem.homepage = "http://github.com/kingsleyh/totally_lazy"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{Port of java functional library totally lazy to ruby}
|
21
|
-
gem.description = %Q{Port of java functional library totally lazy to ruby}
|
22
|
-
gem.email = "kingsleyhendrickse@me.com"
|
23
|
-
gem.authors = ["Kingsley Hendrickse"]
|
24
|
-
# dependencies defined in Gemfile
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
27
|
-
|
28
14
|
require 'rspec/core'
|
29
15
|
require 'rspec/core/rake_task'
|
30
16
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
17
|
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
18
|
end
|
33
19
|
|
34
|
-
desc "Code coverage detail"
|
35
|
-
task :simplecov do
|
36
|
-
ENV['COVERAGE'] = "true"
|
37
|
-
Rake::Task['spec'].execute
|
38
|
-
end
|
39
|
-
|
40
20
|
task :default => :spec
|
41
21
|
|
42
|
-
require 'rdoc/task'
|
43
|
-
Rake::RDocTask.new do |rdoc|
|
44
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
-
|
46
|
-
rdoc.rdoc_dir = 'rdoc'
|
47
|
-
rdoc.title = "totally_lazy #{version}"
|
48
|
-
rdoc.rdoc_files.include('README*')
|
49
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
-
end
|
51
|
-
|
52
22
|
desc 'run rspec guard'
|
53
23
|
task :guard do
|
54
24
|
system('bundle exec guard')
|
55
25
|
end
|
56
26
|
|
27
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
28
|
+
|
29
|
+
require 'jeweler'
|
30
|
+
Jeweler::Tasks.new do |gem|
|
31
|
+
gem.name = 'totally_lazy'
|
32
|
+
gem.version = version
|
33
|
+
gem.homepage = 'http://github.com/raymanoz/totally_lazy'
|
34
|
+
gem.license = 'Apache 2.0'
|
35
|
+
gem.summary = 'A lazy FP library for Ruby'
|
36
|
+
gem.description = 'Port of java functional library totally lazy to ruby'
|
37
|
+
gem.email = 'rbarlow@raymanoz.com'
|
38
|
+
gem.authors = ['Raymond Barlow']
|
39
|
+
end
|
40
|
+
Jeweler::RubygemsDotOrgTasks.new
|
41
|
+
|
42
|
+
|
57
43
|
desc 'rebuild gem'
|
58
44
|
task :re do
|
59
|
-
system(
|
45
|
+
system("gem uninstall totally_lazy && rake build && gem install -l pkg/totally_lazy-#{version}.gem")
|
60
46
|
end
|
61
47
|
|
62
|
-
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/contributors.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Raymond Barlow
|
data/lib/comparators.rb
ADDED
data/lib/enumerators.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
module Enumerators
|
2
|
+
def reverse(e)
|
3
|
+
e.reverse_each
|
4
|
+
end
|
5
|
+
|
6
|
+
def has_next(e)
|
7
|
+
begin
|
8
|
+
e.peek
|
9
|
+
true
|
10
|
+
rescue StopIteration
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def enumerator(fn, init)
|
16
|
+
Enumerator.new do |y|
|
17
|
+
value = init
|
18
|
+
y << value
|
19
|
+
loop do
|
20
|
+
value = fn.(value)
|
21
|
+
y << value
|
22
|
+
end
|
23
|
+
end.lazy
|
24
|
+
end
|
25
|
+
|
26
|
+
def repeat_enumerator(value)
|
27
|
+
Enumerators.repeat_fn_enumerator(returns(value))
|
28
|
+
end
|
29
|
+
|
30
|
+
def repeat_fn_enumerator(fn)
|
31
|
+
Enumerator.new do |y|
|
32
|
+
loop do
|
33
|
+
y << fn.()
|
34
|
+
end
|
35
|
+
end.lazy
|
36
|
+
end
|
37
|
+
|
38
|
+
def character_enumerator(string)
|
39
|
+
Enumerator.new do |y|
|
40
|
+
index = 0
|
41
|
+
loop do
|
42
|
+
raise StopIteration.new unless index < string.size
|
43
|
+
y << string[index]
|
44
|
+
index = index + 1
|
45
|
+
end
|
46
|
+
end.lazy
|
47
|
+
end
|
48
|
+
|
49
|
+
def flatten_enumerator(enumerator)
|
50
|
+
Enumerator.new do |y|
|
51
|
+
current_enumerator = empty_enumerator
|
52
|
+
|
53
|
+
loop do
|
54
|
+
until has_next(current_enumerator)
|
55
|
+
unless has_next(enumerator)
|
56
|
+
current_enumerator = empty_enumerator
|
57
|
+
break
|
58
|
+
end
|
59
|
+
current_enumerator = enumerator.next.enumerator
|
60
|
+
end
|
61
|
+
|
62
|
+
if has_next(current_enumerator)
|
63
|
+
y << current_enumerator.next
|
64
|
+
else
|
65
|
+
raise StopIteration.new
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end.lazy
|
69
|
+
end
|
70
|
+
|
71
|
+
def empty_enumerator
|
72
|
+
[].lazy
|
73
|
+
end
|
74
|
+
end
|
data/lib/functions.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'concurrent/executors'
|
2
|
+
require 'concurrent/promise'
|
3
|
+
|
4
|
+
module Functions
|
5
|
+
def returns(value)
|
6
|
+
-> { value }
|
7
|
+
end
|
8
|
+
|
9
|
+
def identity
|
10
|
+
-> (a) { a }
|
11
|
+
end
|
12
|
+
|
13
|
+
def call_raises(e)
|
14
|
+
-> { raise e }
|
15
|
+
end
|
16
|
+
|
17
|
+
def call
|
18
|
+
->(fn) { fn.() }
|
19
|
+
end
|
20
|
+
|
21
|
+
def flip(fn)
|
22
|
+
->(a, b) { fn.(b, a) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def defer_return(fn)
|
26
|
+
->(value) { defer_apply(fn, value) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def defer_apply(fn, value)
|
30
|
+
->() { fn.(value) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def call_concurrently(sequence_of_fn)
|
34
|
+
pool = Concurrent::CachedThreadPool.new
|
35
|
+
begin
|
36
|
+
call_concurrently_with_pool(sequence_of_fn, pool)
|
37
|
+
ensure
|
38
|
+
pool.shutdown
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def call_concurrently_with_pool(sequence_of_fn, pool)
|
43
|
+
sequence_of_fn.
|
44
|
+
map(as_promise).
|
45
|
+
map(execute_with(pool)).
|
46
|
+
realise.
|
47
|
+
map(realise_promise)
|
48
|
+
end
|
49
|
+
|
50
|
+
def as_promise
|
51
|
+
-> (fn) {
|
52
|
+
Concurrent::Promise.new { fn.() }
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def execute_with(pool)
|
57
|
+
-> (promise) {
|
58
|
+
pool.post { promise.execute }
|
59
|
+
promise
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
def realise_promise
|
64
|
+
->(promise) { promise.value! }
|
65
|
+
end
|
66
|
+
end
|
data/lib/numbers.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Numbers
|
2
|
+
def sum
|
3
|
+
->(a, b) { a + b }
|
4
|
+
end
|
5
|
+
|
6
|
+
def even
|
7
|
+
remainder_is(2, 0)
|
8
|
+
end
|
9
|
+
|
10
|
+
def odd
|
11
|
+
remainder_is(2, 1)
|
12
|
+
end
|
13
|
+
|
14
|
+
def remainder_is(divisor, remainder)
|
15
|
+
->(dividend) { remainder(dividend, divisor) == remainder }
|
16
|
+
end
|
17
|
+
|
18
|
+
def remainder(dividend, divisor)
|
19
|
+
dividend % divisor
|
20
|
+
end
|
21
|
+
|
22
|
+
def range_from(start)
|
23
|
+
Sequence.new(Enumerators::enumerator(increment, start))
|
24
|
+
end
|
25
|
+
|
26
|
+
def range(from, to)
|
27
|
+
Sequence.new((from..to).lazy)
|
28
|
+
end
|
29
|
+
|
30
|
+
def increment
|
31
|
+
->(number) { number + 1 }
|
32
|
+
end
|
33
|
+
|
34
|
+
def mod(divisor)
|
35
|
+
->(number) { number % divisor }
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|