minify-html/ruby/lib/minify_html.rb

19 lines
507 B
Ruby
Raw Normal View History

2020-01-19 03:19:33 -05:00
require 'fiddle'
2020-07-11 11:29:34 -04:00
class MinifyHtmlLoader
2020-01-19 03:19:33 -05:00
def self.operating_system
case RbConfig::CONFIG['host_os'].downcase
when /linux|bsd|solaris/ then 'linux'
when /darwin/ then 'macos'
when /mingw|mswin/ then 'windows'
else 'unknown'
end
end
def self.lib_path
2020-01-20 09:49:42 -05:00
File.join(__dir__, [operating_system, '-ruby', RUBY_VERSION.split('.')[0...-1].join('.')].join(''))
2020-01-19 03:19:33 -05:00
end
end
2020-07-11 11:29:34 -04:00
Fiddle::Function.new(Fiddle.dlopen(MinifyHtmlLoader.lib_path)['Init_minify_html'], [], Fiddle::TYPE_VOIDP).call