vagrant-betterhosts 0.1.0 → 0.2.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/Gemfile.lock +1 -1
- data/lib/vagrant-betterhosts/BetterHosts.rb +17 -33
- data/lib/vagrant-betterhosts/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: eca3ca87fa47244989ff3f69adfa4eac5ac0793cc68d81b05ff1f77d053da052
         | 
| 4 | 
            +
              data.tar.gz: 26bdb0c3f05e282baa1760849a65e7dfeaeba2ab267ab95a6916a6f5dd0f7c02
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: dc7655a442b2ba3aeee62349861c3ee0979e5f754ae8744a7925ff3b67ba184eb4dfc3c8784767332bbb6de080638b7a6b4bfd0b6e966c95305d3d2ee0923473
         | 
| 7 | 
            +
              data.tar.gz: e4c5bf8a7ae014223a0d688d56c8ee5221dcc2ef813ff086b63e164239f0f139a6824ad47d130a7445c01bd8eb0f7ddfaa1da52bfc4c630313752118b4cd8ffd
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
| @@ -71,10 +71,7 @@ module VagrantPlugins | |
| 71 71 |  | 
| 72 72 | 
             
                    case @machine.config.betterhosts.aliases
         | 
| 73 73 | 
             
                    when Array
         | 
| 74 | 
            -
                       | 
| 75 | 
            -
                      ips.each do |ip|
         | 
| 76 | 
            -
                        hostnames[ip] += @machine.config.betterhosts.aliases
         | 
| 77 | 
            -
                      end
         | 
| 74 | 
            +
                      hostnames[ips[0]] += @machine.config.betterhosts.aliases
         | 
| 78 75 | 
             
                    when Hash
         | 
| 79 76 | 
             
                      # complex definition of aliases for various ips
         | 
| 80 77 | 
             
                      @machine.config.betterhosts.aliases.each do |ip, hosts|
         | 
| @@ -82,9 +79,16 @@ module VagrantPlugins | |
| 82 79 | 
             
                      end
         | 
| 83 80 | 
             
                    end
         | 
| 84 81 |  | 
| 85 | 
            -
                     | 
| 82 | 
            +
                    # handle default hostname(s) if not already specified in the aliases
         | 
| 83 | 
            +
                    Array(@machine.config.vm.hostname).each do |host|
         | 
| 84 | 
            +
                      next unless hostnames.none? { |_, v| v.include?(host) }
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                      hostnames[ips[0]].unshift host
         | 
| 87 | 
            +
                    end
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                    hostnames
         | 
| 86 90 | 
             
                  end
         | 
| 87 | 
            -
             | 
| 91 | 
            +
             | 
| 88 92 | 
             
                  def disableClean(ip_address)
         | 
| 89 93 | 
             
                    unless ip_address.nil?
         | 
| 90 94 | 
             
                      return @machine.config.betterhosts.disable_clean
         | 
| @@ -105,6 +109,7 @@ module VagrantPlugins | |
| 105 109 | 
             
                        @ui.error "[vagrant-betterhosts] Error adding some hosts, no IP was provided for the following hostnames: #{hostnames}"
         | 
| 106 110 | 
             
                        next
         | 
| 107 111 | 
             
                      end
         | 
| 112 | 
            +
                      @ui.info "[vagrant-betterhosts] Adding #{hostnames} for address #{ip_address}"
         | 
| 108 113 | 
             
                      if cli.include? ".exe"
         | 
| 109 114 | 
             
                        clean = "\"--clean\","
         | 
| 110 115 | 
             
                        if disableClean(ip_address)
         | 
| @@ -175,37 +180,16 @@ module VagrantPlugins | |
| 175 180 | 
             
                  end
         | 
| 176 181 |  | 
| 177 182 | 
             
                  def generateHostnamesByIps()
         | 
| 178 | 
            -
                    hostnames_by_ips = []
         | 
| 179 183 | 
             
                    ips = getIps
         | 
| 180 | 
            -
                     | 
| 181 | 
            -
             | 
| 182 | 
            -
                     | 
| 184 | 
            +
                    return [] unless ips.any?
         | 
| 185 | 
            +
             | 
| 186 | 
            +
                    hostnames_by_ips = {}
         | 
| 183 187 | 
             
                    hostnames = getHostnames(ips)
         | 
| 184 | 
            -
                     | 
| 185 | 
            -
                       | 
| 186 | 
            -
                        ip_address = ip
         | 
| 187 | 
            -
                        if hostnames[ip].count() > 0
         | 
| 188 | 
            -
                          hostnames[ip].each do |hostname|
         | 
| 189 | 
            -
                            if !ip_address.nil?
         | 
| 190 | 
            -
                              @ui.info "[vagrant-betterhosts] - found entry for: #{ip_address} #{hostname}"
         | 
| 191 | 
            -
                            end
         | 
| 192 | 
            -
                          end
         | 
| 193 | 
            -
                          hostnames_by_ips = { ip_address => hostnames[ip].join(" ") }
         | 
| 194 | 
            -
                        end
         | 
| 195 | 
            -
                      end
         | 
| 196 | 
            -
                    else
         | 
| 197 | 
            -
                      ip_address = ips[0]
         | 
| 198 | 
            -
                      if hostnames[ip_address].count() > 0
         | 
| 199 | 
            -
                        hostnames[ip_address].each do |hostname|
         | 
| 200 | 
            -
                          if !ip_address.nil?
         | 
| 201 | 
            -
                            @ui.info "[vagrant-betterhosts] - found entry for: #{ip_address} #{hostname}"
         | 
| 202 | 
            -
                          end
         | 
| 203 | 
            -
                        end
         | 
| 204 | 
            -
                        hostnames_by_ips = { ip_address => hostnames[ip_address].join(" ") }
         | 
| 205 | 
            -
                      end
         | 
| 188 | 
            +
                    ips.each do |ip|
         | 
| 189 | 
            +
                      hostnames_by_ips[ip] = hostnames[ip].join(' ') if hostnames[ip].any?
         | 
| 206 190 | 
             
                    end
         | 
| 207 191 |  | 
| 208 | 
            -
                     | 
| 192 | 
            +
                    hostnames_by_ips
         | 
| 209 193 | 
             
                  end
         | 
| 210 194 | 
             
                end
         | 
| 211 195 | 
             
              end
         |