julializer 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b642dd1c03b8303e02dc986ef75b05e734310ed
4
- data.tar.gz: c8e5c67d459b55cd43931fe89c668321196ca473
3
+ metadata.gz: f2eafa218bf1e418f652fb5e8191cd253c03301e
4
+ data.tar.gz: 716d951cc59df3a550f105db450164f84a9d30cd
5
5
  SHA512:
6
- metadata.gz: ba346042cb89c7ff9ff2e90b0a2100e897f59ce672f30ac41edcb4fc8a4b88e30353d4097bcb94236ba087645d46b06a01489c5dfbfbd933b1115474417dcd1e
7
- data.tar.gz: d8d2be6a6149114f545c54b415dce47e717f3662e1658b464a8c8dd58096a0ffddbfce3a734761d4856c4caf28a618cbbedcecade620f35a890964fa90ae5c68
6
+ metadata.gz: 8f7464bbd386b33c54d66564aafb82483c20b0c6e435e69fbbbae5685900da5de710a43690518d5d0b81a3fe56811b5e851fdf5af0aa4c8cde9bb9ce4cbfd001
7
+ data.tar.gz: 99bf7cba19f82330748942697393fac2477a2937791108c6646fab4cca262996bbd63cfb78eae3b97cc073f44cf4769f6698534e9157d578e622bb64008b994e
data/README.md CHANGED
@@ -1,7 +1,64 @@
1
- A ruby2julia transpiler made with ❤️:
1
+ A ruby2julia transpiler made with ❤️.
2
2
 
3
- ## Limitation And Restrictions
4
- TBD
3
+ ## Requirement
4
+
5
+ Ruby(MRI) 1.9.3 and up
6
+
7
+ ## Installation
8
+
9
+ ```
10
+ $ gem install julializer
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ From your codebase:
16
+
17
+ ```
18
+ require 'julializer'
19
+ Julializer.ruby2julia("3.5.round") # round(Int64,3.5)
20
+ ```
21
+
22
+ Available from CLI too:
23
+
24
+ ```
25
+ $ echo echo -1.6.to_i | julializer
26
+ trunc(Int64,parse(string((-1.6))));
27
+ $ cat sample.rb
28
+ for i in 0..list.size-1
29
+ list[i] = (i-list.size/2).abs
30
+ end
31
+ $ julializer sample.rb
32
+ for i::Int64 = 0:size(list)[1]-1;list[i+1]=abs((i-size(list)[1]/2));;end;;
33
+ ```
34
+
35
+ ## Supported Classes and Syntax
36
+
37
+ As of v0.1.0, very limited number of classes and methods are supported as shown below.
38
+
39
+ - Supported Classes
40
+ * Most methods are available
41
+ * TrueClass, FalseClass, Fixnum, Float, integer, Numeric, Random
42
+ * Very limited methods are available
43
+ * Array, Range, Hash
44
+ - Supported Modules
45
+ * Math
46
+ - Supported Syntax
47
+ * `def`
48
+ * `while`, `next`, `for`, `if..elsif..end`
49
+ * global variable, constant
50
+
51
+ But there are very many differences between Ruby and Julia which I have no idea how to fix as of now. For example:
52
+
53
+ - Julia doesn't have Class concept(there is workaround though) but Ruby does
54
+ - [Julia does not have a "null" value](http://docs.julialang.org/en/release-0.4/manual/faq/#how-does-null-or-nothingness-work-in-julia) but Ruby does
55
+ * For example in Ruby `[1,2,3].slice!(4)` will return null but in julia there is no nil therefore this raises causes error.
56
+ * Current workaround for this is, do not write this way, instead you need to check boundary by yourself.
57
+ - And many more gaps to be solved
58
+ * e.g.) In Julia `typemax()` and `typemin()` returns Inf but in Ruby `Float::MAX`, `Float::MIN` have specific value
59
+
60
+ For more information about what methods are available in detail, I'm still on a way to write spec and documentation. If anyone out there would want it early, it'd be more than helpful if you can join us by opening new issues for example. Your contribution is more than welcome all the time.
5
61
 
6
62
  ## License
63
+
7
64
  MIT
@@ -1,3 +1,3 @@
1
1
  module Julializer
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/julializer.rb CHANGED
@@ -297,6 +297,10 @@ module Julializer
297
297
  end
298
298
  when "index"
299
299
  "findfirst(#{transpile(s[1][1])}, #{transpile(s[2])})"
300
+ when "to_s"
301
+ "base(#{transpile(s[2])}, #{transpile(s[1][1])})"
302
+ when "to_i"
303
+ "parse(Int, #{transpile(s[1][1])}, #{transpile(s[2])})"
300
304
  when "rindex"
301
305
  "findlast(#{transpile(s[1][1])}, #{transpile(s[2])})"
302
306
  when "div"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: julializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kei Sawada(@remore)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-23 00:00:00.000000000 Z
11
+ date: 2016-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake