ruby-zint 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/.standard.yml +2 -0
  3. data/Gemfile +2 -0
  4. data/README.md +30 -8
  5. data/Rakefile +12 -0
  6. data/ext/ruby-zint/extconf.rb +86 -0
  7. data/lib/zint/aus_post.rb +1 -0
  8. data/lib/zint/aus_redirect.rb +1 -0
  9. data/lib/zint/aus_reply.rb +1 -0
  10. data/lib/zint/aus_route.rb +1 -0
  11. data/lib/zint/azrune.rb +1 -0
  12. data/lib/zint/aztec.rb +1 -0
  13. data/lib/zint/barcode.rb +439 -47
  14. data/lib/zint/{noascii.rb → bc_412.rb} +3 -2
  15. data/lib/zint/c25iata.rb +1 -0
  16. data/lib/zint/c25ind.rb +1 -0
  17. data/lib/zint/c25inter.rb +1 -0
  18. data/lib/zint/c25logic.rb +1 -0
  19. data/lib/zint/c25matrix.rb +1 -0
  20. data/lib/zint/c25standard.rb +1 -0
  21. data/lib/zint/{box.rb → cep_net.rb} +3 -2
  22. data/lib/zint/channel.rb +1 -0
  23. data/lib/zint/codabar.rb +1 -0
  24. data/lib/zint/codablock_f.rb +1 -0
  25. data/lib/zint/code11.rb +1 -0
  26. data/lib/zint/code128.rb +1 -0
  27. data/lib/zint/{dotty_mode.rb → code128ab.rb} +3 -2
  28. data/lib/zint/code128b.rb +2 -4
  29. data/lib/zint/code16k.rb +1 -0
  30. data/lib/zint/code32.rb +1 -0
  31. data/lib/zint/code39.rb +1 -0
  32. data/lib/zint/code49.rb +1 -0
  33. data/lib/zint/code93.rb +1 -0
  34. data/lib/zint/code_one.rb +1 -0
  35. data/lib/zint/constants/capability_flags.rb +14 -11
  36. data/lib/zint/constants/input_data_types.rb +8 -7
  37. data/lib/zint/constants/output_options.rb +14 -11
  38. data/lib/zint/constants/symbologies.rb +13 -6
  39. data/lib/zint/constants/warn_levels.rb +1 -1
  40. data/lib/zint/daft.rb +1 -0
  41. data/lib/zint/data_matrix.rb +1 -0
  42. data/lib/zint/dbarexp.rb +1 -0
  43. data/lib/zint/dbarexpstk.rb +1 -0
  44. data/lib/zint/dbarltd.rb +1 -0
  45. data/lib/zint/dbaromn.rb +1 -0
  46. data/lib/zint/dbaromnstk.rb +1 -0
  47. data/lib/zint/dbarstk.rb +1 -0
  48. data/lib/zint/dependencies.rb +8 -0
  49. data/lib/zint/dot_code.rb +1 -0
  50. data/lib/zint/dpd.rb +1 -0
  51. data/lib/zint/dpident.rb +1 -0
  52. data/lib/zint/dpleit.rb +1 -0
  53. data/lib/zint/ean128.rb +1 -0
  54. data/lib/zint/ean14.rb +1 -0
  55. data/lib/zint/eanx.rb +1 -0
  56. data/lib/zint/eanxchk.rb +1 -0
  57. data/lib/zint/excode39.rb +1 -0
  58. data/lib/zint/fim.rb +1 -0
  59. data/lib/zint/flat.rb +1 -0
  60. data/lib/zint/grid_matrix.rb +1 -0
  61. data/lib/zint/gs1_128.rb +1 -0
  62. data/lib/zint/hanxin.rb +1 -0
  63. data/lib/zint/hibc128.rb +1 -0
  64. data/lib/zint/hibc39.rb +1 -0
  65. data/lib/zint/hibcaztec.rb +1 -0
  66. data/lib/zint/hibcblockf.rb +1 -0
  67. data/lib/zint/hibcdm.rb +1 -0
  68. data/lib/zint/hibcmicpdf.rb +1 -0
  69. data/lib/zint/hibcpdf.rb +1 -0
  70. data/lib/zint/hibcqr.rb +1 -0
  71. data/lib/zint/isbnx.rb +1 -0
  72. data/lib/zint/itf14.rb +1 -0
  73. data/lib/zint/japan_post.rb +1 -0
  74. data/lib/zint/kix.rb +1 -0
  75. data/lib/zint/korea_post.rb +1 -0
  76. data/lib/zint/logmars.rb +1 -0
  77. data/lib/zint/mailmark.rb +1 -0
  78. data/lib/zint/mailmark_2d.rb +8 -0
  79. data/lib/zint/mailmark_4s.rb +8 -0
  80. data/lib/zint/maxi_code.rb +1 -0
  81. data/lib/zint/micro_pdf417.rb +1 -0
  82. data/lib/zint/micro_qr.rb +1 -0
  83. data/lib/zint/msiplessey.rb +1 -0
  84. data/lib/zint/native.rb +87 -0
  85. data/lib/zint/nve18.rb +1 -0
  86. data/lib/zint/one_code.rb +1 -0
  87. data/lib/zint/pdf417.rb +1 -0
  88. data/lib/zint/pdf417comp.rb +1 -0
  89. data/lib/zint/pdf417trunc.rb +1 -0
  90. data/lib/zint/pharma.rb +1 -0
  91. data/lib/zint/pharmatwo.rb +1 -0
  92. data/lib/zint/planet.rb +1 -0
  93. data/lib/zint/plessey.rb +1 -0
  94. data/lib/zint/postnet.rb +1 -0
  95. data/lib/zint/pzn.rb +1 -0
  96. data/lib/zint/qr.rb +1 -0
  97. data/lib/zint/rmqr.rb +1 -0
  98. data/lib/zint/rss14.rb +1 -0
  99. data/lib/zint/rss14stack.rb +1 -0
  100. data/lib/zint/rss14stackomni.rb +1 -0
  101. data/lib/zint/rssexp.rb +1 -0
  102. data/lib/zint/rssexpstack.rb +1 -0
  103. data/lib/zint/rssltd.rb +1 -0
  104. data/lib/zint/structs/structapp.rb +25 -0
  105. data/lib/zint/structs/symbol.rb +44 -36
  106. data/lib/zint/structs/vector.rb +47 -5
  107. data/lib/zint/structs/vector_circle.rb +32 -0
  108. data/lib/zint/structs/vector_hexagon.rb +31 -0
  109. data/lib/zint/structs/vector_rect.rb +37 -0
  110. data/lib/zint/structs/vector_string.rb +43 -8
  111. data/lib/zint/telepen.rb +1 -0
  112. data/lib/zint/telepennum.rb +1 -0
  113. data/lib/zint/ultra.rb +1 -0
  114. data/lib/zint/upc_a.rb +1 -0
  115. data/lib/zint/upc_a_chk.rb +1 -0
  116. data/lib/zint/upc_e.rb +1 -0
  117. data/lib/zint/upc_e_chk.rb +1 -0
  118. data/lib/zint/upnqr.rb +1 -0
  119. data/lib/zint/{bind.rb → upu_s10.rb} +3 -2
  120. data/lib/zint/uspsimail.rb +1 -0
  121. data/lib/zint/version.rb +1 -1
  122. data/lib/zint/vin.rb +1 -0
  123. data/lib/zint/zint_recipe.rb +27 -0
  124. data/lib/zint.rb +15 -83
  125. data/ports/archives/zint-2.12.0-src.tar.gz +0 -0
  126. metadata +34 -12
  127. data/Gemfile.lock +0 -79
  128. data/lib/zint/stdout.rb +0 -7
  129. data/lib/zint/structs/circle.rb +0 -11
  130. data/lib/zint/structs/hexagon.rb +0 -11
  131. data/lib/zint/structs/rect.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f734d5ae4c7959fb5753621a438396bccf285508bb17d80a847e80722f30378
4
- data.tar.gz: 2207324efb9029cd4f6423b4b1aa04d8d8f9339e3fcca5464d048162c72f631d
3
+ metadata.gz: 7cbe79d9fd528474b3cffe957b55cf8cb4aec0bdc97cca55314dc675e74f58c3
4
+ data.tar.gz: a99a851ff4cfc42387d58e2d439c2ae01976fe03ad81595ccdc60cd94f0f5a89
5
5
  SHA512:
6
- metadata.gz: 58b054d6ca8c39d9421a9dfdc49517402659b0935455fc61d0d3b7a65791980ef93b8ce10c36a820940d1a54240589dd928c6cb6ef618e7d87dddd655ae450b0
7
- data.tar.gz: 9b7184006218407385bd2f84c1eb465ab3aa1742b08a98eae58dde5a6653e839d80835f8d234f2d6f768908b10926de94f215a32d6446c0c1de2e202f9a85a7b
6
+ metadata.gz: 75f8c14c3f4a3ad2f3990fa1c60204264f7120902e2ca31e2a51afc011c5e069d88bd3dcbeb0a8a73757163703c457c0ca49003da7470704afef01fb204585fe
7
+ data.tar.gz: '0689e71889b46f0278886f717ad3966c2a1b215dd6502666637913112fc84abad23f5ae604d0a1b82bcf2c0379d77975bedaa43887d24d2dab6295734abf0b23'
data/.standard.yml CHANGED
@@ -1,3 +1,5 @@
1
1
  parallel: true
2
2
  format: progress
3
3
  ruby_version: 2.6
4
+ ignore:
5
+ - 'ext/ruby-zint/tmp/**/*'
data/Gemfile CHANGED
@@ -14,3 +14,5 @@ gem "chunky_png"
14
14
  gem "byebug"
15
15
 
16
16
  gem "standard", "~> 1.3"
17
+
18
+ gem "mini_portile2"
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
- Install the libzint binary with your package manager (eg. `apt install zint` or perhaps `brew install zint`).
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.10](https://sourceforge.net/projects/zint/files/zint/2.10.0/).
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 with:
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
- Or include `gem "ruby-zint"` in your Gemfile.
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.to_buffer
66
+ bitmap = barcode.to_bitmap
45
67
  bitmap.pixels.each do |pixel|
46
- png.compose_pixel(pixel.x, pixel.y, (pixel.colour == "K") ? black : white)
68
+ png.compose_pixel(pixel.x, pixel.y, (pixel.colour == "1") ? black : white)
47
69
  end
48
70
 
49
- png.save(buffer_outfile)
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
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # Australia Post 4-State Barcode
2
3
  class AusPost < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_AUSPOST, options: options)
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # Australia Post Redirection
2
3
  class AusRedirect < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_AUSREDIRECT, options: options)
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # Australia Post Reply Paid
2
3
  class AusReply < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_AUSREPLY, options: options)
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # Australia Post Routing
2
3
  class AusRoute < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_AUSROUTE, options: options)
data/lib/zint/azrune.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # Aztec Runes
2
3
  class Azrune < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_AZRUNE, options: options)
data/lib/zint/aztec.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # Aztec Code
2
3
  class Aztec < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_AZTEC, options: options)