emf2svg 1.1.1-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2139094b75f4e6d84b0d96be3d8a66f73eb88d2e2f90f5e7e841684a82e6c044
4
+ data.tar.gz: b74f68585b7946e79eee6310ec804c05d6aa013f99508669895195802d66a8e9
5
+ SHA512:
6
+ metadata.gz: 6e229783b6366258c0509cf26f32bd147870861e83cbebb575e80aeff89543ac86c780fbf488e7c46661460aca78c631db0375c2ca92d8e35a044da317de5b7b
7
+ data.tar.gz: 2e19ebedff30e10f031620814388d7ee742a87a9c1d889ffdc75c62afce8b678c1cb3c5f4ea9983dc376d4ba8a8fed0ccef7e9038abcdc7cb7472fa2c7bf9fc8
@@ -0,0 +1,126 @@
1
+ name: main
2
+
3
+ on:
4
+ push:
5
+ branches: [ main, master ]
6
+ pull_request:
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ${{ matrix.os }}
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ os: [ ubuntu-18.04, ubuntu-latest, windows-latest, macos-latest ]
16
+ ruby-version: [ '2.7' ]
17
+ include:
18
+ - os: windows-latest
19
+ ruby-version: '3.1'
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+
23
+ - uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: ${{ matrix.ruby-version }}
26
+ bundler-cache: true
27
+
28
+ - run: bundle exec rake
29
+
30
+ build:
31
+ runs-on: ${{ matrix.os }}
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ include:
36
+ - os: ubuntu-18.04
37
+ platform: any
38
+ ruby-version: '2.7'
39
+ - os: ubuntu-18.04
40
+ platform: x86_64-linux
41
+ ruby-version: '2.7'
42
+ - os: windows-latest
43
+ platform: x64-mingw32
44
+ ruby-version: '2.7'
45
+ - os: windows-latest
46
+ platform: x64-mingw-ucrt
47
+ ruby-version: '3.1'
48
+ - os: macos-latest
49
+ platform: x86_64-darwin
50
+ ruby-version: '2.7'
51
+ steps:
52
+ - uses: actions/checkout@v2
53
+
54
+ - uses: ruby/setup-ruby@v1
55
+ with:
56
+ ruby-version: ${{ matrix.ruby-version }}
57
+ bundler-cache: true
58
+
59
+ - run: bundle exec rake gem:native:${{ matrix.platform }}
60
+
61
+ - uses: actions/upload-artifact@v2
62
+ with:
63
+ name: pkg
64
+ path: pkg/*.gem
65
+
66
+ - name: Install gem
67
+ run: gem install -b pkg/emf2svg-*.gem
68
+
69
+ - name: Test conversion
70
+ run: |
71
+ ruby -remf2svg -e "puts File.write('output.svg', Emf2svg.from_file('spec/examples/image1.emf'), mode: 'wb')"
72
+
73
+ test-build:
74
+ needs: build
75
+ runs-on: ${{ matrix.os }}
76
+ strategy:
77
+ fail-fast: false
78
+ matrix:
79
+ include:
80
+ - os: ubuntu-latest
81
+ platform: any
82
+ ruby-version: '2.7'
83
+ - os: windows-latest
84
+ platform: any
85
+ ruby-version: '2.7'
86
+ - os: macos-latest
87
+ platform: any
88
+ ruby-version: '2.7'
89
+ - os: ubuntu-18.04
90
+ platform: x86_64-linux
91
+ ruby-version: '2.7'
92
+ - os: ubuntu-latest
93
+ platform: x86_64-linux
94
+ ruby-version: '2.7'
95
+ - os: windows-latest
96
+ platform: x64-mingw32
97
+ ruby-version: '2.7'
98
+ - os: windows-latest
99
+ platform: x64-mingw-ucrt
100
+ ruby-version: '3.1'
101
+ - os: macos-latest
102
+ platform: x86_64-darwin
103
+ ruby-version: '2.7'
104
+ steps:
105
+ - uses: actions/checkout@v2
106
+
107
+ - uses: ruby/setup-ruby@v1
108
+ with:
109
+ ruby-version: ${{ matrix.ruby-version }}
110
+
111
+ - uses: actions/download-artifact@v2
112
+ with:
113
+ name: pkg
114
+ path: pkg
115
+
116
+ - name: Install native gem
117
+ if: matrix.platform == 'any'
118
+ run: gem install -b pkg/emf2svg-$(ruby -I lib -r emf2svg/version -e "puts Emf2svg::VERSION").gem
119
+
120
+ - name: Install binary gem
121
+ if: matrix.platform != 'any'
122
+ run: gem install -b pkg/emf2svg-*-${{ matrix.platform }}.gem
123
+
124
+ - name: Test conversion
125
+ run: |
126
+ ruby -remf2svg -e "puts File.write('output.svg', Emf2svg.from_file('spec/examples/image1.emf'), mode: 'wb')"
@@ -0,0 +1,81 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ${{ matrix.os }}
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ include:
15
+ - os: ubuntu-18.04
16
+ platform: any
17
+ ruby-version: '2.7'
18
+ - os: ubuntu-18.04
19
+ platform: x86_64-linux
20
+ ruby-version: '2.7'
21
+ - os: windows-latest
22
+ platform: x64-mingw32
23
+ ruby-version: '2.7'
24
+ - os: windows-latest
25
+ platform: x64-mingw-ucrt
26
+ ruby-version: '3.1'
27
+ - os: macos-latest
28
+ platform: x86_64-darwin
29
+ ruby-version: '2.7'
30
+ steps:
31
+ - uses: actions/checkout@v2
32
+
33
+ - uses: ruby/setup-ruby@v1
34
+ with:
35
+ ruby-version: ${{ matrix.ruby-version }}
36
+ bundler-cache: true
37
+
38
+ - run: bundle exec rake gem:native:${{ matrix.platform }}
39
+
40
+ - uses: actions/upload-artifact@v2
41
+ with:
42
+ name: pkg
43
+ path: pkg/*.gem
44
+
45
+ - name: Install gem
46
+ run: gem install -b pkg/emf2svg-*.gem
47
+
48
+ - name: Test conversion
49
+ run: |
50
+ ruby -remf2svg -e "puts File.write('output.svg', Emf2svg.from_file('spec/examples/image1.emf'), mode: 'wb')"
51
+
52
+ publish:
53
+ needs: build
54
+ runs-on: ubuntu-latest
55
+ steps:
56
+ - uses: actions/checkout@v2
57
+
58
+ - uses: ruby/setup-ruby@v1
59
+ with:
60
+ ruby-version: '2.7'
61
+ bundler-cache: true
62
+
63
+ - uses: actions/download-artifact@v2
64
+ with:
65
+ name: pkg
66
+ path: pkg
67
+
68
+ - name: Publish to rubygems.org
69
+ env:
70
+ RUBYGEMS_API_KEY: ${{secrets.METANORMA_CI_RUBYGEMS_API_KEY}}
71
+ run: |
72
+ mkdir -p ~/.gem
73
+ touch ~/.gem/credentials
74
+ cat > ~/.gem/credentials << EOF
75
+ ---
76
+ :rubygems_api_key: ${RUBYGEMS_API_KEY}
77
+ EOF
78
+ chmod 0600 ~/.gem/credentials
79
+ gem signin
80
+ ls -l pkg/
81
+ for gem in pkg/*.gem; do gem push -V $gem; done
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /ports/
10
+ /Gemfile.lock
11
+ *.installed
12
+ *.dll
13
+ *.dylib
14
+ *.so
15
+
16
+ # rspec failure tracking
17
+ .rspec_status
18
+
19
+ # remote file cache
20
+ .rubocop-*
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ inherit_from:
2
+ - 'https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml'
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.7
6
+
7
+ Gemspec/RequireMFA:
8
+ Enabled: false
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at ronald.tse@ribose.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in emf2svg.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
data/README.adoc ADDED
@@ -0,0 +1,143 @@
1
+ = emf2svg
2
+
3
+ == Purpose
4
+
5
+ Provides Ruby access to https://github.com/kakwa/libemf2svg (temporarily using
6
+ the https://github.com/metanorma/libemf2svg[Metanorma fork] until upstreaming
7
+ is complete).
8
+
9
+ == Installation
10
+
11
+ Install the gem directly:
12
+
13
+ [source,sh]
14
+ ----
15
+ gem install 'emf2svg'
16
+ ----
17
+
18
+ Or add it to your `Gemfile`:
19
+
20
+ [source,ruby]
21
+ ----
22
+ gem 'emf2svg'
23
+ ----
24
+
25
+ === Dependencies
26
+
27
+ * libiconv
28
+ * libpng
29
+ * libfontconfig
30
+ * libfreetype
31
+
32
+ ==== Windows
33
+
34
+ On Windows all necessary libraries are precompiled but you'll need Visual
35
+ Studio 2019 with C++ Build Tools, which can be downloaded
36
+ https://visualstudio.microsoft.com/downloads/[here], or installed with
37
+ Chocolatey:
38
+
39
+ [source,sh]
40
+ ----
41
+ choco install visualstudio2019buildtools -y --no-progress --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.18362"
42
+ ----
43
+
44
+ ==== macOS
45
+
46
+ [source,sh]
47
+ ----
48
+ brew install cmake
49
+ ----
50
+
51
+ ==== Linux
52
+
53
+ ===== Debian
54
+
55
+ [source,sh]
56
+ ----
57
+ # compiler
58
+ apt-get install gcc g++
59
+ # or
60
+ apt-get install clang
61
+
62
+ # build deps
63
+ apt-get install cmake pkg-config
64
+
65
+ # library deps with their headers
66
+ apt-get install libpng-dev libc6-dev libfontconfig1-dev libfreetype6-dev zlib1g-dev
67
+ ----
68
+
69
+ ===== Fedora
70
+
71
+ [source,sh]
72
+ ----
73
+ yum install cmake libpng-devel freetype-devel fontconfig-devel gcc-c++ gcc
74
+ ----
75
+
76
+ == Usage
77
+
78
+ This gem embeds libemf2svg, allowing your Ruby code to utilize EMF to SVG
79
+ conversion facilities.
80
+
81
+ [source,ruby]
82
+ ----
83
+ require "emf2svg"
84
+
85
+ data = Emf2svg.from_file("example.emf")
86
+ File.write("output.svg", data, mode: "wb")
87
+ ----
88
+
89
+ It also can use content of emf as an input:
90
+
91
+ [source,ruby]
92
+ ----
93
+ require "emf2svg"
94
+
95
+ emf_content = File.read("example.emf", mode: "rb")
96
+ svg_data = Emf2svg.from_binary_string(emf_content)
97
+ File.write("output.svg", svg_data, mode: "wb")
98
+ ----
99
+
100
+ == Development
101
+
102
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
103
+ `rake spec` to run the tests. You can also run `bin/console` for an interactive
104
+ prompt that will allow you to experiment.
105
+
106
+ To install this gem onto your local machine, run `bundle exec rake install`. To
107
+ release a new version, update the version number in `version.rb`, and then run
108
+ `bundle exec rake release`, which will create a git tag for the version, push
109
+ git commits and the created tag, and push the `.gem` file to
110
+ https://rubygems.org[rubygems.org].
111
+
112
+ === Releasing
113
+
114
+ Releasing is done automatically with GitHub Actions. Just bump and tag with
115
+ `gem-release`.
116
+
117
+ For a patch release (0.0.x) use:
118
+
119
+ [source,sh]
120
+ ----
121
+ gem bump --version patch --tag --push
122
+ ----
123
+
124
+ For a minor release (0.x.0) use:
125
+
126
+ [source,sh]
127
+ ----
128
+ gem bump --version minor --tag --push
129
+ ----
130
+
131
+ == Contributing
132
+
133
+ Bug reports and pull requests are welcome on GitHub at
134
+ https://github.com/metanorma/emf2svg-ruby. This project is intended to be a
135
+ safe, welcoming space for collaboration, and contributors are expected to adhere
136
+ to the
137
+ https://github.com/metanorma/emf2svg-ruby/blob/master/CODE_OF_CONDUCT.md[code of conduct].
138
+
139
+ == Code of Conduct
140
+
141
+ Everyone interacting in the emf2svg project's codebases, issue trackers, chat
142
+ rooms and mailing lists is expected to follow the
143
+ https://github.com/metanorma/emf2svg-ruby/blob/master/CODE_OF_CONDUCT.md[code of conduct].
data/Rakefile ADDED
@@ -0,0 +1,66 @@
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 "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
13
+
14
+ task :compile do
15
+ require_relative "ext/extconf"
16
+ end
17
+ task spec: :compile
18
+
19
+ desc "Build install-compilation gem"
20
+ task "gem:native:any" do
21
+ sh "rake platform:any gem"
22
+ end
23
+
24
+ require "rubygems/package_task"
25
+
26
+ desc "Define the gem task to build on any platform (compile on install)"
27
+ task "platform:any" do
28
+ spec = Gem::Specification::load("emf2svg.gemspec").dup
29
+ task = Gem::PackageTask.new(spec)
30
+ task.define
31
+ end
32
+
33
+ platforms = [
34
+ "x64-mingw32",
35
+ "x64-mingw-ucrt",
36
+ "x86_64-linux",
37
+ "x86_64-darwin",
38
+ ]
39
+
40
+ platforms.each do |platform|
41
+ desc "Build pre-compiled gem for the #{platform} platform"
42
+ task "gem:native:#{platform}" do
43
+ sh "rake compile platform:#{platform} gem"
44
+ end
45
+
46
+ desc "Define the gem task to build on the #{platform} platform (binary gem)"
47
+ task "platform:#{platform}" do
48
+ spec = Gem::Specification::load("emf2svg.gemspec").dup
49
+ spec.platform = Gem::Platform.new(platform)
50
+ spec.files += Dir.glob("lib/emf2svg/*.{dll,so,dylib}")
51
+ spec.extensions = []
52
+ spec.dependencies.reject! { |d| d.name == "mini_portile2" }
53
+
54
+ task = Gem::PackageTask.new(spec)
55
+ task.define
56
+ end
57
+ end
58
+
59
+ require "rake/clean"
60
+
61
+ CLOBBER.include("pkg")
62
+ CLEAN.include("ports",
63
+ "tmp",
64
+ "lib/emf2svg/*.dll",
65
+ "lib/emf2svg/*.dylib",
66
+ "lib/emf2svg/*.so")
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "emf2svg"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/emf2svg ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "emf2svg"
6
+
7
+ svg = Emf2svg.from_file(ARGV[0])
8
+ File.write(ARGV[1], svg, mode: "wb")
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/emf2svg.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/emf2svg/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "emf2svg"
7
+ spec.version = Emf2svg::VERSION
8
+ spec.authors = ["Ribose"]
9
+ spec.email = ["open.source@ribose.com"]
10
+
11
+ spec.summary = "Ruby interface to libemf2svg."
12
+ spec.homepage = "https://github.com/metanorma/emf2svg-ruby"
13
+ spec.license = "BSD-2-Clause"
14
+ spec.required_ruby_version = ">= 2.7.0"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/metanorma/emf2svg-ruby"
18
+ spec.metadata["changelog_uri"] = "https://github.com/metanorma/emf2svg-ruby"
19
+
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject do |f|
22
+ f.match(%r{\A(?:test|spec|features)/})
23
+ end
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_runtime_dependency "ffi", "~> 1.0"
30
+ spec.add_runtime_dependency "mini_portile2", "~> 2.6"
31
+
32
+ spec.add_development_dependency "rubocop", "1.5.2"
33
+ spec.add_development_dependency "rubocop-performance", "~> 1.0"
34
+ spec.add_development_dependency "rubocop-rails", "~> 2.0"
35
+
36
+ spec.extensions = ["ext/extconf.rb"]
37
+ end
data/exe/emf2svg ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "emf2svg"
5
+
6
+ svg = Emf2svg.from_file(ARGV[0])
7
+ File.write(ARGV[1], svg, mode: "wb")
data/ext/Makefile ADDED
@@ -0,0 +1,4 @@
1
+ # dummy Makefile, it is required to build an extension
2
+ all:
3
+ clean:
4
+ install:
data/ext/extconf.rb ADDED
@@ -0,0 +1,6 @@
1
+ $: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
2
+
3
+ require "emf2svg/recipe"
4
+
5
+ recipe = Emf2svg::Recipe.new
6
+ recipe.cook
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,91 @@
1
+ require "mini_portile2"
2
+ require "pathname"
3
+ require "tmpdir"
4
+
5
+ module Emf2svg
6
+ class Recipe < MiniPortileCMake
7
+ ROOT = Pathname.new(File.expand_path("../..", __dir__))
8
+
9
+ def initialize
10
+ super("libemf2svg", "1.3.1")
11
+
12
+ @files << {
13
+ url: "https://github.com/metanorma/libemf2svg/releases/download/1.3.1/libemf2svg.tar.gz",
14
+ sha256: "732c60c54d0692a8634221e6ffb0733ad0bb1d9a246a03ba2433c535441eb73e", # rubocop:disable Layout/LineLength
15
+ }
16
+
17
+ @target = ROOT.join(@target).to_s
18
+ @printed = {}
19
+ end
20
+
21
+ def cook_if_not
22
+ cook unless File.exist?(checkpoint)
23
+ end
24
+
25
+ def cook
26
+ super
27
+
28
+ FileUtils.touch(checkpoint)
29
+ end
30
+
31
+ def checkpoint
32
+ File.join(@target, "#{name}-#{version}-#{host}.installed")
33
+ end
34
+
35
+ def configure_defaults
36
+ opts = []
37
+
38
+ opts << "-DCMAKE_BUILD_TYPE=Release"
39
+
40
+ if MiniPortile.windows?
41
+ opts << "-DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake"
42
+ end
43
+
44
+ opts
45
+ end
46
+
47
+ def compile
48
+ execute("compile", "#{make_cmd} --target emf2svg")
49
+ end
50
+
51
+ def make_cmd
52
+ "cmake --build #{File.expand_path(work_path)} --config Release"
53
+ end
54
+
55
+ def install
56
+ libs = if MiniPortile.windows?
57
+ Dir.glob(File.join(work_path, "Release", "*.dll"))
58
+ else
59
+ Dir.glob(File.join(work_path, "libemf2svg.{so,dylib}"))
60
+ .grep(/\/(?:lib)?[a-zA-Z0-9\-]+\.(?:so|dylib)$/)
61
+ end
62
+
63
+ FileUtils.cp_r(libs, ROOT.join("lib", "emf2svg"), verbose: true)
64
+ end
65
+
66
+ def execute(action, command, command_opts = {})
67
+ super(action, command, command_opts.merge(debug: true))
68
+ end
69
+
70
+ def message(text)
71
+ return super unless text.start_with?("\rDownloading")
72
+
73
+ match = text.match(/(\rDownloading .*)\(\s*\d+%\)/)
74
+ pattern = match ? match[1] : text
75
+ return if @printed[pattern]
76
+
77
+ @printed[pattern] = true
78
+ super
79
+ end
80
+
81
+ private
82
+
83
+ def tmp_path
84
+ @tmp_path ||= Dir.mktmpdir
85
+ end
86
+
87
+ def port_path
88
+ "port"
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Emf2svg
4
+ VERSION = "1.1.1"
5
+ end
Binary file
data/lib/emf2svg.rb ADDED
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ffi"
4
+ require_relative "emf2svg/version"
5
+
6
+ module Emf2svg
7
+ class Error < StandardError; end
8
+
9
+ class GeneratorOptions < FFI::Struct
10
+ layout :nameSpace, :string,
11
+ :verbose, :bool,
12
+ :emfplus, :bool,
13
+ :svgDelimiter, :bool,
14
+ :imgHeight, :double,
15
+ :imgWidth, :double
16
+ end
17
+
18
+ extend FFI::Library
19
+
20
+ lib_filename = if FFI::Platform.windows?
21
+ "emf2svg.dll"
22
+ elsif FFI::Platform.mac?
23
+ "libemf2svg.dylib"
24
+ else
25
+ "libemf2svg.so"
26
+ end
27
+
28
+ ffi_lib File.expand_path("emf2svg/#{lib_filename}", __dir__)
29
+ .gsub("/", File::ALT_SEPARATOR || File::SEPARATOR)
30
+
31
+ attach_function :emf2svg,
32
+ [
33
+ :pointer,
34
+ :size_t,
35
+ :pointer,
36
+ :pointer,
37
+ GeneratorOptions.by_ref,
38
+ ],
39
+ :int
40
+
41
+ class << self
42
+ def from_file(path)
43
+ content = File.read(path, mode: "rb")
44
+ from_binary_string(content)
45
+ end
46
+
47
+ def from_binary_string(content)
48
+ svg_out = FFI::MemoryPointer.new(:pointer)
49
+ svg_out_len = FFI::MemoryPointer.new(:pointer)
50
+ content_ptr = FFI::MemoryPointer.from_string(content)
51
+
52
+ ret = emf2svg(content_ptr, content.size, svg_out, svg_out_len, options)
53
+ raise Error, "emf2svg failed with error code: #{ret}" unless ret == 1
54
+
55
+ svg_out.read_pointer.read_bytes(svg_out_len.read_int)
56
+ end
57
+
58
+ private
59
+
60
+ def options
61
+ GeneratorOptions.new.tap do |opts|
62
+ opts[:verbose] = false
63
+ opts[:emfplus] = true
64
+ opts[:svgDelimiter] = true
65
+ opts[:imgHeight] = 0
66
+ opts[:imgWidth] = 0
67
+ end
68
+ end
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: emf2svg
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.1
5
+ platform: x64-mingw-ucrt
6
+ authors:
7
+ - Ribose
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-03-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.5.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.5.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop-performance
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ description:
70
+ email:
71
+ - open.source@ribose.com
72
+ executables:
73
+ - emf2svg
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".github/workflows/main.yml"
78
+ - ".github/workflows/release.yml"
79
+ - ".gitignore"
80
+ - ".rspec"
81
+ - ".rubocop.yml"
82
+ - CODE_OF_CONDUCT.md
83
+ - Gemfile
84
+ - README.adoc
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/emf2svg
88
+ - bin/setup
89
+ - emf2svg.gemspec
90
+ - exe/emf2svg
91
+ - ext/Makefile
92
+ - ext/extconf.rb
93
+ - lib/emf2svg.rb
94
+ - lib/emf2svg/brotlicommon.dll
95
+ - lib/emf2svg/brotlidec.dll
96
+ - lib/emf2svg/bz2.dll
97
+ - lib/emf2svg/emf2svg.dll
98
+ - lib/emf2svg/fontconfig-1.dll
99
+ - lib/emf2svg/freetype.dll
100
+ - lib/emf2svg/iconv-2.dll
101
+ - lib/emf2svg/libexpat.dll
102
+ - lib/emf2svg/libpng16.dll
103
+ - lib/emf2svg/recipe.rb
104
+ - lib/emf2svg/version.rb
105
+ - lib/emf2svg/zlib1.dll
106
+ homepage: https://github.com/metanorma/emf2svg-ruby
107
+ licenses:
108
+ - BSD-2-Clause
109
+ metadata:
110
+ homepage_uri: https://github.com/metanorma/emf2svg-ruby
111
+ source_code_uri: https://github.com/metanorma/emf2svg-ruby
112
+ changelog_uri: https://github.com/metanorma/emf2svg-ruby
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: 2.7.0
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubygems_version: 3.3.7
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Ruby interface to libemf2svg.
132
+ test_files: []