coelacanth 0.6.1 → 0.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94493e66b4aae51d1790f03eb89c95d2ec1861b9d150c1001bba7554a1b37ab7
4
- data.tar.gz: acdd939524543ec62740e153774c44f5fcdee11d30a9bd5ca4e6bcabe2f65398
3
+ metadata.gz: f1bc84d97135234e0e80586a789381ea2e10785c66fac0bebe21375205489ef3
4
+ data.tar.gz: fdbea80d5c55c1059aedc568ec593121517cf0cbcf55d145fbe123c121b66c2a
5
5
  SHA512:
6
- metadata.gz: 05b8789bd0bf8a23cb678b9f17349a403c0f1e7017903dea14ae13dbea1df1204a3a5cdd184c70e86e0d7366dce67cabbbd528846c2c498953088c1309830421
7
- data.tar.gz: 047d1acabd38e890579947bd7311178ab0197089acd0185d5dbfa0628bbe6a5ad003c330e786c2d82d44fbada5b3ed13882178b50cba86c74ed2e2e12a527199
6
+ metadata.gz: 37165c8087b6119d7cd9ce3517bfd12b1c5f52c8c27b7c4eab12351f47034d46b2e86c7fe72820e6b425e02e7f643494e74766995805d1052469fdfaec7f47f2
7
+ data.tar.gz: d45c1d607c7e35f938ca6fc3658ec082020fcdcfb6888c2a60a7e080e508c7430eedcf9f7eddcf78dad2320f3dfae2803de975d8de9f7cbfb66282944547c5f1
data/CHANGELOG.md CHANGED
@@ -4,11 +4,8 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [v0.6.1] - 2026-06-15
8
- ### :bug: Bug Fixes
9
- - [`f387ef9`](https://github.com/slidict/coelacanth/commit/f387ef997e0c383458a4fd0384f74883fcb63f37) - Update gem-push.yml *(commit by [@abechan1](https://github.com/abechan1))*
10
-
7
+ ## [v0.7.0] - 2026-07-08
11
8
  ### :wrench: Chores
12
- - [`4ad8456`](https://github.com/slidict/coelacanth/commit/4ad8456deba3aea4e6eea8836d6bdf728fbbdb70) - Bump version to 0.6.1 *(commit by [@abechan1](https://github.com/abechan1))*
9
+ - [`ab6d634`](https://github.com/slidict/coelacanth/commit/ab6d634abbc5f954b4b9861e19e3420ee034fd77) - bump version to 0.7.0 *(commit by [@abechan1](https://github.com/abechan1))*
13
10
 
14
- [v0.6.1]: https://github.com/slidict/coelacanth/compare/v0.6.0...v0.6.1
11
+ [v0.7.0]: https://github.com/slidict/coelacanth/compare/v0.6.1...v0.7.0
data/README.md CHANGED
@@ -32,6 +32,7 @@ it into contemporary ingestion stacks without bespoke glue code.
32
32
  multi-byte sources.
33
33
  - **Screenshot capture** – Fetches full-page PNGs via a configurable browser client so you can archive visual context alongside
34
34
  the extracted text.
35
+ - **PDF generation** – Renders any URL to PDF through Ferrum so you can persist printer-friendly snapshots of source pages.
35
36
  - **Redirect resolution** – Follows HTTP redirects and long redirect chains to guarantee the extractor works on the final
36
37
  landing page.
37
38
  - **Configurable HTTP headers** – Inject custom headers (user agent, authorization, etc.) into the remote browser session for
@@ -82,6 +83,9 @@ result[:extraction] # => article metadata and body markdown
82
83
  result[:dom] # => Oga DOM representation for downstream processing
83
84
  result[:screenshot] # => PNG screenshot as a binary string
84
85
  result[:response] # => HTTP status, headers, and final URL
86
+
87
+ pdf = Coelacanth.pdf("https://example.com/article")
88
+ File.binwrite("article.pdf", pdf)
85
89
  ```
86
90
 
87
91
  # Plain-text morphology
@@ -181,6 +185,8 @@ development:
181
185
  - **Gotenberg client** – Set `client: "gotenberg"` to capture screenshots through Gotenberg's Chromium URL screenshot
182
186
  endpoint. Configure `gotenberg.url`, request timeouts, an optional `wait_delay`, an optional screenshot `user_agent`,
183
187
  and optional `extra_http_headers`.
188
+ - **PDF generation** – `Coelacanth.pdf(url)` renders the URL with the Ferrum client and returns the generated PDF as a binary
189
+ string. Configure `remote_client` with a Chrome-compatible WebSocket endpoint before using this helper.
184
190
  - **Eyecatch image extraction** – Representative images are discovered automatically by checking Open Graph/Twitter metadata,
185
191
  Schema.org JSON-LD payloads, and high-signal `<img>` elements (hero/cover images, large dimensions, etc.). No manual XPath
186
192
  maintenance is required.
@@ -23,5 +23,9 @@ module Coelacanth::Client
23
23
  def get_screenshot
24
24
  raise "Must be implemented in subclass"
25
25
  end
26
+
27
+ def get_pdf
28
+ raise "Must be implemented in subclass"
29
+ end
26
30
  end
27
31
  end
@@ -29,6 +29,13 @@ module Coelacanth::Client
29
29
  raise sanitized_remote_client_error(e)
30
30
  end
31
31
 
32
+ def get_pdf
33
+ wait_for_network_idle
34
+ remote_client.pdf
35
+ rescue => e
36
+ raise sanitized_remote_client_error(e)
37
+ end
38
+
32
39
  private
33
40
 
34
41
  def sanitized_remote_client_error(error)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coelacanth
4
- VERSION = "0.6.1"
4
+ VERSION = "0.7.0"
5
5
  end
data/lib/coelacanth.rb CHANGED
@@ -48,6 +48,10 @@ module Coelacanth
48
48
  }
49
49
  end
50
50
 
51
+ def self.pdf(url)
52
+ Client::Ferrum.new(url).get_pdf
53
+ end
54
+
51
55
  def self.client_class_for(client_name)
52
56
  case client_name
53
57
  when "screenshot_one"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coelacanth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke