julializer 0.1.1 → 0.1.2
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 +4 -4
 - data/bin/julializer +12 -10
 - data/lib/julializer/version.rb +1 -1
 - data/lib/julializer.rb +12 -6
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 70d8479457b323508c5464e36655e5114bd27d5a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: cc5e118fd88d913e8d6e8ebec309d640c5cacf71
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a252661e9addce63fd307b232612f104936dd8a586a9d531d557eee1ea38f8cac733b1a1a87b2a51c08032bb1edc561e39c2abf7ab8f641ef44efb7a3bf3a21d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 43ca600965fc6f7847107152aceb5852fb3e5b4a2bfbc31ee684a915bce569bec90fd58a17744e2eeff1a060bb575a43e6fda9c5575e26ba3cbad758f4ee3660
         
     | 
    
        data/bin/julializer
    CHANGED
    
    | 
         @@ -2,20 +2,22 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require 'optparse'
         
     | 
| 
       3 
3 
     | 
    
         
             
            require 'julializer'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
      
 5 
     | 
    
         
            +
            config = {}
         
     | 
| 
       5 
6 
     | 
    
         
             
            Options = OptionParser.new do |opts|
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
              opts.on("-v", "--version", "Print version") { |v| puts Julializer::VERSION; exit 0}
         
     | 
| 
      
 8 
     | 
    
         
            +
              opts.on("-n", "--nullable", "Allow nil(Nullable) conversion") { |v| config[:nullable] = true}
         
     | 
| 
       7 
9 
     | 
    
         
             
            end
         
     | 
| 
       8 
10 
     | 
    
         
             
            Options.parse!(ARGV)
         
     | 
| 
       9 
11 
     | 
    
         | 
| 
       10 
12 
     | 
    
         
             
            if ARGV.empty?
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
              printf Julializer.ruby2julia($stdin.read, config)
         
     | 
| 
       12 
14 
     | 
    
         
             
            else
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
              ARGV.each do |file|
         
     | 
| 
      
 16 
     | 
    
         
            +
                if File.exist? file
         
     | 
| 
      
 17 
     | 
    
         
            +
                  printf Julializer.ruby2julia(File.read(file), config)
         
     | 
| 
      
 18 
     | 
    
         
            +
                else
         
     | 
| 
      
 19 
     | 
    
         
            +
                  puts "File was not found: #{file}"
         
     | 
| 
      
 20 
     | 
    
         
            +
                  exit
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
       21 
23 
     | 
    
         
             
            end
         
     | 
    
        data/lib/julializer/version.rb
    CHANGED
    
    
    
        data/lib/julializer.rb
    CHANGED
    
    | 
         @@ -4,8 +4,11 @@ module Julializer 
     | 
|
| 
       4 
4 
     | 
    
         
             
              class << self
         
     | 
| 
       5 
5 
     | 
    
         
             
                require "julializer/version"
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
                def ruby2julia(source)
         
     | 
| 
      
 7 
     | 
    
         
            +
                def ruby2julia(source, config={})
         
     | 
| 
       8 
8 
     | 
    
         
             
                  @globals = []
         
     | 
| 
      
 9 
     | 
    
         
            +
                  {:nullable=>false}.each do |k,v|
         
     | 
| 
      
 10 
     | 
    
         
            +
                    instance_variable_set("@#{k}", config[k] || v)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  end
         
     | 
| 
       9 
12 
     | 
    
         
             
                  #File.write("./__julialize_debug.log", Ripper.sexp(source).pretty_inspect)
         
     | 
| 
       10 
13 
     | 
    
         
             
                  transpile(Ripper.sexp(source))
         
     | 
| 
       11 
14 
     | 
    
         
             
                end
         
     | 
| 
         @@ -394,17 +397,20 @@ module Julializer 
     | 
|
| 
       394 
397 
     | 
    
         
             
                        "#{transpile(s[1])}:#{transpile(s[2])}"
         
     | 
| 
       395 
398 
     | 
    
         | 
| 
       396 
399 
     | 
    
         
             
                      when :aref, :aref_field
         
     | 
| 
      
 400 
     | 
    
         
            +
                        aref_string = ->(type, list, index){
         
     | 
| 
      
 401 
     | 
    
         
            +
                          # using #get function for Nullable compatible access
         
     | 
| 
      
 402 
     | 
    
         
            +
                          type==:aref && @nullable ? "get(#{list}, #{index}, Nullable)" : list + "[#{index}]"
         
     | 
| 
      
 403 
     | 
    
         
            +
                        }
         
     | 
| 
       397 
404 
     | 
    
         
             
                        if !s[2].flatten.include?(:dot2) && !s[2].flatten.include?(:dot3) && s[2][1][0][0]!=:string_literal then
         
     | 
| 
       398 
     | 
    
         
            -
                          transpile(s[1])  
     | 
| 
      
 405 
     | 
    
         
            +
                          aref_string.call(s[0], transpile(s[1]), transpile(s[2])+"+1")
         
     | 
| 
       399 
406 
     | 
    
         
             
                        else
         
     | 
| 
       400 
407 
     | 
    
         
             
                          if s[2].flatten.include?(:dot2)
         
     | 
| 
       401 
     | 
    
         
            -
                             
     | 
| 
      
 408 
     | 
    
         
            +
                            transpile(s[1]) + "[#{transpile(s[2][1][0][1])}+1:#{transpile(s[2][1][0][2])}+1]"
         
     | 
| 
       402 
409 
     | 
    
         
             
                          elsif s[2].flatten.include?(:dot3)
         
     | 
| 
       403 
     | 
    
         
            -
                             
     | 
| 
      
 410 
     | 
    
         
            +
                            transpile(s[1]) + "[#{transpile(s[2][1][0][1])}+1:#{transpile(s[2][1][0][2])}]"
         
     | 
| 
       404 
411 
     | 
    
         
             
                          else
         
     | 
| 
       405 
     | 
    
         
            -
                             
     | 
| 
      
 412 
     | 
    
         
            +
                            aref_string.call(s[0], transpile(s[1]), transpile(s[2]))
         
     | 
| 
       406 
413 
     | 
    
         
             
                          end
         
     | 
| 
       407 
     | 
    
         
            -
                          transpile(s[1]) + "[" + range + "]"
         
     | 
| 
       408 
414 
     | 
    
         
             
                        end
         
     | 
| 
       409 
415 
     | 
    
         | 
| 
       410 
416 
     | 
    
         
             
                      when :const_path_ref
         
     | 
    
        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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.2
         
     | 
| 
       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- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-09-12 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rake
         
     |