emf2svg 1.3.0-arm64-darwin

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: 52290461530aa886828a24b76309d67545dd319b4fb79f0f55c0f661c20832f9
4
+ data.tar.gz: e448c4d904168ffc6048fbd7347fc7caeea39a8fc582aac5a496571f9d63cb5b
5
+ SHA512:
6
+ metadata.gz: 0cdc29176f604f064e197cb08c7599703a77220c5535c2447d81c868d6ec90e4b098847559b9913e6b19498a5a52543b68ee03d9bd0c2b7559abfd23f82b85e7
7
+ data.tar.gz: 69c93c12ddcd0fd77b9e8ec469a026c3964d40c02259e8eafb4f6a87625fd94a0cd10b42867d8d89d71036417b7b974478f3c36b280e62361291f9522f205726
@@ -0,0 +1,167 @@
1
+ name: main
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ${{ matrix.os }}
12
+ strategy:
13
+ max-parallel: 4
14
+ fail-fast: false
15
+ matrix:
16
+ os: [ ubuntu-18.04, ubuntu-latest, windows-latest, macos-latest ]
17
+ ruby-version: [ '2.7' ]
18
+ include:
19
+ - os: windows-latest
20
+ ruby-version: '3.1'
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+
24
+ - uses: ruby/setup-ruby@v1
25
+ with:
26
+ bundler-cache: true
27
+ ruby-version: ${{ matrix.ruby-version }}
28
+
29
+ - run: bundle exec rake
30
+
31
+ build:
32
+ runs-on: ${{ matrix.os }}
33
+ strategy:
34
+ max-parallel: 4
35
+ fail-fast: false
36
+ matrix:
37
+ include:
38
+ - os: ubuntu-18.04
39
+ platform: any
40
+ ruby-version: '2.7'
41
+ - os: ubuntu-18.04
42
+ platform: x86_64-linux
43
+ ruby-version: '2.7'
44
+ - os: windows-latest
45
+ platform: x64-mingw32
46
+ ruby-version: '2.7'
47
+ - os: windows-latest
48
+ platform: x64-mingw-ucrt
49
+ ruby-version: '3.1'
50
+ - os: macos-latest
51
+ platform: x86_64-darwin
52
+ ruby-version: '2.7'
53
+ steps:
54
+ - uses: actions/checkout@v2
55
+
56
+ - uses: ruby/setup-ruby@v1
57
+ with:
58
+ ruby-version: ${{ matrix.ruby-version }}
59
+ bundler-cache: true
60
+
61
+ - run: bundle exec rake gem:native:${{ matrix.platform }}
62
+
63
+ - uses: actions/upload-artifact@v2
64
+ with:
65
+ name: pkg
66
+ path: pkg/*.gem
67
+
68
+ - name: Install gem
69
+ run: gem install -b pkg/emf2svg-*.gem
70
+
71
+ - name: Test conversion
72
+ run: |
73
+ ruby -remf2svg -e "puts File.write('output.svg', Emf2svg.from_file('spec/examples/image1.emf'), mode: 'wb')"
74
+
75
+ test-build:
76
+ needs: build
77
+ runs-on: ${{ matrix.os }}
78
+ strategy:
79
+ max-parallel: 4
80
+ fail-fast: false
81
+ matrix:
82
+ include:
83
+ - os: ubuntu-latest
84
+ platform: any
85
+ ruby-version: '2.7'
86
+ - os: windows-latest
87
+ platform: any
88
+ ruby-version: '2.7'
89
+ - os: macos-latest
90
+ platform: any
91
+ ruby-version: '2.7'
92
+ - os: ubuntu-18.04
93
+ platform: x86_64-linux
94
+ ruby-version: '2.7'
95
+ - os: ubuntu-latest
96
+ platform: x86_64-linux
97
+ ruby-version: '2.7'
98
+ - os: windows-latest
99
+ platform: x64-mingw32
100
+ ruby-version: '2.7'
101
+ - os: windows-latest
102
+ platform: x64-mingw-ucrt
103
+ ruby-version: '3.1'
104
+ - os: macos-latest
105
+ platform: x86_64-darwin
106
+ ruby-version: '2.7'
107
+
108
+ steps:
109
+ - uses: actions/checkout@v2
110
+
111
+ - uses: ruby/setup-ruby@v1
112
+ with:
113
+ ruby-version: ${{ matrix.ruby-version }}
114
+
115
+ - uses: actions/download-artifact@v2
116
+ with:
117
+ name: pkg
118
+ path: pkg
119
+
120
+ - name: Install native gem
121
+ if: matrix.platform == 'any'
122
+ run: gem install -b pkg/emf2svg-$(ruby -I lib -r emf2svg/version -e "puts Emf2svg::VERSION").gem
123
+
124
+ - name: Install binary gem
125
+ if: matrix.platform != 'any'
126
+ run: gem install -b pkg/emf2svg-*-${{ matrix.platform }}.gem
127
+
128
+ - name: Test conversion
129
+ run: |
130
+ ruby -remf2svg -e "puts File.write('output.svg', Emf2svg.from_file('spec/examples/image1.emf'), mode: 'wb')"
131
+
132
+ cross:
133
+ runs-on: ${{ matrix.os }}
134
+ strategy:
135
+ max-parallel: 4
136
+ fail-fast: false
137
+ matrix:
138
+ include:
139
+ - os: ubuntu-latest
140
+ platform: arm64-linux
141
+ ruby-version: '2.7'
142
+ - os: macos-latest
143
+ platform: arm64-darwin
144
+ ruby-version: '2.7'
145
+ steps:
146
+ - uses: actions/checkout@v2
147
+
148
+ - name: Install packages
149
+ if: matrix.os == 'ubuntu-latest'
150
+ run: |
151
+ sudo apt-get update
152
+ sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu gperf
153
+
154
+ - uses: ruby/setup-ruby@v1
155
+ with:
156
+ ruby-version: ${{ matrix.ruby-version }}
157
+ bundler-cache: true
158
+
159
+ - run: bundle exec rake gem:native:${{ matrix.platform }}
160
+
161
+ - uses: actions/upload-artifact@v2
162
+ with:
163
+ name: pkg
164
+ path: pkg/*.gem
165
+
166
+ - name: Install gem
167
+ run: gem install -b pkg/emf2svg-*.gem
@@ -0,0 +1,119 @@
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
+ max-parallel: 3
13
+ fail-fast: false
14
+ matrix:
15
+ include:
16
+ - os: ubuntu-18.04
17
+ platform: any
18
+ ruby-version: '2.7'
19
+ - os: ubuntu-18.04
20
+ platform: x86_64-linux
21
+ ruby-version: '2.7'
22
+ - os: windows-latest
23
+ platform: x64-mingw32
24
+ ruby-version: '2.7'
25
+ - os: windows-latest
26
+ platform: x64-mingw-ucrt
27
+ ruby-version: '3.1'
28
+ - os: macos-latest
29
+ platform: x86_64-darwin
30
+ ruby-version: '2.7'
31
+ steps:
32
+ - uses: actions/checkout@v2
33
+
34
+ - uses: ruby/setup-ruby@v1
35
+ with:
36
+ ruby-version: ${{ matrix.ruby-version }}
37
+ bundler-cache: true
38
+
39
+ - run: bundle exec rake gem:native:${{ matrix.platform }}
40
+
41
+ - uses: actions/upload-artifact@v2
42
+ with:
43
+ name: pkg
44
+ path: pkg/*.gem
45
+
46
+ - name: Install gem
47
+ run: gem install -b pkg/emf2svg-*.gem
48
+
49
+ - name: Test conversion
50
+ run: |
51
+ ruby -remf2svg -e "puts File.write('output.svg', Emf2svg.from_file('spec/examples/image1.emf'), mode: 'wb')"
52
+
53
+ cross:
54
+ runs-on: ${{ matrix.os }}
55
+ strategy:
56
+ max-parallel: 3
57
+ fail-fast: false
58
+ matrix:
59
+ include:
60
+ - os: ubuntu-latest
61
+ platform: arm64-linux
62
+ ruby-version: '2.7'
63
+ - os: macos-latest
64
+ platform: arm64-darwin
65
+ ruby-version: '2.7'
66
+ steps:
67
+ - uses: actions/checkout@v2
68
+
69
+ - name: Install packages
70
+ if: matrix.os == 'ubuntu-latest'
71
+ run: |
72
+ sudo apt-get update
73
+ sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu gperf
74
+
75
+ - uses: ruby/setup-ruby@v1
76
+ with:
77
+ ruby-version: ${{ matrix.ruby-version }}
78
+ bundler-cache: true
79
+
80
+ - run: bundle exec rake gem:native:${{ matrix.platform }}
81
+
82
+ - uses: actions/upload-artifact@v2
83
+ with:
84
+ name: pkg
85
+ path: pkg/*.gem
86
+
87
+ - name: Install gem
88
+ run: gem install -b pkg/emf2svg-*.gem
89
+
90
+ publish:
91
+ needs: [ build, cross ]
92
+ runs-on: ubuntu-latest
93
+ steps:
94
+ - uses: actions/checkout@v2
95
+
96
+ - uses: ruby/setup-ruby@v1
97
+ with:
98
+ ruby-version: '2.7'
99
+ bundler-cache: true
100
+
101
+ - uses: actions/download-artifact@v2
102
+ with:
103
+ name: pkg
104
+ path: pkg
105
+
106
+ - name: Publish to rubygems.org
107
+ env:
108
+ RUBYGEMS_API_KEY: ${{secrets.METANORMA_CI_RUBYGEMS_API_KEY}}
109
+ run: |
110
+ mkdir -p ~/.gem
111
+ touch ~/.gem/credentials
112
+ cat > ~/.gem/credentials << EOF
113
+ ---
114
+ :rubygems_api_key: ${RUBYGEMS_API_KEY}
115
+ EOF
116
+ chmod 0600 ~/.gem/credentials
117
+ gem signin
118
+ ls -l pkg/
119
+ 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,9 @@
1
+ inherit_from:
2
+ - 'https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml'
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.5
6
+ SuggestExtensions: false
7
+
8
+ Gemspec/RequireMFA:
9
+ 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,76 @@
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
+ "arm64-linux",
38
+ "aarch64-linux",
39
+ "x86_64-darwin",
40
+ "arm64-darwin",
41
+ "aarch64-darwin",
42
+ "x86_64-macos",
43
+ "arm64-macos",
44
+ "aarch64-macos",
45
+ "x86_64-osx",
46
+ "arm64-osx",
47
+ "aarch64-osx",
48
+ ]
49
+
50
+ platforms.each do |platform|
51
+ desc "Build pre-compiled gem for the #{platform} platform"
52
+ task "gem:native:#{platform}" do
53
+ sh "rake compile platform:#{platform} gem target_platform=#{platform}"
54
+ end
55
+
56
+ desc "Define the gem task to build on the #{platform} platform (binary gem)"
57
+ task "platform:#{platform}" do
58
+ spec = Gem::Specification::load("emf2svg.gemspec").dup
59
+ spec.platform = Gem::Platform.new(platform)
60
+ spec.files += Dir.glob("lib/emf2svg/*.{dll,so,dylib}")
61
+ spec.extensions = []
62
+ spec.dependencies.reject! { |d| d.name == "mini_portile2" }
63
+
64
+ task = Gem::PackageTask.new(spec)
65
+ task.define
66
+ end
67
+ end
68
+
69
+ require "rake/clean"
70
+
71
+ CLOBBER.include("pkg")
72
+ CLEAN.include("ports",
73
+ "tmp",
74
+ "lib/emf2svg/*.dll",
75
+ "lib/emf2svg/*.dylib",
76
+ "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
@@ -0,0 +1,154 @@
1
+ require "rbconfig"
2
+ require "mini_portile2"
3
+ require "pathname"
4
+ require "tmpdir"
5
+
6
+ module Emf2svg
7
+ class Recipe < MiniPortileCMake
8
+ ROOT = Pathname.new(File.expand_path("../..", __dir__))
9
+
10
+ def initialize
11
+ super("libemf2svg", "1.6.0")
12
+
13
+ @files << {
14
+ url: "https://github.com/metanorma/libemf2svg/releases/download/v1.6.0/libemf2svg.tar.gz",
15
+ sha256: "0f186f40b98c06acdec1278a314cEc1f093e7504d34f7a15b697ebfe6c4d3097", # rubocop:disable Layout/LineLength
16
+ }
17
+
18
+ @target = ROOT.join(@target).to_s
19
+ @printed = {}
20
+ end
21
+
22
+ def cook_if_not
23
+ cook unless File.exist?(checkpoint)
24
+ end
25
+
26
+ def cook
27
+ super
28
+
29
+ FileUtils.touch(checkpoint)
30
+ end
31
+
32
+ # rubocop:disable Metrics/MethodLength
33
+ # rubocop:disable Metrics/CyclomaticComplexity
34
+ def host_platform
35
+ @host_platform ||=
36
+ case @host
37
+ when /\Ax86_64.*mingw32/
38
+ "x64-mingw32"
39
+ when /\Ai[3-6]86.*mingw32/
40
+ "x86-mingw32"
41
+ when /\Ax86_64.*linux/
42
+ "x86_64-linux"
43
+ when /\A(arm64|aarch64).*linux/
44
+ "arm64-linux"
45
+ when /\Ai[3-6]86.*linux/
46
+ "x86-linux"
47
+ when /\Ax86_64.*(darwin|macos|osx)/
48
+ "x86_64-darwin"
49
+ when /\A(arm64|aarch64).*(darwin|macos|osx)/
50
+ "arm64-darwin"
51
+ else
52
+ @host
53
+ end
54
+ end
55
+
56
+ def target_platform
57
+ @target_platform ||=
58
+ case ENV["target_platform"]
59
+ when /\A(arm64|aarch64).*(darwin|macos|osx)/
60
+ "arm64-darwin"
61
+ when /\Ac86_64.*(darwin|macos|osx)/
62
+ "x86_64-darwin"
63
+ when /\A(arm64|aarch64).*linux/
64
+ "arm64-linux"
65
+ else
66
+ ENV["target_platform"] || host_platform
67
+ end
68
+ end
69
+
70
+ def target_triplet
71
+ @target_triplet ||=
72
+ case target_platform
73
+ when "arm64-darwin"
74
+ "arm64-osx"
75
+ when "x86_64-darwin"
76
+ "x86_64-osx"
77
+ else
78
+ target_platform
79
+ end
80
+ end
81
+
82
+ # rubocop:enable Metrics/CyclomaticComplexity
83
+ # rubocop:enable Metrics/MethodLength
84
+
85
+ def cross_compiling?
86
+ not host_platform.eql? target_platform
87
+ end
88
+
89
+ def checkpoint
90
+ File.join(@target, "#{name}-#{version}-#{target_platform}.installed")
91
+ end
92
+
93
+ def configure_defaults
94
+ opts = []
95
+
96
+ opts << "-DCMAKE_BUILD_TYPE=Release"
97
+
98
+ if MiniPortile.windows? || cross_compiling?
99
+ opts << "-DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake"
100
+ end
101
+
102
+ if cross_compiling? && (not MiniPortile.windows?)
103
+ message("Cross-compiling on #{host_platform} for #{target_platform}\n")
104
+ opts << "-DVCPKG_TARGET_TRIPLET=#{target_triplet}"
105
+ end
106
+
107
+ opts
108
+ end
109
+
110
+ def compile
111
+ execute("compile", "#{make_cmd} --target emf2svg")
112
+ end
113
+
114
+ def make_cmd
115
+ "cmake --build #{File.expand_path(work_path)} --config Release"
116
+ end
117
+
118
+ def install
119
+ libs = if MiniPortile.windows?
120
+ Dir.glob(File.join(work_path, "Release", "*.dll"))
121
+ else
122
+ Dir.glob(File.join(work_path, "libemf2svg.{so,dylib}"))
123
+ .grep(/\/(?:lib)?[a-zA-Z0-9\-]+\.(?:so|dylib)$/)
124
+ end
125
+
126
+ FileUtils.cp_r(libs, ROOT.join("lib", "emf2svg"), verbose: true)
127
+ end
128
+
129
+ def execute(action, command, command_opts = {})
130
+ super(action, command, command_opts.merge(debug: true))
131
+ end
132
+
133
+ def message(text)
134
+ return super unless text.start_with?("\rDownloading")
135
+
136
+ match = text.match(/(\rDownloading .*)\(\s*\d+%\)/)
137
+ pattern = match ? match[1] : text
138
+ return if @printed[pattern]
139
+
140
+ @printed[pattern] = true
141
+ super
142
+ end
143
+
144
+ private
145
+
146
+ def tmp_path
147
+ @tmp_path ||= Dir.mktmpdir
148
+ end
149
+
150
+ def port_path
151
+ "port"
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Emf2svg
4
+ VERSION = "1.3.0"
5
+ end
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,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: emf2svg
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.0
5
+ platform: arm64-darwin
6
+ authors:
7
+ - Ribose
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-03-25 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/libemf2svg.dylib
95
+ - lib/emf2svg/recipe.rb
96
+ - lib/emf2svg/version.rb
97
+ homepage: https://github.com/metanorma/emf2svg-ruby
98
+ licenses:
99
+ - BSD-2-Clause
100
+ metadata:
101
+ homepage_uri: https://github.com/metanorma/emf2svg-ruby
102
+ source_code_uri: https://github.com/metanorma/emf2svg-ruby
103
+ changelog_uri: https://github.com/metanorma/emf2svg-ruby
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 2.5.0
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubygems_version: 3.1.6
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: Ruby interface to libemf2svg.
123
+ test_files: []