ruby-zint 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.standard.yml +2 -0
- data/Gemfile +2 -0
- data/README.md +30 -8
- data/Rakefile +12 -0
- data/ext/ruby-zint/extconf.rb +86 -0
- data/lib/zint/aus_post.rb +1 -0
- data/lib/zint/aus_redirect.rb +1 -0
- data/lib/zint/aus_reply.rb +1 -0
- data/lib/zint/aus_route.rb +1 -0
- data/lib/zint/azrune.rb +1 -0
- data/lib/zint/aztec.rb +1 -0
- data/lib/zint/barcode.rb +439 -47
- data/lib/zint/{noascii.rb → bc_412.rb} +3 -2
- data/lib/zint/c25iata.rb +1 -0
- data/lib/zint/c25ind.rb +1 -0
- data/lib/zint/c25inter.rb +1 -0
- data/lib/zint/c25logic.rb +1 -0
- data/lib/zint/c25matrix.rb +1 -0
- data/lib/zint/c25standard.rb +1 -0
- data/lib/zint/{box.rb → cep_net.rb} +3 -2
- data/lib/zint/channel.rb +1 -0
- data/lib/zint/codabar.rb +1 -0
- data/lib/zint/codablock_f.rb +1 -0
- data/lib/zint/code11.rb +1 -0
- data/lib/zint/code128.rb +1 -0
- data/lib/zint/{dotty_mode.rb → code128ab.rb} +3 -2
- data/lib/zint/code128b.rb +2 -4
- data/lib/zint/code16k.rb +1 -0
- data/lib/zint/code32.rb +1 -0
- data/lib/zint/code39.rb +1 -0
- data/lib/zint/code49.rb +1 -0
- data/lib/zint/code93.rb +1 -0
- data/lib/zint/code_one.rb +1 -0
- data/lib/zint/constants/capability_flags.rb +14 -11
- data/lib/zint/constants/input_data_types.rb +8 -7
- data/lib/zint/constants/output_options.rb +14 -11
- data/lib/zint/constants/symbologies.rb +13 -6
- data/lib/zint/constants/warn_levels.rb +1 -1
- data/lib/zint/daft.rb +1 -0
- data/lib/zint/data_matrix.rb +1 -0
- data/lib/zint/dbarexp.rb +1 -0
- data/lib/zint/dbarexpstk.rb +1 -0
- data/lib/zint/dbarltd.rb +1 -0
- data/lib/zint/dbaromn.rb +1 -0
- data/lib/zint/dbaromnstk.rb +1 -0
- data/lib/zint/dbarstk.rb +1 -0
- data/lib/zint/dependencies.rb +8 -0
- data/lib/zint/dot_code.rb +1 -0
- data/lib/zint/dpd.rb +1 -0
- data/lib/zint/dpident.rb +1 -0
- data/lib/zint/dpleit.rb +1 -0
- data/lib/zint/ean128.rb +1 -0
- data/lib/zint/ean14.rb +1 -0
- data/lib/zint/eanx.rb +1 -0
- data/lib/zint/eanxchk.rb +1 -0
- data/lib/zint/excode39.rb +1 -0
- data/lib/zint/fim.rb +1 -0
- data/lib/zint/flat.rb +1 -0
- data/lib/zint/grid_matrix.rb +1 -0
- data/lib/zint/gs1_128.rb +1 -0
- data/lib/zint/hanxin.rb +1 -0
- data/lib/zint/hibc128.rb +1 -0
- data/lib/zint/hibc39.rb +1 -0
- data/lib/zint/hibcaztec.rb +1 -0
- data/lib/zint/hibcblockf.rb +1 -0
- data/lib/zint/hibcdm.rb +1 -0
- data/lib/zint/hibcmicpdf.rb +1 -0
- data/lib/zint/hibcpdf.rb +1 -0
- data/lib/zint/hibcqr.rb +1 -0
- data/lib/zint/isbnx.rb +1 -0
- data/lib/zint/itf14.rb +1 -0
- data/lib/zint/japan_post.rb +1 -0
- data/lib/zint/kix.rb +1 -0
- data/lib/zint/korea_post.rb +1 -0
- data/lib/zint/logmars.rb +1 -0
- data/lib/zint/mailmark.rb +1 -0
- data/lib/zint/mailmark_2d.rb +8 -0
- data/lib/zint/mailmark_4s.rb +8 -0
- data/lib/zint/maxi_code.rb +1 -0
- data/lib/zint/micro_pdf417.rb +1 -0
- data/lib/zint/micro_qr.rb +1 -0
- data/lib/zint/msiplessey.rb +1 -0
- data/lib/zint/native.rb +87 -0
- data/lib/zint/nve18.rb +1 -0
- data/lib/zint/one_code.rb +1 -0
- data/lib/zint/pdf417.rb +1 -0
- data/lib/zint/pdf417comp.rb +1 -0
- data/lib/zint/pdf417trunc.rb +1 -0
- data/lib/zint/pharma.rb +1 -0
- data/lib/zint/pharmatwo.rb +1 -0
- data/lib/zint/planet.rb +1 -0
- data/lib/zint/plessey.rb +1 -0
- data/lib/zint/postnet.rb +1 -0
- data/lib/zint/pzn.rb +1 -0
- data/lib/zint/qr.rb +1 -0
- data/lib/zint/rmqr.rb +1 -0
- data/lib/zint/rss14.rb +1 -0
- data/lib/zint/rss14stack.rb +1 -0
- data/lib/zint/rss14stackomni.rb +1 -0
- data/lib/zint/rssexp.rb +1 -0
- data/lib/zint/rssexpstack.rb +1 -0
- data/lib/zint/rssltd.rb +1 -0
- data/lib/zint/structs/structapp.rb +25 -0
- data/lib/zint/structs/symbol.rb +44 -36
- data/lib/zint/structs/vector.rb +47 -5
- data/lib/zint/structs/vector_circle.rb +32 -0
- data/lib/zint/structs/vector_hexagon.rb +31 -0
- data/lib/zint/structs/vector_rect.rb +37 -0
- data/lib/zint/structs/vector_string.rb +43 -8
- data/lib/zint/telepen.rb +1 -0
- data/lib/zint/telepennum.rb +1 -0
- data/lib/zint/ultra.rb +1 -0
- data/lib/zint/upc_a.rb +1 -0
- data/lib/zint/upc_a_chk.rb +1 -0
- data/lib/zint/upc_e.rb +1 -0
- data/lib/zint/upc_e_chk.rb +1 -0
- data/lib/zint/upnqr.rb +1 -0
- data/lib/zint/{bind.rb → upu_s10.rb} +3 -2
- data/lib/zint/uspsimail.rb +1 -0
- data/lib/zint/version.rb +1 -1
- data/lib/zint/vin.rb +1 -0
- data/lib/zint/zint_recipe.rb +27 -0
- data/lib/zint.rb +15 -83
- data/ports/archives/zint-2.12.0-src.tar.gz +0 -0
- metadata +34 -12
- data/Gemfile.lock +0 -79
- data/lib/zint/stdout.rb +0 -7
- data/lib/zint/structs/circle.rb +0 -11
- data/lib/zint/structs/hexagon.rb +0 -11
- data/lib/zint/structs/rect.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cbe79d9fd528474b3cffe957b55cf8cb4aec0bdc97cca55314dc675e74f58c3
|
4
|
+
data.tar.gz: a99a851ff4cfc42387d58e2d439c2ae01976fe03ad81595ccdc60cd94f0f5a89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75f8c14c3f4a3ad2f3990fa1c60204264f7120902e2ca31e2a51afc011c5e069d88bd3dcbeb0a8a73757163703c457c0ca49003da7470704afef01fb204585fe
|
7
|
+
data.tar.gz: '0689e71889b46f0278886f717ad3966c2a1b215dd6502666637913112fc84abad23f5ae604d0a1b82bcf2c0379d77975bedaa43887d24d2dab6295734abf0b23'
|
data/.standard.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -8,19 +8,41 @@ See the [documentation](https://rubydoc.info/github/api-walker/ruby-zint) for a
|
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
|
-
|
11
|
+
By default ruby-zint first tries to use libzint installed on the system.
|
12
|
+
If libzint can't be found or if it isn't a supported version, then the zint version, bundled into the gem, is compiled and used.
|
13
|
+
Both install methods can be enforced by using `--enable-system-libzint` or `--disable-system-libzint` options, see below.
|
14
|
+
|
15
|
+
### With libzint source code (recommended)
|
16
|
+
First install CMake with your package manager (e. g. `apt install cmake`).
|
17
|
+
|
18
|
+
Afterwards install the gem and force builtin libzint:
|
19
|
+
|
20
|
+
```
|
21
|
+
$ gem install ruby-zint -- --disable-system-libzint
|
22
|
+
```
|
23
|
+
|
24
|
+
### With system libraries
|
25
|
+
|
26
|
+
Install the libzint binary with your package manager (e. g. `apt install zint` or perhaps `brew install zint`).
|
12
27
|
|
13
28
|
Other platforms require building [from source](https://www.zint.org.uk/manual/chapter/2).
|
14
29
|
|
15
|
-
**NOTE:** It is assumed that you are using libzint with the version [2.
|
30
|
+
**NOTE:** It is assumed that you are using libzint with the version [2.12](https://sourceforge.net/projects/zint/files/zint/2.12.0/).
|
16
31
|
|
17
|
-
Then install this gem
|
32
|
+
Then install this gem and enforce system libzint:
|
18
33
|
|
19
34
|
```
|
20
|
-
$ gem install ruby-zint
|
35
|
+
$ gem install ruby-zint -- --enable-system-libzint
|
21
36
|
```
|
22
37
|
|
23
|
-
|
38
|
+
### Gemfile
|
39
|
+
|
40
|
+
Include `gem "ruby-zint"` in your Gemfile.
|
41
|
+
Optionally set the install option by running bundler like so:
|
42
|
+
|
43
|
+
```
|
44
|
+
bundle config build.ruby-zint --enable-system-libzint
|
45
|
+
```
|
24
46
|
|
25
47
|
## Usage
|
26
48
|
|
@@ -41,12 +63,12 @@ png = ChunkyPNG::Image.new(bitmap.width, bitmap.height, ChunkyPNG::Color::TRANSP
|
|
41
63
|
white = ChunkyPNG::Color("white")
|
42
64
|
black = ChunkyPNG::Color("black")
|
43
65
|
|
44
|
-
bitmap = barcode.
|
66
|
+
bitmap = barcode.to_bitmap
|
45
67
|
bitmap.pixels.each do |pixel|
|
46
|
-
png.compose_pixel(pixel.x, pixel.y, (pixel.colour == "
|
68
|
+
png.compose_pixel(pixel.x, pixel.y, (pixel.colour == "1") ? black : white)
|
47
69
|
end
|
48
70
|
|
49
|
-
png.save(
|
71
|
+
png.save("out.png")
|
50
72
|
|
51
73
|
# Use vector export
|
52
74
|
vector_struct = barcode.to_vector
|
data/Rakefile
CHANGED
@@ -1,8 +1,20 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
+
require_relative "lib/zint/zint_recipe"
|
4
|
+
|
5
|
+
CLOBBER.include "pkg"
|
6
|
+
CLEAN.include "ports"
|
7
|
+
CLEAN.include "tmp"
|
8
|
+
CLEAN.include "ext/ruby-zint/tmp"
|
3
9
|
|
4
10
|
RSpec::Core::RakeTask.new(:spec)
|
5
11
|
|
6
12
|
require "standard/rake"
|
7
13
|
|
8
14
|
task default: %i[spec standard]
|
15
|
+
|
16
|
+
task gem: :build
|
17
|
+
task :compile do
|
18
|
+
sh "ruby -C ext/ruby-zint extconf.rb --disable-system-libzint"
|
19
|
+
sh "make -C ext/ruby-zint install RUBYARCHDIR=../../lib"
|
20
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# #!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "ffi"
|
5
|
+
require "fileutils"
|
6
|
+
|
7
|
+
if RUBY_PLATFORM.match?(/java/)
|
8
|
+
# JRuby's C extension support is disabled by default, so we can not use it
|
9
|
+
|
10
|
+
# Implement very simple verions of mkmf-helpers used below
|
11
|
+
def enable_config(name, default = nil)
|
12
|
+
if ARGV.include?("--enable-#{name}")
|
13
|
+
true
|
14
|
+
elsif ARGV.include?("--disable-#{name}")
|
15
|
+
false
|
16
|
+
else
|
17
|
+
default
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def arg_config(name)
|
22
|
+
ARGV.include?(name)
|
23
|
+
end
|
24
|
+
else
|
25
|
+
require "mkmf"
|
26
|
+
end
|
27
|
+
|
28
|
+
if RUBY_PLATFORM.match?(/darwin/)
|
29
|
+
ENV["SDKROOT"] ||= `xcrun --sdk macosx --show-sdk-path`.chomp
|
30
|
+
end
|
31
|
+
|
32
|
+
def do_help
|
33
|
+
print <<~HELP
|
34
|
+
usage: ruby #{$0} [options]
|
35
|
+
--enable-system-libzint / --disable-system-libzint
|
36
|
+
Force use of system or builtin libzint library.
|
37
|
+
Default is to prefer system libraries and fallback to builtin.
|
38
|
+
HELP
|
39
|
+
exit! 0
|
40
|
+
end
|
41
|
+
|
42
|
+
do_help if arg_config("--help")
|
43
|
+
|
44
|
+
def libzint_usable?
|
45
|
+
m = Module.new do
|
46
|
+
extend FFI::Library
|
47
|
+
|
48
|
+
ffi_lib(%w[libzint.so.2.12 libzint zint])
|
49
|
+
attach_function(:ZBarcode_Version, [], :int32)
|
50
|
+
end
|
51
|
+
|
52
|
+
(21200...21300) === m.ZBarcode_Version
|
53
|
+
rescue LoadError
|
54
|
+
false
|
55
|
+
end
|
56
|
+
|
57
|
+
def build_bundled_libzint
|
58
|
+
puts "Build"
|
59
|
+
require_relative "../../lib/zint/zint_recipe"
|
60
|
+
|
61
|
+
recipe = Zint::ZintRecipe.new
|
62
|
+
recipe.cook_and_activate
|
63
|
+
recipe.path
|
64
|
+
end
|
65
|
+
|
66
|
+
unless enable_config("system-libzint", libzint_usable?)
|
67
|
+
# Unable to load libzint library on this system,
|
68
|
+
# so we build our bundled version:
|
69
|
+
libzint_path = build_bundled_libzint
|
70
|
+
end
|
71
|
+
|
72
|
+
# Create a Makefile which copies the libzint library files to the gem's lib dir.
|
73
|
+
File.open("Makefile", "wb") do |mf|
|
74
|
+
mf.puts <<~EOT
|
75
|
+
RUBYARCHDIR = #{RbConfig::MAKEFILE_CONFIG["sitearchdir"].dump}
|
76
|
+
all:
|
77
|
+
clean:
|
78
|
+
install:
|
79
|
+
EOT
|
80
|
+
|
81
|
+
if libzint_path
|
82
|
+
mf.puts <<-EOT
|
83
|
+
cp -r #{libzint_path.dump}/*/libzint* $(RUBYARCHDIR)
|
84
|
+
EOT
|
85
|
+
end
|
86
|
+
end
|
data/lib/zint/aus_post.rb
CHANGED
data/lib/zint/aus_redirect.rb
CHANGED
data/lib/zint/aus_reply.rb
CHANGED
data/lib/zint/aus_route.rb
CHANGED
data/lib/zint/azrune.rb
CHANGED