nodo 1.6.4 → 1.6.5
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/README.md +44 -36
 - data/lib/nodo/core.rb +1 -1
 - data/lib/nodo/version.rb +1 -1
 - metadata +10 -10
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 85e8ece889660e457a3473919da402124d9688011c3dbe5f69015e9f5e258465
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 32ed8d2c1905c22cc68cf2734272f0d743890be066add8ce8de1a72132c6c3f4
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 1c6a6af11b36730dae8bc00d31a17a96f0fbe0fe3a5ddc3da5df636efcdc648a6890e37aee63c7f0b67fc000ce354247eaa61cde12557eb9a3126b6cd0d9a291
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: b12074e9a1312694fcb46246eb2d66d418054b3f518be6dc5b2469a908b8b7e35d55d4a30b77144005b2b898c193ed062473ee4916239022c9d32361a5e324c4
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            []( 
     | 
| 
      
 1 
     | 
    
         
            +
            [](https://badge.fury.io/rb/nodo)
         
     | 
| 
       2 
2 
     | 
    
         
             
            [](https://github.com/mtgrosser/nodo/actions/workflows/build.yml)
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            # Nōdo – call Node.js from Ruby
         
     | 
| 
         @@ -54,6 +54,26 @@ foo.say_hi('Nodo') 
     | 
|
| 
       54 
54 
     | 
    
         
             
            => "Hello Nodo!"
         
     | 
| 
       55 
55 
     | 
    
         
             
            ```
         
     | 
| 
       56 
56 
     | 
    
         | 
| 
      
 57 
     | 
    
         
            +
            JS code can also be supplied using the `code:` keyword argument:
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 60 
     | 
    
         
            +
            function :hello, code: "() => 'world'"
         
     | 
| 
      
 61 
     | 
    
         
            +
            ```
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            ### Async functions
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            `Nodo` supports calling `async` functions from Ruby.
         
     | 
| 
      
 66 
     | 
    
         
            +
            The Ruby call will happen synchronously, i.e. it will block until the JS
         
     | 
| 
      
 67 
     | 
    
         
            +
            function resolves:
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 70 
     | 
    
         
            +
            class SyncFoo < Nodo::Core
         
     | 
| 
      
 71 
     | 
    
         
            +
              function :do_something, <<~JS
         
     | 
| 
      
 72 
     | 
    
         
            +
                async () => { return await asyncFunc(); }
         
     | 
| 
      
 73 
     | 
    
         
            +
              JS
         
     | 
| 
      
 74 
     | 
    
         
            +
            end
         
     | 
| 
      
 75 
     | 
    
         
            +
            ```
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
       57 
77 
     | 
    
         
             
            ### Using npm modules
         
     | 
| 
       58 
78 
     | 
    
         | 
| 
       59 
79 
     | 
    
         
             
            Install your modules to `node_modules`:
         
     | 
| 
         @@ -79,7 +99,6 @@ bar = Bar.new 
     | 
|
| 
       79 
99 
     | 
    
         
             
            bar.v4 => "b305f5c4-db9a-4504-b0c3-4e097a5ec8b9"
         
     | 
| 
       80 
100 
     | 
    
         
             
            ```
         
     | 
| 
       81 
101 
     | 
    
         | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
102 
     | 
    
         
             
            ### Aliasing requires
         
     | 
| 
       84 
103 
     | 
    
         | 
| 
       85 
104 
     | 
    
         
             
            If the library name cannot be used as name of the constant, the `const` name
         
     | 
| 
         @@ -108,25 +127,6 @@ end 
     | 
|
| 
       108 
127 
     | 
    
         | 
| 
       109 
128 
     | 
    
         
             
            Note that the availability of dynamic imports depends on your Node version.
         
     | 
| 
       110 
129 
     | 
    
         | 
| 
       111 
     | 
    
         
            -
            ### Alternate function definition syntax
         
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
            JS code can also be supplied using the `code:` keyword argument:
         
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
            ```ruby
         
     | 
| 
       116 
     | 
    
         
            -
            function :hello, code: "() => 'world'"
         
     | 
| 
       117 
     | 
    
         
            -
            ```
         
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
            ### Setting NODE_PATH
         
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
            By default, `./node_modules` is used as the `NODE_PATH`.
         
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
            To set a custom path:
         
     | 
| 
       124 
     | 
    
         
            -
            ```ruby
         
     | 
| 
       125 
     | 
    
         
            -
            Nodo.modules_root = 'path/to/node_modules'
         
     | 
| 
       126 
     | 
    
         
            -
            ```
         
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
            Also see: [Clean your Rails root](#Clean-your-Rails-root)
         
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
130 
     | 
    
         
             
            ### Defining JS constants
         
     | 
| 
       131 
131 
     | 
    
         | 
| 
       132 
132 
     | 
    
         
             
            ```ruby
         
     | 
| 
         @@ -188,20 +188,6 @@ SubFoo.new.bar => "callingsuperclass" 
     | 
|
| 
       188 
188 
     | 
    
         
             
            SubSubFoo.new.bar => "callingsubsubclass"
         
     | 
| 
       189 
189 
     | 
    
         
             
            ```
         
     | 
| 
       190 
190 
     | 
    
         | 
| 
       191 
     | 
    
         
            -
            ### Async functions
         
     | 
| 
       192 
     | 
    
         
            -
             
     | 
| 
       193 
     | 
    
         
            -
            `Nodo` supports calling `async` functions from Ruby. 
         
     | 
| 
       194 
     | 
    
         
            -
            The Ruby call will happen synchronously, i.e. it will block until the JS
         
     | 
| 
       195 
     | 
    
         
            -
            function resolves:
         
     | 
| 
       196 
     | 
    
         
            -
             
     | 
| 
       197 
     | 
    
         
            -
            ```ruby
         
     | 
| 
       198 
     | 
    
         
            -
            class SyncFoo < Nodo::Core
         
     | 
| 
       199 
     | 
    
         
            -
              function :do_something, <<~JS
         
     | 
| 
       200 
     | 
    
         
            -
                async () => { return await asyncFunc(); }
         
     | 
| 
       201 
     | 
    
         
            -
              JS
         
     | 
| 
       202 
     | 
    
         
            -
            end
         
     | 
| 
       203 
     | 
    
         
            -
            ```
         
     | 
| 
       204 
     | 
    
         
            -
             
     | 
| 
       205 
191 
     | 
    
         
             
            ### Deferred function definition
         
     | 
| 
       206 
192 
     | 
    
         | 
| 
       207 
193 
     | 
    
         
             
            By default, the function code string literal is created when the class
         
     | 
| 
         @@ -258,6 +244,17 @@ Foo.new.sleep(2) 
     | 
|
| 
       258 
244 
     | 
    
         
             
            =>  Nodo::TimeoutError raised
         
     | 
| 
       259 
245 
     | 
    
         
             
            ```
         
     | 
| 
       260 
246 
     | 
    
         | 
| 
      
 247 
     | 
    
         
            +
            ### Setting NODE_PATH
         
     | 
| 
      
 248 
     | 
    
         
            +
             
     | 
| 
      
 249 
     | 
    
         
            +
            By default, `./node_modules` is used as the `NODE_PATH`.
         
     | 
| 
      
 250 
     | 
    
         
            +
             
     | 
| 
      
 251 
     | 
    
         
            +
            To set a custom path:
         
     | 
| 
      
 252 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 253 
     | 
    
         
            +
            Nodo.modules_root = 'path/to/node_modules'
         
     | 
| 
      
 254 
     | 
    
         
            +
            ```
         
     | 
| 
      
 255 
     | 
    
         
            +
             
     | 
| 
      
 256 
     | 
    
         
            +
            Also see: [Clean your Rails root](#Clean-your-Rails-root)
         
     | 
| 
      
 257 
     | 
    
         
            +
             
     | 
| 
       261 
258 
     | 
    
         
             
            ### Logging
         
     | 
| 
       262 
259 
     | 
    
         | 
| 
       263 
260 
     | 
    
         
             
            By default, JS errors will be logged to `STDOUT`.
         
     | 
| 
         @@ -270,7 +267,6 @@ Nodo.logger = Logger.new('nodo.log') 
     | 
|
| 
       270 
267 
     | 
    
         | 
| 
       271 
268 
     | 
    
         
             
            In Rails applications, `Rails.logger` will automatically be set.
         
     | 
| 
       272 
269 
     | 
    
         | 
| 
       273 
     | 
    
         
            -
             
     | 
| 
       274 
270 
     | 
    
         
             
            ### Debugging
         
     | 
| 
       275 
271 
     | 
    
         | 
| 
       276 
272 
     | 
    
         
             
            To get verbose debug output, set
         
     | 
| 
         @@ -356,3 +352,15 @@ With this new default, all `yarn` operations should be done after `cd`ing to `ve 
     | 
|
| 
       356 
352 
     | 
    
         | 
| 
       357 
353 
     | 
    
         
             
            This repo provides an [adapted version](https://github.com/mtgrosser/nodo/blob/master/install/yarn.rake)
         
     | 
| 
       358 
354 
     | 
    
         
             
            of the `yarn:install` rake task which will automatically take care of the vendored module location.
         
     | 
| 
      
 355 
     | 
    
         
            +
             
     | 
| 
      
 356 
     | 
    
         
            +
             
     | 
| 
      
 357 
     | 
    
         
            +
            ## Working with web mocking frameworks like WebMock
         
     | 
| 
      
 358 
     | 
    
         
            +
             
     | 
| 
      
 359 
     | 
    
         
            +
            Nodo uses HTTP via UNIX sockets to connect to its Node process. This may lead to
         
     | 
| 
      
 360 
     | 
    
         
            +
            conflicts during tests when using `WebMock` or other tools which interfere with
         
     | 
| 
      
 361 
     | 
    
         
            +
            `Net::HTTP`. In order to work with WebMock, you need to enable its `allow_localhost`
         
     | 
| 
      
 362 
     | 
    
         
            +
            option:
         
     | 
| 
      
 363 
     | 
    
         
            +
             
     | 
| 
      
 364 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 365 
     | 
    
         
            +
            WebMock.disable_net_connect!(allow_localhost: true)
         
     | 
| 
      
 366 
     | 
    
         
            +
            ```
         
     | 
    
        data/lib/nodo/core.rb
    CHANGED
    
    | 
         @@ -221,7 +221,7 @@ module Nodo 
     | 
|
| 
       221 
221 
     | 
    
         
             
                  socket = nil
         
     | 
| 
       222 
222 
     | 
    
         
             
                  while Time.now - start < LAUNCH_TIMEOUT
         
     | 
| 
       223 
223 
     | 
    
         
             
                    begin
         
     | 
| 
       224 
     | 
    
         
            -
                      break if socket = UNIXSocket.new(socket_path)
         
     | 
| 
      
 224 
     | 
    
         
            +
                      break if socket = UNIXSocket.new(socket_path.to_s)
         
     | 
| 
       225 
225 
     | 
    
         
             
                    rescue Errno::ENOENT, Errno::ECONNREFUSED, Errno::ENOTDIR
         
     | 
| 
       226 
226 
     | 
    
         
             
                      Kernel.sleep(0.2)
         
     | 
| 
       227 
227 
     | 
    
         
             
                    end
         
     | 
    
        data/lib/nodo/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: nodo
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.6. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.6.5
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Matthias Grosser
         
     | 
| 
         @@ -11,56 +11,56 @@ cert_chain: [] 
     | 
|
| 
       11 
11 
     | 
    
         
             
            date: 2021-10-12 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
     | 
    
         
            -
              name: bundler
         
     | 
| 
       15 
14 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       16 
15 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
16 
     | 
    
         
             
                - - ">="
         
     | 
| 
       18 
17 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
18 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       20 
     | 
    
         
            -
               
     | 
| 
      
 19 
     | 
    
         
            +
              name: bundler
         
     | 
| 
       21 
20 
     | 
    
         
             
              prerelease: false
         
     | 
| 
      
 21 
     | 
    
         
            +
              type: :development
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
24 
     | 
    
         
             
                - - ">="
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
26 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
     | 
    
         
            -
              name: rake
         
     | 
| 
       29 
28 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
29 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
30 
     | 
    
         
             
                - - ">="
         
     | 
| 
       32 
31 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
32 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       34 
     | 
    
         
            -
               
     | 
| 
      
 33 
     | 
    
         
            +
              name: rake
         
     | 
| 
       35 
34 
     | 
    
         
             
              prerelease: false
         
     | 
| 
      
 35 
     | 
    
         
            +
              type: :development
         
     | 
| 
       36 
36 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
37 
     | 
    
         
             
                requirements:
         
     | 
| 
       38 
38 
     | 
    
         
             
                - - ">="
         
     | 
| 
       39 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
40 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       41 
41 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
     | 
    
         
            -
              name: byebug
         
     | 
| 
       43 
42 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       44 
43 
     | 
    
         
             
                requirements:
         
     | 
| 
       45 
44 
     | 
    
         
             
                - - ">="
         
     | 
| 
       46 
45 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       47 
46 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       48 
     | 
    
         
            -
               
     | 
| 
      
 47 
     | 
    
         
            +
              name: byebug
         
     | 
| 
       49 
48 
     | 
    
         
             
              prerelease: false
         
     | 
| 
      
 49 
     | 
    
         
            +
              type: :development
         
     | 
| 
       50 
50 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       51 
51 
     | 
    
         
             
                requirements:
         
     | 
| 
       52 
52 
     | 
    
         
             
                - - ">="
         
     | 
| 
       53 
53 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
54 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       55 
55 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       56 
     | 
    
         
            -
              name: minitest
         
     | 
| 
       57 
56 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       58 
57 
     | 
    
         
             
                requirements:
         
     | 
| 
       59 
58 
     | 
    
         
             
                - - ">="
         
     | 
| 
       60 
59 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       61 
60 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       62 
     | 
    
         
            -
               
     | 
| 
      
 61 
     | 
    
         
            +
              name: minitest
         
     | 
| 
       63 
62 
     | 
    
         
             
              prerelease: false
         
     | 
| 
      
 63 
     | 
    
         
            +
              type: :development
         
     | 
| 
       64 
64 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       65 
65 
     | 
    
         
             
                requirements:
         
     | 
| 
       66 
66 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       105 
105 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       106 
106 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       107 
107 
     | 
    
         
             
            requirements: []
         
     | 
| 
       108 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
      
 108 
     | 
    
         
            +
            rubygems_version: 3.3.25
         
     | 
| 
       109 
109 
     | 
    
         
             
            signing_key:
         
     | 
| 
       110 
110 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       111 
111 
     | 
    
         
             
            summary: Call Node.js from Ruby
         
     |