elixir.rb 0.0.0 → 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/CHANGELOG.md +21 -2
- data/README.md +51 -5
- data/Rakefile +0 -1
- data/elixir.rb.gemspec +10 -6
- data/lib/elixir.rb +16 -0
- data/lib/elixir/agent.rb +42 -0
- data/lib/elixir/atom.rb +13 -0
- data/lib/elixir/base.rb +99 -0
- data/lib/elixir/dict.rb +87 -0
- data/lib/elixir/enum.rb +29 -5
- data/lib/elixir/file.rb +17 -0
- data/lib/elixir/float.rb +34 -0
- data/lib/elixir/integer.rb +31 -0
- data/lib/elixir/list.rb +121 -0
- data/lib/elixir/option_parser.rb +91 -0
- data/lib/elixir/path.rb +29 -0
- data/lib/elixir/range.rb +13 -0
- data/lib/elixir/set.rb +49 -0
- data/lib/elixir/stream.rb +9 -5
- data/lib/elixir/string.rb +154 -0
- data/lib/elixir/system.rb +91 -0
- data/lib/elixir/task.rb +30 -0
- data/lib/elixir/tuple.rb +23 -0
- data/lib/elixir/version.rb +32 -1
- metadata +74 -7
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'etc'
|
3
|
+
|
4
|
+
module Elixir
|
5
|
+
module System
|
6
|
+
module_function
|
7
|
+
|
8
|
+
def argv
|
9
|
+
ARGV
|
10
|
+
end
|
11
|
+
|
12
|
+
def argv= new_argv
|
13
|
+
Object.const_set :ARGV, new_argv
|
14
|
+
end
|
15
|
+
|
16
|
+
def at_exit fun
|
17
|
+
at_exit &fun
|
18
|
+
end
|
19
|
+
|
20
|
+
def build_info
|
21
|
+
version = RUBY_VERSION
|
22
|
+
date = Date.parse(RUBY_RELEASE_DATE).rfc2822
|
23
|
+
|
24
|
+
{version: version, date: date}.inspect
|
25
|
+
end
|
26
|
+
|
27
|
+
def cmd command, args, opts = []
|
28
|
+
# TODO
|
29
|
+
end
|
30
|
+
|
31
|
+
def cwd
|
32
|
+
Dir.pwd rescue nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def cwd!
|
36
|
+
Dir.pwd
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete_env varname
|
40
|
+
ENV.delete varname
|
41
|
+
end
|
42
|
+
|
43
|
+
def find_executable program
|
44
|
+
# TODO
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_env varname
|
48
|
+
ENV[varname]
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_pid
|
52
|
+
Process.pid.to_s
|
53
|
+
end
|
54
|
+
|
55
|
+
def halt status = 0
|
56
|
+
exit status
|
57
|
+
end
|
58
|
+
|
59
|
+
def put_env varname, value
|
60
|
+
ENV[varname] = value
|
61
|
+
end
|
62
|
+
|
63
|
+
def put_envs hash
|
64
|
+
hash.each { |varname, value| ENV[varname] = value }
|
65
|
+
end
|
66
|
+
|
67
|
+
def stacktrace
|
68
|
+
caller_locations
|
69
|
+
end
|
70
|
+
|
71
|
+
def tmp_dir
|
72
|
+
Dir.tmpdir rescue nil
|
73
|
+
end
|
74
|
+
|
75
|
+
def tmp_dir!
|
76
|
+
Dir.tmpdir
|
77
|
+
end
|
78
|
+
|
79
|
+
def user_home
|
80
|
+
Dir.home(Etc.getlogin) rescue nil
|
81
|
+
end
|
82
|
+
|
83
|
+
def user_home!
|
84
|
+
Dir.home Etc.getlogin
|
85
|
+
end
|
86
|
+
|
87
|
+
def version
|
88
|
+
RUBY_VERSION
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/lib/elixir/task.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'concurrent/async'
|
2
|
+
require 'concurrent/executor/fixed_thread_pool'
|
3
|
+
|
4
|
+
module Elixir
|
5
|
+
module Task
|
6
|
+
POOL = Concurrent::FixedThreadPool.new Concurrent.processor_count + 2
|
7
|
+
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def async fun
|
11
|
+
fun.extend Concurrent::Async
|
12
|
+
fun.init_mutex
|
13
|
+
|
14
|
+
fun.async.call
|
15
|
+
end
|
16
|
+
|
17
|
+
def await task, timeout = 5000
|
18
|
+
value = task.value timeout / 1000
|
19
|
+
task.fail && raise(StandardError, 'time out') if task.pending?
|
20
|
+
|
21
|
+
value
|
22
|
+
end
|
23
|
+
|
24
|
+
def start fun
|
25
|
+
POOL << fun
|
26
|
+
end
|
27
|
+
|
28
|
+
# TODO: Explain Ruby implementation limitations and add other Task module functions.
|
29
|
+
end
|
30
|
+
end
|
data/lib/elixir/tuple.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Elixir
|
2
|
+
module Tuple
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def delete_at array, index
|
6
|
+
array.delete_at index
|
7
|
+
|
8
|
+
array
|
9
|
+
end
|
10
|
+
|
11
|
+
def duplicate data, size
|
12
|
+
Array.new size, data
|
13
|
+
end
|
14
|
+
|
15
|
+
def insert_at array, index, value
|
16
|
+
array.insert index, value
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_list array
|
20
|
+
array.to_a
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/elixir/version.rb
CHANGED
@@ -1,3 +1,34 @@
|
|
1
1
|
module Elixir
|
2
|
-
VERSION = '0.
|
2
|
+
VERSION = '0.1.0'
|
3
|
+
|
4
|
+
module Version
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def compare version1, version2
|
8
|
+
case Gem::Version.new(version1) <=> Gem::Version.new(version2)
|
9
|
+
when 1
|
10
|
+
:gt
|
11
|
+
when 0
|
12
|
+
:eq
|
13
|
+
when -1
|
14
|
+
:lt
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def match? version, requirement
|
19
|
+
Gem::Dependency.new('', requirement).match? '', version
|
20
|
+
end
|
21
|
+
|
22
|
+
def parse version
|
23
|
+
[:ok, Gem::Version.new(version)]
|
24
|
+
rescue
|
25
|
+
:error
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse_requirements string
|
29
|
+
[:ok, Gem::Requirement.new(string)]
|
30
|
+
rescue
|
31
|
+
:error
|
32
|
+
end
|
33
|
+
end
|
3
34
|
end
|
metadata
CHANGED
@@ -1,29 +1,75 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elixir.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shannon Skipper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: base32
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.3'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.3.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.3'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.3.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: concurrent-ruby
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.8'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.8.0
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.8'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.8.0
|
13
53
|
- !ruby/object:Gem::Dependency
|
14
54
|
name: rake
|
15
55
|
requirement: !ruby/object:Gem::Requirement
|
16
56
|
requirements:
|
17
57
|
- - "~>"
|
18
58
|
- !ruby/object:Gem::Version
|
19
|
-
version: '10.
|
59
|
+
version: '10.4'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 10.4.2
|
20
63
|
type: :development
|
21
64
|
prerelease: false
|
22
65
|
version_requirements: !ruby/object:Gem::Requirement
|
23
66
|
requirements:
|
24
67
|
- - "~>"
|
25
68
|
- !ruby/object:Gem::Version
|
26
|
-
version: '10.
|
69
|
+
version: '10.4'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 10.4.2
|
27
73
|
- !ruby/object:Gem::Dependency
|
28
74
|
name: minitest
|
29
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,6 +77,9 @@ dependencies:
|
|
31
77
|
- - "~>"
|
32
78
|
- !ruby/object:Gem::Version
|
33
79
|
version: '5.7'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 5.7.0
|
34
83
|
type: :development
|
35
84
|
prerelease: false
|
36
85
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,7 +87,10 @@ dependencies:
|
|
38
87
|
- - "~>"
|
39
88
|
- !ruby/object:Gem::Version
|
40
89
|
version: '5.7'
|
41
|
-
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 5.7.0
|
93
|
+
description: An implementation of parts of the Elixir standard library in Ruby.
|
42
94
|
email:
|
43
95
|
- shannonskipper@gmail.com
|
44
96
|
executables: []
|
@@ -54,8 +106,24 @@ files:
|
|
54
106
|
- elixir.rb.gemspec
|
55
107
|
- gem.deps.rb
|
56
108
|
- lib/elixir.rb
|
109
|
+
- lib/elixir/agent.rb
|
110
|
+
- lib/elixir/atom.rb
|
111
|
+
- lib/elixir/base.rb
|
112
|
+
- lib/elixir/dict.rb
|
57
113
|
- lib/elixir/enum.rb
|
114
|
+
- lib/elixir/file.rb
|
115
|
+
- lib/elixir/float.rb
|
116
|
+
- lib/elixir/integer.rb
|
117
|
+
- lib/elixir/list.rb
|
118
|
+
- lib/elixir/option_parser.rb
|
119
|
+
- lib/elixir/path.rb
|
120
|
+
- lib/elixir/range.rb
|
121
|
+
- lib/elixir/set.rb
|
58
122
|
- lib/elixir/stream.rb
|
123
|
+
- lib/elixir/string.rb
|
124
|
+
- lib/elixir/system.rb
|
125
|
+
- lib/elixir/task.rb
|
126
|
+
- lib/elixir/tuple.rb
|
59
127
|
- lib/elixir/version.rb
|
60
128
|
homepage: https://github.com/havenwood/elixir.rb
|
61
129
|
licenses:
|
@@ -80,7 +148,6 @@ rubyforge_project:
|
|
80
148
|
rubygems_version: 2.4.8
|
81
149
|
signing_key:
|
82
150
|
specification_version: 4
|
83
|
-
summary: The Elixir standard library
|
84
|
-
code spike with parts of Enum and Stream.
|
151
|
+
summary: The Elixir standard library in Ruby.
|
85
152
|
test_files: []
|
86
153
|
has_rdoc:
|