screenshotscout 0.6.0 → 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 +4 -4
- data/README.md +19 -1
- data/lib/screenshotscout/capture_values.rb +1 -0
- data/lib/screenshotscout/client.rb +6 -1
- data/lib/screenshotscout/internal/json_codec.rb +1 -1
- data/lib/screenshotscout/responses.rb +4 -3
- data/lib/screenshotscout/version.rb +1 -1
- data/sig/screenshotscout.rbs +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 18951bbf1de70e6e9394f429d1d1ec45b9b3fb5232e60bf6ebcee0610d6a0b0a
|
|
4
|
+
data.tar.gz: ea3c295ea79b836e5aadb60279b53910fd41981da0ad26d6fb82496be4c68821
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 17eec08be24d0a88987e1a185d8d9035c6874ca666047e4fc0c5092b31aed207b055fea99aec9526c4fc4f32867554837c58ad5ca600dcdd8f68c9626720da1c
|
|
7
|
+
data.tar.gz: 796491a3b4fd7e35dc5a98dadb54cb5fd7cd7cdd705d0bac2fff4b65b6ecab2595471e83a0e9ce098f8b1a76d1d719b531c2d16331f9203403cdda5e931d06fb
|
data/README.md
CHANGED
|
@@ -52,10 +52,28 @@ puts response.screenshot_url
|
|
|
52
52
|
`capture` uses POST by default, or GET when the client has a secret key. It returns a
|
|
53
53
|
`BinaryCaptureResponse` when `response_type` is omitted or set to `CaptureResponseType::BINARY`.
|
|
54
54
|
|
|
55
|
+
## Get a page as Markdown
|
|
56
|
+
|
|
57
|
+
Set `format` to `CaptureFormat::MD` to get the page as Markdown:
|
|
58
|
+
|
|
59
|
+
```ruby
|
|
60
|
+
require "screenshotscout"
|
|
61
|
+
|
|
62
|
+
client = ScreenshotScout::Client.new # Reads SCREENSHOTSCOUT_ACCESS_KEY
|
|
63
|
+
response = client.capture(
|
|
64
|
+
"https://example.com",
|
|
65
|
+
ScreenshotScout::CaptureOptions.new(format: ScreenshotScout::CaptureFormat::MD)
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
File.write("page.md", response.markdown)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`markdown` returns the Markdown text as a UTF-8 string, or `nil` for other formats.
|
|
72
|
+
|
|
55
73
|
## Request a JSON result
|
|
56
74
|
|
|
57
75
|
Set `response_type` to `CaptureResponseType::JSON` to receive capture metadata instead of binary
|
|
58
|
-
image or
|
|
76
|
+
image, PDF, or Markdown output:
|
|
59
77
|
|
|
60
78
|
```ruby
|
|
61
79
|
require "screenshotscout"
|
|
@@ -173,7 +173,8 @@ module ScreenshotScout
|
|
|
173
173
|
raw_response: raw_response,
|
|
174
174
|
screenshot_url: raw_response.header("Screenshot-Scout-Screenshot-URL").first,
|
|
175
175
|
screenshot_url_expires_at: raw_response.header("Screenshot-Scout-Screenshot-URL-Expires-At").first,
|
|
176
|
-
cache_status: raw_response.header("Screenshot-Scout-Cache-Status").first
|
|
176
|
+
cache_status: raw_response.header("Screenshot-Scout-Cache-Status").first,
|
|
177
|
+
markdown: markdown_media_type?(raw_response.content_type) ? utf8_text(raw_response.body) : nil
|
|
177
178
|
)
|
|
178
179
|
end
|
|
179
180
|
|
|
@@ -250,6 +251,10 @@ module ScreenshotScout
|
|
|
250
251
|
media_type == "application/json" || media_type.end_with?("+json")
|
|
251
252
|
end
|
|
252
253
|
|
|
254
|
+
def markdown_media_type?(content_type) = content_type.to_s.partition(";").first.strip.downcase == "text/markdown"
|
|
255
|
+
|
|
256
|
+
def utf8_text(bytes) = bytes.dup.force_encoding(Encoding::UTF_8).scrub
|
|
257
|
+
|
|
253
258
|
private_constant :ACCESS_KEY_PATTERN
|
|
254
259
|
end
|
|
255
260
|
end
|
|
@@ -43,16 +43,17 @@ module ScreenshotScout
|
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
# Successful binary capture, including response metadata and image
|
|
46
|
+
# Successful binary capture, including response metadata and image, PDF, or Markdown bytes.
|
|
47
47
|
class BinaryCaptureResponse < CaptureResponse
|
|
48
|
-
attr_reader :bytes, :screenshot_url, :screenshot_url_expires_at, :cache_status
|
|
48
|
+
attr_reader :bytes, :screenshot_url, :screenshot_url_expires_at, :cache_status, :markdown
|
|
49
49
|
|
|
50
|
-
def initialize(raw_response:, screenshot_url:, screenshot_url_expires_at:, cache_status:)
|
|
50
|
+
def initialize(raw_response:, screenshot_url:, screenshot_url_expires_at:, cache_status:, markdown: nil)
|
|
51
51
|
super(raw_response: raw_response)
|
|
52
52
|
@bytes = raw_response.body
|
|
53
53
|
@screenshot_url = screenshot_url
|
|
54
54
|
@screenshot_url_expires_at = screenshot_url_expires_at
|
|
55
55
|
@cache_status = cache_status
|
|
56
|
+
@markdown = markdown
|
|
56
57
|
freeze
|
|
57
58
|
end
|
|
58
59
|
end
|
data/sig/screenshotscout.rbs
CHANGED
|
@@ -14,6 +14,7 @@ module ScreenshotScout
|
|
|
14
14
|
GIF: String
|
|
15
15
|
JPEG: String
|
|
16
16
|
JPG: String
|
|
17
|
+
MD: String
|
|
17
18
|
PDF: String
|
|
18
19
|
PNG: String
|
|
19
20
|
TIFF: String
|
|
@@ -246,12 +247,14 @@ module ScreenshotScout
|
|
|
246
247
|
attr_reader screenshot_url: String?
|
|
247
248
|
attr_reader screenshot_url_expires_at: String?
|
|
248
249
|
attr_reader cache_status: String?
|
|
250
|
+
attr_reader markdown: String?
|
|
249
251
|
|
|
250
252
|
def initialize: (
|
|
251
253
|
raw_response: RawResponse,
|
|
252
254
|
screenshot_url: String?,
|
|
253
255
|
screenshot_url_expires_at: String?,
|
|
254
|
-
cache_status: String
|
|
256
|
+
cache_status: String?,
|
|
257
|
+
?markdown: String?
|
|
255
258
|
) -> void
|
|
256
259
|
end
|
|
257
260
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: screenshotscout
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Oleksii Velykyi
|
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
112
112
|
- !ruby/object:Gem::Version
|
|
113
113
|
version: '0'
|
|
114
114
|
requirements: []
|
|
115
|
-
rubygems_version:
|
|
115
|
+
rubygems_version: 3.6.9
|
|
116
116
|
specification_version: 4
|
|
117
117
|
summary: Official Ruby SDK for the Screenshot Scout screenshot API.
|
|
118
118
|
test_files: []
|