kleya 0.0.2 → 0.0.3
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 +27 -1
- data/bin/kleya +51 -0
- data/lib/kleya/artifact.rb +2 -0
- data/test/artifact_test.rb +15 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9d67fbb3a7754b0af20ff18f877da9f7fe8eb1c1f2885c94a17ab8f8c0ab85c
|
4
|
+
data.tar.gz: 6ead13010ce66ca8d0f96e07b5df9abab103c3014ad66d1584d22d16981a5e13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9a46f780e038d591dd60d2172258cbd12128ce2342c672a4fdb5d92d93efc903f1e045cbc5375379f5beb7b696e6723a845fb3a3368ef8fed3dcc44ed290be1
|
7
|
+
data.tar.gz: cf575c64b78b13c15f5a654725c7b4779b2ce15f0a71a8b641f01ff54d19500e59f7c6b1695f571566f6b92d7b62bb9328ca50d9ea0478ee1b49cef1832d50fb
|
data/README.md
CHANGED
@@ -30,6 +30,12 @@ The simplest way to capture a screenshot and save it can look like this,
|
|
30
30
|
Kleya.capture('https://www.hellotext.com').save
|
31
31
|
```
|
32
32
|
|
33
|
+
Or directly via the CLI
|
34
|
+
|
35
|
+
```bash
|
36
|
+
kleya https://www.hellotext.com
|
37
|
+
```
|
38
|
+
|
33
39
|
## Usage
|
34
40
|
|
35
41
|
```ruby
|
@@ -52,6 +58,27 @@ puts artifact.content_type # "image/jpeg"
|
|
52
58
|
browser.quit
|
53
59
|
```
|
54
60
|
|
61
|
+
## CLI Usage
|
62
|
+
|
63
|
+
Kleya includes a command-line interface for quick screenshot captures:
|
64
|
+
|
65
|
+
```bash
|
66
|
+
# Basic usage
|
67
|
+
kleya https://www.hellotext.com
|
68
|
+
|
69
|
+
# With options
|
70
|
+
kleya https://www.hellotext.com --format png --quality 95 --area page
|
71
|
+
```
|
72
|
+
|
73
|
+
CLI Options
|
74
|
+
|
75
|
+
- `--format`, `-f` - Image format (jpeg, png). Default: jpeg
|
76
|
+
- `--quality`, `-q` - Image quality (1-100). Default: 90
|
77
|
+
- `--area`, `-a` - Capture area (viewport, page). Default: viewport
|
78
|
+
- `--encoding`, `-e` - Output encoding (binary, base64). Default: base64
|
79
|
+
- `--output`, `-o` - Output destination, defaults to the current directory.
|
80
|
+
- `--help`, `-h` - Show help message
|
81
|
+
|
55
82
|
### Presets
|
56
83
|
|
57
84
|
Kleya includes convenient viewport presets for social media platforms and common devices. You can pass any of the following values when initializing a browser instance.
|
@@ -187,7 +214,6 @@ end
|
|
187
214
|
- Memory usage optimization for large batches
|
188
215
|
- Request blocking (ads, analytics, fonts)
|
189
216
|
|
190
|
-
- CLI tool for quick captures (`kleya capture https://example.com`)
|
191
217
|
- Debug mode with browser preview
|
192
218
|
- Capture metrics (timing, size, errors)
|
193
219
|
|
data/bin/kleya
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'kleya'
|
5
|
+
|
6
|
+
options = {
|
7
|
+
format: :jpeg,
|
8
|
+
quality: 90,
|
9
|
+
area: :viewport,
|
10
|
+
encoding: :base64,
|
11
|
+
output: nil
|
12
|
+
}
|
13
|
+
|
14
|
+
parser = OptionParser.new do |opts|
|
15
|
+
opts.banner = 'Usage: kleya [url] [options]'
|
16
|
+
|
17
|
+
opts.on('-f', '--format FORMAT', [:jpeg, :png], 'Image format (jpeg, png)') do |format|
|
18
|
+
options[:format] = format
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on('-q', '--quality QUALITY', Integer, 'Image quality (0-100)') do |quality|
|
22
|
+
options[:quality] = quality
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on('-a', '--area AREA', [:viewport, :full], 'Area to capture (viewport, full)') do |area|
|
26
|
+
options[:area] = area
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on('-e', '--encoding ENCODING', [:base64, :binary], 'Encoding (base64, binary)') do |encoding|
|
30
|
+
options[:encoding] = encoding
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on('-o', '--output OUTPUT', String, 'Output file path') do |output|
|
34
|
+
options[:output] = output
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on('-h', '--help', 'Show this message') do
|
38
|
+
puts opts
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
parser.parse!
|
44
|
+
|
45
|
+
if ARGV.empty?
|
46
|
+
puts "Error: URL is required"
|
47
|
+
puts parser
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
|
51
|
+
Kleya.capture(ARGV[0], **options).save(options[:output])
|
data/lib/kleya/artifact.rb
CHANGED
data/test/artifact_test.rb
CHANGED
@@ -11,6 +11,11 @@ class ArtifactTest < Minitest::Test
|
|
11
11
|
)
|
12
12
|
end
|
13
13
|
|
14
|
+
def teardown
|
15
|
+
FileUtils.rm_f('test.jpg')
|
16
|
+
FileUtils.rm_f('appends_extension.jpeg')
|
17
|
+
end
|
18
|
+
|
14
19
|
def test_artifact_size
|
15
20
|
assert_equal(4, @artifact.size)
|
16
21
|
end
|
@@ -19,6 +24,16 @@ class ArtifactTest < Minitest::Test
|
|
19
24
|
assert_runs_without_errors do
|
20
25
|
@artifact.save('test.jpg')
|
21
26
|
end
|
27
|
+
|
28
|
+
assert File.exist?('test.jpg')
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_artifact_save_with_content_type_extension
|
32
|
+
assert_runs_without_errors do
|
33
|
+
@artifact.save('appends_extension')
|
34
|
+
end
|
35
|
+
|
36
|
+
assert File.exist?('appends_extension.jpeg')
|
22
37
|
end
|
23
38
|
|
24
39
|
def test_artifact_base64
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kleya
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hellotext
|
8
8
|
- Ahmed Khattab
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -81,12 +81,14 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.17'
|
83
83
|
description: Screenshots, made easy.
|
84
|
-
executables:
|
84
|
+
executables:
|
85
|
+
- kleya
|
85
86
|
extensions: []
|
86
87
|
extra_rdoc_files: []
|
87
88
|
files:
|
88
89
|
- README.md
|
89
90
|
- Rakefile
|
91
|
+
- bin/kleya
|
90
92
|
- lib/kleya.rb
|
91
93
|
- lib/kleya/artifact.rb
|
92
94
|
- lib/kleya/browser.rb
|