elixir.rb 0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 15fb2272872a876e03b59892cfb9d9cced68d84d
4
+ data.tar.gz: 333f401ceba52b483d13b4e1c461e06efe7c5b91
5
+ SHA512:
6
+ metadata.gz: fd7906c50277830fca9aecccfbeea3aa0080f1b641f3391681b0adbcb827a8ea82ab215eb6538d46fa7829bf2d52f3e3a48499bcdc9fd3a886851b9de4b438e8
7
+ data.tar.gz: 3468e8bcc516a445b4d44cd9ed3fee8d2d8a20dced5b59b6e9df9db13b2b96461235c0ed651766f16fddc19eb95f47647023c0b544024bb929d4a4f99feded96
@@ -0,0 +1,7 @@
1
+ /coverage/
2
+ /doc/
3
+ /gem.deps.rb.lock
4
+ /pkg/
5
+ /tmp/
6
+ /_yardoc/
7
+ /.yardoc
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem i -g --no-lock
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.0.0 (2015-06-26)
4
+
5
+ * Primordial ooze
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2015 Shannon Skipper
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ # Elixir.rb
2
+
3
+ The Elixir standard library implemented in Ruby. This is currently just a code spike that implements parts of Enum and Stream.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ gem install elixir.rb
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ruby
14
+ require 'elixir/stream'
15
+
16
+ include Elixir
17
+
18
+ Fib = Stream.unfold [0, 1] do |a, b|
19
+ [a, [b, a + b]]
20
+ end
21
+
22
+ Fib.take 5
23
+ #=> [0, 1, 1, 2, 3]
24
+ ```
25
+
26
+ ```ruby
27
+ require 'elixir/enum'
28
+
29
+ include Elixir
30
+
31
+ Enum.filter [1, 2, 3], &:odd?
32
+ #=> [1, 3]
33
+ ```
34
+
35
+ ## Development
36
+
37
+ Install Elixir.rb and its deps:
38
+ ```bash
39
+ git clone https://github.com/havenwood/elixir.rb
40
+ cd elixir.rb
41
+ gem install -g --no-lock
42
+ ```
43
+
44
+ Run the tests:
45
+ ```bash
46
+ rake
47
+ ```
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new :test do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path '../lib', File.basename(__FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'elixir/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'elixir.rb'
8
+ gem.version = Elixir::VERSION
9
+ gem.author = 'Shannon Skipper'
10
+ gem.license = 'MIT'
11
+ gem.email = ['shannonskipper@gmail.com']
12
+
13
+ gem.summary = 'The Elixir standard library implemented in Ruby. This is currently just a code spike with parts of Enum and Stream.'
14
+ gem.description = 'A Ruby implementation of part of the Elixir standard library.'
15
+ gem.homepage = 'https://github.com/havenwood/elixir.rb'
16
+
17
+ gem.files = `git ls-files -z`.split("\x0").reject { |path| path.start_with? 'test' }
18
+ gem.require_paths = ['lib']
19
+
20
+ gem.add_development_dependency 'rake', '~> 10.0'
21
+ gem.add_development_dependency 'minitest', '~> 5.7'
22
+ end
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,6 @@
1
+ require 'elixir/enum'
2
+ require 'elixir/stream'
3
+ require 'elixir/version'
4
+
5
+ module Elixir
6
+ end
@@ -0,0 +1,191 @@
1
+ module Elixir
2
+ module Enum
3
+ module_function
4
+
5
+ def all? collection, &block
6
+ collection.all? &block
7
+ end
8
+
9
+ def any? collection, &block
10
+ collection.any? &block
11
+ end
12
+
13
+ def at collection, index, default = nil
14
+ collection.first(index.next)[index] || default
15
+ end
16
+
17
+ def chunk collection, n, step: nil, pad: nil
18
+ end
19
+
20
+ def chunk_by collection, &block
21
+ collection.chunk(&block).map(&:last).to_a
22
+ end
23
+
24
+ def concat *collections
25
+ collections.inject :concat
26
+ end
27
+
28
+ def count collection, &block
29
+ collection.count &block
30
+ end
31
+
32
+ def drop collection, count
33
+ collection.drop count
34
+ end
35
+
36
+ def drop_while collection, &block
37
+ collection.drop_while &block
38
+ end
39
+
40
+ def empty? collection
41
+ collection.empty?
42
+ end
43
+
44
+ def fetch collection, n
45
+ end
46
+
47
+ def fetch! collection, n
48
+ end
49
+
50
+ def filter collection, &block
51
+ collection.select &block
52
+ end
53
+
54
+ def filter_map collection, filter, mapper
55
+ end
56
+
57
+ def find collection, ifnone = nil, &block
58
+ collection.find ifnone, &block
59
+ end
60
+
61
+ def find_index collection, &block
62
+ end
63
+
64
+ def find_value collection, ifnone = nil, &block
65
+ end
66
+
67
+ def flat_map collection, &block
68
+ collection.flat_map &block
69
+ end
70
+
71
+ def flat_map_reduce collection, acc, &block
72
+ end
73
+
74
+ def group_by collection, dict = {}, &block
75
+ end
76
+
77
+ def intersperse collection, element
78
+ end
79
+
80
+ def into collection, list, transform = nil
81
+ end
82
+
83
+ def join collection, joiner = ''
84
+ collection.join joiner
85
+ end
86
+
87
+ def map collection, &block
88
+ collection.map &block
89
+ end
90
+
91
+ def map_join collection, joiner = '', &block
92
+ end
93
+
94
+ def map_reduce collection, acc, &block
95
+ end
96
+
97
+ def max collection
98
+ collection.max
99
+ end
100
+
101
+ def max_by collection, &block
102
+ end
103
+
104
+ def member? collection, value
105
+ collection.member? value
106
+ end
107
+
108
+ def min collection
109
+ collection.min
110
+ end
111
+
112
+ def min_by collection, &block
113
+ collection.min_by &block
114
+ end
115
+
116
+ def partition collection, &block
117
+ collection.partition &block
118
+ end
119
+
120
+ def reduce collection, acc = nil, &block
121
+ collection.reduce acc, &block
122
+ end
123
+
124
+ def reject collection, &block
125
+ collection.reject &block
126
+ end
127
+
128
+ def reverse collection, tail = nil
129
+ if tail
130
+ collection.reverse << tail
131
+ else
132
+ collection.reverse
133
+ end
134
+ end
135
+
136
+ def scan collection, acc = 0, &block
137
+ end
138
+
139
+ def shuffle collection
140
+ collection.shuffle
141
+ end
142
+
143
+ def slice collection, x, count = nil
144
+ end
145
+
146
+ def sort collection, &block
147
+ collection.sort &block
148
+ end
149
+
150
+ def sort_by collection, mapper, sorter = nil
151
+ end
152
+
153
+ def split collection, count
154
+
155
+ end
156
+
157
+ def split_while collection, &block
158
+ end
159
+
160
+ def sum collection
161
+ collection.inject :+
162
+ end
163
+
164
+ def take collection, count
165
+ collection.take count
166
+ end
167
+
168
+ def take_every collection, nth
169
+ collection.step by: nth
170
+ end
171
+
172
+ def take_while collection, &block
173
+ end
174
+
175
+ def to_list collection
176
+ collection.to_a
177
+ end
178
+
179
+ def uniq collection, &block
180
+ collection.uniq &block
181
+ end
182
+
183
+ def with_index collection
184
+ collection.each_with_index.to_a
185
+ end
186
+
187
+ def zip collection1, collection2
188
+ collection1.zip collection2
189
+ end
190
+ end
191
+ end
@@ -0,0 +1,51 @@
1
+ module Elixir
2
+ module Stream
3
+ module_function
4
+
5
+ def cycle collection
6
+ collection.cycle
7
+ end
8
+
9
+ def interval milliseconds
10
+ Enumerator.new Float::INFINITY do |yielder|
11
+ 0.upto Float::INFINITY do |n|
12
+ sleep milliseconds.fdiv 1000
13
+ yielder << n
14
+ end
15
+ end
16
+ end
17
+
18
+ def iterate value
19
+ Enumerator.new Float::INFINITY do |yielder|
20
+ loop do
21
+ yielder << value
22
+ value = yield value
23
+ end
24
+ end
25
+ end
26
+
27
+ def repeatedly
28
+ Enumerator.new Float::INFINITY do |yielder|
29
+ loop do
30
+ yielder << yield
31
+ end
32
+ end
33
+ end
34
+
35
+ def timer milliseconds
36
+ Enumerator.new 1 do |yielder|
37
+ sleep milliseconds.fdiv 1000
38
+ yielder << 0
39
+ end
40
+ end
41
+
42
+ def unfold tuple
43
+ Enumerator.new Float::INFINITY do |yielder|
44
+ loop do
45
+ value, tuple = yield tuple
46
+ yielder << value
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module Elixir
2
+ VERSION = '0.0.0'
3
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: elixir.rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Shannon Skipper
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '10.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '10.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.7'
41
+ description: A Ruby implementation of part of the Elixir standard library.
42
+ email:
43
+ - shannonskipper@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - CHANGELOG.md
51
+ - MIT-LICENSE
52
+ - README.md
53
+ - Rakefile
54
+ - elixir.rb.gemspec
55
+ - gem.deps.rb
56
+ - lib/elixir.rb
57
+ - lib/elixir/enum.rb
58
+ - lib/elixir/stream.rb
59
+ - lib/elixir/version.rb
60
+ homepage: https://github.com/havenwood/elixir.rb
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.4.8
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: The Elixir standard library implemented in Ruby. This is currently just a
84
+ code spike with parts of Enum and Stream.
85
+ test_files: []
86
+ has_rdoc: