avm-tools 0.81.0 → 0.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/avm/data/unit.rb +8 -3
- data/lib/avm/eac_redmine_base0/data_unit.rb +29 -1
- data/lib/avm/tools/version.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 168c054cba584a1c2d268e08f1c89d38768fab0c72696b69480db37b0392b605
         | 
| 4 | 
            +
              data.tar.gz: 43eea0c69bbdf91f0cc7e30a9cf631461ae3023028c6b8191b5631ea5f5c562b
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 95bc36c2b16d6b625d4400a98e89a05f53a478cc2e78378e917de85ef0ba0833216c48104f7ad5aab779ecc462bbd972444580cf4a244b1c700949dcbfd460c6
         | 
| 7 | 
            +
              data.tar.gz: 884b8fa7d13e6d590b61c71fa512986ba37d22630c55ea7bad36fecb475f9a5a2c2249535e9b28b3366215f32ae117a57ebb30b13a92d2e0526c2b620d90671e
         | 
    
        data/lib/avm/data/unit.rb
    CHANGED
    
    | @@ -12,11 +12,12 @@ module Avm | |
| 12 12 | 
             
                  enable_console_speaker
         | 
| 13 13 |  | 
| 14 14 | 
             
                  %w[dump load].each do |action|
         | 
| 15 | 
            +
                    method_name = "#{action}_command"
         | 
| 15 16 | 
             
                    class_eval <<~CODE, __FILE__, __LINE__ + 1
         | 
| 16 17 | 
             
                      # Should be overrided.
         | 
| 17 18 | 
             
                      # @return [EacRubyUtils::Envs::Command]
         | 
| 18 | 
            -
                      def #{ | 
| 19 | 
            -
                        fail " | 
| 19 | 
            +
                      def #{method_name}
         | 
| 20 | 
            +
                        fail "\\"#{method_name}\\" is a abstract method. Override in #{singleton_class}."
         | 
| 20 21 | 
             
                      end
         | 
| 21 22 | 
             
                    CODE
         | 
| 22 23 |  | 
| @@ -69,7 +70,7 @@ module Avm | |
| 69 70 | 
             
                  def load(data_path)
         | 
| 70 71 | 
             
                    run_callbacks :load do
         | 
| 71 72 | 
             
                      infom "Loading unit \"#{name}\" from \"#{data_path}\"..."
         | 
| 72 | 
            -
                       | 
| 73 | 
            +
                      do_load(data_path)
         | 
| 73 74 | 
             
                    end
         | 
| 74 75 | 
             
                  end
         | 
| 75 76 |  | 
| @@ -79,6 +80,10 @@ module Avm | |
| 79 80 | 
             
                    dump_command.execute!(output_file: data_path)
         | 
| 80 81 | 
             
                  end
         | 
| 81 82 |  | 
| 83 | 
            +
                  def do_load(data_path)
         | 
| 84 | 
            +
                    load_command.execute!(input_file: data_path)
         | 
| 85 | 
            +
                  end
         | 
| 86 | 
            +
             | 
| 82 87 | 
             
                  private
         | 
| 83 88 |  | 
| 84 89 | 
             
                  def unit_on_directory_path(directory, identifier)
         | 
| @@ -2,6 +2,7 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            require 'avm/data/instance/unit'
         | 
| 4 4 | 
             
            require 'eac_ruby_utils/core_ext'
         | 
| 5 | 
            +
            require 'curb'
         | 
| 5 6 | 
             
            require 'open-uri'
         | 
| 6 7 |  | 
| 7 8 | 
             
            module Avm
         | 
| @@ -17,8 +18,35 @@ module Avm | |
| 17 18 | 
             
                    end
         | 
| 18 19 | 
             
                  end
         | 
| 19 20 |  | 
| 21 | 
            +
                  def do_load(data_path)
         | 
| 22 | 
            +
                    do_load_by_web(data_path) || do_load_by_rake(data_path) || raise('Failed to load')
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  def do_load_by_web(data_path)
         | 
| 26 | 
            +
                    c = Curl::Easy.new(import_url)
         | 
| 27 | 
            +
                    c.multipart_form_post = true
         | 
| 28 | 
            +
                    c.http_post(Curl::PostField.file('redmine_with_git_tableless_load[path]', data_path))
         | 
| 29 | 
            +
                    c.perform
         | 
| 30 | 
            +
                    true
         | 
| 31 | 
            +
                  rescue Curl::Err::ConnectionFailedError
         | 
| 32 | 
            +
                    false
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  def do_load_by_rake(data_path)
         | 
| 36 | 
            +
                    instance.bundle('exec', 'rake', "redmine_with_git:load:all[#{data_path}]").system
         | 
| 37 | 
            +
                    true
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
             | 
| 20 40 | 
             
                  def export_url
         | 
| 21 | 
            -
                     | 
| 41 | 
            +
                    url('/backup/export')
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  def import_url
         | 
| 45 | 
            +
                    url('/backup/import.json')
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  def url(path)
         | 
| 49 | 
            +
                    uri = ::Addressable::URI.parse(instance.read_entry('web.url')) + path
         | 
| 22 50 | 
             
                    uri.query_values = { key: instance.read_entry('admin.api_key') }
         | 
| 23 51 | 
             
                    uri.to_s
         | 
| 24 52 | 
             
                  end
         | 
    
        data/lib/avm/tools/version.rb
    CHANGED