himg 0.0.2 → 0.0.4
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/.rubocop.yml +20 -0
- data/Appraisals +7 -0
- data/CHANGELOG.md +22 -0
- data/Cargo.lock +1 -1
- data/README.md +42 -14
- data/Rakefile +8 -2
- data/Steepfile +0 -10
- data/ext/himg/Cargo.toml +1 -1
- data/ext/himg/examples/file.rs +2 -1
- data/ext/himg/src/html_to_image.rs +19 -7
- data/ext/himg/src/lib.rs +39 -39
- data/ext/himg/src/options.rs +1 -0
- data/ext/himg/src/renderer.rs +28 -0
- data/ext/himg/src/writer.rs +8 -7
- data/gemfiles/plain_ruby.gemfile +0 -7
- data/gemfiles/plain_ruby.gemfile.lock +10 -21
- data/gemfiles/rails_6.gemfile +0 -6
- data/gemfiles/rails_6.gemfile.lock +18 -28
- data/gemfiles/rails_7_0.gemfile +0 -6
- data/gemfiles/rails_7_0.gemfile.lock +18 -28
- data/gemfiles/rails_7_1.gemfile +0 -6
- data/gemfiles/rails_7_1.gemfile.lock +18 -28
- data/gemfiles/rails_7_2.gemfile +0 -6
- data/gemfiles/rails_7_2.gemfile.lock +18 -28
- data/gemfiles/rails_8.gemfile +0 -6
- data/gemfiles/rails_8.gemfile.lock +18 -28
- data/lib/himg/railtie/template_handler.rb +8 -4
- data/lib/himg/railtie.rb +21 -3
- data/lib/himg/version.rb +1 -1
- data/lib/himg.rb +5 -1
- metadata +12 -26
- data/.standard.yml +0 -3
- data/test.html.rbd +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e2af1a8848987b76777bf3aed2c0dfc3254e2486aab89e816e2751cb00ec10f
|
4
|
+
data.tar.gz: d4e71ff28a851c19ccc36403997cf2965e082f8267852f25a4efd704d4f96fa9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3706e38ff13df4d57636bbb10bd58994d666454b5b2fbcd9dfbbdd5fe31a78ab13e7c768f56b8d188b8752a648eca6653452c7044eda88c7927ad89be61489c9
|
7
|
+
data.tar.gz: 33c0de522e5ff80866457b88263540532a561ebc7fd0740649d08f3861370824456f7cc98f4d94b5e07ff28f02cc58706c716ed564f6bac0586676e6c4495d93
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 3.1
|
3
|
+
|
4
|
+
Style/StringLiterals:
|
5
|
+
EnforcedStyle: double_quotes
|
6
|
+
|
7
|
+
Style/StringLiteralsInInterpolation:
|
8
|
+
EnforcedStyle: double_quotes
|
9
|
+
|
10
|
+
Style/FrozenStringLiteralComment:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Metrics/BlockLength:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Bundler/OrderedGems:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Layout/ExtraSpacing:
|
20
|
+
Enabled: false
|
data/Appraisals
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
appraise "plain-ruby" do
|
2
|
+
remove_gem "rails"
|
3
|
+
remove_gem "puma"
|
2
4
|
end
|
3
5
|
|
4
6
|
appraise "rails-6" do
|
7
|
+
remove_gem "puma"
|
5
8
|
gem "rails", "~> 6.0"
|
6
9
|
gem "rspec-rails", "~> 6.0"
|
7
10
|
gem "concurrent-ruby", "1.3.4" # Logger dependency fix, see: https://stackoverflow.com/questions/79360526/uninitialized-constant-activesupportloggerthreadsafelevellogger-nameerror
|
@@ -10,6 +13,7 @@ appraise "rails-6" do
|
|
10
13
|
end
|
11
14
|
|
12
15
|
appraise "rails-7-0" do
|
16
|
+
remove_gem "puma"
|
13
17
|
gem "rails", "~> 7.0.0"
|
14
18
|
gem "rspec-rails", "~> 7.0"
|
15
19
|
gem "concurrent-ruby", "1.3.4" # Logger dependency fix, see: https://stackoverflow.com/questions/79360526/uninitialized-constant-activesupportloggerthreadsafelevellogger-nameerror
|
@@ -18,16 +22,19 @@ appraise "rails-7-0" do
|
|
18
22
|
end
|
19
23
|
|
20
24
|
appraise "rails-7-1" do
|
25
|
+
remove_gem "puma"
|
21
26
|
gem "rails", "~> 7.1.0"
|
22
27
|
gem "rspec-rails", "~> 7.0"
|
23
28
|
end
|
24
29
|
|
25
30
|
appraise "rails-7-2" do
|
31
|
+
remove_gem "puma"
|
26
32
|
gem "rails", "~> 7.2.0"
|
27
33
|
gem "rspec-rails", "~> 7.0"
|
28
34
|
end
|
29
35
|
|
30
36
|
appraise "rails-8" do
|
37
|
+
remove_gem "puma"
|
31
38
|
gem "rails", "~> 8.0"
|
32
39
|
gem "rspec-rails", "~> 7.0"
|
33
40
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.0.4] - 2025-04-22
|
4
|
+
|
5
|
+
- Allow `width`, `height` and `truncate` to be passed to the render function.
|
6
|
+
|
7
|
+
## [0.0.3] - 2025-04-22
|
8
|
+
|
9
|
+
- Ensure that when render height is expanded to fit the content that we update
|
10
|
+
the height we try to write in the png metadata to match.
|
11
|
+
- Rust creates a ruby string with the binary png data so we don't need to convert with .pack("C*")
|
12
|
+
- Himg::Error wraps errors from a Rust Result<_,Err>
|
13
|
+
- Added OpenGraph metadata example
|
14
|
+
- Default dimensions of 720x405 to match the ideal 16:9 ratio and image size
|
15
|
+
for sharing og-image on messengers and social media.
|
16
|
+
|
17
|
+
## [0.0.2] - 2025-04-21
|
18
|
+
|
19
|
+
- Adds Rails support via a ActionView template handler.
|
20
|
+
Takes views like `action.show.erb`, pre-processes them with Erb and renders
|
21
|
+
to a .png with 'image/png' set as the MIME type.
|
22
|
+
- Adds a `ActionController::Renderer` so `render himg: '<div>Some HTML</div>'`
|
23
|
+
can be used either directly or from a `format.png`/`format.himg` block.
|
24
|
+
|
3
25
|
## [0.0.1] - 2025-04-19
|
4
26
|
|
5
27
|
- Initial alpha
|
data/Cargo.lock
CHANGED
data/README.md
CHANGED
@@ -16,8 +16,7 @@ In Rails this will mean you can process user.himg.erb to display an image includ
|
|
16
16
|
4. Network requests can be made: don't use this library with untrusted inputs.
|
17
17
|
5. file:// URLs are resolved: this could expose files on your computer.
|
18
18
|
6. Native extensions are not yet being published for different os/arch
|
19
|
-
7.
|
20
|
-
8. Verbose logging is hardcoded
|
19
|
+
7. Verbose logging is hardcoded
|
21
20
|
|
22
21
|
## Installation
|
23
22
|
|
@@ -35,6 +34,16 @@ gem install himg
|
|
35
34
|
|
36
35
|
## Usage
|
37
36
|
|
37
|
+
### Ruby
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
png = Himg.render("<html bgcolor='blue'></html>")
|
41
|
+
```
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
png = Himg.render("<h1>Hi</h1>", width: 24, height: 24, truncate: false)
|
45
|
+
```
|
46
|
+
|
38
47
|
### Rails
|
39
48
|
|
40
49
|
Simply add a `show.himg.erb`!
|
@@ -43,6 +52,18 @@ Simply add a `show.himg.erb`!
|
|
43
52
|
<div><%= @username %></div>
|
44
53
|
```
|
45
54
|
|
55
|
+
### Adding OpenGraph Meta Tags
|
56
|
+
|
57
|
+
Once you've added a view template for your resource, you can use it to generate image cards that will be shown when the page is shared on messenger apps or social media.
|
58
|
+
|
59
|
+
```html
|
60
|
+
<meta property="og:title" content="<%= @user.username %>" />
|
61
|
+
<meta property="og:description" content="<%= @user.tagline %>" />
|
62
|
+
<meta property="og:image" content="<%= user_url(@user.username, format: :png) %>" />
|
63
|
+
```
|
64
|
+
|
65
|
+
### Advanced Rails Usage
|
66
|
+
|
46
67
|
A :himg template handler is registered and will be called by rails' `default_render` method automatically when the corresponding view is found. This can be `show.himg` for a static image, or `show.himg.erb` to use variables from the controller.
|
47
68
|
|
48
69
|
If you prefer you could also use `render himg: "<div>My Data</div>"` instead, but should be careful with untrusted input if constructing HTML manually.
|
@@ -64,24 +85,31 @@ respond_to do |format|
|
|
64
85
|
end
|
65
86
|
```
|
66
87
|
|
67
|
-
### Run from Ruby
|
68
|
-
|
69
|
-
```ruby
|
70
|
-
png = Himg.render("<html bgcolor='blue'></html>")
|
71
|
-
```
|
72
|
-
|
73
|
-
## Development
|
74
|
-
|
75
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
76
|
-
|
77
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
78
|
-
|
79
88
|
### Run directly from the command line to output an image
|
89
|
+
|
80
90
|
```bash
|
81
91
|
bundle exec cargo run --example file
|
82
92
|
bundle exec cargo run --example file -- path/to/file.html
|
83
93
|
```
|
84
94
|
|
95
|
+
## Development
|
96
|
+
|
97
|
+
1. Run `bin/setup` to install dependencies.
|
98
|
+
2. Run `rake spec` to run the tests with the default development setup
|
99
|
+
3. Run `appraisal rake spec` to run tests against different versions of rails and to confirm that the gem works in a plain ruby environment
|
100
|
+
4. Run `bin/console` for an interactive prompt that will allow you to experiment.
|
101
|
+
5. Run `RAILS_ENV=development bundle exec spec/dummy/dummy_rails server` to check the dummy app.
|
102
|
+
- http://localhost:3000/users/jamedjo.png will display an opengraph compatible png
|
103
|
+
- http://localhost:3000/users/jamedjo.himg will also render the same png
|
104
|
+
- http://localhost:3000/users/jamedjo will render an HTML page with opengraph meta tags
|
105
|
+
6. To install this gem onto your local machine, run `bundle exec rake install`.
|
106
|
+
|
107
|
+
## Releases
|
108
|
+
|
109
|
+
To release a new version:
|
110
|
+
1. Run `rake bump:patch` to update the version numbers in `version.rb` and `ext/himg/Cargo.toml`.
|
111
|
+
3. Run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
112
|
+
|
85
113
|
## Contributing
|
86
114
|
|
87
115
|
Bug reports and pull requests are welcome on GitHub at https://github.com/jamedjo/himg.
|
data/Rakefile
CHANGED
@@ -5,7 +5,9 @@ require "rspec/core/rake_task"
|
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
require "
|
8
|
+
require "rubocop/rake_task"
|
9
|
+
|
10
|
+
RuboCop::RakeTask.new
|
9
11
|
|
10
12
|
require "rb_sys/extensiontask"
|
11
13
|
|
@@ -17,4 +19,8 @@ RbSys::ExtensionTask.new("himg", GEMSPEC) do |ext|
|
|
17
19
|
ext.lib_dir = "lib/himg"
|
18
20
|
end
|
19
21
|
|
20
|
-
|
22
|
+
require "bump/tasks"
|
23
|
+
Bump.replace_in_default = %w[Cargo.lock ext/himg/Cargo.toml]
|
24
|
+
Bump.changelog = :editor
|
25
|
+
|
26
|
+
task default: %i[compile rubocop]
|
data/Steepfile
CHANGED
@@ -17,13 +17,3 @@ target :lib do
|
|
17
17
|
# hash[D::Ruby::NoMethod] = :information
|
18
18
|
# end
|
19
19
|
end
|
20
|
-
|
21
|
-
#target :test do
|
22
|
-
# unreferenced! # Skip type checking the `lib` code when types in `test` target is changed
|
23
|
-
# signature "sig/test" # Put RBS files for tests under `sig/test`
|
24
|
-
# check "test" # Type check Ruby scripts under `test`
|
25
|
-
|
26
|
-
# configure_code_diagnostics(D::Ruby.lenient) # Weak type checking for test code
|
27
|
-
|
28
|
-
# # library "pathname" # Standard libraries
|
29
|
-
#end
|
data/ext/himg/Cargo.toml
CHANGED
data/ext/himg/examples/file.rs
CHANGED
@@ -30,6 +30,7 @@ async fn main() {
|
|
30
30
|
height: 800,
|
31
31
|
hidpi_scale: 1.0,
|
32
32
|
},
|
33
|
+
truncate: false,
|
33
34
|
color_scheme: ColorScheme::Light,
|
34
35
|
allow_net_requests: true, //TODO: Implement using this
|
35
36
|
};
|
@@ -43,7 +44,7 @@ async fn main() {
|
|
43
44
|
let mut file = File::create(&out_path).unwrap();
|
44
45
|
|
45
46
|
// Encode buffer as PNG and write it to a file
|
46
|
-
write_png(&mut file, &buffer, options.image_size.scaled_width(), options.image_size.scaled_height());
|
47
|
+
write_png(&mut file, &buffer, options.image_size.scaled_width(), options.image_size.scaled_height()).unwrap();
|
47
48
|
logger.log("Wrote out png");
|
48
49
|
|
49
50
|
logger.log_total_time("\nDone");
|
@@ -11,12 +11,17 @@ use crate::image_size::ImageSize;
|
|
11
11
|
use crate::logger::Logger;
|
12
12
|
use crate::options::Options;
|
13
13
|
|
14
|
+
pub struct RenderOutput {
|
15
|
+
pub buffer: Vec<u8>,
|
16
|
+
pub image_size: ImageSize,
|
17
|
+
}
|
18
|
+
|
14
19
|
pub async fn html_to_image(
|
15
20
|
html: &str,
|
16
21
|
base_url: Option<String>,
|
17
22
|
options: Options,
|
18
23
|
logger: &mut dyn Logger,
|
19
|
-
) ->
|
24
|
+
) -> RenderOutput {
|
20
25
|
let (mut recv, callback) = MpscCallback::new();
|
21
26
|
logger.log("Initial config");
|
22
27
|
|
@@ -59,11 +64,15 @@ pub async fn html_to_image(
|
|
59
64
|
logger.log("Resolved styles and layout");
|
60
65
|
|
61
66
|
// Determine height to render
|
62
|
-
let
|
63
|
-
|
64
|
-
|
65
|
-
height
|
66
|
-
|
67
|
+
let render_size = if options.truncate {
|
68
|
+
options.image_size
|
69
|
+
} else {
|
70
|
+
let computed_height = document.as_ref().root_element().final_layout.size.height;
|
71
|
+
let render_height = (computed_height as u32).max(options.image_size.height).min(10_000);
|
72
|
+
ImageSize {
|
73
|
+
height: render_height,
|
74
|
+
..options.image_size
|
75
|
+
}
|
67
76
|
};
|
68
77
|
logger.log("Calculated render dimensions from document");
|
69
78
|
|
@@ -83,5 +92,8 @@ pub async fn html_to_image(
|
|
83
92
|
|
84
93
|
logger.log("Rendered to buffer");
|
85
94
|
|
86
|
-
|
95
|
+
RenderOutput {
|
96
|
+
buffer: buffer,
|
97
|
+
image_size: render_size,
|
98
|
+
}
|
87
99
|
}
|
data/ext/himg/src/lib.rs
CHANGED
@@ -1,50 +1,49 @@
|
|
1
|
-
pub mod
|
2
|
-
pub mod image_size;
|
1
|
+
pub mod renderer;
|
3
2
|
pub mod html_to_image;
|
4
|
-
pub mod
|
3
|
+
pub mod image_size;
|
5
4
|
pub mod options;
|
5
|
+
pub mod writer;
|
6
|
+
pub mod logger;
|
6
7
|
|
7
|
-
pub use
|
8
|
-
pub use image_size::ImageSize;
|
9
|
-
pub use options::Options;
|
10
|
-
pub use writer::write_png;
|
11
|
-
pub use logger::{Logger, TimedLogger};
|
12
|
-
|
13
|
-
use blitz_traits::{ColorScheme};
|
14
|
-
use magnus::{function, prelude::*, Error, Ruby};
|
15
|
-
|
16
|
-
pub fn render_blocking(html: String) -> Vec<u8> {
|
17
|
-
tokio::runtime::Runtime::new()
|
18
|
-
.unwrap()
|
19
|
-
.block_on(render(html))
|
20
|
-
}
|
8
|
+
pub use renderer::render_blocking;
|
21
9
|
|
22
|
-
|
23
|
-
|
10
|
+
use crate::image_size::ImageSize;
|
11
|
+
use crate::options::Options;
|
12
|
+
use blitz_traits::ColorScheme;
|
13
|
+
use magnus::{function, prelude::*, ExceptionClass, Error, Ruby, RString, RHash};
|
24
14
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
color_scheme: ColorScheme::Light,
|
33
|
-
allow_net_requests: true, //TODO: Implement using this
|
34
|
-
};
|
15
|
+
impl Options {
|
16
|
+
fn get_option<V: magnus::TryConvert + magnus::IntoValue>(optional_hash: Option<RHash>, key: &str, default: V) -> Result<V, Error> {
|
17
|
+
match optional_hash {
|
18
|
+
Some(hash) => hash.lookup2::<&str, V, V>(key, default),
|
19
|
+
None => Ok(default),
|
20
|
+
}
|
21
|
+
}
|
35
22
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
23
|
+
pub fn from_ruby(hash: Option<RHash>) -> Result<Self, Error> {
|
24
|
+
let options = Options {
|
25
|
+
image_size: ImageSize {
|
26
|
+
width: Self::get_option(hash, "width", 720)?,
|
27
|
+
height: Self::get_option(hash, "height", 405)?,
|
28
|
+
hidpi_scale: 1.0,
|
29
|
+
},
|
30
|
+
truncate: Self::get_option(hash, "truncate", true)?,
|
31
|
+
color_scheme: ColorScheme::Light,
|
32
|
+
allow_net_requests: true, //TODO: Implement using this
|
33
|
+
};
|
40
34
|
|
41
|
-
|
42
|
-
|
35
|
+
Ok(options)
|
36
|
+
}
|
37
|
+
}
|
43
38
|
|
44
|
-
|
45
|
-
|
39
|
+
pub fn render_blocking_rb(ruby: &Ruby, html: String, options: Option<RHash>) -> Result<RString, Error> {
|
40
|
+
let options = Options::from_ruby(options)?;
|
41
|
+
let exception_class = ExceptionClass::from_value(magnus::eval("Himg::Error").unwrap()).unwrap();
|
46
42
|
|
47
|
-
|
43
|
+
match render_blocking(html, options) {
|
44
|
+
Ok(data) => Ok(ruby.str_from_slice(&data)),
|
45
|
+
Err(e) => Err(Error::new(exception_class, format!("{}", e))),
|
46
|
+
}
|
48
47
|
}
|
49
48
|
|
50
49
|
#[magnus::init]
|
@@ -52,7 +51,8 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
52
51
|
let module = ruby.define_module("Himg")?;
|
53
52
|
|
54
53
|
//TODO: Allow optional base_url for resolving linked resources (stylesheets, images, fonts, etc)
|
55
|
-
module.define_singleton_method("
|
54
|
+
module.define_singleton_method("render_to_string", function!(render_blocking_rb, 2))?;
|
55
|
+
|
56
56
|
Ok(())
|
57
57
|
}
|
58
58
|
|
data/ext/himg/src/options.rs
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
use crate::html_to_image::html_to_image;
|
2
|
+
use crate::options::Options;
|
3
|
+
use crate::writer::write_png;
|
4
|
+
use crate::logger::{TimedLogger};
|
5
|
+
|
6
|
+
pub fn render_blocking(html: String, options: Options) -> Result<Vec<u8>, std::io::Error> {
|
7
|
+
let runtime = tokio::runtime::Runtime::new()?;
|
8
|
+
|
9
|
+
runtime.block_on(render(html, options))
|
10
|
+
}
|
11
|
+
|
12
|
+
// render_to_bytes, render_to_string, render_to_file, render_to_io
|
13
|
+
pub async fn render(html: String, options: Options) -> Result<Vec<u8>, std::io::Error> {
|
14
|
+
let mut logger = TimedLogger::init();
|
15
|
+
|
16
|
+
// Render to Image
|
17
|
+
//let base_url = format!("file://{}", path_string.clone());
|
18
|
+
let base_url = None;
|
19
|
+
let render_output = html_to_image(&html, base_url, options, &mut logger).await;
|
20
|
+
|
21
|
+
// Determine output path, and open a file at that path.
|
22
|
+
let mut output_buffer: Vec<u8> = Vec::new();
|
23
|
+
|
24
|
+
// Encode buffer as PNG and write it to a file
|
25
|
+
write_png(&mut output_buffer, &render_output.buffer, render_output.image_size.scaled_width(), render_output.image_size.scaled_height())?;
|
26
|
+
|
27
|
+
Ok(output_buffer)
|
28
|
+
}
|
data/ext/himg/src/writer.rs
CHANGED
@@ -4,9 +4,9 @@ use png::{Encoder, ColorType, BitDepth, PixelDimensions, Unit};
|
|
4
4
|
const INCHES_PER_METER: f64 = 39.3701;
|
5
5
|
const DEFAULT_DPI: f64 = 144.0;
|
6
6
|
|
7
|
-
pub fn write_png<W: Write>(writer: W, buffer: &[u8], width: u32, height: u32) {
|
7
|
+
pub fn write_png<W: Write>(writer: W, buffer: &[u8], width: u32, height: u32) -> Result<(), std::io::Error> {
|
8
8
|
let encoder = create_encoder(writer, width, height, DEFAULT_DPI);
|
9
|
-
write_data(encoder, buffer)
|
9
|
+
write_data(encoder, buffer)
|
10
10
|
}
|
11
11
|
|
12
12
|
fn create_encoder<'a, W: Write>(writer: W, width: u32, height: u32, dpi: f64) -> Encoder<'a, W> {
|
@@ -24,10 +24,11 @@ fn create_encoder<'a, W: Write>(writer: W, width: u32, height: u32, dpi: f64) ->
|
|
24
24
|
encoder
|
25
25
|
}
|
26
26
|
|
27
|
-
fn write_data<W: Write>(encoder: Encoder<W>, buffer: &[u8]) {
|
28
|
-
|
29
|
-
let mut writer = encoder.write_header().unwrap();
|
27
|
+
fn write_data<W: Write>(encoder: Encoder<W>, buffer: &[u8]) -> Result<(), std::io::Error> {
|
28
|
+
let mut writer = encoder.write_header()?;
|
30
29
|
|
31
|
-
writer.write_image_data(buffer)
|
32
|
-
writer.finish()
|
30
|
+
writer.write_image_data(buffer)?;
|
31
|
+
writer.finish()?;
|
32
|
+
|
33
|
+
Ok(())
|
33
34
|
}
|
data/gemfiles/plain_ruby.gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
himg (0.0.
|
4
|
+
himg (0.0.4)
|
5
5
|
rb_sys (~> 0.9)
|
6
6
|
|
7
7
|
GEM
|
@@ -28,10 +28,14 @@ GEM
|
|
28
28
|
base64 (0.2.0)
|
29
29
|
benchmark (0.4.0)
|
30
30
|
bigdecimal (3.1.9)
|
31
|
+
bump (0.10.0)
|
31
32
|
concurrent-ruby (1.3.5)
|
32
33
|
connection_pool (2.5.1)
|
33
34
|
csv (3.3.4)
|
34
35
|
date (3.4.1)
|
36
|
+
debug (1.10.0)
|
37
|
+
irb (~> 1.10)
|
38
|
+
reline (>= 0.3.8)
|
35
39
|
diff-lcs (1.6.1)
|
36
40
|
drb (2.2.1)
|
37
41
|
ffi (1.17.2)
|
@@ -118,24 +122,8 @@ GEM
|
|
118
122
|
rubocop-ast (1.44.1)
|
119
123
|
parser (>= 3.3.7.2)
|
120
124
|
prism (~> 1.4)
|
121
|
-
rubocop-performance (1.25.0)
|
122
|
-
lint_roller (~> 1.1)
|
123
|
-
rubocop (>= 1.75.0, < 2.0)
|
124
|
-
rubocop-ast (>= 1.38.0, < 2.0)
|
125
125
|
ruby-progressbar (1.13.0)
|
126
126
|
securerandom (0.4.1)
|
127
|
-
standard (1.49.0)
|
128
|
-
language_server-protocol (~> 3.17.0.2)
|
129
|
-
lint_roller (~> 1.0)
|
130
|
-
rubocop (~> 1.75.2)
|
131
|
-
standard-custom (~> 1.0.0)
|
132
|
-
standard-performance (~> 1.8)
|
133
|
-
standard-custom (1.0.2)
|
134
|
-
lint_roller (~> 1.0)
|
135
|
-
rubocop (~> 1.50)
|
136
|
-
standard-performance (1.8.0)
|
137
|
-
lint_roller (~> 1.1)
|
138
|
-
rubocop-performance (~> 1.25.0)
|
139
127
|
steep (1.10.0)
|
140
128
|
activesupport (>= 5.1)
|
141
129
|
concurrent-ruby (>= 1.1.10)
|
@@ -171,7 +159,6 @@ PLATFORMS
|
|
171
159
|
arm-linux-gnu
|
172
160
|
arm-linux-musl
|
173
161
|
arm64-darwin
|
174
|
-
ruby
|
175
162
|
x86-linux-gnu
|
176
163
|
x86-linux-musl
|
177
164
|
x86_64-darwin
|
@@ -180,12 +167,14 @@ PLATFORMS
|
|
180
167
|
|
181
168
|
DEPENDENCIES
|
182
169
|
appraisal
|
170
|
+
bump
|
171
|
+
debug
|
183
172
|
himg!
|
184
173
|
irb
|
185
|
-
rake
|
174
|
+
rake
|
186
175
|
rake-compiler
|
187
|
-
rspec
|
188
|
-
|
176
|
+
rspec
|
177
|
+
rubocop
|
189
178
|
steep
|
190
179
|
|
191
180
|
BUNDLED WITH
|
data/gemfiles/rails_6.gemfile
CHANGED