-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Command-line parameters check, Ruby 3.0 tests, libemf2svg 1.7.1 (#32)
* libemf2svg 1.7.1 * Command-line consistency checks * Ruby 3.0 tests and CI refactoring * Expose width and height parameters for target image
- Loading branch information
Showing
10 changed files
with
261 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,38 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
require "bundler/setup" | ||
require "emf2svg" | ||
|
||
svg = Emf2svg.from_file(ARGV[0]) | ||
File.write(ARGV[1], svg, mode: "wb") | ||
def print_usage | ||
usage = %{Usage: emf2svg <input> <output> [<width>] [<height>] | ||
<input> -- emf file to convert | ||
<output> -- svg file to save | ||
<width> -- svg image width, defaults to source width in px if not set or 0 | ||
<height> -- svg image height, defaults to source height in px if not set or 0 | ||
Note: width and height specify bounding rectangle, the image will be scaled | ||
propotionally to fit into it. | ||
} | ||
puts usage | ||
end | ||
|
||
def tint(pos) | ||
ARGV.size > pos ? Integer(ARGV[pos]) : 0 | ||
rescue ArgumentError, TypeError => e | ||
puts "ERROR: Failed to convert #{ARGV[pos]} to integer: #{e.message}" | ||
print_usage | ||
exit 1 | ||
end | ||
|
||
if ARGV.size < 2 || ARGV.size > 4 || ARGV[0].casecmp("help").zero? | ||
print_usage | ||
exit 0 | ||
end | ||
|
||
begin | ||
svg = Emf2svg.from_file(ARGV[0], tint(2), tint(3)) | ||
File.write(ARGV[1], svg, mode: "wb") | ||
rescue StandardError => e | ||
puts "ERROR: Failed to process #{ARGV[0]}: #{e.message}" | ||
print_usage | ||
exit 1 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec| | |
spec.authors = ["Ribose"] | ||
spec.email = ["[email protected]"] | ||
|
||
spec.summary = "Ruby interface to libemf2svg." | ||
spec.summary = "EMF to SVG conversion in Ruby." | ||
spec.homepage = "https://github.com/metanorma/emf2svg-ruby" | ||
spec.license = "BSD-2-Clause" | ||
spec.required_ruby_version = ">= 2.6.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.