svg2img 0.1.0-x86_64-linux

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a1e502555ea706b8800bbe2fcd5e52a7a606ccfc06f7dea63732d3b364ff32cd
4
+ data.tar.gz: e7c9ca2f389725a7064d560da83a52993970ef970b093df1822509816dad1053
5
+ SHA512:
6
+ metadata.gz: 91a14a95ac847e15a8e9643725fac38abed72a9330dd92ccdbdf146b1cfa3a51a2d98ddcda4df52a31d315551677d8b73ced2411827430e0ace3a8b42643068d
7
+ data.tar.gz: 26d5776e3290ca0c2cca6b636f05c47c9c5ed4509b6d3ac0070a5aa17433ef210bbb2c9bbf7c67b9fe119880db04c81793834378ad1300ead3ece768adce5919
data/.envrc ADDED
@@ -0,0 +1 @@
1
+ use_flake . --impure
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-08-17
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Orvar Segerström
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,78 @@
1
+ # Svg2img
2
+
3
+ Convert SVG to image. Uses a bundled native binary, and requires no external dependencies.
4
+ Supported output formats for now:
5
+
6
+ - png
7
+ - jpg
8
+ - webp
9
+ - gif
10
+
11
+ ## Installation
12
+
13
+ Add the `svg2img` gem to your Gemfile and run `bundle install`:
14
+
15
+ ```ruby
16
+ gem "svg2img"
17
+ ```
18
+
19
+ Alternatively, you can install the gem manually:
20
+
21
+ ```sh
22
+ gem install svg2img
23
+ ```
24
+
25
+ ### Precompiled gems
26
+
27
+ We recommend installing the `svg2img` precompiled gems available for Linux and macOS. Installing a precompiled gem avoids the need to compile from source code, which is generally slower and less reliable.
28
+
29
+ When installing the `svg2img` gem for the first time using `bundle install`, Bundler will automatically download the precompiled gem for your current platform. However, you will need to inform Bundler of any additional platforms you plan to use.
30
+
31
+ To do this, lock your Bundle to the required platforms you will need from the list of supported platforms below:
32
+
33
+ ```sh
34
+ bundle lock --add-platform x86_64-linux # Standard Linux (e.g. Heroku, GitHub Actions, etc.)
35
+ bundle lock --add-platform x86_64-linux-musl # MUSL Linux deployments (i.e. Alpine Linux)
36
+ bundle lock --add-platform aarch64-linux # ARM64 Linux deployments (i.e. AWS Graviton2)
37
+ bundle lock --add-platform x86_64-darwin # Intel MacOS (i.e. pre-M1)
38
+ bundle lock --add-platform arm64-darwin # Apple Silicon MacOS (i.e. M1)
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ Example usage:
44
+
45
+ ```ruby
46
+ require "svg2img"
47
+
48
+ circle_svg = <<~SVG
49
+ <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
50
+ <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
51
+ </svg>
52
+ SVG
53
+ png_path = Svg2Img.process_svg(circle_svg, output_format: :png)
54
+ # png_path is a path to the generated PNG file
55
+
56
+ # Rails example
57
+ data = Rails.cache.fetch([some, deps]) do
58
+ png_path = Svg2Img.process_svg(circle_svg, output_format: :png)
59
+ png_data = File.binread(png_path)
60
+ File.delete(png_path)
61
+ png_data
62
+ end
63
+ send_data(png_data, type: 'image/png', disposition: 'inline')
64
+ ```
65
+
66
+ ## Development
67
+
68
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
69
+
70
+ 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).
71
+
72
+ ## Contributing
73
+
74
+ Bug reports and pull requests are welcome on GitHub at https://github.com/0rvar/svg2img-rb.
75
+
76
+ ## License
77
+
78
+ 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,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rb_sys/extensiontask"
5
+
6
+ task build: :compile
7
+
8
+ GEMSPEC = Gem::Specification.load("svg2img.gemspec")
9
+
10
+ RbSys::ExtensionTask.new("svg2img", GEMSPEC) do |ext|
11
+ ext.lib_dir = "lib/svg2img"
12
+
13
+ ext.cross_compile = true
14
+ end
15
+
16
+ task default: :compile
data/flake.lock ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "nodes": {
3
+ "flake-compat": {
4
+ "flake": false,
5
+ "locked": {
6
+ "lastModified": 1696426674,
7
+ "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
8
+ "owner": "edolstra",
9
+ "repo": "flake-compat",
10
+ "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
11
+ "type": "github"
12
+ },
13
+ "original": {
14
+ "owner": "edolstra",
15
+ "repo": "flake-compat",
16
+ "type": "github"
17
+ }
18
+ },
19
+ "flake-utils": {
20
+ "inputs": {
21
+ "systems": "systems"
22
+ },
23
+ "locked": {
24
+ "lastModified": 1694529238,
25
+ "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
26
+ "owner": "numtide",
27
+ "repo": "flake-utils",
28
+ "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
29
+ "type": "github"
30
+ },
31
+ "original": {
32
+ "owner": "numtide",
33
+ "repo": "flake-utils",
34
+ "type": "github"
35
+ }
36
+ },
37
+ "nixpkgs": {
38
+ "locked": {
39
+ "lastModified": 1709961763,
40
+ "narHash": "sha256-6H95HGJHhEZtyYA3rIQpvamMKAGoa8Yh2rFV29QnuGw=",
41
+ "owner": "NixOS",
42
+ "repo": "nixpkgs",
43
+ "rev": "3030f185ba6a4bf4f18b87f345f104e6a6961f34",
44
+ "type": "github"
45
+ },
46
+ "original": {
47
+ "owner": "NixOS",
48
+ "ref": "nixos-unstable",
49
+ "repo": "nixpkgs",
50
+ "type": "github"
51
+ }
52
+ },
53
+ "nixpkgs-ruby": {
54
+ "inputs": {
55
+ "flake-compat": "flake-compat",
56
+ "flake-utils": "flake-utils",
57
+ "nixpkgs": [
58
+ "nixpkgs"
59
+ ]
60
+ },
61
+ "locked": {
62
+ "lastModified": 1722577194,
63
+ "narHash": "sha256-nWLATuXQYs/AHFxC9mi/uo6mVUz6nFYcWNd6flGCxVk=",
64
+ "owner": "bobvanderlinden",
65
+ "repo": "nixpkgs-ruby",
66
+ "rev": "b2ac79f24e50faac5d4ce3a878b7a9f0270fa2bd",
67
+ "type": "github"
68
+ },
69
+ "original": {
70
+ "owner": "bobvanderlinden",
71
+ "repo": "nixpkgs-ruby",
72
+ "type": "github"
73
+ }
74
+ },
75
+ "root": {
76
+ "inputs": {
77
+ "nixpkgs": "nixpkgs",
78
+ "nixpkgs-ruby": "nixpkgs-ruby"
79
+ }
80
+ },
81
+ "systems": {
82
+ "locked": {
83
+ "lastModified": 1681028828,
84
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
85
+ "owner": "nix-systems",
86
+ "repo": "default",
87
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
88
+ "type": "github"
89
+ },
90
+ "original": {
91
+ "owner": "nix-systems",
92
+ "repo": "default",
93
+ "type": "github"
94
+ }
95
+ }
96
+ },
97
+ "root": "root",
98
+ "version": 7
99
+ }
data/flake.nix ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ description = "Devshell with all the dependencies needed to develop and build the project";
3
+
4
+ inputs = {
5
+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6
+ nixpkgs-ruby.url = "github:bobvanderlinden/nixpkgs-ruby";
7
+ nixpkgs-ruby.inputs.nixpkgs.follows = "nixpkgs";
8
+ };
9
+
10
+
11
+ outputs = { self, nixpkgs, nixpkgs-ruby }:
12
+ let
13
+ # Boilerplate function for generating attributes for all systems
14
+ forAllSystems = function:
15
+ nixpkgs.lib.genAttrs [
16
+ "x86_64-linux"
17
+ "aarch64-linux"
18
+ "x86_64-darwin"
19
+ "aarch64-darwin"
20
+ ]
21
+ (system:
22
+ (function (import nixpkgs {
23
+ inherit system;
24
+ })) system);
25
+ in
26
+ {
27
+ packages = forAllSystems (pkgs: system:
28
+ let
29
+ ruby = nixpkgs-ruby.lib.packageFromRubyVersionFile {
30
+ file = ./.ruby-version;
31
+ inherit system;
32
+ };
33
+ tools = [ ruby ] ++ (with pkgs; [
34
+ nodejs_20
35
+ yarn
36
+ mprocs
37
+ ]);
38
+ gemDependencies = with pkgs; [
39
+ zstd
40
+ libxml2
41
+ libxslt
42
+ imagemagick
43
+ ];
44
+ root = builtins.getEnv "PWD";
45
+ in
46
+ {
47
+ default = pkgs.mkShell {
48
+ buildInputs = tools ++ gemDependencies;
49
+ shellHook = ''
50
+ # https://github.com/sass/sassc-ruby/issues/148#issuecomment-644450274
51
+ bundle config build.sassc --disable-lto
52
+ export BUNDLE_BUILD__SASSC="--disable-lto"
53
+
54
+ export GEM_HOME="${root}/.bundle"
55
+ export GEM_PATH="${root}/.bundle"
56
+ export PATH="${root}/.bundle/bin:$PATH"
57
+ export RUBY_YJIT_ENABLE=1
58
+ '';
59
+ };
60
+ });
61
+ };
62
+ }
Binary file
Binary file
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Svg2Img
4
+ VERSION = "0.1.0"
5
+ end
data/lib/svg2img.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "svg2img/version"
4
+ require_relative "svg2img/svg2img"
5
+
6
+ module Svg2Img
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
data/package.sh ADDED
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+
3
+ set -eo pipefail
4
+
5
+ PLATFORMS="x86_64-linux x86_64-linux-musl x86_64-darwin aarch64-linux aarch64-linux-musl arm64-darwin"
6
+ for P in $PLATFORMS; do
7
+ bundle exec rb-sys-dock -p $P --build -r 3.2,3.3
8
+ done
data/sig/svg2img.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Svg2Img
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: svg2img
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: x86_64-linux
6
+ authors:
7
+ - Orvar Segerström
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-08-17 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - orvarsegerstrom@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".envrc"
21
+ - ".rspec"
22
+ - ".ruby-version"
23
+ - CHANGELOG.md
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - flake.lock
28
+ - flake.nix
29
+ - lib/svg2img.rb
30
+ - lib/svg2img/3.2/svg2img.so
31
+ - lib/svg2img/3.3/svg2img.so
32
+ - lib/svg2img/version.rb
33
+ - package.sh
34
+ - sig/svg2img.rbs
35
+ homepage: https://github.com/0rvar/svg2img-rb
36
+ licenses:
37
+ - MIT
38
+ metadata:
39
+ homepage_uri: https://github.com/0rvar/svg2img-rb
40
+ source_code_uri: https://github.com/0rvar/svg2img-rb
41
+ changelog_uri: https://github.com/0rvar/svg2img-rb/blob/master/CHANGELOG.md
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '3.2'
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: 3.4.dev
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 3.3.11
59
+ requirements: []
60
+ rubygems_version: 3.4.4
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Convert svg to png, jpg, or webp, with no runtime dependencies.
64
+ test_files: []