MuranoCLI 3.0.2 → 3.0.4
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/.rubocop.yml +30 -59
 - data/Gemfile +9 -3
 - data/MuranoCLI.gemspec +11 -4
 - data/bin/murano +2 -90
 - data/lib/MrMurano.rb +5 -1
 - data/lib/MrMurano/{spec_commander.rb → Commander-Entry.rb} +1 -2
 - data/lib/MrMurano/Solution.rb +12 -15
 - data/lib/MrMurano/SolutionId.rb +1 -5
 - data/lib/MrMurano/SyncAllowed.rb +2 -2
 - data/lib/MrMurano/SyncUpDown.rb +6 -3
 - data/lib/MrMurano/progress.rb +11 -2
 - data/lib/MrMurano/verbosing.rb +3 -2
 - data/lib/MrMurano/version.rb +2 -2
 - data/spec/Account-Passwords_spec.rb +34 -48
 - data/spec/Account_spec.rb +58 -63
 - data/spec/Business_spec.rb +151 -139
 - data/spec/ConfigFile_spec.rb +15 -11
 - data/spec/ConfigMigrate_spec.rb +23 -12
 - data/spec/Config_spec.rb +57 -54
 - data/spec/Content_spec.rb +233 -201
 - data/spec/GatewayBase_spec.rb +35 -27
 - data/spec/GatewayDevice_spec.rb +149 -149
 - data/spec/GatewayResource_spec.rb +115 -102
 - data/spec/GatewaySettings_spec.rb +69 -62
 - data/spec/Http_spec.rb +66 -56
 - data/spec/MakePretties_spec.rb +82 -73
 - data/spec/Mock_spec.rb +38 -29
 - data/spec/ProjectFile_spec.rb +118 -106
 - data/spec/Setting_spec.rb +24 -15
 - data/spec/Solution-ServiceConfig_spec.rb +168 -140
 - data/spec/Solution-ServiceEventHandler_spec.rb +186 -188
 - data/spec/Solution-ServiceModules_spec.rb +314 -232
 - data/spec/Solution-UsersRoles_spec.rb +136 -86
 - data/spec/Solution_spec.rb +78 -50
 - data/spec/SyncRoot_spec.rb +26 -24
 - data/spec/SyncUpDown_spec.rb +268 -249
 - data/spec/Verbosing_spec.rb +95 -93
 - data/spec/Webservice-Cors_spec.rb +141 -95
 - data/spec/Webservice-Endpoint_spec.rb +382 -346
 - data/spec/Webservice-File_spec.rb +148 -109
 - data/spec/Webservice-Setting_spec.rb +47 -41
 - data/spec/cmd_business_spec.rb +17 -17
 - data/spec/cmd_common.rb +27 -7
 - data/spec/cmd_config_spec.rb +31 -20
 - data/spec/cmd_content_spec.rb +80 -68
 - data/spec/cmd_cors_spec.rb +11 -5
 - data/spec/cmd_device_spec.rb +16 -14
 - data/spec/cmd_domain_spec.rb +10 -8
 - data/spec/cmd_exchange_spec.rb +3 -3
 - data/spec/cmd_init_spec.rb +100 -101
 - data/spec/cmd_keystore_spec.rb +17 -12
 - data/spec/cmd_link_spec.rb +22 -37
 - data/spec/cmd_password_spec.rb +11 -7
 - data/spec/cmd_setting_application_spec.rb +47 -33
 - data/spec/cmd_setting_product_spec.rb +32 -27
 - data/spec/cmd_status_spec.rb +125 -114
 - data/spec/cmd_syncdown_spec.rb +70 -65
 - data/spec/cmd_syncup_spec.rb +19 -15
 - data/spec/cmd_usage_spec.rb +14 -10
 - metadata +29 -15
 
| 
         @@ -1,3 +1,10 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Last Modified: 2017.09.12 /coding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright © 2016-2017 Exosite LLC.
         
     | 
| 
      
 5 
     | 
    
         
            +
            # License: MIT. See LICENSE.txt.
         
     | 
| 
      
 6 
     | 
    
         
            +
            #  vim:tw=0:ts=2:sw=2:et:ai
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       1 
8 
     | 
    
         
             
            require 'tempfile'
         
     | 
| 
       2 
9 
     | 
    
         
             
            require 'MrMurano/version'
         
     | 
| 
       3 
10 
     | 
    
         
             
            require 'MrMurano/ProjectFile'
         
     | 
| 
         @@ -5,7 +12,7 @@ require 'MrMurano/Solution-Services' 
     | 
|
| 
       5 
12 
     | 
    
         
             
            require '_workspace'
         
     | 
| 
       6 
13 
     | 
    
         | 
| 
       7 
14 
     | 
    
         
             
            RSpec.describe MrMurano::Module do
         
     | 
| 
       8 
     | 
    
         
            -
              include_context  
     | 
| 
      
 15 
     | 
    
         
            +
              include_context 'WORKSPACE'
         
     | 
| 
       9 
16 
     | 
    
         
             
              before(:example) do
         
     | 
| 
       10 
17 
     | 
    
         
             
                $cfg = MrMurano::Config.new
         
     | 
| 
       11 
18 
     | 
    
         
             
                $cfg.load
         
     | 
| 
         @@ -15,127 +22,166 @@ RSpec.describe MrMurano::Module do 
     | 
|
| 
       15 
22 
     | 
    
         
             
                $cfg['application.id'] = 'XYZ'
         
     | 
| 
       16 
23 
     | 
    
         | 
| 
       17 
24 
     | 
    
         
             
                @srv = MrMurano::Module.new
         
     | 
| 
       18 
     | 
    
         
            -
                allow(@srv).to receive(:token).and_return( 
     | 
| 
      
 25 
     | 
    
         
            +
                allow(@srv).to receive(:token).and_return('TTTTTTTTTT')
         
     | 
| 
       19 
26 
     | 
    
         
             
              end
         
     | 
| 
       20 
27 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
              it  
     | 
| 
      
 28 
     | 
    
         
            +
              it 'initializes' do
         
     | 
| 
       22 
29 
     | 
    
         
             
                uri = @srv.endpoint('/')
         
     | 
| 
       23 
     | 
    
         
            -
                expect(uri.to_s).to eq( 
     | 
| 
      
 30 
     | 
    
         
            +
                expect(uri.to_s).to eq(
         
     | 
| 
      
 31 
     | 
    
         
            +
                  'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/'
         
     | 
| 
      
 32 
     | 
    
         
            +
                )
         
     | 
| 
       24 
33 
     | 
    
         
             
              end
         
     | 
| 
       25 
34 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
              it  
     | 
| 
       27 
     | 
    
         
            -
                body = { 
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                   
     | 
| 
      
 35 
     | 
    
         
            +
              it 'lists' do
         
     | 
| 
      
 36 
     | 
    
         
            +
                body = {
         
     | 
| 
      
 37 
     | 
    
         
            +
                  items: [
         
     | 
| 
      
 38 
     | 
    
         
            +
                    {
         
     | 
| 
      
 39 
     | 
    
         
            +
                      id: '9K0',
         
     | 
| 
      
 40 
     | 
    
         
            +
                      name: 'debug',
         
     | 
| 
      
 41 
     | 
    
         
            +
                      alias: 'XYZ_debug',
         
     | 
| 
      
 42 
     | 
    
         
            +
                      solution_id: 'XYZ',
         
     | 
| 
      
 43 
     | 
    
         
            +
                      created_at: '2016-07-07T19:16:19.479Z',
         
     | 
| 
      
 44 
     | 
    
         
            +
                      updated_at: '2016-09-12T13:26:55.868Z',
         
     | 
| 
      
 45 
     | 
    
         
            +
                    },
         
     | 
| 
      
 46 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 47 
     | 
    
         
            +
                  total: 1,
         
     | 
| 
      
 48 
     | 
    
         
            +
                }
         
     | 
| 
      
 49 
     | 
    
         
            +
                stub_request(
         
     | 
| 
      
 50 
     | 
    
         
            +
                  :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module'
         
     | 
| 
      
 51 
     | 
    
         
            +
                ).with(
         
     | 
| 
      
 52 
     | 
    
         
            +
                  headers: {
         
     | 
| 
      
 53 
     | 
    
         
            +
                    'Authorization' => 'token TTTTTTTTTT',
         
     | 
| 
      
 54 
     | 
    
         
            +
                    'Content-Type' => 'application/json',
         
     | 
| 
      
 55 
     | 
    
         
            +
                  }
         
     | 
| 
      
 56 
     | 
    
         
            +
                ).to_return(body: body.to_json)
         
     | 
| 
       38 
57 
     | 
    
         | 
| 
       39 
58 
     | 
    
         
             
                ret = @srv.list
         
     | 
| 
       40 
59 
     | 
    
         
             
                expect(ret).to eq(body[:items])
         
     | 
| 
       41 
60 
     | 
    
         
             
              end
         
     | 
| 
       42 
61 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
              context  
     | 
| 
       44 
     | 
    
         
            -
                it  
     | 
| 
       45 
     | 
    
         
            -
                  body = { 
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
      
 62 
     | 
    
         
            +
              context 'fetching' do
         
     | 
| 
      
 63 
     | 
    
         
            +
                it 'fetches' do
         
     | 
| 
      
 64 
     | 
    
         
            +
                  body = {
         
     | 
| 
      
 65 
     | 
    
         
            +
                    id: '9K0',
         
     | 
| 
      
 66 
     | 
    
         
            +
                    name: 'debug',
         
     | 
| 
      
 67 
     | 
    
         
            +
                    alias: 'XYZ_debug',
         
     | 
| 
      
 68 
     | 
    
         
            +
                    solution_id: 'XYZ',
         
     | 
| 
      
 69 
     | 
    
         
            +
                    created_at: '2016-07-07T19:16:19.479Z',
         
     | 
| 
      
 70 
     | 
    
         
            +
                    updated_at: '2016-09-12T13:26:55.868Z',
         
     | 
| 
      
 71 
     | 
    
         
            +
                    script: %{-- lua code is here
         
     | 
| 
       52 
72 
     | 
    
         
             
                  function foo(bar)
         
     | 
| 
       53 
73 
     | 
    
         
             
                    return bar + 1
         
     | 
| 
       54 
74 
     | 
    
         
             
                  end
         
     | 
| 
      
 75 
     | 
    
         
            +
                  },
         
     | 
| 
       55 
76 
     | 
    
         
             
                  }
         
     | 
| 
       56 
     | 
    
         
            -
                   
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
      
 77 
     | 
    
         
            +
                  stub_request(
         
     | 
| 
      
 78 
     | 
    
         
            +
                    :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0'
         
     | 
| 
      
 79 
     | 
    
         
            +
                  ).with(
         
     | 
| 
      
 80 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 81 
     | 
    
         
            +
                      'Authorization' => 'token TTTTTTTTTT',
         
     | 
| 
      
 82 
     | 
    
         
            +
                      'Content-Type' => 'application/json',
         
     | 
| 
      
 83 
     | 
    
         
            +
                    }
         
     | 
| 
      
 84 
     | 
    
         
            +
                  ).to_return(body: body.to_json)
         
     | 
| 
       61 
85 
     | 
    
         | 
| 
       62 
86 
     | 
    
         
             
                  ret = @srv.fetch('9K0')
         
     | 
| 
       63 
87 
     | 
    
         
             
                  expect(ret).to eq(body[:script])
         
     | 
| 
       64 
88 
     | 
    
         
             
                end
         
     | 
| 
       65 
89 
     | 
    
         | 
| 
       66 
     | 
    
         
            -
                it  
     | 
| 
       67 
     | 
    
         
            -
                  body = { 
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
      
 90 
     | 
    
         
            +
                it 'fetches with block' do
         
     | 
| 
      
 91 
     | 
    
         
            +
                  body = {
         
     | 
| 
      
 92 
     | 
    
         
            +
                    id: '9K0',
         
     | 
| 
      
 93 
     | 
    
         
            +
                    name: 'debug',
         
     | 
| 
      
 94 
     | 
    
         
            +
                    alias: 'XYZ_debug',
         
     | 
| 
      
 95 
     | 
    
         
            +
                    solution_id: 'XYZ',
         
     | 
| 
      
 96 
     | 
    
         
            +
                    created_at: '2016-07-07T19:16:19.479Z',
         
     | 
| 
      
 97 
     | 
    
         
            +
                    updated_at: '2016-09-12T13:26:55.868Z',
         
     | 
| 
      
 98 
     | 
    
         
            +
                    script: %{-- lua code is here
         
     | 
| 
       74 
99 
     | 
    
         
             
                  function foo(bar)
         
     | 
| 
       75 
100 
     | 
    
         
             
                    return bar + 1
         
     | 
| 
       76 
101 
     | 
    
         
             
                  end
         
     | 
| 
      
 102 
     | 
    
         
            +
                  },
         
     | 
| 
       77 
103 
     | 
    
         
             
                  }
         
     | 
| 
       78 
     | 
    
         
            -
                   
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
      
 104 
     | 
    
         
            +
                  stub_request(
         
     | 
| 
      
 105 
     | 
    
         
            +
                    :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0'
         
     | 
| 
      
 106 
     | 
    
         
            +
                  ).with(
         
     | 
| 
      
 107 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 108 
     | 
    
         
            +
                      'Authorization' => 'token TTTTTTTTTT',
         
     | 
| 
      
 109 
     | 
    
         
            +
                      'Content-Type' => 'application/json',
         
     | 
| 
      
 110 
     | 
    
         
            +
                    }
         
     | 
| 
      
 111 
     | 
    
         
            +
                  ).to_return(body: body.to_json)
         
     | 
| 
       83 
112 
     | 
    
         | 
| 
       84 
113 
     | 
    
         
             
                  ret = nil
         
     | 
| 
       85 
     | 
    
         
            -
                  @srv.fetch('9K0') {|sc| ret = sc}
         
     | 
| 
      
 114 
     | 
    
         
            +
                  @srv.fetch('9K0') { |sc| ret = sc }
         
     | 
| 
       86 
115 
     | 
    
         
             
                  expect(ret).to eq(body[:script])
         
     | 
| 
       87 
116 
     | 
    
         
             
                end
         
     | 
| 
       88 
117 
     | 
    
         | 
| 
       89 
     | 
    
         
            -
                it  
     | 
| 
       90 
     | 
    
         
            -
                  body = { 
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
      
 118 
     | 
    
         
            +
                it 'Returns empty if script missing' do
         
     | 
| 
      
 119 
     | 
    
         
            +
                  body = {
         
     | 
| 
      
 120 
     | 
    
         
            +
                    id: '9K0',
         
     | 
| 
      
 121 
     | 
    
         
            +
                    name: 'debug',
         
     | 
| 
      
 122 
     | 
    
         
            +
                    alias: 'XYZ_debug',
         
     | 
| 
      
 123 
     | 
    
         
            +
                    solution_id: 'XYZ',
         
     | 
| 
      
 124 
     | 
    
         
            +
                    created_at: '2016-07-07T19:16:19.479Z',
         
     | 
| 
      
 125 
     | 
    
         
            +
                    updated_at: '2016-09-12T13:26:55.868Z',
         
     | 
| 
       96 
126 
     | 
    
         
             
                  }
         
     | 
| 
       97 
     | 
    
         
            -
                  stub_request( 
     | 
| 
       98 
     | 
    
         
            -
                     
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
                     
     | 
| 
      
 127 
     | 
    
         
            +
                  stub_request(
         
     | 
| 
      
 128 
     | 
    
         
            +
                    :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0'
         
     | 
| 
      
 129 
     | 
    
         
            +
                  ).with(
         
     | 
| 
      
 130 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 131 
     | 
    
         
            +
                      'Authorization' => 'token TTTTTTTTTT',
         
     | 
| 
      
 132 
     | 
    
         
            +
                      'Content-Type' => 'application/json',
         
     | 
| 
      
 133 
     | 
    
         
            +
                    }
         
     | 
| 
      
 134 
     | 
    
         
            +
                  ).to_return(body: body.to_json)
         
     | 
| 
       101 
135 
     | 
    
         | 
| 
       102 
136 
     | 
    
         
             
                  ret = @srv.fetch('9K0')
         
     | 
| 
       103 
137 
     | 
    
         
             
                  expect(ret).to eq('')
         
     | 
| 
       104 
138 
     | 
    
         
             
                end
         
     | 
| 
       105 
139 
     | 
    
         | 
| 
       106 
     | 
    
         
            -
                it  
     | 
| 
       107 
     | 
    
         
            -
                  stub_request( 
     | 
| 
       108 
     | 
    
         
            -
                     
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
                     
     | 
| 
      
 140 
     | 
    
         
            +
                it 'Displays error if wrong result type' do
         
     | 
| 
      
 141 
     | 
    
         
            +
                  stub_request(
         
     | 
| 
      
 142 
     | 
    
         
            +
                    :get, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0'
         
     | 
| 
      
 143 
     | 
    
         
            +
                  ).with(
         
     | 
| 
      
 144 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 145 
     | 
    
         
            +
                      'Authorization' => 'token TTTTTTTTTT',
         
     | 
| 
      
 146 
     | 
    
         
            +
                      'Content-Type' => 'application/json',
         
     | 
| 
      
 147 
     | 
    
         
            +
                    }
         
     | 
| 
      
 148 
     | 
    
         
            +
                  ).to_return(body: "this isn't what we expected")
         
     | 
| 
       111 
149 
     | 
    
         | 
| 
       112 
150 
     | 
    
         
             
                  saved = $stderr
         
     | 
| 
       113 
151 
     | 
    
         
             
                  $stderr = StringIO.new
         
     | 
| 
       114 
152 
     | 
    
         
             
                  ret = @srv.fetch('9K0')
         
     | 
| 
       115 
153 
     | 
    
         
             
                  expect(ret).to eq('')
         
     | 
| 
       116 
154 
     | 
    
         
             
                  expect($stderr.string).to start_with(
         
     | 
| 
       117 
     | 
    
         
            -
                    % 
     | 
| 
      
 155 
     | 
    
         
            +
                    %(\e[31m#{MrMurano::SolutionId::UNEXPECTED_TYPE_OR_ERROR_MSG})
         
     | 
| 
       118 
156 
     | 
    
         
             
                  )
         
     | 
| 
       119 
157 
     | 
    
         
             
                  $stderr = saved
         
     | 
| 
       120 
158 
     | 
    
         
             
                end
         
     | 
| 
       121 
159 
     | 
    
         
             
              end
         
     | 
| 
       122 
160 
     | 
    
         | 
| 
       123 
     | 
    
         
            -
              it  
     | 
| 
       124 
     | 
    
         
            -
                stub_request( 
     | 
| 
       125 
     | 
    
         
            -
                   
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
                   
     | 
| 
      
 161 
     | 
    
         
            +
              it 'removes' do
         
     | 
| 
      
 162 
     | 
    
         
            +
                stub_request(
         
     | 
| 
      
 163 
     | 
    
         
            +
                  :delete, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0'
         
     | 
| 
      
 164 
     | 
    
         
            +
                ).with(
         
     | 
| 
      
 165 
     | 
    
         
            +
                  headers: {
         
     | 
| 
      
 166 
     | 
    
         
            +
                    'Authorization' => 'token TTTTTTTTTT',
         
     | 
| 
      
 167 
     | 
    
         
            +
                    'Content-Type' => 'application/json',
         
     | 
| 
      
 168 
     | 
    
         
            +
                  }
         
     | 
| 
      
 169 
     | 
    
         
            +
                ).to_return(body: '')
         
     | 
| 
       128 
170 
     | 
    
         | 
| 
       129 
171 
     | 
    
         
             
                ret = @srv.remove('9K0')
         
     | 
| 
       130 
172 
     | 
    
         
             
                expect(ret).to eq({})
         
     | 
| 
       131 
173 
     | 
    
         
             
              end
         
     | 
| 
       132 
174 
     | 
    
         | 
| 
       133 
     | 
    
         
            -
              context  
     | 
| 
       134 
     | 
    
         
            -
                it  
     | 
| 
       135 
     | 
    
         
            -
                  stub_request( 
     | 
| 
       136 
     | 
    
         
            -
                     
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
      
 175 
     | 
    
         
            +
              context 'uploads' do
         
     | 
| 
      
 176 
     | 
    
         
            +
                it 'over old version' do
         
     | 
| 
      
 177 
     | 
    
         
            +
                  stub_request(
         
     | 
| 
      
 178 
     | 
    
         
            +
                    :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug'
         
     | 
| 
      
 179 
     | 
    
         
            +
                  ).with(
         
     | 
| 
      
 180 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 181 
     | 
    
         
            +
                      'Authorization' => 'token TTTTTTTTTT',
         
     | 
| 
      
 182 
     | 
    
         
            +
                      'Content-Type' => 'application/json',
         
     | 
| 
      
 183 
     | 
    
         
            +
                    }
         
     | 
| 
      
 184 
     | 
    
         
            +
                  ).to_return(body: '')
         
     | 
| 
       139 
185 
     | 
    
         | 
| 
       140 
186 
     | 
    
         
             
                  Tempfile.open('foo') do |tio|
         
     | 
| 
       141 
187 
     | 
    
         
             
                    tio << %{-- lua code is here
         
     | 
| 
         @@ -145,26 +191,36 @@ RSpec.describe MrMurano::Module do 
     | 
|
| 
       145 
191 
     | 
    
         
             
                    }
         
     | 
| 
       146 
192 
     | 
    
         
             
                    tio.close
         
     | 
| 
       147 
193 
     | 
    
         | 
| 
       148 
     | 
    
         
            -
                    ret = @srv.upload( 
     | 
| 
      
 194 
     | 
    
         
            +
                    ret = @srv.upload(
         
     | 
| 
      
 195 
     | 
    
         
            +
                      tio.path,
         
     | 
| 
       149 
196 
     | 
    
         
             
                      MrMurano::Module::ModuleItem.new(
         
     | 
| 
       150 
     | 
    
         
            -
                        : 
     | 
| 
       151 
     | 
    
         
            -
                        : 
     | 
| 
       152 
     | 
    
         
            -
                        : 
     | 
| 
       153 
     | 
    
         
            -
                        : 
     | 
| 
       154 
     | 
    
         
            -
                      ) 
     | 
| 
      
 197 
     | 
    
         
            +
                        id: '9K0',
         
     | 
| 
      
 198 
     | 
    
         
            +
                        name: 'debug',
         
     | 
| 
      
 199 
     | 
    
         
            +
                        alias: 'XYZ_debug',
         
     | 
| 
      
 200 
     | 
    
         
            +
                        solution_id: 'XYZ',
         
     | 
| 
      
 201 
     | 
    
         
            +
                      )
         
     | 
| 
      
 202 
     | 
    
         
            +
                    )
         
     | 
| 
       155 
203 
     | 
    
         
             
                    expect(ret)
         
     | 
| 
       156 
204 
     | 
    
         
             
                  end
         
     | 
| 
       157 
205 
     | 
    
         
             
                end
         
     | 
| 
       158 
206 
     | 
    
         | 
| 
       159 
     | 
    
         
            -
                it  
     | 
| 
       160 
     | 
    
         
            -
                  stub_request( 
     | 
| 
       161 
     | 
    
         
            -
                     
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
             
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
      
 207 
     | 
    
         
            +
                it 'when nothing is there' do
         
     | 
| 
      
 208 
     | 
    
         
            +
                  stub_request(
         
     | 
| 
      
 209 
     | 
    
         
            +
                    :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug'
         
     | 
| 
      
 210 
     | 
    
         
            +
                  ).with(
         
     | 
| 
      
 211 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 212 
     | 
    
         
            +
                      'Authorization' => 'token TTTTTTTTTT',
         
     | 
| 
      
 213 
     | 
    
         
            +
                      'Content-Type' => 'application/json',
         
     | 
| 
      
 214 
     | 
    
         
            +
                    }
         
     | 
| 
      
 215 
     | 
    
         
            +
                  ).to_return(status: 404)
         
     | 
| 
      
 216 
     | 
    
         
            +
                  stub_request(
         
     | 
| 
      
 217 
     | 
    
         
            +
                    :post, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/'
         
     | 
| 
      
 218 
     | 
    
         
            +
                  ).with(
         
     | 
| 
      
 219 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 220 
     | 
    
         
            +
                      'Authorization' => 'token TTTTTTTTTT',
         
     | 
| 
      
 221 
     | 
    
         
            +
                      'Content-Type' => 'application/json',
         
     | 
| 
      
 222 
     | 
    
         
            +
                    }
         
     | 
| 
      
 223 
     | 
    
         
            +
                  ).to_return(body: '')
         
     | 
| 
       168 
224 
     | 
    
         | 
| 
       169 
225 
     | 
    
         
             
                  Tempfile.open('foo') do |tio|
         
     | 
| 
       170 
226 
     | 
    
         
             
                    tio << %{-- lua code is here
         
     | 
| 
         @@ -177,20 +233,25 @@ RSpec.describe MrMurano::Module do 
     | 
|
| 
       177 
233 
     | 
    
         
             
                    ret = @srv.upload(
         
     | 
| 
       178 
234 
     | 
    
         
             
                      tio.path,
         
     | 
| 
       179 
235 
     | 
    
         
             
                      MrMurano::Module::ModuleItem.new(
         
     | 
| 
       180 
     | 
    
         
            -
                        : 
     | 
| 
       181 
     | 
    
         
            -
                        : 
     | 
| 
       182 
     | 
    
         
            -
                        : 
     | 
| 
       183 
     | 
    
         
            -
                        : 
     | 
| 
       184 
     | 
    
         
            -
                      ) 
     | 
| 
      
 236 
     | 
    
         
            +
                        id: '9K0',
         
     | 
| 
      
 237 
     | 
    
         
            +
                        name: 'debug',
         
     | 
| 
      
 238 
     | 
    
         
            +
                        alias: 'XYZ_debug',
         
     | 
| 
      
 239 
     | 
    
         
            +
                        solution_id: 'XYZ',
         
     | 
| 
      
 240 
     | 
    
         
            +
                      )
         
     | 
| 
      
 241 
     | 
    
         
            +
                    )
         
     | 
| 
       185 
242 
     | 
    
         
             
                    expect(ret)
         
     | 
| 
       186 
243 
     | 
    
         
             
                  end
         
     | 
| 
       187 
244 
     | 
    
         
             
                end
         
     | 
| 
       188 
245 
     | 
    
         | 
| 
       189 
     | 
    
         
            -
                it  
     | 
| 
       190 
     | 
    
         
            -
                  stub_request( 
     | 
| 
       191 
     | 
    
         
            -
                     
     | 
| 
       192 
     | 
    
         
            -
             
     | 
| 
       193 
     | 
    
         
            -
             
     | 
| 
      
 246 
     | 
    
         
            +
                it 'shows other errors' do
         
     | 
| 
      
 247 
     | 
    
         
            +
                  stub_request(
         
     | 
| 
      
 248 
     | 
    
         
            +
                    :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug'
         
     | 
| 
      
 249 
     | 
    
         
            +
                  ).with(
         
     | 
| 
      
 250 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 251 
     | 
    
         
            +
                      'Authorization' => 'token TTTTTTTTTT',
         
     | 
| 
      
 252 
     | 
    
         
            +
                      'Content-Type' => 'application/json',
         
     | 
| 
      
 253 
     | 
    
         
            +
                    }
         
     | 
| 
      
 254 
     | 
    
         
            +
                  ).to_return(status: 418, body: %({"teapot":true}))
         
     | 
| 
       194 
255 
     | 
    
         | 
| 
       195 
256 
     | 
    
         
             
                  Tempfile.open('foo') do |tio|
         
     | 
| 
       196 
257 
     | 
    
         
             
                    tio << %{-- lua code is here
         
     | 
| 
         @@ -201,22 +262,28 @@ RSpec.describe MrMurano::Module do 
     | 
|
| 
       201 
262 
     | 
    
         
             
                    tio.close
         
     | 
| 
       202 
263 
     | 
    
         | 
| 
       203 
264 
     | 
    
         
             
                    expect(@srv).to receive(:error).and_return(nil)
         
     | 
| 
       204 
     | 
    
         
            -
                    ret = @srv.upload( 
     | 
| 
      
 265 
     | 
    
         
            +
                    ret = @srv.upload(
         
     | 
| 
      
 266 
     | 
    
         
            +
                      tio.path,
         
     | 
| 
       205 
267 
     | 
    
         
             
                      MrMurano::Module::ModuleItem.new(
         
     | 
| 
       206 
     | 
    
         
            -
                        : 
     | 
| 
       207 
     | 
    
         
            -
                        : 
     | 
| 
       208 
     | 
    
         
            -
                        : 
     | 
| 
       209 
     | 
    
         
            -
                        : 
     | 
| 
       210 
     | 
    
         
            -
                      ) 
     | 
| 
      
 268 
     | 
    
         
            +
                        id: '9K0',
         
     | 
| 
      
 269 
     | 
    
         
            +
                        name: 'debug',
         
     | 
| 
      
 270 
     | 
    
         
            +
                        alias: 'XYZ_debug',
         
     | 
| 
      
 271 
     | 
    
         
            +
                        solution_id: 'XYZ',
         
     | 
| 
      
 272 
     | 
    
         
            +
                      )
         
     | 
| 
      
 273 
     | 
    
         
            +
                    )
         
     | 
| 
       211 
274 
     | 
    
         
             
                    expect(ret)
         
     | 
| 
       212 
275 
     | 
    
         
             
                  end
         
     | 
| 
       213 
276 
     | 
    
         
             
                end
         
     | 
| 
       214 
277 
     | 
    
         | 
| 
       215 
     | 
    
         
            -
                it  
     | 
| 
       216 
     | 
    
         
            -
                  stub_request( 
     | 
| 
       217 
     | 
    
         
            -
                     
     | 
| 
       218 
     | 
    
         
            -
             
     | 
| 
       219 
     | 
    
         
            -
             
     | 
| 
      
 278 
     | 
    
         
            +
                it 'over old version; replacing cache miss' do
         
     | 
| 
      
 279 
     | 
    
         
            +
                  stub_request(
         
     | 
| 
      
 280 
     | 
    
         
            +
                    :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug'
         
     | 
| 
      
 281 
     | 
    
         
            +
                  ).with(
         
     | 
| 
      
 282 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 283 
     | 
    
         
            +
                      'Authorization' => 'token TTTTTTTTTT',
         
     | 
| 
      
 284 
     | 
    
         
            +
                      'Content-Type' => 'application/json',
         
     | 
| 
      
 285 
     | 
    
         
            +
                    }
         
     | 
| 
      
 286 
     | 
    
         
            +
                  ).to_return(body: '')
         
     | 
| 
       220 
287 
     | 
    
         | 
| 
       221 
288 
     | 
    
         
             
                  Tempfile.open('foo') do |tio|
         
     | 
| 
       222 
289 
     | 
    
         
             
                    tio << %{-- lua code is here
         
     | 
| 
         @@ -226,24 +293,30 @@ RSpec.describe MrMurano::Module do 
     | 
|
| 
       226 
293 
     | 
    
         
             
                    }
         
     | 
| 
       227 
294 
     | 
    
         
             
                    tio.close
         
     | 
| 
       228 
295 
     | 
    
         | 
| 
       229 
     | 
    
         
            -
                     
     | 
| 
       230 
     | 
    
         
            -
                    FileUtils.touch( 
     | 
| 
       231 
     | 
    
         
            -
                    ret = @srv.upload( 
     | 
| 
      
 296 
     | 
    
         
            +
                    cache_file = $cfg.file_at(@srv.cache_file_name)
         
     | 
| 
      
 297 
     | 
    
         
            +
                    FileUtils.touch(cache_file.to_path)
         
     | 
| 
      
 298 
     | 
    
         
            +
                    ret = @srv.upload(
         
     | 
| 
      
 299 
     | 
    
         
            +
                      tio.path,
         
     | 
| 
       232 
300 
     | 
    
         
             
                      MrMurano::Module::ModuleItem.new(
         
     | 
| 
       233 
     | 
    
         
            -
                        : 
     | 
| 
       234 
     | 
    
         
            -
                        : 
     | 
| 
       235 
     | 
    
         
            -
                        : 
     | 
| 
       236 
     | 
    
         
            -
                        : 
     | 
| 
       237 
     | 
    
         
            -
                      ) 
     | 
| 
      
 301 
     | 
    
         
            +
                        id: '9K0',
         
     | 
| 
      
 302 
     | 
    
         
            +
                        name: 'debug',
         
     | 
| 
      
 303 
     | 
    
         
            +
                        alias: 'XYZ_debug',
         
     | 
| 
      
 304 
     | 
    
         
            +
                        solution_id: 'XYZ',
         
     | 
| 
      
 305 
     | 
    
         
            +
                      )
         
     | 
| 
      
 306 
     | 
    
         
            +
                    )
         
     | 
| 
       238 
307 
     | 
    
         
             
                    expect(ret)
         
     | 
| 
       239 
308 
     | 
    
         
             
                  end
         
     | 
| 
       240 
309 
     | 
    
         
             
                end
         
     | 
| 
       241 
310 
     | 
    
         | 
| 
       242 
     | 
    
         
            -
                it  
     | 
| 
       243 
     | 
    
         
            -
                  stub_request( 
     | 
| 
       244 
     | 
    
         
            -
                     
     | 
| 
       245 
     | 
    
         
            -
             
     | 
| 
       246 
     | 
    
         
            -
             
     | 
| 
      
 311 
     | 
    
         
            +
                it 'over old version; replacing cache hit' do
         
     | 
| 
      
 312 
     | 
    
         
            +
                  stub_request(
         
     | 
| 
      
 313 
     | 
    
         
            +
                    :put, 'https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug'
         
     | 
| 
      
 314 
     | 
    
         
            +
                  ).with(
         
     | 
| 
      
 315 
     | 
    
         
            +
                    headers: {
         
     | 
| 
      
 316 
     | 
    
         
            +
                      'Authorization' => 'token TTTTTTTTTT',
         
     | 
| 
      
 317 
     | 
    
         
            +
                      'Content-Type' => 'application/json',
         
     | 
| 
      
 318 
     | 
    
         
            +
                    }
         
     | 
| 
      
 319 
     | 
    
         
            +
                  ).to_return(body: '')
         
     | 
| 
       247 
320 
     | 
    
         | 
| 
       248 
321 
     | 
    
         
             
                  Tempfile.open('foo') do |tio|
         
     | 
| 
       249 
322 
     | 
    
         
             
                    tio << %{-- lua code is here
         
     | 
| 
         @@ -253,217 +326,226 @@ RSpec.describe MrMurano::Module do 
     | 
|
| 
       253 
326 
     | 
    
         
             
                    }
         
     | 
| 
       254 
327 
     | 
    
         
             
                    tio.close
         
     | 
| 
       255 
328 
     | 
    
         | 
| 
       256 
     | 
    
         
            -
                     
     | 
| 
       257 
     | 
    
         
            -
                     
     | 
| 
       258 
     | 
    
         
            -
                      cfio << { 
     | 
| 
       259 
     | 
    
         
            -
             
     | 
| 
      
 329 
     | 
    
         
            +
                    cache_file = $cfg.file_at(@srv.cache_file_name)
         
     | 
| 
      
 330 
     | 
    
         
            +
                    cache_file.open('w') do |cfio|
         
     | 
| 
      
 331 
     | 
    
         
            +
                      cfio << {
         
     | 
| 
      
 332 
     | 
    
         
            +
                        tio.path => {
         
     | 
| 
      
 333 
     | 
    
         
            +
                          sha1: '6',
         
     | 
| 
      
 334 
     | 
    
         
            +
                          updated_at: Time.now.getutc.to_datetime.iso8601(3),
         
     | 
| 
      
 335 
     | 
    
         
            +
                        },
         
     | 
| 
       260 
336 
     | 
    
         
             
                      }.to_yaml
         
     | 
| 
       261 
337 
     | 
    
         
             
                    end
         
     | 
| 
       262 
     | 
    
         
            -
                    ret = @srv.upload( 
     | 
| 
      
 338 
     | 
    
         
            +
                    ret = @srv.upload(
         
     | 
| 
      
 339 
     | 
    
         
            +
                      tio.path,
         
     | 
| 
       263 
340 
     | 
    
         
             
                      MrMurano::Module::ModuleItem.new(
         
     | 
| 
       264 
     | 
    
         
            -
                        : 
     | 
| 
       265 
     | 
    
         
            -
                        : 
     | 
| 
       266 
     | 
    
         
            -
                        : 
     | 
| 
       267 
     | 
    
         
            -
                        : 
     | 
| 
       268 
     | 
    
         
            -
                      ) 
     | 
| 
      
 341 
     | 
    
         
            +
                        id: '9K0',
         
     | 
| 
      
 342 
     | 
    
         
            +
                        name: 'debug',
         
     | 
| 
      
 343 
     | 
    
         
            +
                        alias: 'XYZ_debug',
         
     | 
| 
      
 344 
     | 
    
         
            +
                        solution_id: 'XYZ',
         
     | 
| 
      
 345 
     | 
    
         
            +
                      )
         
     | 
| 
      
 346 
     | 
    
         
            +
                    )
         
     | 
| 
       269 
347 
     | 
    
         
             
                    expect(ret)
         
     | 
| 
       270 
348 
     | 
    
         
             
                  end
         
     | 
| 
       271 
349 
     | 
    
         
             
                end
         
     | 
| 
       272 
350 
     | 
    
         
             
              end
         
     | 
| 
       273 
351 
     | 
    
         | 
| 
       274 
     | 
    
         
            -
              context  
     | 
| 
      
 352 
     | 
    
         
            +
              context 'compares' do
         
     | 
| 
       275 
353 
     | 
    
         
             
                before(:example) do
         
     | 
| 
       276 
     | 
    
         
            -
                  @ 
     | 
| 
       277 
     | 
    
         
            -
             
     | 
| 
       278 
     | 
    
         
            -
             
     | 
| 
       279 
     | 
    
         
            -
             
     | 
| 
       280 
     | 
    
         
            -
             
     | 
| 
       281 
     | 
    
         
            -
             
     | 
| 
       282 
     | 
    
         
            -
             
     | 
| 
       283 
     | 
    
         
            -
             
     | 
| 
       284 
     | 
    
         
            -
             
     | 
| 
       285 
     | 
    
         
            -
             
     | 
| 
       286 
     | 
    
         
            -
             
     | 
| 
       287 
     | 
    
         
            -
             
     | 
| 
      
 354 
     | 
    
         
            +
                  @i_a = {
         
     | 
| 
      
 355 
     | 
    
         
            +
                    id: '9K0',
         
     | 
| 
      
 356 
     | 
    
         
            +
                    name: 'debug',
         
     | 
| 
      
 357 
     | 
    
         
            +
                    alias: 'XYZ_debug',
         
     | 
| 
      
 358 
     | 
    
         
            +
                    solution_id: 'XYZ',
         
     | 
| 
      
 359 
     | 
    
         
            +
                    created_at: '2016-07-07T19:16:19.479Z',
         
     | 
| 
      
 360 
     | 
    
         
            +
                    updated_at: '2016-09-12T13:26:55.868Z',
         
     | 
| 
      
 361 
     | 
    
         
            +
                  }
         
     | 
| 
      
 362 
     | 
    
         
            +
                  @i_b = {
         
     | 
| 
      
 363 
     | 
    
         
            +
                    id: '9K0',
         
     | 
| 
      
 364 
     | 
    
         
            +
                    name: 'debug',
         
     | 
| 
      
 365 
     | 
    
         
            +
                    alias: 'XYZ_debug',
         
     | 
| 
      
 366 
     | 
    
         
            +
                    solution_id: 'XYZ',
         
     | 
| 
      
 367 
     | 
    
         
            +
                    created_at: '2016-07-07T19:16:19.479Z',
         
     | 
| 
      
 368 
     | 
    
         
            +
                    updated_at: '2016-09-12T13:26:55.868Z',
         
     | 
| 
      
 369 
     | 
    
         
            +
                  }
         
     | 
| 
       288 
370 
     | 
    
         
             
                end
         
     | 
| 
       289 
     | 
    
         
            -
                it  
     | 
| 
       290 
     | 
    
         
            -
                  ret = @srv.docmp(@ 
     | 
| 
      
 371 
     | 
    
         
            +
                it 'both have updated_at' do
         
     | 
| 
      
 372 
     | 
    
         
            +
                  ret = @srv.docmp(@i_a, @i_b)
         
     | 
| 
       291 
373 
     | 
    
         
             
                  expect(ret).to eq(false)
         
     | 
| 
       292 
374 
     | 
    
         
             
                end
         
     | 
| 
       293 
375 
     | 
    
         | 
| 
       294 
     | 
    
         
            -
                context  
     | 
| 
       295 
     | 
    
         
            -
                  it  
     | 
| 
      
 376 
     | 
    
         
            +
                context 'i_a is a local file' do
         
     | 
| 
      
 377 
     | 
    
         
            +
                  it 'no cache_file' do
         
     | 
| 
       296 
378 
     | 
    
         
             
                    Tempfile.open('foo') do |tio|
         
     | 
| 
       297 
     | 
    
         
            -
                      tio <<  
     | 
| 
      
 379 
     | 
    
         
            +
                      tio << 'something'
         
     | 
| 
       298 
380 
     | 
    
         
             
                      tio.close
         
     | 
| 
       299 
     | 
    
         
            -
                       
     | 
| 
       300 
     | 
    
         
            -
                         
     | 
| 
       301 
     | 
    
         
            -
                       
     | 
| 
       302 
     | 
    
         
            -
                      ret = @srv.docmp( 
     | 
| 
      
 381 
     | 
    
         
            +
                      i_a = @i_a.reject do |k, _v|
         
     | 
| 
      
 382 
     | 
    
         
            +
                        k == :updated_at
         
     | 
| 
      
 383 
     | 
    
         
            +
                      end.merge(local_path: Pathname.new(tio.path))
         
     | 
| 
      
 384 
     | 
    
         
            +
                      ret = @srv.docmp(i_a, @i_b)
         
     | 
| 
       303 
385 
     | 
    
         
             
                      expect(ret).to eq(true)
         
     | 
| 
       304 
386 
     | 
    
         | 
| 
       305 
     | 
    
         
            -
                       
     | 
| 
       306 
     | 
    
         
            -
                      ret = @srv.docmp( 
     | 
| 
      
 387 
     | 
    
         
            +
                      i_b = @i_b.merge(updated_at: Pathname.new(tio.path).mtime.getutc)
         
     | 
| 
      
 388 
     | 
    
         
            +
                      ret = @srv.docmp(i_a, i_b)
         
     | 
| 
       307 
389 
     | 
    
         
             
                      expect(ret).to eq(false)
         
     | 
| 
       308 
390 
     | 
    
         
             
                    end
         
     | 
| 
       309 
391 
     | 
    
         
             
                  end
         
     | 
| 
       310 
392 
     | 
    
         | 
| 
       311 
     | 
    
         
            -
                  it  
     | 
| 
       312 
     | 
    
         
            -
                     
     | 
| 
       313 
     | 
    
         
            -
                    FileUtils.touch( 
     | 
| 
      
 393 
     | 
    
         
            +
                  it 'cache miss' do
         
     | 
| 
      
 394 
     | 
    
         
            +
                    cache_file = $cfg.file_at(@srv.cache_file_name)
         
     | 
| 
      
 395 
     | 
    
         
            +
                    FileUtils.touch(cache_file.to_path)
         
     | 
| 
       314 
396 
     | 
    
         
             
                    Tempfile.open('foo') do |tio|
         
     | 
| 
       315 
     | 
    
         
            -
                      tio <<  
     | 
| 
      
 397 
     | 
    
         
            +
                      tio << 'something'
         
     | 
| 
       316 
398 
     | 
    
         
             
                      tio.close
         
     | 
| 
       317 
     | 
    
         
            -
                       
     | 
| 
       318 
     | 
    
         
            -
                         
     | 
| 
       319 
     | 
    
         
            -
                       
     | 
| 
       320 
     | 
    
         
            -
                      ret = @srv.docmp( 
     | 
| 
      
 399 
     | 
    
         
            +
                      i_a = @i_a.reject do |k, _v|
         
     | 
| 
      
 400 
     | 
    
         
            +
                        k == :updated_at
         
     | 
| 
      
 401 
     | 
    
         
            +
                      end.merge(local_path: Pathname.new(tio.path))
         
     | 
| 
      
 402 
     | 
    
         
            +
                      ret = @srv.docmp(i_a, @i_b)
         
     | 
| 
       321 
403 
     | 
    
         
             
                      expect(ret).to eq(true)
         
     | 
| 
       322 
404 
     | 
    
         | 
| 
       323 
     | 
    
         
            -
                       
     | 
| 
       324 
     | 
    
         
            -
                      ret = @srv.docmp( 
     | 
| 
      
 405 
     | 
    
         
            +
                      i_b = @i_b.merge(updated_at: Pathname.new(tio.path).mtime.getutc)
         
     | 
| 
      
 406 
     | 
    
         
            +
                      ret = @srv.docmp(i_a, i_b)
         
     | 
| 
       325 
407 
     | 
    
         
             
                      expect(ret).to eq(false)
         
     | 
| 
       326 
408 
     | 
    
         
             
                    end
         
     | 
| 
       327 
409 
     | 
    
         
             
                  end
         
     | 
| 
       328 
410 
     | 
    
         | 
| 
       329 
     | 
    
         
            -
                  it  
     | 
| 
       330 
     | 
    
         
            -
                     
     | 
| 
      
 411 
     | 
    
         
            +
                  it 'cache hit' do
         
     | 
| 
      
 412 
     | 
    
         
            +
                    cache_file = $cfg.file_at(@srv.cache_file_name)
         
     | 
| 
       331 
413 
     | 
    
         
             
                    Tempfile.open('foo') do |tio|
         
     | 
| 
       332 
     | 
    
         
            -
                      tio <<  
     | 
| 
      
 414 
     | 
    
         
            +
                      tio << 'something'
         
     | 
| 
       333 
415 
     | 
    
         
             
                      tio.close
         
     | 
| 
       334 
416 
     | 
    
         
             
                      tio_mtime = Pathname.new(tio.path).mtime.getutc
         
     | 
| 
       335 
417 
     | 
    
         
             
                      entry = {
         
     | 
| 
       336 
     | 
    
         
            -
                        : 
     | 
| 
       337 
     | 
    
         
            -
                        : 
     | 
| 
      
 418 
     | 
    
         
            +
                        sha1: Digest::SHA1.file(tio.path).hexdigest,
         
     | 
| 
      
 419 
     | 
    
         
            +
                        updated_at: tio_mtime.to_datetime.iso8601(3),
         
     | 
| 
       338 
420 
     | 
    
         
             
                      }
         
     | 
| 
       339 
     | 
    
         
            -
                       
     | 
| 
      
 421 
     | 
    
         
            +
                      cache_file.open('w') do |io|
         
     | 
| 
       340 
422 
     | 
    
         
             
                        cache = {}
         
     | 
| 
       341 
423 
     | 
    
         
             
                        cache[tio.path] = entry
         
     | 
| 
       342 
424 
     | 
    
         
             
                        io << cache.to_yaml
         
     | 
| 
       343 
425 
     | 
    
         
             
                      end
         
     | 
| 
       344 
426 
     | 
    
         | 
| 
       345 
     | 
    
         
            -
                       
     | 
| 
       346 
     | 
    
         
            -
                         
     | 
| 
       347 
     | 
    
         
            -
                       
     | 
| 
       348 
     | 
    
         
            -
                      ret = @srv.docmp( 
     | 
| 
      
 427 
     | 
    
         
            +
                      i_a = @i_a.reject do |k, _v|
         
     | 
| 
      
 428 
     | 
    
         
            +
                        k == :updated_at
         
     | 
| 
      
 429 
     | 
    
         
            +
                      end.merge(local_path: Pathname.new(tio.path))
         
     | 
| 
      
 430 
     | 
    
         
            +
                      ret = @srv.docmp(i_a, @i_b)
         
     | 
| 
       349 
431 
     | 
    
         
             
                      expect(ret).to eq(true)
         
     | 
| 
       350 
432 
     | 
    
         | 
| 
       351 
     | 
    
         
            -
                       
     | 
| 
       352 
     | 
    
         
            -
                      ret = @srv.docmp( 
     | 
| 
      
 433 
     | 
    
         
            +
                      i_b = @i_b.merge(updated_at: tio_mtime)
         
     | 
| 
      
 434 
     | 
    
         
            +
                      ret = @srv.docmp(i_a, i_b)
         
     | 
| 
       353 
435 
     | 
    
         
             
                      expect(ret).to eq(false)
         
     | 
| 
       354 
436 
     | 
    
         
             
                    end
         
     | 
| 
       355 
437 
     | 
    
         
             
                  end
         
     | 
| 
       356 
438 
     | 
    
         
             
                end
         
     | 
| 
       357 
439 
     | 
    
         | 
| 
       358 
     | 
    
         
            -
                context  
     | 
| 
       359 
     | 
    
         
            -
                  it  
     | 
| 
      
 440 
     | 
    
         
            +
                context 'i_b is a local file' do
         
     | 
| 
      
 441 
     | 
    
         
            +
                  it 'no cache_file' do
         
     | 
| 
       360 
442 
     | 
    
         
             
                    Tempfile.open('foo') do |tio|
         
     | 
| 
       361 
     | 
    
         
            -
                      tio <<  
     | 
| 
      
 443 
     | 
    
         
            +
                      tio << 'something'
         
     | 
| 
       362 
444 
     | 
    
         
             
                      tio.close
         
     | 
| 
       363 
     | 
    
         
            -
                       
     | 
| 
       364 
     | 
    
         
            -
                         
     | 
| 
       365 
     | 
    
         
            -
                       
     | 
| 
       366 
     | 
    
         
            -
                      ret = @srv.docmp(@ 
     | 
| 
      
 445 
     | 
    
         
            +
                      i_b = @i_b.reject do |k, _v|
         
     | 
| 
      
 446 
     | 
    
         
            +
                        k == :updated_at
         
     | 
| 
      
 447 
     | 
    
         
            +
                      end.merge(local_path: Pathname.new(tio.path))
         
     | 
| 
      
 448 
     | 
    
         
            +
                      ret = @srv.docmp(@i_a, i_b)
         
     | 
| 
       367 
449 
     | 
    
         
             
                      expect(ret).to eq(true)
         
     | 
| 
       368 
450 
     | 
    
         | 
| 
       369 
     | 
    
         
            -
                       
     | 
| 
       370 
     | 
    
         
            -
                      ret = @srv.docmp( 
     | 
| 
      
 451 
     | 
    
         
            +
                      i_a = @i_a.merge(updated_at: Pathname.new(tio.path).mtime.getutc)
         
     | 
| 
      
 452 
     | 
    
         
            +
                      ret = @srv.docmp(i_a, i_b)
         
     | 
| 
       371 
453 
     | 
    
         
             
                      expect(ret).to eq(false)
         
     | 
| 
       372 
454 
     | 
    
         
             
                    end
         
     | 
| 
       373 
455 
     | 
    
         
             
                  end
         
     | 
| 
       374 
456 
     | 
    
         | 
| 
       375 
     | 
    
         
            -
                  it  
     | 
| 
       376 
     | 
    
         
            -
                     
     | 
| 
       377 
     | 
    
         
            -
                    FileUtils.touch( 
     | 
| 
      
 457 
     | 
    
         
            +
                  it 'cache miss' do
         
     | 
| 
      
 458 
     | 
    
         
            +
                    cache_file = $cfg.file_at(@srv.cache_file_name)
         
     | 
| 
      
 459 
     | 
    
         
            +
                    FileUtils.touch(cache_file.to_path)
         
     | 
| 
       378 
460 
     | 
    
         
             
                    Tempfile.open('foo') do |tio|
         
     | 
| 
       379 
     | 
    
         
            -
                      tio <<  
     | 
| 
      
 461 
     | 
    
         
            +
                      tio << 'something'
         
     | 
| 
       380 
462 
     | 
    
         
             
                      tio.close
         
     | 
| 
       381 
     | 
    
         
            -
                       
     | 
| 
       382 
     | 
    
         
            -
                         
     | 
| 
       383 
     | 
    
         
            -
                       
     | 
| 
       384 
     | 
    
         
            -
                      ret = @srv.docmp(@ 
     | 
| 
      
 463 
     | 
    
         
            +
                      i_b = @i_b.reject do |k, _v|
         
     | 
| 
      
 464 
     | 
    
         
            +
                        k == :updated_at
         
     | 
| 
      
 465 
     | 
    
         
            +
                      end.merge(local_path: Pathname.new(tio.path))
         
     | 
| 
      
 466 
     | 
    
         
            +
                      ret = @srv.docmp(@i_a, i_b)
         
     | 
| 
       385 
467 
     | 
    
         
             
                      expect(ret).to eq(true)
         
     | 
| 
       386 
468 
     | 
    
         | 
| 
       387 
     | 
    
         
            -
                       
     | 
| 
       388 
     | 
    
         
            -
                      ret = @srv.docmp( 
     | 
| 
      
 469 
     | 
    
         
            +
                      i_a = @i_a.merge(updated_at: Pathname.new(tio.path).mtime.getutc)
         
     | 
| 
      
 470 
     | 
    
         
            +
                      ret = @srv.docmp(i_a, i_b)
         
     | 
| 
       389 
471 
     | 
    
         
             
                      expect(ret).to eq(false)
         
     | 
| 
       390 
472 
     | 
    
         
             
                    end
         
     | 
| 
       391 
473 
     | 
    
         
             
                  end
         
     | 
| 
       392 
474 
     | 
    
         | 
| 
       393 
     | 
    
         
            -
                  it  
     | 
| 
       394 
     | 
    
         
            -
                     
     | 
| 
      
 475 
     | 
    
         
            +
                  it 'cache hit' do
         
     | 
| 
      
 476 
     | 
    
         
            +
                    cache_file = $cfg.file_at(@srv.cache_file_name)
         
     | 
| 
       395 
477 
     | 
    
         
             
                    Tempfile.open('foo') do |tio|
         
     | 
| 
       396 
     | 
    
         
            -
                      tio <<  
     | 
| 
      
 478 
     | 
    
         
            +
                      tio << 'something'
         
     | 
| 
       397 
479 
     | 
    
         
             
                      tio.close
         
     | 
| 
       398 
480 
     | 
    
         
             
                      tio_mtime = Pathname.new(tio.path).mtime.getutc
         
     | 
| 
       399 
481 
     | 
    
         
             
                      entry = {
         
     | 
| 
       400 
     | 
    
         
            -
                        : 
     | 
| 
       401 
     | 
    
         
            -
                        : 
     | 
| 
      
 482 
     | 
    
         
            +
                        sha1: Digest::SHA1.file(tio.path).hexdigest,
         
     | 
| 
      
 483 
     | 
    
         
            +
                        updated_at: tio_mtime.to_datetime.iso8601(3),
         
     | 
| 
       402 
484 
     | 
    
         
             
                      }
         
     | 
| 
       403 
     | 
    
         
            -
                       
     | 
| 
      
 485 
     | 
    
         
            +
                      cache_file.open('w') do |io|
         
     | 
| 
       404 
486 
     | 
    
         
             
                        cache = {}
         
     | 
| 
       405 
487 
     | 
    
         
             
                        cache[tio.path] = entry
         
     | 
| 
       406 
488 
     | 
    
         
             
                        io << cache.to_yaml
         
     | 
| 
       407 
489 
     | 
    
         
             
                      end
         
     | 
| 
       408 
490 
     | 
    
         | 
| 
       409 
     | 
    
         
            -
                       
     | 
| 
       410 
     | 
    
         
            -
                         
     | 
| 
       411 
     | 
    
         
            -
                       
     | 
| 
       412 
     | 
    
         
            -
                      ret = @srv.docmp(@ 
     | 
| 
      
 491 
     | 
    
         
            +
                      i_b = @i_b.reject do |k, _v|
         
     | 
| 
      
 492 
     | 
    
         
            +
                        k == :updated_at
         
     | 
| 
      
 493 
     | 
    
         
            +
                      end.merge(local_path: Pathname.new(tio.path))
         
     | 
| 
      
 494 
     | 
    
         
            +
                      ret = @srv.docmp(@i_a, i_b)
         
     | 
| 
       413 
495 
     | 
    
         
             
                      expect(ret).to eq(true)
         
     | 
| 
       414 
496 
     | 
    
         | 
| 
       415 
     | 
    
         
            -
                       
     | 
| 
       416 
     | 
    
         
            -
                      ret = @srv.docmp( 
     | 
| 
      
 497 
     | 
    
         
            +
                      i_a = @i_a.merge(updated_at: tio_mtime)
         
     | 
| 
      
 498 
     | 
    
         
            +
                      ret = @srv.docmp(i_a, i_b)
         
     | 
| 
       417 
499 
     | 
    
         
             
                      expect(ret).to eq(false)
         
     | 
| 
       418 
500 
     | 
    
         
             
                    end
         
     | 
| 
       419 
501 
     | 
    
         
             
                  end
         
     | 
| 
       420 
502 
     | 
    
         
             
                end
         
     | 
| 
       421 
503 
     | 
    
         
             
              end
         
     | 
| 
       422 
504 
     | 
    
         | 
| 
       423 
     | 
    
         
            -
              context  
     | 
| 
       424 
     | 
    
         
            -
                it  
     | 
| 
       425 
     | 
    
         
            -
                  ret = @srv.tolocalname({ : 
     | 
| 
      
 505 
     | 
    
         
            +
              context 'Lookup functions' do
         
     | 
| 
      
 506 
     | 
    
         
            +
                it 'gets local name' do
         
     | 
| 
      
 507 
     | 
    
         
            +
                  ret = @srv.tolocalname({ name: 'bob' }, nil)
         
     | 
| 
       426 
508 
     | 
    
         
             
                  expect(ret).to eq('bob.lua')
         
     | 
| 
       427 
509 
     | 
    
         
             
                end
         
     | 
| 
       428 
510 
     | 
    
         | 
| 
       429 
     | 
    
         
            -
                it  
     | 
| 
       430 
     | 
    
         
            -
                  ret = @srv.synckey( 
     | 
| 
       431 
     | 
    
         
            -
                  expect(ret).to eq( 
     | 
| 
      
 511 
     | 
    
         
            +
                it 'gets synckey' do
         
     | 
| 
      
 512 
     | 
    
         
            +
                  ret = @srv.synckey(name: 'device')
         
     | 
| 
      
 513 
     | 
    
         
            +
                  expect(ret).to eq('device')
         
     | 
| 
       432 
514 
     | 
    
         
             
                end
         
     | 
| 
       433 
515 
     | 
    
         | 
| 
       434 
     | 
    
         
            -
                it  
     | 
| 
       435 
     | 
    
         
            -
                  $cfg['modules.searchFor'] = % 
     | 
| 
      
 516 
     | 
    
         
            +
                it 'gets searchfor' do
         
     | 
| 
      
 517 
     | 
    
         
            +
                  $cfg['modules.searchFor'] = %(a b c/**/d/*.bob)
         
     | 
| 
       436 
518 
     | 
    
         
             
                  ret = @srv.searchFor
         
     | 
| 
       437 
     | 
    
         
            -
                  expect(ret).to eq([ 
     | 
| 
      
 519 
     | 
    
         
            +
                  expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
         
     | 
| 
       438 
520 
     | 
    
         
             
                end
         
     | 
| 
       439 
521 
     | 
    
         | 
| 
       440 
     | 
    
         
            -
                it  
     | 
| 
       441 
     | 
    
         
            -
                  $cfg['modules.ignoring'] = % 
     | 
| 
      
 522 
     | 
    
         
            +
                it 'gets ignoring' do
         
     | 
| 
      
 523 
     | 
    
         
            +
                  $cfg['modules.ignoring'] = %(a b c/**/d/*.bob)
         
     | 
| 
       442 
524 
     | 
    
         
             
                  ret = @srv.ignoring
         
     | 
| 
       443 
     | 
    
         
            -
                  expect(ret).to eq([ 
     | 
| 
      
 525 
     | 
    
         
            +
                  expect(ret).to eq(['a', 'b', 'c/**/d/*.bob'])
         
     | 
| 
       444 
526 
     | 
    
         
             
                end
         
     | 
| 
       445 
527 
     | 
    
         | 
| 
       446 
     | 
    
         
            -
                it  
     | 
| 
       447 
     | 
    
         
            -
                  expect  
     | 
| 
       448 
     | 
    
         
            -
                    @srv.mkname(MrMurano::Module::EventHandlerItem.new 
     | 
| 
       449 
     | 
    
         
            -
                   
     | 
| 
      
 528 
     | 
    
         
            +
                it 'raises on alias without name' do
         
     | 
| 
      
 529 
     | 
    
         
            +
                  expect do
         
     | 
| 
      
 530 
     | 
    
         
            +
                    @srv.mkname(MrMurano::Module::EventHandlerItem.new)
         
     | 
| 
      
 531 
     | 
    
         
            +
                  end.to raise_error(NameError)
         
     | 
| 
       450 
532 
     | 
    
         
             
                end
         
     | 
| 
       451 
533 
     | 
    
         | 
| 
       452 
     | 
    
         
            -
                it  
     | 
| 
       453 
     | 
    
         
            -
                  expect  
     | 
| 
       454 
     | 
    
         
            -
                    @srv.mkalias(MrMurano::Module::EventHandlerItem.new 
     | 
| 
       455 
     | 
    
         
            -
                   
     | 
| 
      
 534 
     | 
    
         
            +
                it 'raises on name without name' do
         
     | 
| 
      
 535 
     | 
    
         
            +
                  expect do
         
     | 
| 
      
 536 
     | 
    
         
            +
                    @srv.mkalias(MrMurano::Module::EventHandlerItem.new)
         
     | 
| 
      
 537 
     | 
    
         
            +
                  end.to raise_error(NameError)
         
     | 
| 
       456 
538 
     | 
    
         
             
                end
         
     | 
| 
       457 
539 
     | 
    
         
             
              end
         
     | 
| 
       458 
540 
     | 
    
         | 
| 
       459 
     | 
    
         
            -
              context  
     | 
| 
       460 
     | 
    
         
            -
                it  
     | 
| 
      
 541 
     | 
    
         
            +
              context 'to_remote_item' do
         
     | 
| 
      
 542 
     | 
    
         
            +
                it 'reads one' do
         
     | 
| 
       461 
543 
     | 
    
         
             
                  root = Pathname.new(@project_dir)
         
     | 
| 
       462 
544 
     | 
    
         
             
                  path = Pathname.new(@project_dir) + 'test.lua'
         
     | 
| 
       463 
545 
     | 
    
         
             
                  ret = @srv.to_remote_item(root, path)
         
     | 
| 
       464 
546 
     | 
    
         
             
                  expect(ret).to eq(name: 'test')
         
     | 
| 
       465 
547 
     | 
    
         
             
                end
         
     | 
| 
       466 
     | 
    
         
            -
                it  
     | 
| 
      
 548 
     | 
    
         
            +
                it 'reads sub folder one' do
         
     | 
| 
       467 
549 
     | 
    
         
             
                  root = Pathname.new(@project_dir)
         
     | 
| 
       468 
550 
     | 
    
         
             
                  path = Pathname.new(@project_dir) + 'src/test.lua'
         
     | 
| 
       469 
551 
     | 
    
         
             
                  ret = @srv.to_remote_item(root, path)
         
     | 
| 
         @@ -471,4 +553,4 @@ RSpec.describe MrMurano::Module do 
     | 
|
| 
       471 
553 
     | 
    
         
             
                end
         
     | 
| 
       472 
554 
     | 
    
         
             
              end
         
     | 
| 
       473 
555 
     | 
    
         
             
            end
         
     | 
| 
       474 
     | 
    
         
            -
             
     | 
| 
      
 556 
     | 
    
         
            +
             
     |