emf2svg 1.0.0-x64-mingw32

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: b7513937773bd6544eaa43ee27090ef54c5d4692a3ae5fba36b9dab8086851fc
4
+ data.tar.gz: 711652a830aef3205d4d3aec7da28c1b49db66d255f2252a1d3f7807e092280c
5
+ SHA512:
6
+ metadata.gz: 86291df0f7e62095ef9210a3d6c9e5b89155ea5cf5b832387d6967db8aaced587050c5b0be3085a8deabb93cf568da18c9bb4cdba109c799ca79b408b81ca183
7
+ data.tar.gz: 02344b44ffb0c5504b57f5c10c35ca3fa027d58c2e1e87daf5087368cdb50d8f38937fe14428b1dd3293f7b3b8e0f7a28d85e09059e8d8ac59f1640f018fe4ae
@@ -0,0 +1,104 @@
1
+ name: main
2
+
3
+ on:
4
+ push:
5
+ branches: [ main, master ]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ${{ matrix.os }}
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ os: [ ubuntu-18.04, ubuntu-latest, windows-latest, macos-latest ]
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+
18
+ - uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: 2.6.6
21
+ bundler-cache: true
22
+
23
+ - run: bundle exec rake
24
+
25
+ build:
26
+ runs-on: ${{ matrix.os }}
27
+ strategy:
28
+ fail-fast: false
29
+ matrix:
30
+ include:
31
+ - os: ubuntu-18.04
32
+ platform: any
33
+ - os: ubuntu-18.04
34
+ platform: x86_64-linux
35
+ - os: windows-latest
36
+ platform: x64-mingw32
37
+ - os: macos-latest
38
+ platform: x86_64-darwin
39
+ steps:
40
+ - uses: actions/checkout@v2
41
+
42
+ - uses: ruby/setup-ruby@v1
43
+ with:
44
+ ruby-version: '2.6'
45
+ bundler-cache: true
46
+
47
+ - run: bundle exec rake gem:native:${{ matrix.platform }}
48
+
49
+ - uses: actions/upload-artifact@v2
50
+ with:
51
+ name: pkg
52
+ path: pkg/*.gem
53
+
54
+ - name: Install gem
55
+ run: gem install --no-document pkg/emf2svg-*.gem
56
+
57
+ - name: Test conversion
58
+ run: |
59
+ ruby -remf2svg -e "puts File.write('output.svg', Emf2svg.from_file('spec/examples/image1.emf'), mode: 'wb')"
60
+
61
+ test-build:
62
+ needs: build
63
+ runs-on: ${{ matrix.os }}
64
+ strategy:
65
+ fail-fast: false
66
+ matrix:
67
+ include:
68
+ - os: ubuntu-latest
69
+ platform: any
70
+ - os: windows-latest
71
+ platform: any
72
+ - os: macos-latest
73
+ platform: any
74
+ - os: ubuntu-18.04
75
+ platform: x86_64-linux
76
+ - os: ubuntu-latest
77
+ platform: x86_64-linux
78
+ - os: windows-latest
79
+ platform: x64-mingw32
80
+ - os: macos-latest
81
+ platform: x86_64-darwin
82
+ steps:
83
+ - uses: actions/checkout@v2
84
+
85
+ - uses: ruby/setup-ruby@v1
86
+ with:
87
+ ruby-version: '2.6'
88
+
89
+ - uses: actions/download-artifact@v2
90
+ with:
91
+ name: pkg
92
+ path: pkg
93
+
94
+ - name: Install native gem
95
+ if: matrix.platform == 'any'
96
+ run: gem install --no-document pkg/emf2svg-$(ruby -I lib -r emf2svg/version -e "puts Emf2svg::VERSION").gem
97
+
98
+ - name: Install binary gem
99
+ if: matrix.platform != 'any'
100
+ run: gem install --no-document pkg/emf2svg-*-${{ matrix.platform }}.gem
101
+
102
+ - name: Test conversion
103
+ run: |
104
+ ruby -remf2svg -e "puts File.write('output.svg', Emf2svg.from_file('spec/examples/image1.emf'), mode: 'wb')"
@@ -0,0 +1,74 @@
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
+ - os: ubuntu-18.04
18
+ platform: x86_64-linux
19
+ - os: windows-latest
20
+ platform: x64-mingw32
21
+ - os: macos-latest
22
+ platform: x86_64-darwin
23
+ steps:
24
+ - uses: actions/checkout@v2
25
+
26
+ - uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: '2.6'
29
+ bundler-cache: true
30
+
31
+ - run: bundle exec rake gem:native:${{ matrix.platform }}
32
+
33
+ - uses: actions/upload-artifact@v2
34
+ with:
35
+ name: pkg
36
+ path: pkg/*.gem
37
+
38
+ - name: Install gem
39
+ run: gem install --no-document pkg/emf2svg-*.gem
40
+
41
+ - name: Test conversion
42
+ run: |
43
+ ruby -remf2svg -e "puts File.write('output.svg', Emf2svg.from_file('spec/examples/image1.emf'), mode: 'wb')"
44
+
45
+ publish:
46
+ needs: build
47
+ runs-on: ubuntu-latest
48
+ steps:
49
+ - uses: actions/checkout@v2
50
+
51
+ - uses: ruby/setup-ruby@v1
52
+ with:
53
+ ruby-version: '2.6'
54
+ bundler-cache: true
55
+
56
+ - uses: actions/download-artifact@v2
57
+ with:
58
+ name: pkg
59
+ path: pkg
60
+
61
+ - name: Publish to rubygems.org
62
+ env:
63
+ RUBYGEMS_API_KEY: ${{secrets.METANORMA_CI_RUBYGEMS_API_KEY}}
64
+ run: |
65
+ mkdir -p ~/.gem
66
+ touch ~/.gem/credentials
67
+ cat > ~/.gem/credentials << EOF
68
+ ---
69
+ :rubygems_api_key: ${RUBYGEMS_API_KEY}
70
+ EOF
71
+ chmod 0600 ~/.gem/credentials
72
+ gem signin
73
+ ls -l pkg/
74
+ 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,5 @@
1
+ inherit_from:
2
+ - 'https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml'
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.5
@@ -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,65 @@
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
+ "x86_64-linux",
36
+ "x86_64-darwin",
37
+ ]
38
+
39
+ platforms.each do |platform|
40
+ desc "Build pre-compiled gem for the #{platform} platform"
41
+ task "gem:native:#{platform}" do
42
+ sh "rake compile platform:#{platform} gem"
43
+ end
44
+
45
+ desc "Define the gem task to build on the #{platform} platform (binary gem)"
46
+ task "platform:#{platform}" do
47
+ spec = Gem::Specification::load("emf2svg.gemspec").dup
48
+ spec.platform = Gem::Platform.new(platform)
49
+ spec.files += Dir.glob("lib/emf2svg/*.{dll,so,dylib}")
50
+ spec.extensions = []
51
+ spec.dependencies.reject! { |d| d.name == "mini_portile2" }
52
+
53
+ task = Gem::PackageTask.new(spec)
54
+ task.define
55
+ end
56
+ end
57
+
58
+ require "rake/clean"
59
+
60
+ CLOBBER.include("pkg")
61
+ CLEAN.include("ports",
62
+ "tmp",
63
+ "lib/emf2svg/*.dll",
64
+ "lib/emf2svg/*.dylib",
65
+ "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.5.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
Binary file
@@ -0,0 +1,92 @@
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.0")
11
+
12
+ @files << {
13
+ url: "https://github.com/metanorma/libemf2svg/releases/download/1.3.0/libemf2svg.tar.gz",
14
+ sha256: "aacbf001701e3f863e97c6c117146ee710636283851d866b715de653fb79343e", # 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
+ opts << "-GVisual Studio 16 2019"
43
+ end
44
+
45
+ opts
46
+ end
47
+
48
+ def compile
49
+ execute("compile", "#{make_cmd} --target emf2svg")
50
+ end
51
+
52
+ def make_cmd
53
+ "cmake --build #{File.expand_path(work_path)} --config Release"
54
+ end
55
+
56
+ def install
57
+ libs = if MiniPortile.windows?
58
+ Dir.glob(File.join(work_path, "Release", "*.dll"))
59
+ else
60
+ Dir.glob(File.join(work_path, "libemf2svg.{so,dylib}"))
61
+ .grep(/\/(?:lib)?[a-zA-Z0-9\-]+\.(?:so|dylib)$/)
62
+ end
63
+
64
+ FileUtils.cp_r(libs, ROOT.join("lib", "emf2svg"), verbose: true)
65
+ end
66
+
67
+ def execute(action, command, command_opts = {})
68
+ super(action, command, command_opts.merge(debug: true))
69
+ end
70
+
71
+ def message(text)
72
+ return super unless text.start_with?("\rDownloading")
73
+
74
+ match = text.match(/(\rDownloading .*)\(\s*\d+%\)/)
75
+ pattern = match ? match[1] : text
76
+ return if @printed[pattern]
77
+
78
+ @printed[pattern] = true
79
+ super
80
+ end
81
+
82
+ private
83
+
84
+ def tmp_path
85
+ @tmp_path ||= Dir.mktmpdir
86
+ end
87
+
88
+ def port_path
89
+ "port"
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Emf2svg
4
+ VERSION = "1.0.0"
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,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: emf2svg
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: x64-mingw32
6
+ authors:
7
+ - Ribose
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-09-06 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/intl-8.dll
102
+ - lib/emf2svg/libexpat.dll
103
+ - lib/emf2svg/libpng16.dll
104
+ - lib/emf2svg/recipe.rb
105
+ - lib/emf2svg/version.rb
106
+ - lib/emf2svg/zlib1.dll
107
+ homepage: https://github.com/metanorma/emf2svg-ruby
108
+ licenses:
109
+ - BSD-2-Clause
110
+ metadata:
111
+ homepage_uri: https://github.com/metanorma/emf2svg-ruby
112
+ source_code_uri: https://github.com/metanorma/emf2svg-ruby
113
+ changelog_uri: https://github.com/metanorma/emf2svg-ruby
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 2.5.0
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubygems_version: 3.0.3.1
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Ruby interface to libemf2svg.
133
+ test_files: []