Module: Jekyll::Pagefind
- Defined in:
- lib/jekyll-pagefind.rb,
lib/jekyll/pagefind/version.rb
Overview
module Jekyll::Pagefind
Constant Summary collapse
- GEM_ROOT =
File.("..", __dir__)
- VERSION =
"0.2.1"
Class Method Summary collapse
-
.pagefind_binary_path ⇒ Object
rubocop:disable Metrics/MethodLength.
-
.run_pagefind(site_destination) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
Class Method Details
.pagefind_binary_path ⇒ Object
rubocop:disable Metrics/MethodLength
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/jekyll-pagefind.rb', line 14 def self.pagefind_binary_path # rubocop:disable Metrics/MethodLength os = RbConfig::CONFIG["host_os"] cpu = RbConfig::CONFIG["host_cpu"] case os when /darwin|mac os/i # Differentiate between Apple Silicon and Intel Macs if cpu =~ /arm64|aarch64/i File.join(GEM_ROOT, "assets", "macos-arm64", "pagefind") else File.join(GEM_ROOT, "assets", "macos-x64", "pagefind") end when /linux/i # Differentiate between standard servers and ARM instances if cpu =~ /arm64|aarch64/i File.join(GEM_ROOT, "assets", "linux-arm64", "pagefind") else File.join(GEM_ROOT, "assets", "linux-x64", "pagefind") end # spellchecker:disable-next-line when /mswin|msys|mingw|cygwin|bccwin/i File.join(GEM_ROOT, "assets", "windows-x64", "pagefind.exe") else raise "Jekyll-PF Mismatch Error: Pagefind binary not provided for host environment: #{os} (#{cpu})" end end |
.run_pagefind(site_destination) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/jekyll-pagefind.rb', line 43 def self.run_pagefind(site_destination) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength binary = pagefind_binary_path # Force execution bits on UNIX hosts because gem unpacking can reset permissions flags # spellchecker:disable-next-line if RbConfig::CONFIG["host_os"] !~ /mswin|msys|mingw|cygwin|bccwin/i && !File.executable?(binary) File.chmod(0o755, binary) end # Run the indexer pointing explicitly at Jekyll's output directory Jekyll.logger.info "Jekyll-PF:", "Starting Pagefind indexing on target folder..." stdout, stderr, status = Open3.capture3("#{binary} --site \"#{site_destination}\"") if status.success? Jekyll.logger.info "Jekyll-PF:", "Indexing finished successfully!" puts stdout else Jekyll.logger.error "Jekyll-PF Error:", stderr raise "Pagefind binary exited with non-zero status code: #{status.exitstatus}" end end |