middleman-core 3.3.2 → 3.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/features/helpers_select_tag.feature +6 -8
  3. data/lib/middleman-core.rb +1 -2
  4. data/lib/middleman-core/application.rb +10 -9
  5. data/lib/middleman-core/cli.rb +9 -13
  6. data/lib/middleman-core/cli/build.rb +26 -27
  7. data/lib/middleman-core/cli/bundler.rb +6 -7
  8. data/lib/middleman-core/cli/console.rb +10 -13
  9. data/lib/middleman-core/cli/extension.rb +2 -4
  10. data/lib/middleman-core/cli/init.rb +27 -28
  11. data/lib/middleman-core/cli/server.rb +43 -44
  12. data/lib/middleman-core/configuration.rb +13 -11
  13. data/lib/middleman-core/core_extensions/data.rb +21 -29
  14. data/lib/middleman-core/core_extensions/extensions.rb +8 -8
  15. data/lib/middleman-core/core_extensions/external_helpers.rb +3 -5
  16. data/lib/middleman-core/core_extensions/file_watcher.rb +7 -11
  17. data/lib/middleman-core/core_extensions/front_matter.rb +5 -6
  18. data/lib/middleman-core/core_extensions/rendering.rb +40 -30
  19. data/lib/middleman-core/core_extensions/request.rb +16 -19
  20. data/lib/middleman-core/core_extensions/routing.rb +37 -36
  21. data/lib/middleman-core/core_extensions/show_exceptions.rb +1 -5
  22. data/lib/middleman-core/extension.rb +14 -16
  23. data/lib/middleman-core/extensions.rb +4 -6
  24. data/lib/middleman-core/load_paths.rb +3 -6
  25. data/lib/middleman-core/logger.rb +1 -3
  26. data/lib/middleman-core/meta_pages.rb +11 -11
  27. data/lib/middleman-core/meta_pages/config_setting.rb +4 -4
  28. data/lib/middleman-core/meta_pages/sitemap_resource.rb +2 -2
  29. data/lib/middleman-core/meta_pages/sitemap_tree.rb +4 -4
  30. data/lib/middleman-core/preview_server.rb +12 -11
  31. data/lib/middleman-core/profiling.rb +6 -8
  32. data/lib/middleman-core/renderers/asciidoc.rb +12 -13
  33. data/lib/middleman-core/renderers/coffee_script.rb +2 -4
  34. data/lib/middleman-core/renderers/erb.rb +3 -4
  35. data/lib/middleman-core/renderers/haml.rb +2 -4
  36. data/lib/middleman-core/renderers/kramdown.rb +3 -4
  37. data/lib/middleman-core/renderers/less.rb +3 -9
  38. data/lib/middleman-core/renderers/liquid.rb +4 -8
  39. data/lib/middleman-core/renderers/markdown.rb +7 -11
  40. data/lib/middleman-core/renderers/redcarpet.rb +14 -16
  41. data/lib/middleman-core/renderers/sass.rb +36 -15
  42. data/lib/middleman-core/renderers/slim.rb +7 -10
  43. data/lib/middleman-core/renderers/stylus.rb +2 -6
  44. data/lib/middleman-core/sitemap.rb +6 -13
  45. data/lib/middleman-core/sitemap/extensions/ignores.rb +4 -10
  46. data/lib/middleman-core/sitemap/extensions/on_disk.rb +3 -7
  47. data/lib/middleman-core/sitemap/extensions/proxies.rb +7 -12
  48. data/lib/middleman-core/sitemap/extensions/redirects.rb +7 -15
  49. data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +7 -15
  50. data/lib/middleman-core/sitemap/extensions/traversal.rb +4 -7
  51. data/lib/middleman-core/sitemap/queryable.rb +22 -27
  52. data/lib/middleman-core/sitemap/resource.rb +13 -25
  53. data/lib/middleman-core/sitemap/store.rb +11 -15
  54. data/lib/middleman-core/templates.rb +9 -12
  55. data/lib/middleman-core/templates/default.rb +6 -7
  56. data/lib/middleman-core/templates/empty.rb +0 -1
  57. data/lib/middleman-core/templates/extension/Gemfile +1 -1
  58. data/lib/middleman-core/templates/extension/Rakefile +2 -2
  59. data/lib/middleman-core/templates/extension/lib/lib.rb +0 -1
  60. data/lib/middleman-core/templates/html5.rb +6 -7
  61. data/lib/middleman-core/templates/local.rb +1 -2
  62. data/lib/middleman-core/templates/mobile.rb +3 -4
  63. data/lib/middleman-core/templates/shared/config.ru +1 -1
  64. data/lib/middleman-core/util.rb +5 -6
  65. data/lib/middleman-core/version.rb +1 -1
  66. data/lib/middleman-more/core_extensions/compass.rb +0 -1
  67. data/lib/middleman-more/core_extensions/default_helpers.rb +25 -16
  68. data/lib/middleman-more/core_extensions/i18n.rb +24 -23
  69. data/lib/middleman-more/extensions/asset_hash.rb +4 -6
  70. data/lib/middleman-more/extensions/asset_host.rb +1 -1
  71. data/lib/middleman-more/extensions/automatic_alt_tags.rb +2 -3
  72. data/lib/middleman-more/extensions/automatic_image_sizes.rb +4 -5
  73. data/lib/middleman-more/extensions/cache_buster.rb +0 -1
  74. data/lib/middleman-more/extensions/gzip.rb +1 -1
  75. data/lib/middleman-more/extensions/lorem.rb +8 -8
  76. data/lib/middleman-more/extensions/minify_css.rb +9 -8
  77. data/lib/middleman-more/extensions/minify_javascript.rb +5 -6
  78. data/lib/middleman-more/extensions/relative_assets.rb +0 -1
  79. data/lib/middleman-more/templates/smacss.rb +6 -7
  80. data/middleman-core.gemspec +1 -1
  81. metadata +5 -5
@@ -1,6 +1,5 @@
1
1
  # Local templates
2
2
  class Middleman::Templates::Local < Middleman::Templates::Base
3
-
4
3
  # Look for templates in ~/.middleman
5
4
  # @return [String]
6
5
  def self.source_root
@@ -20,7 +19,7 @@ Dir[File.join(Middleman::Templates::Local.source_root, '*')].each do |dir|
20
19
 
21
20
  template_file = File.join(dir, 'template.rb')
22
21
 
23
- if File.exists?(template_file)
22
+ if File.exist?(template_file)
24
23
  require template_file
25
24
  else
26
25
  Middleman::Templates.register(File.basename(dir).to_sym, Middleman::Templates::Local)
@@ -1,10 +1,9 @@
1
1
  # Mobile HTML5 Boilerplate
2
2
  class Middleman::Templates::Mobile < Middleman::Templates::Base
3
-
4
3
  # Slightly different paths
5
- class_option :css_dir, :default => 'css'
6
- class_option :js_dir, :default => 'js'
7
- class_option :images_dir, :default => 'img'
4
+ class_option :css_dir, default: 'css'
5
+ class_option :js_dir, default: 'js'
6
+ class_option :images_dir, default: 'img'
8
7
 
9
8
  # Template files are relative to this file
10
9
  # @return [String]
@@ -1,4 +1,4 @@
1
1
  require 'rubygems'
2
2
  require 'middleman/rack'
3
3
 
4
- run Middleman.server
4
+ run Middleman.server
@@ -14,7 +14,6 @@ require 'rack/mime'
14
14
  module Middleman
15
15
  module Util
16
16
  class << self
17
-
18
17
  # Whether the source file is binary.
19
18
  #
20
19
  # @param [String] filename The file to check.
@@ -27,7 +26,7 @@ module Middleman
27
26
 
28
27
  return false if Tilt.registered?(ext.sub('.', ''))
29
28
 
30
- dot_ext = (ext.to_s[0] == ?.) ? ext.dup : ".#{ext}"
29
+ dot_ext = (ext.to_s[0] == '.') ? ext.dup : ".#{ext}"
31
30
 
32
31
  if mime = ::Rack::Mime.mime_type(dot_ext, nil)
33
32
  !nonbinary_mime?(mime)
@@ -69,7 +68,7 @@ module Middleman
69
68
  # @return [String]
70
69
  def normalize_path(path)
71
70
  # The tr call works around a bug in Ruby's Unicode handling
72
- path.sub(%r{^/}, '').tr('','')
71
+ path.sub(%r{^/}, '').tr('', '')
73
72
  end
74
73
 
75
74
  # This is a separate method from normalize_path in case we
@@ -85,7 +84,7 @@ module Middleman
85
84
  def extract_response_text(response)
86
85
  # The rack spec states all response bodies must respond to each
87
86
  result = ''
88
- response.each do |part, s|
87
+ response.each do |part, _|
89
88
  result << part
90
89
  end
91
90
  result
@@ -210,7 +209,7 @@ module Middleman
210
209
  def full_path(path, app)
211
210
  resource = app.sitemap.find_resource_by_destination_path(path)
212
211
 
213
- if !resource
212
+ unless resource
214
213
  # Try it with /index.html at the end
215
214
  indexed_path = File.join(path.sub(%r{/$}, ''), app.config[:index_file])
216
215
  resource = app.sitemap.find_resource_by_destination_path(indexed_path)
@@ -223,7 +222,7 @@ module Middleman
223
222
  end
224
223
  end
225
224
 
226
- private
225
+ private
227
226
 
228
227
  # Is mime type known to be non-binary?
229
228
  #
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  # Current Version
3
3
  # @return [String]
4
- VERSION = '3.3.2' unless const_defined?(:VERSION)
4
+ VERSION = '3.3.3' unless const_defined?(:VERSION)
5
5
  end
@@ -2,7 +2,6 @@ require 'middleman-core/renderers/sass'
2
2
  require 'compass'
3
3
 
4
4
  class Middleman::CoreExtensions::Compass < ::Middleman::Extension
5
-
6
5
  def initialize(app, options_hash={}, &block)
7
6
  super
8
7
 
@@ -6,8 +6,9 @@ require 'padrino-helpers'
6
6
 
7
7
  class Padrino::Helpers::OutputHelpers::ErbHandler
8
8
  # Force Erb capture not to use safebuffer
9
+ # rubocop:disable UnderscorePrefixedVariableName
9
10
  def capture_from_template(*args, &block)
10
- self.output_buffer, _buf_was = '', self.output_buffer
11
+ self.output_buffer, _buf_was = '', output_buffer
11
12
  raw = block.call(*args)
12
13
  captured = template.instance_variable_get(:@_out_buf)
13
14
  self.output_buffer = _buf_was
@@ -16,7 +17,6 @@ class Padrino::Helpers::OutputHelpers::ErbHandler
16
17
  end
17
18
 
18
19
  class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
19
-
20
20
  def initialize(app, options_hash={}, &block)
21
21
  super
22
22
 
@@ -39,7 +39,8 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
39
39
  helpers do
40
40
 
41
41
  # Make all block content html_safe
42
- def content_tag(name, content = nil, options = nil, &block)
42
+ # rubocop:disable Semicolon
43
+ def content_tag(name, content=nil, options=nil, &block)
43
44
  if block_given?
44
45
  options = content if content.is_a?(Hash)
45
46
  content = capture_html(&block)
@@ -108,8 +109,10 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
108
109
  def auto_tag(asset_ext, asset_dir=nil)
109
110
  if asset_dir.nil?
110
111
  asset_dir = case asset_ext
111
- when :js then js_dir
112
- when :css then css_dir
112
+ when :js
113
+ js_dir
114
+ when :css
115
+ css_dir
113
116
  end
114
117
  end
115
118
 
@@ -124,7 +127,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
124
127
  # Generate body css classes based on the current path
125
128
  #
126
129
  # @return [String]
127
- def page_classes(path = current_path.dup, options={})
130
+ def page_classes(path=current_path.dup, options={})
128
131
  if path.is_a? Hash
129
132
  options = path
130
133
  path = current_path.dup
@@ -135,7 +138,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
135
138
 
136
139
  classes = []
137
140
  parts = path.split('.').first.split('/')
138
- parts.each_with_index { |_, i| classes << parts.first(i+1).join('_') }
141
+ parts.each_with_index { |_, i| classes << parts.first(i + 1).join('_') }
139
142
 
140
143
  prefix = options[:numeric_prefix] || 'x'
141
144
  classes.map do |c|
@@ -155,13 +158,19 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
155
158
  # @return [String]
156
159
  def asset_path(kind, source)
157
160
  return source if source.to_s.include?('//') || source.to_s.start_with?('data:')
158
- asset_folder = case kind
159
- when :css then css_dir
160
- when :js then js_dir
161
- when :images then images_dir
162
- when :fonts then fonts_dir
163
- else kind.to_s
161
+ asset_folder = case kind
162
+ when :css
163
+ css_dir
164
+ when :js
165
+ js_dir
166
+ when :images
167
+ images_dir
168
+ when :fonts
169
+ fonts_dir
170
+ else
171
+ kind.to_s
164
172
  end
173
+
165
174
  source = source.to_s.tr(' ', '')
166
175
  ignore_extension = (kind == :images || kind == :fonts) # don't append extension
167
176
  source << ".#{kind}" unless ignore_extension || source.end_with?(".#{kind}")
@@ -177,7 +186,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
177
186
  # @return [String] The fully qualified asset url
178
187
  def asset_url(path, prefix='')
179
188
  # Don't touch assets which already have a full path
180
- if path.include?('//') or path.start_with?('data:')
189
+ if path.include?('//') || path.start_with?('data:')
181
190
  path
182
191
  else # rewrite paths to use their destination path
183
192
  if resource = sitemap.find_resource_by_destination_path(url_for(path))
@@ -221,12 +230,12 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
221
230
  options_index = block_given? ? 1 : 2
222
231
 
223
232
  if block_given? && args.size > 2
224
- raise ArgumentError.new('Too many arguments to link_to(url, options={}, &block)')
233
+ raise ArgumentError, 'Too many arguments to link_to(url, options={}, &block)'
225
234
  end
226
235
 
227
236
  if url = args[url_arg_index]
228
237
  options = args[options_index] || {}
229
- raise ArgumentError.new('Options must be a hash') unless options.is_a?(Hash)
238
+ raise ArgumentError, 'Options must be a hash' unless options.is_a?(Hash)
230
239
 
231
240
  # Transform the url through our magic url_for method
232
241
  args[url_arg_index] = url_for(url, options)
@@ -37,8 +37,8 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
37
37
 
38
38
  configure_i18n
39
39
 
40
- if !app.build?
41
- logger.info "== Locales: #{langs.join(", ")} (Default #{@mount_at_root})"
40
+ unless app.build?
41
+ logger.info "== Locales: #{langs.join(', ')} (Default #{@mount_at_root})"
42
42
  end
43
43
 
44
44
  # Don't output localizable files
@@ -55,10 +55,10 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
55
55
  end
56
56
  end
57
57
 
58
- delegate :logger, :to => :app
58
+ delegate :logger, to: :app
59
59
 
60
60
  def langs
61
- @_langs ||= get_known_languages
61
+ @_langs ||= known_languages
62
62
  end
63
63
 
64
64
  # Update the main sitemap resource list
@@ -70,10 +70,10 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
70
70
 
71
71
  resources.each do |resource|
72
72
  # If it uses file extension localization
73
- if !parse_locale_extension(resource.path).nil?
73
+ if parse_locale_extension(resource.path)
74
74
  result = parse_locale_extension(resource.path)
75
- lang, path, page_id = result
76
- new_resources << build_resource(path, resource.path, page_id, lang)
75
+ ext_lang, path, page_id = result
76
+ new_resources << build_resource(path, resource.path, page_id, ext_lang)
77
77
  # If it's a "localizable template"
78
78
  elsif File.fnmatch?(File.join(options[:templates_dir], '**'), resource.path)
79
79
  page_id = File.basename(resource.path, File.extname(resource.path))
@@ -90,7 +90,6 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
90
90
 
91
91
  private
92
92
 
93
-
94
93
  def on_file_changed(file)
95
94
  if @locales_regex =~ file
96
95
  @_langs = nil # Clear langs cache
@@ -100,7 +99,7 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
100
99
 
101
100
  def convert_glob_to_regex(glob)
102
101
  # File.fnmatch doesn't support brackets: {rb,yml,yaml}
103
- regex = @locales_glob.sub(/\./, '\.').sub(File.join('**', '*'), '.*').sub(/\//, '\/').sub('{rb,yml,yaml}', '(rb|ya?ml)')
102
+ regex = glob.sub(/\./, '\.').sub(File.join('**', '*'), '.*').sub(/\//, '\/').sub('{rb,yml,yaml}', '(rb|ya?ml)')
104
103
  %r{^#{regex}}
105
104
  end
106
105
 
@@ -116,7 +115,7 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
116
115
  end
117
116
 
118
117
  def metadata_for_path(url)
119
- if d = get_localization_data(url)
118
+ if d = localization_data(url)
120
119
  lang, page_id = d
121
120
  else
122
121
  # Default to the @mount_at_root lang
@@ -124,36 +123,38 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
124
123
  lang = @mount_at_root
125
124
  end
126
125
 
127
- instance_vars = Proc.new do
126
+ instance_vars = proc do
128
127
  @lang = lang
129
128
  @page_id = page_id
130
129
  end
131
130
 
132
131
  locals = {
133
- :lang => lang,
134
- :page_id => page_id
132
+ lang: lang,
133
+ page_id: page_id
135
134
  }
136
135
 
137
136
  {
138
- :blocks => [instance_vars],
139
- :locals => locals,
140
- :options => { :lang => lang }
137
+ blocks: [instance_vars],
138
+ locals: locals,
139
+ options: { lang: lang }
141
140
  }
142
141
  end
143
142
 
144
- def get_known_languages
143
+ def known_languages
145
144
  if options[:langs]
146
145
  Array(options[:langs]).map(&:to_sym)
147
146
  else
148
147
  known_langs = app.files.known_paths.select do |p|
149
- p.to_s.match(@locales_regex) && (p.to_s.split(File::SEPARATOR).length === 2)
150
- end.map { |p|
148
+ p.to_s.match(@locales_regex) && (p.to_s.split(File::SEPARATOR).length == 2)
149
+ end
150
+
151
+ known_langs.map { |p|
151
152
  File.basename(p.to_s).sub(/\.ya?ml$/, '').sub(/\.rb$/, '')
152
153
  }.sort.map(&:to_sym)
153
154
  end
154
155
  end
155
156
 
156
- def get_localization_data(path)
157
+ def localization_data(path)
157
158
  @_localization_data ||= {}
158
159
  @_localization_data[path]
159
160
  end
@@ -176,9 +177,9 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
176
177
  def build_resource(path, source_path, page_id, lang)
177
178
  old_locale = ::I18n.locale
178
179
  ::I18n.locale = lang
179
- localized_page_id = ::I18n.t("paths.#{page_id}", :default => page_id, :fallback => [])
180
+ localized_page_id = ::I18n.t("paths.#{page_id}", default: page_id, fallback: [])
180
181
 
181
- prefix = if (options[:mount_at_root] == lang) || (options[:mount_at_root] == nil && langs[0] == lang)
182
+ prefix = if (options[:mount_at_root] == lang) || (options[:mount_at_root].nil? && langs[0] == lang)
182
183
  '/'
183
184
  else
184
185
  replacement = options[:lang_map].fetch(lang, lang)
@@ -190,7 +191,7 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
190
191
  File.join(prefix, path.sub(page_id, localized_page_id))
191
192
  )
192
193
 
193
- path.gsub!(options[:templates_dir]+'/', '')
194
+ path.gsub!(options[:templates_dir] + '/', '')
194
195
 
195
196
  @_localization_data[path] = [lang, path, localized_page_id]
196
197
 
@@ -16,7 +16,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
16
16
  # Allow specifying regexes to ignore, plus always ignore apple touch icons
17
17
  @ignore = Array(options.ignore) + [/^apple-touch-icon/]
18
18
 
19
- app.use Middleware, :exts => options.exts, :middleman_app => app, :ignore => @ignore
19
+ app.use Middleware, exts: options.exts, middleman_app: app, ignore: @ignore
20
20
  end
21
21
 
22
22
  # Update the main sitemap resource list
@@ -44,7 +44,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
44
44
  return if resource.ignored?
45
45
 
46
46
  # Render through the Rack interface so middleware and mounted apps get a shot
47
- response = @rack_client.get(URI.escape(resource.destination_path), {}, { 'bypass_asset_hash' => 'true' })
47
+ response = @rack_client.get(URI.escape(resource.destination_path), {}, 'bypass_asset_hash' => 'true')
48
48
  raise "#{resource.path} should be in the sitemap!" unless response.status == 200
49
49
 
50
50
  digest = Digest::SHA1.hexdigest(response.body)[0..7]
@@ -63,7 +63,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
63
63
  @rack_app = app
64
64
  @exts = options[:exts]
65
65
  @ignore = options[:ignore]
66
- @exts_regex_text = @exts.map {|e| Regexp.escape(e) }.join('|')
66
+ @exts_regex_text = @exts.map { |e| Regexp.escape(e) }.join('|')
67
67
  @middleman_app = options[:middleman_app]
68
68
  end
69
69
 
@@ -85,7 +85,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
85
85
  [status, headers, response]
86
86
  end
87
87
 
88
- private
88
+ private
89
89
 
90
90
  def rewrite_paths(body, path)
91
91
  dirpath = Pathname.new(File.dirname(path))
@@ -111,9 +111,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
111
111
  end
112
112
  end
113
113
  end
114
-
115
114
  end
116
-
117
115
  end
118
116
 
119
117
  # =================Temp Generate Test data==============================
@@ -14,7 +14,7 @@ class Middleman::Extensions::AssetHost < ::Middleman::Extension
14
14
  if asset_host.is_a?(Proc)
15
15
  config.asset_host(&asset_host)
16
16
  else
17
- config.asset_host do |asset|
17
+ config.asset_host do |_|
18
18
  asset_host
19
19
  end
20
20
  end
@@ -1,6 +1,5 @@
1
1
  # Automatic Image alt tags from image names extension
2
2
  class Middleman::Extensions::AutomaticAltTags < ::Middleman::Extension
3
-
4
3
  def initialize(app, options_hash={}, &block)
5
4
  super
6
5
  end
@@ -10,14 +9,14 @@ class Middleman::Extensions::AutomaticAltTags < ::Middleman::Extension
10
9
  # containing image name.
11
10
 
12
11
  def image_tag(path)
13
- if !path.include?('://')
12
+ unless path.include?('://')
14
13
  params[:alt] ||= ''
15
14
 
16
15
  real_path = path
17
16
  real_path = File.join(images_dir, real_path) unless real_path.start_with?('/')
18
17
  full_path = File.join(source_dir, real_path)
19
18
 
20
- if File.exists?(full_path)
19
+ if File.exist?(full_path)
21
20
  begin
22
21
  alt_text = File.basename(full_path, '.*')
23
22
  alt_text.capitalize!
@@ -1,6 +1,5 @@
1
1
  # Automatic Image Sizes extension
2
2
  class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension
3
-
4
3
  def initialize(app, options_hash={}, &block)
5
4
  super
6
5
 
@@ -16,22 +15,22 @@ class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension
16
15
  # @param [Hash] params
17
16
  # @return [String]
18
17
  def image_tag(path, params={})
19
- if !params.has_key?(:width) && !params.has_key?(:height) && !path.include?('://')
18
+ if !params.key?(:width) && !params.key?(:height) && !path.include?('://')
20
19
  params[:alt] ||= ''
21
20
 
22
21
  real_path = path
23
22
  real_path = File.join(images_dir, real_path) unless real_path.start_with?('/')
24
23
  full_path = File.join(source_dir, real_path)
25
24
 
26
- if File.exists?(full_path)
25
+ if File.exist?(full_path)
27
26
  begin
28
- width, height = ::FastImage.size(full_path, :raise_on_failure => true)
27
+ width, height = ::FastImage.size(full_path, raise_on_failure: true)
29
28
  params[:width] = width
30
29
  params[:height] = height
31
30
  rescue FastImage::UnknownImageType
32
31
  # No message, it's just not supported
33
32
  rescue
34
- warn "Couldn't determine dimensions for image #{path}: #{$!.message}"
33
+ warn "Couldn't determine dimensions for image #{path}: #{$ERROR_INFO.message}"
35
34
  end
36
35
  end
37
36
  end