docker_rails_proxy 0.1.7 → 0.1.8
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/docker_rails_proxy/concerns/rsync.rb +31 -5
- data/lib/docker_rails_proxy/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: fdfc5f1dd0658381390e579aebafb630968d988e7ef84b496fb139295265164b
         | 
| 4 | 
            +
              data.tar.gz: 981fef93157bce97cd8f767abdb3f79aa81d9161e89c399dbe617ec2767a98c4
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b1786efd36b559e38e68ec0ab699acf596455a2229b1d6f483413907044a8ef9fcf68ec4eb9418b9ddb5db82fc8c8690e6be0bdf838bc40947316e61fe178da0
         | 
| 7 | 
            +
              data.tar.gz: 613b2069af30e06b70064c0e4b73d0046c439d4f3b351e8460e99f44a53b4452d5eb44570f39080fb7665cde023a918cde66f27fc0fb6db680e4faae66fca94c
         | 
| @@ -1,7 +1,9 @@ | |
| 1 1 | 
             
            module DockerRailsProxy
         | 
| 2 2 | 
             
              module Rsync
         | 
| 3 3 | 
             
                class << self
         | 
| 4 | 
            -
                  attr_accessor :exclusions
         | 
| 4 | 
            +
                  attr_accessor :exclusions,
         | 
| 5 | 
            +
                                :exclusions_from_host_to_container,
         | 
| 6 | 
            +
                                :exclusions_from_container_to_host
         | 
| 5 7 |  | 
| 6 8 | 
             
                  def included(base)
         | 
| 7 9 | 
             
                    base.extend(ClassMethods)
         | 
| @@ -19,6 +21,9 @@ module DockerRailsProxy | |
| 19 21 | 
             
                  .git*
         | 
| 20 22 | 
             
                ]
         | 
| 21 23 |  | 
| 24 | 
            +
                self.exclusions_from_host_to_container = []
         | 
| 25 | 
            +
                self.exclusions_from_container_to_host = []
         | 
| 26 | 
            +
             | 
| 22 27 | 
             
                module ClassMethods
         | 
| 23 28 | 
             
                end
         | 
| 24 29 |  | 
| @@ -59,9 +64,12 @@ module DockerRailsProxy | |
| 59 64 | 
             
                  end
         | 
| 60 65 |  | 
| 61 66 | 
             
                  def sync(options)
         | 
| 67 | 
            +
                    return if source_in_exclusions?(options)
         | 
| 62 68 | 
             
                    source, target, volume = normalize_options(options)
         | 
| 63 69 |  | 
| 64 | 
            -
                    result = send "sync_#{volume}",  | 
| 70 | 
            +
                    result = send "sync_#{volume}", {
         | 
| 71 | 
            +
                      source: source, target: target, reverse: options[:reverse]
         | 
| 72 | 
            +
                    }
         | 
| 65 73 |  | 
| 66 74 | 
             
                    if result && options[:silent].eql?(false)
         | 
| 67 75 | 
             
                      puts "#{source}   =======>   #{target}"
         | 
| @@ -87,17 +95,19 @@ module DockerRailsProxy | |
| 87 95 | 
             
                    [paths.send(reverse ? :reverse : :to_a), values.last].flatten
         | 
| 88 96 | 
             
                  end
         | 
| 89 97 |  | 
| 90 | 
            -
                  def sync_app(source:, target:)
         | 
| 98 | 
            +
                  def sync_app(source:, target:, reverse:)
         | 
| 99 | 
            +
                    exclusions = all_exclusions(reverse: reverse)
         | 
| 100 | 
            +
             | 
| 91 101 | 
             
                    system <<-EOS
         | 
| 92 102 | 
             
                    rsync -avqP --no-owner --no-group \
         | 
| 93 | 
            -
                    #{ | 
| 103 | 
            +
                    #{exclusions.map{ |e| "--exclude '#{e}'" }.join(' '.freeze)} \
         | 
| 94 104 | 
             
                      --force \
         | 
| 95 105 | 
             
                      --delete \
         | 
| 96 106 | 
             
                      #{source} #{target}
         | 
| 97 107 | 
             
                    EOS
         | 
| 98 108 | 
             
                  end
         | 
| 99 109 |  | 
| 100 | 
            -
                  def sync_gems(source:, target | 
| 110 | 
            +
                  def sync_gems(source:, target:, **)
         | 
| 101 111 | 
             
                    system <<-EOS
         | 
| 102 112 | 
             
                    rsync -avqP --no-owner --no-group \
         | 
| 103 113 | 
             
                      --exclude '.git*' \
         | 
| @@ -106,6 +116,22 @@ module DockerRailsProxy | |
| 106 116 | 
             
                      #{source} #{target}
         | 
| 107 117 | 
             
                    EOS
         | 
| 108 118 | 
             
                  end
         | 
| 119 | 
            +
             | 
| 120 | 
            +
                  def all_exclusions(reverse:)
         | 
| 121 | 
            +
                    one_way_exclusions = if reverse
         | 
| 122 | 
            +
                                           Rsync.exclusions_from_container_to_host
         | 
| 123 | 
            +
                                          else
         | 
| 124 | 
            +
                                            Rsync.exclusions_from_host_to_container
         | 
| 125 | 
            +
                                          end
         | 
| 126 | 
            +
             | 
| 127 | 
            +
                    Rsync.exclusions + one_way_exclusions
         | 
| 128 | 
            +
                  end
         | 
| 129 | 
            +
             | 
| 130 | 
            +
                  def source_in_exclusions?(source:, reverse:, **)
         | 
| 131 | 
            +
                    !!all_exclusions(reverse: reverse).find do |e|
         | 
| 132 | 
            +
                      source.include?("#{APP_PATH}/#{e}")
         | 
| 133 | 
            +
                    end
         | 
| 134 | 
            +
                  end
         | 
| 109 135 | 
             
                end
         | 
| 110 136 | 
             
              end
         | 
| 111 137 | 
             
            end
         |