himg 0.0.1

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.
data/Cargo.toml ADDED
@@ -0,0 +1,13 @@
1
+ # This Cargo.toml is here to let externals tools (IDEs, etc.) know that this is
2
+ # a Rust project. Your extensions dependencies should be added to the Cargo.toml
3
+ # in the ext/ directory.
4
+
5
+ [workspace]
6
+ members = ["./ext/himg"]
7
+ resolver = "2"
8
+
9
+ [profile.release]
10
+ # By default, debug symbols are stripped from the final binary which makes it
11
+ # harder to debug if something goes wrong. As we don't mind a larger binary size
12
+ # we can keep these in the release build so that you can debug if needed.
13
+ debug = true
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 James Edwards-Jones
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Himg
2
+
3
+ Library for generating an image from HTML
4
+
5
+ Parses a minimal subset of HTML/CSS, fetches nested resources, renders an image on the GPU.
6
+
7
+ Uses rust libraries to do this in a fast, hopefully safe way.
8
+
9
+ In Rails this will mean you can process user.himg.erb to display an image including data from a user's profile.
10
+
11
+ ## Installation
12
+
13
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
14
+
15
+ Install the gem and add to the application's Gemfile by executing:
16
+
17
+ ```bash
18
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
19
+ ```
20
+
21
+ If bundler is not being used to manage dependencies, install the gem by executing:
22
+
23
+ ```bash
24
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### Run from Ruby
30
+
31
+ ```ruby
32
+ png = Himg.render("<html bgcolor='blue'></html>")
33
+ ```
34
+
35
+ ### Run directly from the command line to output an image
36
+ ```bash
37
+ bundle exec cargo run --example file
38
+ bundle exec cargo run --example file -- path/to/file.html
39
+ ```
40
+
41
+ ## Development
42
+
43
+ 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.
44
+
45
+ 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).
46
+
47
+ ## Contributing
48
+
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jamedjo/himg.
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "standard/rake"
9
+
10
+ require "rb_sys/extensiontask"
11
+
12
+ task build: :compile
13
+
14
+ GEMSPEC = Gem::Specification.load("himg.gemspec")
15
+
16
+ RbSys::ExtensionTask.new("himg", GEMSPEC) do |ext|
17
+ ext.lib_dir = "lib/himg"
18
+ end
19
+
20
+ task default: %i[compile spec standard]
data/Steepfile ADDED
@@ -0,0 +1,29 @@
1
+ D = Steep::Diagnostic
2
+
3
+ target :lib do
4
+ signature "sig"
5
+ ignore_signature "sig/test"
6
+
7
+ check "lib" # Directory name
8
+
9
+ # library "pathname" # Standard libraries
10
+ # library "strong_json" # Gems
11
+
12
+ # configure_code_diagnostics(D::Ruby.default) # `default` diagnostics setting (applies by default)
13
+ # configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting
14
+ # configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
15
+ # configure_code_diagnostics(D::Ruby.silent) # `silent` diagnostics setting
16
+ # configure_code_diagnostics do |hash| # You can setup everything yourself
17
+ # hash[D::Ruby::NoMethod] = :information
18
+ # end
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