middleman-core 3.3.12 → 3.4.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.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/cucumber.yml +2 -0
  4. data/features/asset_hash.feature +9 -0
  5. data/features/chained_templates.feature +4 -1
  6. data/features/cli/preview_server.feature +532 -0
  7. data/features/i18n_link_to.feature +209 -0
  8. data/features/javascript-testing.feature +18 -0
  9. data/features/redirects.feature +1 -0
  10. data/features/relative_assets.feature +11 -0
  11. data/features/support/env.rb +3 -0
  12. data/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff +0 -0
  13. data/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff2 +0 -0
  14. data/fixtures/asset-hash-app/source/stylesheets/uses_fonts.css +4 -0
  15. data/fixtures/chained-app/source/test.erb.combobreaker.str.erb +8 -0
  16. data/fixtures/javascript-app/config.rb +0 -0
  17. data/fixtures/javascript-app/source/index.html +17 -0
  18. data/fixtures/preview-server-app/bin/dns_server.rb +33 -0
  19. data/fixtures/preview-server-app/config-complications.rb +11 -0
  20. data/fixtures/preview-server-app/config-empty.rb +0 -0
  21. data/fixtures/preview-server-app/config.rb +11 -0
  22. data/fixtures/preview-server-app/source/index.html.erb +1 -0
  23. data/fixtures/preview-server-app/source/layout.erb +9 -0
  24. data/fixtures/preview-server-app/source/layouts/custom.erb +8 -0
  25. data/fixtures/preview-server-app/source/real.html +1 -0
  26. data/fixtures/preview-server-app/source/real/index.html.erb +5 -0
  27. data/fixtures/preview-server-app/source/should_be_ignored.html +1 -0
  28. data/fixtures/preview-server-app/source/should_be_ignored2.html +1 -0
  29. data/fixtures/preview-server-app/source/should_be_ignored3.html +1 -0
  30. data/fixtures/preview-server-app/source/static.html +1 -0
  31. data/fixtures/relative-assets-app/source/absolute_image_relative_css.html.erb +9 -0
  32. data/fixtures/relative-assets-app/source/javascripts/app.js +3 -0
  33. data/fixtures/relative-assets-app/source/relative_image.html.erb +1 -0
  34. data/fixtures/relative-assets-app/source/relative_image_absolute_css.html.erb +9 -0
  35. data/lib/middleman-core/application.rb +11 -5
  36. data/lib/middleman-core/cli/build.rb +3 -1
  37. data/lib/middleman-core/cli/bundler.rb +1 -1
  38. data/lib/middleman-core/cli/extension.rb +2 -2
  39. data/lib/middleman-core/cli/init.rb +3 -3
  40. data/lib/middleman-core/cli/server.rb +9 -1
  41. data/lib/middleman-core/configuration.rb +0 -2
  42. data/lib/middleman-core/core_extensions/data.rb +2 -2
  43. data/lib/middleman-core/core_extensions/external_helpers.rb +2 -1
  44. data/lib/middleman-core/core_extensions/file_watcher.rb +7 -0
  45. data/lib/middleman-core/core_extensions/front_matter.rb +13 -4
  46. data/lib/middleman-core/core_extensions/rendering.rb +20 -6
  47. data/lib/middleman-core/core_extensions/request.rb +2 -2
  48. data/lib/middleman-core/dns_resolver.rb +73 -0
  49. data/lib/middleman-core/dns_resolver/basic_network_resolver.rb +52 -0
  50. data/lib/middleman-core/dns_resolver/hosts_resolver.rb +63 -0
  51. data/lib/middleman-core/dns_resolver/local_link_resolver.rb +44 -0
  52. data/lib/middleman-core/dns_resolver/network_resolver.rb +42 -0
  53. data/lib/middleman-core/extension.rb +0 -1
  54. data/lib/middleman-core/meta_pages.rb +1 -1
  55. data/lib/middleman-core/preview_server.rb +94 -37
  56. data/lib/middleman-core/preview_server/checks.rb +81 -0
  57. data/lib/middleman-core/preview_server/information.rb +273 -0
  58. data/lib/middleman-core/preview_server/network_interface_inventory.rb +65 -0
  59. data/lib/middleman-core/preview_server/server_hostname.rb +39 -0
  60. data/lib/middleman-core/preview_server/server_information.rb +144 -0
  61. data/lib/middleman-core/preview_server/server_information_validator.rb +18 -0
  62. data/lib/middleman-core/preview_server/server_ip_address.rb +55 -0
  63. data/lib/middleman-core/preview_server/server_url.rb +50 -0
  64. data/lib/middleman-core/preview_server/tcp_port_prober.rb +29 -0
  65. data/lib/middleman-core/sitemap.rb +4 -4
  66. data/lib/middleman-core/sitemap/extensions/ignores.rb +5 -1
  67. data/lib/middleman-core/sitemap/extensions/proxies.rb +0 -1
  68. data/lib/middleman-core/sitemap/extensions/redirects.rb +2 -1
  69. data/lib/middleman-core/sitemap/queryable.rb +2 -1
  70. data/lib/middleman-core/sitemap/store.rb +3 -3
  71. data/lib/middleman-core/step_definitions.rb +1 -0
  72. data/lib/middleman-core/step_definitions/builder_steps.rb +7 -7
  73. data/lib/middleman-core/step_definitions/commandline_steps.rb +88 -0
  74. data/lib/middleman-core/step_definitions/server_steps.rb +25 -28
  75. data/lib/middleman-core/templates/extension/Gemfile +0 -1
  76. data/lib/middleman-core/templates/extension/Rakefile +1 -1
  77. data/lib/middleman-core/util.rb +24 -0
  78. data/lib/middleman-core/version.rb +1 -1
  79. data/lib/middleman-more/core_extensions/default_helpers.rb +49 -8
  80. data/lib/middleman-more/core_extensions/i18n.rb +101 -27
  81. data/lib/middleman-more/extensions/asset_hash.rb +1 -1
  82. data/lib/middleman-more/extensions/asset_host.rb +1 -1
  83. data/lib/middleman-more/extensions/automatic_image_sizes.rb +7 -0
  84. data/lib/middleman-more/extensions/cache_buster.rb +1 -1
  85. data/lib/middleman-more/extensions/lorem.rb +2 -2
  86. data/lib/middleman-more/extensions/minify_javascript.rb +6 -4
  87. data/lib/middleman-more/extensions/relative_assets.rb +4 -8
  88. data/middleman-core.gemspec +3 -3
  89. data/spec/middleman-core/dns_resolver_spec.rb +118 -0
  90. data/spec/middleman-core/preview_server/server_hostname_spec.rb +39 -0
  91. data/spec/middleman-core/preview_server/server_ip_address_spec.rb +43 -0
  92. data/spec/spec_helper.rb +26 -0
  93. metadata +81 -17
@@ -1,6 +1,7 @@
1
1
  <html>
2
2
  <head>
3
3
  <%= stylesheet_link_tag :relative_assets %>
4
+ <%= javascript_include_tag :app %>
4
5
  </head>
5
6
  <body>
6
7
  <%= image_tag "blank.gif" %>
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ <%= stylesheet_link_tag :relative_assets, relative: false %>
4
+ <%= javascript_include_tag :app, relative: false %>
5
+ </head>
6
+ <body>
7
+ <%= image_tag "blank.gif" %>
8
+ </body>
9
+ </html>
@@ -8,10 +8,6 @@ require 'i18n'
8
8
  # users expect.
9
9
  ::I18n.enforce_available_locales = false
10
10
 
11
- # Use ActiveSupport JSON
12
- require 'active_support/json'
13
- require 'active_support/core_ext/integer/inflections'
14
-
15
11
  # Simple callback library
16
12
  require 'hooks'
17
13
 
@@ -57,7 +53,9 @@ module Middleman
57
53
  # Root project directory (overwritten in middleman build/server)
58
54
  # @return [String]
59
55
  def self.root
60
- ENV['MM_ROOT'] || Dir.pwd
56
+ r = ENV['MM_ROOT'] ? ENV['MM_ROOT'].dup : ::Middleman::Util.current_directory
57
+ r.encode!('UTF-8', 'UTF-8-MAC') if RUBY_PLATFORM =~ /darwin/
58
+ r
61
59
  end
62
60
  delegate :root, to: :"self.class"
63
61
 
@@ -71,6 +69,14 @@ module Middleman
71
69
  # @return [Fixnum]
72
70
  config.define_setting :port, 4567, 'The preview server port'
73
71
 
72
+ # Which server name should be used
73
+ # @return [NilClass, String]
74
+ config.define_setting :server_name, nil, 'The server name of preview server'
75
+
76
+ # Which bind address the preview server should use
77
+ # @return [NilClass, String]
78
+ config.define_setting :bind_address, nil, 'The bind address of the preview server'
79
+
74
80
  # Whether to serve the preview server over HTTPS.
75
81
  # @return [Boolean]
76
82
  config.define_setting :https, false, 'Serve the preview server over SSL/TLS'
@@ -138,7 +138,9 @@ module Middleman::Cli
138
138
  base.remove_file f, force: true
139
139
  end
140
140
 
141
- Dir[@build_dir.join('**', '*')].select { |d| File.directory?(d) }.each do |d|
141
+ ::Middleman::Util.glob_directory(@build_dir.join('**', '*'))
142
+ .select { |d| File.directory?(d) }
143
+ .each do |d|
142
144
  base.remove_file d, force: true if directory_empty? d
143
145
  end
144
146
  end
@@ -34,6 +34,6 @@ module Middleman::Cli
34
34
 
35
35
  # Map "u" to "upgrade"
36
36
  Base.map(
37
- 'u' => 'upgrade'
37
+ 'u' => 'upgrade'
38
38
  )
39
39
  end
@@ -35,13 +35,13 @@ module Middleman::Cli
35
35
  # Output a .gitignore file
36
36
  class_option :git, type: :boolean, default: true
37
37
 
38
- no_tasks {
38
+ no_tasks do
39
39
  # Write a .gitignore file for project
40
40
  # @return [void]
41
41
  def generate_gitignore!
42
42
  return unless options[:git]
43
43
  copy_file 'gitignore', File.join(name, '.gitignore')
44
44
  end
45
- }
45
+ end
46
46
  end
47
47
  end
@@ -64,8 +64,8 @@ module Middleman::Cli
64
64
 
65
65
  # Map "i", "new" and "n" to "init"
66
66
  Base.map(
67
- 'i' => 'init',
68
- 'new' => 'init',
69
- 'n' => 'init'
67
+ 'i' => 'init',
68
+ 'new' => 'init',
69
+ 'n' => 'init'
70
70
  )
71
71
  end
@@ -14,6 +14,12 @@ module Middleman::Cli
14
14
  method_option :port,
15
15
  aliases: '-p',
16
16
  desc: 'The port Middleman will listen on'
17
+ method_option :server_name,
18
+ aliases: '-s',
19
+ desc: 'The server name name Middleman will use'
20
+ method_option :bind_address,
21
+ aliases: '-b',
22
+ desc: 'The bind address Middleman will listen on'
17
23
  method_option :https,
18
24
  type: :boolean,
19
25
  desc: 'Serve the preview server over SSL/TLS'
@@ -59,13 +65,15 @@ module Middleman::Cli
59
65
  unless ENV['MM_ROOT']
60
66
  puts '== Could not find a Middleman project config.rb'
61
67
  puts '== Treating directory as a static site to be served'
62
- ENV['MM_ROOT'] = Dir.pwd
68
+ ENV['MM_ROOT'] = ::Middleman::Util.current_directory
63
69
  ENV['MM_SOURCE'] = ''
64
70
  end
65
71
 
66
72
  params = {
67
73
  port: options['port'],
74
+ bind_address: options['bind_address'],
68
75
  https: options['https'],
76
+ server_name: options['server_name'],
69
77
  ssl_certificate: options['ssl_certificate'],
70
78
  ssl_private_key: options['ssl_private_key'],
71
79
  environment: options['environment'],
@@ -118,7 +118,6 @@ module Middleman
118
118
  # Set the value of a setting by key. Creates the setting if it doesn't exist.
119
119
  # @param [Symbol] key
120
120
  # @param [Object] val
121
- # rubocop:disable UselessSetterCall
122
121
  def []=(key, val)
123
122
  setting_obj = setting(key) || define_setting(key)
124
123
  setting_obj.value = val
@@ -228,7 +227,6 @@ module Middleman
228
227
  end
229
228
 
230
229
  # Whether or not there has been a value set beyond the default
231
- # rubocop:disable TrivialAccessors
232
230
  def value_set?
233
231
  @value_set
234
232
  end
@@ -9,7 +9,7 @@ module Middleman
9
9
  def registered(app)
10
10
  # Data formats
11
11
  require 'yaml'
12
- require 'active_support/json'
12
+ require 'json'
13
13
 
14
14
  app.config.define_setting :data_dir, 'data', 'The directory data files are stored in'
15
15
  app.send :include, InstanceMethods
@@ -98,7 +98,7 @@ module Middleman
98
98
  if %w(.yaml .yml).include?(extension)
99
99
  data = YAML.load_file(full_path)
100
100
  elsif extension == '.json'
101
- data = ActiveSupport::JSON.decode(full_path.read)
101
+ data = JSON.parse(full_path.read)
102
102
  else
103
103
  return
104
104
  end
@@ -19,7 +19,8 @@ module Middleman
19
19
  helpers_path = File.join(root, config[:helpers_dir])
20
20
  next unless File.exist?(helpers_path)
21
21
 
22
- Dir[File.join(helpers_path, config[:helpers_filename_glob])].each do |filename|
22
+ glob = File.join(helpers_path, config[:helpers_filename_glob])
23
+ ::Middleman::Util.glob_directory(glob).each do |filename|
23
24
  module_name = config[:helpers_filename_to_module_name_proc].call(filename)
24
25
  next unless module_name
25
26
 
@@ -95,6 +95,8 @@ module Middleman
95
95
  # @param [Pathname] path The file that changed
96
96
  # @return [void]
97
97
  def did_change(path)
98
+ path = path.to_s.encode!('UTF-8', 'UTF-8-MAC') if RUBY_PLATFORM =~ /darwin/
99
+
98
100
  path = Pathname(path)
99
101
  logger.debug "== File Change: #{path}"
100
102
  @known_paths << path
@@ -106,6 +108,8 @@ module Middleman
106
108
  # @param [Pathname] path The file that was deleted
107
109
  # @return [void]
108
110
  def did_delete(path)
111
+ path = path.to_s.encode!('UTF-8', 'UTF-8-MAC') if RUBY_PLATFORM =~ /darwin/
112
+
109
113
  path = Pathname(path)
110
114
  logger.debug "== File Deletion: #{path}"
111
115
  @known_paths.delete(path)
@@ -146,7 +150,10 @@ module Middleman
146
150
  end
147
151
 
148
152
  def exists?(path)
153
+ path = path.to_s.encode!('UTF-8', 'UTF-8-MAC') if RUBY_PLATFORM =~ /darwin/
154
+
149
155
  p = Pathname(path)
156
+
150
157
  p = p.relative_path_from(Pathname(@app.root)) unless p.relative?
151
158
  @known_paths.include?(p)
152
159
  end
@@ -5,7 +5,7 @@ require 'pathname'
5
5
  require 'yaml'
6
6
 
7
7
  # Parsing JSON frontmatter
8
- require 'active_support/json'
8
+ require 'json'
9
9
 
10
10
  # Extensions namespace
11
11
  module Middleman::CoreExtensions
@@ -101,7 +101,7 @@ module Middleman::CoreExtensions
101
101
  data, content = frontmatter_and_content(p)
102
102
 
103
103
  if app.files.exists?("#{path}.frontmatter")
104
- external_data, _ = frontmatter_and_content("#{p}.frontmatter")
104
+ external_data, = frontmatter_and_content("#{p}.frontmatter")
105
105
  data = external_data.deep_merge(data)
106
106
  end
107
107
 
@@ -154,7 +154,7 @@ module Middleman::CoreExtensions
154
154
 
155
155
  begin
156
156
  json = ($1 + $2).sub(';;;', '{').sub(';;;', '}')
157
- data = ActiveSupport::JSON.decode(json).symbolize_keys
157
+ data = JSON.parse(json).symbolize_keys
158
158
  rescue => e
159
159
  app.logger.error "JSON Exception parsing #{full_path}: #{e.message}"
160
160
  return false
@@ -185,7 +185,7 @@ module Middleman::CoreExtensions
185
185
 
186
186
  # Avoid weird race condition when a file is renamed.
187
187
  content = begin
188
- File.read(full_path)
188
+ read_data_file(full_path)
189
189
  rescue ::EOFError
190
190
  rescue ::IOError
191
191
  rescue ::Errno::ENOENT
@@ -208,6 +208,15 @@ module Middleman::CoreExtensions
208
208
  [data, content]
209
209
  end
210
210
 
211
+ def read_data_file(path)
212
+ data = File.open(path, 'rb') { |io| io.read }
213
+ if data.respond_to?(:force_encoding)
214
+ # Set it to the default external (without verifying)
215
+ data.force_encoding(Encoding.default_external) if Encoding.default_external
216
+ end
217
+ data
218
+ end
219
+
211
220
  def normalize_path(path)
212
221
  path.sub(%r{^#{Regexp.escape(app.source_dir)}\/}, '')
213
222
  end
@@ -217,10 +217,19 @@ module Middleman
217
217
  # Render the partial if found, otherwide throw exception
218
218
  _render_with_all_renderers(found_partial, locals, self, options, &block)
219
219
  else
220
- File.read(found_partial)
220
+ read_template_file(found_partial)
221
221
  end
222
222
  end
223
223
 
224
+ def read_template_file(path)
225
+ data = ::File.open(path, 'rb') { |io| io.read }
226
+ if data.respond_to?(:force_encoding)
227
+ # Set it to the default external (without verifying)
228
+ data.force_encoding(::Encoding.default_external) if ::Encoding.default_external
229
+ end
230
+ data
231
+ end
232
+
224
233
  # Partial locator.
225
234
  #
226
235
  # @param [String] partial_name
@@ -277,6 +286,7 @@ module Middleman
277
286
  extension = File.extname(path)
278
287
  options = opts.dup.merge(options_for_ext(extension))
279
288
  options[:outvar] ||= '@_out_buf'
289
+ options[:default_encoding] ||= 'UTF-8'
280
290
  options.delete(:layout)
281
291
 
282
292
  # Overwrite with frontmatter options
@@ -300,7 +310,7 @@ module Middleman
300
310
  end
301
311
 
302
312
  # Render using Tilt
303
- content = template.render(context, locs, &block)
313
+ content = template.render(context || ::Object.new, locs, &block)
304
314
 
305
315
  # Allow hooks to manipulate the result after render
306
316
  self.class.callbacks_for_hook(:after_render).each do |callback|
@@ -326,7 +336,7 @@ module Middleman
326
336
  # @param [String] path
327
337
  # @return [String]
328
338
  def template_data_for_file(path)
329
- File.read(File.expand_path(path, source_dir))
339
+ read_template_file(File.expand_path(path, source_dir))
330
340
  end
331
341
 
332
342
  # Get a hash of configuration options for a given file extension, from
@@ -418,11 +428,16 @@ module Middleman
418
428
 
419
429
  layout_path = locate_layout(layout_name, current_engine)
420
430
 
431
+ unless layout_path
432
+ raise ::Middleman::CoreExtensions::Rendering::TemplateNotFound, "Could not locate layout: #{layout_name}"
433
+ end
434
+
421
435
  extension = File.extname(layout_path)
422
436
  engine = extension[1..-1].to_sym
423
437
 
424
438
  # Store last engine for later (could be inside nested renders)
425
- self.current_engine, engine_was = engine, current_engine
439
+ self.current_engine = engine
440
+ engine_was = current_engine
426
441
 
427
442
  begin
428
443
  content = if block_given?
@@ -447,7 +462,6 @@ module Middleman
447
462
  end
448
463
 
449
464
  # The currently rendering engine
450
- # rubocop:disable TrivialAccessors
451
465
  # @return [Symbol, nil]
452
466
  def current_engine=(v)
453
467
  @_current_engine = v
@@ -502,7 +516,7 @@ module Middleman
502
516
 
503
517
  found_path = nil
504
518
  search_paths.each do |path_with_ext|
505
- found_path = Dir[path_with_ext].find do |path|
519
+ found_path = ::Middleman::Util.glob_directory(path_with_ext).find do |path|
506
520
  ::Tilt[path]
507
521
  end
508
522
 
@@ -173,8 +173,8 @@ module Middleman
173
173
  def current_path=(path)
174
174
  Thread.current[:current_path] = path
175
175
  Thread.current[:legacy_request] = ::Thor::CoreExt::HashWithIndifferentAccess.new(
176
- path: path,
177
- params: req ? ::Thor::CoreExt::HashWithIndifferentAccess.new(req.params) : {}
176
+ path: path,
177
+ params: req ? ::Thor::CoreExt::HashWithIndifferentAccess.new(req.params) : {}
178
178
  )
179
179
  end
180
180
 
@@ -0,0 +1,73 @@
1
+ require 'resolv'
2
+ require 'middleman-core/dns_resolver/network_resolver'
3
+ require 'middleman-core/dns_resolver/hosts_resolver'
4
+
5
+ module Middleman
6
+ # This resolves IP address to names and vice versa
7
+ class DnsResolver
8
+ private
9
+
10
+ attr_reader :resolvers
11
+
12
+ public
13
+
14
+ # Create resolver
15
+ #
16
+ # First the local resolver is used. If environment variable HOSTSRC is
17
+ # given this file is used for local name lookup.
18
+ #
19
+ # @param [#getnames, #getaddresses] network_resolver
20
+ # The resolver which uses a network name server to resolve ip addresses
21
+ # and names.
22
+ #
23
+ # @param [#getnames, #getaddresses] local_resolver
24
+ # The resolver uses /etc/hosts on POSIX-systems and
25
+ # C:\Windows\System32\drivers\etc\hosts on Windows-operating systems to
26
+ # resolve ip addresses and names.
27
+ #
28
+ # First the local resolver is queried. If this raises an error or returns
29
+ # nil or [] the network resolver is queried.
30
+ def initialize(opts={})
31
+ @resolvers = []
32
+ @resolvers << opts.fetch(:hosts_resolver, HostsResolver.new)
33
+
34
+ if RUBY_VERSION >= '2.1'
35
+ require 'middleman-core/dns_resolver/local_link_resolver'
36
+ @resolvers << opts.fetch(:local_link_resolver, LocalLinkResolver.new)
37
+ end
38
+
39
+ @resolvers << opts.fetch(:network_resolver, NetworkResolver.new)
40
+ end
41
+
42
+ # Get names for given ip
43
+ #
44
+ # @param [String] ip
45
+ # The ip which should be resolved.
46
+ def names_for(ip)
47
+ resolvers.each do |r|
48
+ names = r.getnames(ip)
49
+
50
+ return names unless names.nil? || names.empty?
51
+ end
52
+
53
+ []
54
+ end
55
+
56
+ # Get ips for given name
57
+ #
58
+ # First the local resolver is used. On POSIX-systems /etc/hosts is used. On
59
+ # Windows C:\Windows\System32\drivers\etc\hosts is used.
60
+ #
61
+ # @param [String] name
62
+ # The name which should be resolved.
63
+ def ips_for(name)
64
+ resolvers.each do |r|
65
+ ips = r.getaddresses(name)
66
+
67
+ return ips unless ips.nil? || ips.empty?
68
+ end
69
+
70
+ []
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,52 @@
1
+ module Middleman
2
+ class DnsResolver
3
+ # Use network name server to resolve ips and names
4
+ class BasicNetworkResolver
5
+ private
6
+
7
+ attr_reader :resolver, :timeouts
8
+
9
+ public
10
+
11
+ def initialize(opts={})
12
+ @timeouts = opts.fetch(:timeouts, 2)
13
+ end
14
+
15
+ # Get names for ip
16
+ #
17
+ # @param [#to_s] ip
18
+ # The ip to resolve into names
19
+ #
20
+ # @return [Array]
21
+ # Array of Names
22
+ def getnames(ip)
23
+ resolver.getnames(ip.to_s).map(&:to_s)
24
+ rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL
25
+ []
26
+ end
27
+
28
+ # Get ips for name
29
+ #
30
+ # @param [#to_s] name
31
+ # The name to resolve into ips
32
+ #
33
+ # @return [Array]
34
+ # Array of ipaddresses
35
+ def getaddresses(name)
36
+ resolver.getaddresses(name.to_s).map(&:to_s)
37
+ rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL
38
+ []
39
+ end
40
+
41
+ # Set timeout for lookup
42
+ #
43
+ # @param [Integer] value
44
+ # The timeout value
45
+ def timeouts=(timeouts)
46
+ return if RUBY_VERSION < '2'
47
+
48
+ resolver.timeouts = timeouts
49
+ end
50
+ end
51
+ end
52
+ end