ex 0.1.0 → 0.2.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
- SHA1:
3
- metadata.gz: 985df3343e3d3035ff180d128197b956fbdc9fc3
4
- data.tar.gz: 3eb74ecb972858652b1333ddb051bf5f5e226c0f
2
+ SHA256:
3
+ metadata.gz: 41d8743c3322fc70e78f190651ebf1a530d5b4c1be1b1a4ff119a88e96123e52
4
+ data.tar.gz: 3748f9bdf62a2dc104b23248cea6717104d68c1a8011485368272bed58b2eebf
5
5
  SHA512:
6
- metadata.gz: 76348c1c94c5d4ce75b806c67b2de4df6d1d28f08deaf2ad5d586c312f7194af2565c70c9c512a3af1803fda04ec3badc9338bb14e8aa56df1118f5dcfd0567c
7
- data.tar.gz: ef0aa28f09086759d4d6d23c3b9ea6d7ec2caf4e8e13aa51887f406ee89c54ae62b9e7628549650a6753006836d4627e59bb3037d357806cf19cb7cf0addbcd2
6
+ metadata.gz: 9e3a26414b1079eb617d561d71d667d1f3d9db54263b4defa621f2bb0e7a0c4d0b0f566667f011aced76f06e295f7ee42738da308b748f2d541748333569115e
7
+ data.tar.gz: 547a75ed5f8d82f2855ee2429fa39d404845143339efc23f67d73507c17768b934d9a20d086af27e7cd720b8967ca14ef8b626ff111e4f9dc6c5f4ed948b8e12
data/README.md CHANGED
@@ -1,8 +1,15 @@
1
1
  # Ex
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ex`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ An attempt to make Ruby look like Elixir.
4
+ Without abiding by any rules.
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
+ ## FAQ
7
+
8
+ Q: Why?
9
+ A: No reason.
10
+
11
+ Q: What practical application does this have?
12
+ A: None.
6
13
 
7
14
  ## Installation
8
15
 
@@ -22,7 +29,18 @@ Or install it yourself as:
22
29
 
23
30
  ## Usage
24
31
 
25
- TODO: Write usage instructions here
32
+ ```
33
+ require "elixir"
34
+
35
+ defmodule MyModule do
36
+ dẹf hello do
37
+ "world"
38
+ end
39
+ end
40
+
41
+ MyModule.hello
42
+ => "world"
43
+ ```
26
44
 
27
45
  ## Development
28
46
 
@@ -34,7 +52,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
34
52
 
35
53
  Bug reports and pull requests are welcome on GitHub at https://github.com/elliotthilaire/ex.
36
54
 
37
-
38
55
  ## License
39
56
 
40
57
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/ex.gemspec CHANGED
@@ -9,8 +9,14 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Elliott Hilaire"]
10
10
  spec.email = ["elliott.hilaire@gmail.com"]
11
11
 
12
- spec.summary = "Coming soon."
13
- spec.description = "A gem that is coming soon"
12
+ spec.summary = "An experiment to make Ruby look like Elixir without abiding by any rules."
13
+ spec.description = "
14
+ Q: Why?
15
+ A: No reason.
16
+
17
+ Q: What practical application does this have?
18
+ A: None.
19
+ "
14
20
  spec.homepage = "https://github.com/elliotthilaire/ex"
15
21
  spec.license = "MIT"
16
22
 
data/lib/elixir.rb ADDED
@@ -0,0 +1 @@
1
+ require "ex"
@@ -0,0 +1,67 @@
1
+ class UndefinedFunctionError < StandardError
2
+ end
3
+
4
+ class Object
5
+ def defmodule(name, &block)
6
+ eval("#{name.to_s} = Module.new()")
7
+
8
+ m = Kernel.const_get(name.to_s)
9
+
10
+ m.class_eval do
11
+ def method_missing(m_missing_name, *m_missing_args, &m_missing_block)
12
+ [m_missing_name, m_missing_args, m_missing_block]
13
+ end
14
+
15
+ module_function :method_missing
16
+ end
17
+
18
+ m.class_variable_set(:@@public_functions, {})
19
+ m.class_variable_set(:@@current_arg_values, [])
20
+ m.class_variable_set(:@@current_arg_names, [])
21
+
22
+ m.class_eval do
23
+ def defP(ast, &block)
24
+ function_name = ast[0]
25
+ arg_names = ast[1].map {|list| list[0]}
26
+ arity = arg_names.size
27
+
28
+ p = self.class_variable_get(:@@public_functions)
29
+ p[{name: function_name, arity: arity}] = {args: arg_names, proc: block}
30
+ p = self.class_variable_set(:@@public_functions, p)
31
+ end
32
+
33
+ m.class_eval do
34
+ def method_missing(m_missing_name, *m_missing_args, &m_missing_block)
35
+
36
+ if f = self.class_variable_get(:@@public_functions)[{name: m_missing_name, arity: m_missing_args.size}]
37
+ self.class_variable_set(:@@current_arg_values, m_missing_args)
38
+ self.class_variable_set(:@@current_arg_names, f[:args])
39
+
40
+ f[:proc].call
41
+ elsif index = self.class_variable_get(:@@current_arg_names).find_index(m_missing_name)
42
+ self.class_variable_get(:@@current_arg_values)[index]
43
+ else
44
+ raise UndefinedFunctionError
45
+ end
46
+ end
47
+ end
48
+
49
+ alias_method :dẹf, :defP
50
+
51
+ module_function :defP, :dẹf
52
+ end
53
+
54
+ m.class_eval(&block)
55
+
56
+ eval("
57
+ module #{m}
58
+ module_function #{m.instance_methods.map(&:to_s).map {|t| ':' + t }.join(', ')}
59
+ end
60
+ ")
61
+
62
+ end
63
+
64
+ def self.const_missing(name)
65
+ name
66
+ end
67
+ end
data/lib/ex/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ex
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/ex.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "ex/version"
2
+ require "ex/defmodule"
2
3
 
3
4
  module Ex
4
5
  # Your code goes here...
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliott Hilaire
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-28 00:00:00.000000000 Z
11
+ date: 2019-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,8 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
- description: A gem that is coming soon
55
+ description: "\n Q: Why?\n A: No reason.\n\n Q: What practical application
56
+ does this have?\n A: None.\n "
56
57
  email:
57
58
  - elliott.hilaire@gmail.com
58
59
  executables: []
@@ -68,7 +69,9 @@ files:
68
69
  - bin/console
69
70
  - bin/setup
70
71
  - ex.gemspec
72
+ - lib/elixir.rb
71
73
  - lib/ex.rb
74
+ - lib/ex/defmodule.rb
72
75
  - lib/ex/version.rb
73
76
  homepage: https://github.com/elliotthilaire/ex
74
77
  licenses:
@@ -90,9 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
93
  version: '0'
91
94
  requirements: []
92
95
  rubyforge_project:
93
- rubygems_version: 2.6.8
96
+ rubygems_version: 2.7.6
94
97
  signing_key:
95
98
  specification_version: 4
96
- summary: Coming soon.
99
+ summary: An experiment to make Ruby look like Elixir without abiding by any rules.
97
100
  test_files: []
98
- has_rdoc: