Class: JekyllImgFlow::Providers::HttpBase

Inherits:
BaseProvider show all
Defined in:
lib/jekyll-imgflow/providers/base_provider.rb

Overview

Shared base for HTTP-based providers (imgproxy, weserv, flyimg). Subclasses must implement service_url, build_combined_url, and define a TIMEOUT constant. They may optionally override provider_label for error messages.

Direct Known Subclasses

Flyimg, Imgproxy, Weserv

Constant Summary

Constants inherited from BaseProvider

BaseProvider::COMPASS_TO_SHORT, BaseProvider::KNOWN_OPERATIONS, BaseProvider::SMARTCROP_POSITIONS

Instance Attribute Summary

Attributes inherited from BaseProvider

#config

Instance Method Summary collapse

Methods inherited from BaseProvider

#add_watermark, #alpha_byte_value, #alpha_opacity=, #check_http_service, #cli_available?, #compass_to_short, #convert_format, #crop, #crop_coords, #crop_geometry, #encode_file_url, #find_op, #format, #initialize, #input_format_ext, #op?, #opacity, #operations, #optimize, provider_name, #quality, #quality=, #relative_file_path, #reset_operations, #resize, #smartcrop_interestingness, supports_operation?, #supports_operation?, #temp_path, unsupported_operations, #watermark, #watermark_parts

Constructor Details

This class inherits a constructor from JekyllImgFlow::Providers::BaseProvider

Instance Method Details

#available? ⇒ Boolean

Returns:

  • (Boolean)


312
313
314
315
316
317
# File 'lib/jekyll-imgflow/providers/base_provider.rb', line 312

def available?
  url = service_url
  return false unless url

  check_http_service(url)
end

#execute(input_path, output_path) ⇒ Object



319
320
321
322
323
324
325
326
327
# File 'lib/jekyll-imgflow/providers/base_provider.rb', line 319

def execute(input_path, output_path)
  return if @operations.empty?

  url = build_combined_url(input_path)
  fetch_and_save(url, output_path)
  output_path
ensure
  reset_operations
end