ruby-zint 1.0.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 (129) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.standard.yml +3 -0
  4. data/Gemfile +16 -0
  5. data/Gemfile.lock +79 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +80 -0
  8. data/Rakefile +8 -0
  9. data/lib/ruby-zint.rb +1 -0
  10. data/lib/zint/aus_post.rb +7 -0
  11. data/lib/zint/aus_redirect.rb +7 -0
  12. data/lib/zint/aus_reply.rb +7 -0
  13. data/lib/zint/aus_route.rb +7 -0
  14. data/lib/zint/azrune.rb +7 -0
  15. data/lib/zint/aztec.rb +7 -0
  16. data/lib/zint/barcode.rb +148 -0
  17. data/lib/zint/bind.rb +7 -0
  18. data/lib/zint/bitmap.rb +4 -0
  19. data/lib/zint/bitmap_pixel.rb +4 -0
  20. data/lib/zint/box.rb +7 -0
  21. data/lib/zint/c25iata.rb +7 -0
  22. data/lib/zint/c25ind.rb +7 -0
  23. data/lib/zint/c25inter.rb +7 -0
  24. data/lib/zint/c25logic.rb +7 -0
  25. data/lib/zint/c25matrix.rb +7 -0
  26. data/lib/zint/c25standard.rb +7 -0
  27. data/lib/zint/channel.rb +7 -0
  28. data/lib/zint/codabar.rb +7 -0
  29. data/lib/zint/codablock_f.rb +7 -0
  30. data/lib/zint/code11.rb +7 -0
  31. data/lib/zint/code128.rb +7 -0
  32. data/lib/zint/code128b.rb +7 -0
  33. data/lib/zint/code16k.rb +7 -0
  34. data/lib/zint/code32.rb +7 -0
  35. data/lib/zint/code39.rb +7 -0
  36. data/lib/zint/code49.rb +7 -0
  37. data/lib/zint/code93.rb +7 -0
  38. data/lib/zint/code_one.rb +7 -0
  39. data/lib/zint/constants/capability_flags.rb +18 -0
  40. data/lib/zint/constants/debug_flags.rb +9 -0
  41. data/lib/zint/constants/errors.rb +19 -0
  42. data/lib/zint/constants/input_data_types.rb +14 -0
  43. data/lib/zint/constants/output_options.rb +18 -0
  44. data/lib/zint/constants/specific_options.rb +12 -0
  45. data/lib/zint/constants/symbologies.rb +130 -0
  46. data/lib/zint/constants/warn_levels.rb +9 -0
  47. data/lib/zint/constants/warnings.rb +12 -0
  48. data/lib/zint/daft.rb +7 -0
  49. data/lib/zint/data_matrix.rb +18 -0
  50. data/lib/zint/dbarexp.rb +7 -0
  51. data/lib/zint/dbarexpstk.rb +7 -0
  52. data/lib/zint/dbarltd.rb +7 -0
  53. data/lib/zint/dbaromn.rb +7 -0
  54. data/lib/zint/dbaromnstk.rb +7 -0
  55. data/lib/zint/dbarstk.rb +7 -0
  56. data/lib/zint/dot_code.rb +7 -0
  57. data/lib/zint/dotty_mode.rb +7 -0
  58. data/lib/zint/dpd.rb +7 -0
  59. data/lib/zint/dpident.rb +7 -0
  60. data/lib/zint/dpleit.rb +7 -0
  61. data/lib/zint/ean128.rb +7 -0
  62. data/lib/zint/ean14.rb +7 -0
  63. data/lib/zint/eanx.rb +7 -0
  64. data/lib/zint/eanxchk.rb +7 -0
  65. data/lib/zint/excode39.rb +7 -0
  66. data/lib/zint/fim.rb +7 -0
  67. data/lib/zint/flat.rb +7 -0
  68. data/lib/zint/grid_matrix.rb +7 -0
  69. data/lib/zint/gs1_128.rb +9 -0
  70. data/lib/zint/hanxin.rb +7 -0
  71. data/lib/zint/hibc128.rb +7 -0
  72. data/lib/zint/hibc39.rb +7 -0
  73. data/lib/zint/hibcaztec.rb +7 -0
  74. data/lib/zint/hibcblockf.rb +7 -0
  75. data/lib/zint/hibcdm.rb +7 -0
  76. data/lib/zint/hibcmicpdf.rb +7 -0
  77. data/lib/zint/hibcpdf.rb +7 -0
  78. data/lib/zint/hibcqr.rb +7 -0
  79. data/lib/zint/isbnx.rb +7 -0
  80. data/lib/zint/itf14.rb +7 -0
  81. data/lib/zint/japan_post.rb +7 -0
  82. data/lib/zint/kix.rb +7 -0
  83. data/lib/zint/korea_post.rb +7 -0
  84. data/lib/zint/logmars.rb +7 -0
  85. data/lib/zint/mailmark.rb +7 -0
  86. data/lib/zint/maxi_code.rb +7 -0
  87. data/lib/zint/micro_pdf417.rb +7 -0
  88. data/lib/zint/micro_qr.rb +7 -0
  89. data/lib/zint/msiplessey.rb +7 -0
  90. data/lib/zint/noascii.rb +7 -0
  91. data/lib/zint/nve18.rb +7 -0
  92. data/lib/zint/one_code.rb +7 -0
  93. data/lib/zint/pdf417.rb +7 -0
  94. data/lib/zint/pdf417comp.rb +7 -0
  95. data/lib/zint/pdf417trunc.rb +7 -0
  96. data/lib/zint/pharma.rb +7 -0
  97. data/lib/zint/pharmatwo.rb +7 -0
  98. data/lib/zint/planet.rb +7 -0
  99. data/lib/zint/plessey.rb +7 -0
  100. data/lib/zint/postnet.rb +7 -0
  101. data/lib/zint/pzn.rb +7 -0
  102. data/lib/zint/qr.rb +17 -0
  103. data/lib/zint/rmqr.rb +7 -0
  104. data/lib/zint/rss14.rb +7 -0
  105. data/lib/zint/rss14stack.rb +7 -0
  106. data/lib/zint/rss14stackomni.rb +7 -0
  107. data/lib/zint/rssexp.rb +7 -0
  108. data/lib/zint/rssexpstack.rb +7 -0
  109. data/lib/zint/rssltd.rb +7 -0
  110. data/lib/zint/stdout.rb +7 -0
  111. data/lib/zint/structs/circle.rb +11 -0
  112. data/lib/zint/structs/hexagon.rb +11 -0
  113. data/lib/zint/structs/rect.rb +12 -0
  114. data/lib/zint/structs/symbol.rb +41 -0
  115. data/lib/zint/structs/vector.rb +12 -0
  116. data/lib/zint/structs/vector_string.rb +15 -0
  117. data/lib/zint/telepen.rb +7 -0
  118. data/lib/zint/telepennum.rb +7 -0
  119. data/lib/zint/ultra.rb +7 -0
  120. data/lib/zint/upc_a.rb +7 -0
  121. data/lib/zint/upc_a_chk.rb +7 -0
  122. data/lib/zint/upc_e.rb +7 -0
  123. data/lib/zint/upc_e_chk.rb +7 -0
  124. data/lib/zint/upnqr.rb +7 -0
  125. data/lib/zint/uspsimail.rb +7 -0
  126. data/lib/zint/version.rb +3 -0
  127. data/lib/zint/vin.rb +7 -0
  128. data/lib/zint.rb +236 -0
  129. metadata +186 -0
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class Pdf417trunc < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_PDF417TRUNC, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class Pharma < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_PHARMA, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class PharmaTwo < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_PHARMA_TWO, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class Planet < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_PLANET, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class Plessey < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_PLESSEY, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class Postnet < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_POSTNET, options: options)
5
+ end
6
+ end
7
+ end
data/lib/zint/pzn.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class Pzn < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_PZN, options: options)
5
+ end
6
+ end
7
+ end
data/lib/zint/qr.rb ADDED
@@ -0,0 +1,17 @@
1
+ module Zint
2
+ class Qr < Barcode
3
+ # ECC Levels
4
+ ECC_LEVEL_L = 1
5
+ ECC_LEVEL_M = 2
6
+ ECC_LEVEL_Q = 3
7
+ ECC_LEVEL_H = 4
8
+
9
+ # Current ECC level of QR code
10
+ attr_reader :ecc_level
11
+
12
+ def initialize(value: nil, input_file: nil, ecc_level: ECC_LEVEL_L, options: {})
13
+ super(value: value, input_file: input_file, type: Zint::BARCODE_QRCODE, options: options.merge(option_1: ecc_level))
14
+ @ecc_level = ecc_level
15
+ end
16
+ end
17
+ end
data/lib/zint/rmqr.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class Rmqr < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_RMQR, options: options)
5
+ end
6
+ end
7
+ end
data/lib/zint/rss14.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class Rss14 < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_RSS14, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class Rss14stack < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_RSS14STACK, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class Rss14stackOmni < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_RSS14STACK_OMNI, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class RssExp < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_RSS_EXP, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class RssExpstack < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_RSS_EXPSTACK, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class RssLtd < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_RSS_LTD, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class Stdout < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_STDOUT, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ module Zint
2
+ module Structs
3
+ class Circle < FFI::Struct
4
+ layout :x, :float,
5
+ :y, :float,
6
+ :diameter, :float,
7
+ :colour, :int,
8
+ :next, :pointer
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Zint
2
+ module Structs
3
+ class Hexagon < FFI::Struct
4
+ layout :x, :float,
5
+ :y, :float,
6
+ :diameter, :float,
7
+ :rotation, :int,
8
+ :next, :pointer
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ module Zint
2
+ module Structs
3
+ class Rect < FFI::Struct
4
+ layout :x, :float,
5
+ :y, :float,
6
+ :height, :float,
7
+ :width, :float,
8
+ :colour, :int,
9
+ :next, :pointer
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,41 @@
1
+ module Zint
2
+ module Structs
3
+ class Symbol < FFI::Struct
4
+ layout :symbology, :int,
5
+ :height, :float,
6
+ :whitespace_width, :int,
7
+ :whitespace_height, :int,
8
+ :border_width, :int,
9
+ :output_options, :int,
10
+ :fgcolour, [:char, 10],
11
+ :bgcolour, [:char, 10],
12
+ :fgcolor, :pointer,
13
+ :bgcolor, :pointer,
14
+ :outfile, [:char, 256],
15
+ :scale, :float,
16
+ :option_1, :int,
17
+ :option_2, :int,
18
+ :option_3, :int,
19
+ :show_hrt, :int,
20
+ :fontsize, :int,
21
+ :input_mode, :int,
22
+ :eci, :int,
23
+ :text, [:uchar, 128],
24
+ :rows, :int,
25
+ :width, :int,
26
+ :primary, [:char, 128],
27
+ :encoded_data, [:uchar, 200 * 143],
28
+ :row_height, [:float, 200],
29
+ :errtxt, [:char, 100],
30
+ :bitmap, :pointer,
31
+ :bitmap_width, :int,
32
+ :bitmap_height, :int,
33
+ :alphamap, :pointer,
34
+ :bitmap_byte_length, :uchar,
35
+ :dot_size, :float,
36
+ :vector, :pointer,
37
+ :debug, :int,
38
+ :warn_level, :int
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,12 @@
1
+ module Zint
2
+ module Structs
3
+ class Vector < FFI::Struct
4
+ layout :width, :float,
5
+ :height, :float,
6
+ :rectangles, :pointer,
7
+ :hexagons, :pointer,
8
+ :strings, :pointer,
9
+ :circles, :pointer
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ module Zint
2
+ module Structs
3
+ class VectorString < FFI::Struct
4
+ layout :x, :float,
5
+ :y, :float,
6
+ :fsize, :float,
7
+ :width, :float,
8
+ :length, :int,
9
+ :rotation, :int,
10
+ :halign, :int,
11
+ :text, :pointer,
12
+ :next, :pointer
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class Telepen < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_TELEPEN, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class TelepenNum < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_TELEPEN_NUM, options: options)
5
+ end
6
+ end
7
+ end
data/lib/zint/ultra.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class Ultra < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_ULTRA, options: options)
5
+ end
6
+ end
7
+ end
data/lib/zint/upc_a.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class UpcA < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_UPCA, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class UpcAChk < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_UPCA_CHK, options: options)
5
+ end
6
+ end
7
+ end
data/lib/zint/upc_e.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class UpcE < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_UPCE, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class UpcEChk < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_UPCE_CHK, options: options)
5
+ end
6
+ end
7
+ end
data/lib/zint/upnqr.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class Upnqr < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_UPNQR, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class UspsImail < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_USPS_IMAIL, options: options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Zint
2
+ VERSION = "1.0.0"
3
+ end
data/lib/zint/vin.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Zint
2
+ class Vin < Barcode
3
+ def initialize(value: nil, input_file: nil, options: {})
4
+ super(value: value, input_file: input_file, type: Zint::BARCODE_VIN, options: options)
5
+ end
6
+ end
7
+ end
data/lib/zint.rb ADDED
@@ -0,0 +1,236 @@
1
+ require "ffi"
2
+
3
+ require "zint/version"
4
+
5
+ # Zint constants
6
+ require "zint/constants/capability_flags"
7
+ require "zint/constants/debug_flags"
8
+ require "zint/constants/errors"
9
+ require "zint/constants/input_data_types"
10
+ require "zint/constants/output_options"
11
+ require "zint/constants/specific_options"
12
+ require "zint/constants/symbologies"
13
+ require "zint/constants/warn_levels"
14
+ require "zint/constants/warnings"
15
+
16
+ # Zint structs
17
+ require "zint/structs/circle"
18
+ require "zint/structs/hexagon"
19
+ require "zint/structs/rect"
20
+ require "zint/structs/symbol"
21
+ require "zint/structs/vector_string"
22
+ require "zint/structs/vector"
23
+
24
+ module Zint
25
+ # Zint constants
26
+ include Constants::CapabilityFlags
27
+ include Constants::DebugFlags
28
+ include Constants::Errors
29
+ include Constants::InputDataTypes
30
+ include Constants::OutputOptions
31
+ include Constants::SpecificOptions
32
+ include Constants::Symbologies
33
+ include Constants::WarnLevels
34
+ include Constants::Warnings
35
+
36
+ # Barcode
37
+ autoload :Bitmap, "zint/bitmap"
38
+ autoload :BitmapPixel, "zint/bitmap_pixel"
39
+ autoload :Barcode, "zint/barcode"
40
+ autoload :AusPost, "zint/aus_post"
41
+ autoload :AusRedirect, "zint/aus_redirect"
42
+ autoload :AusReply, "zint/aus_reply"
43
+ autoload :AusRoute, "zint/aus_route"
44
+ autoload :Azrune, "zint/azrune"
45
+ autoload :Aztec, "zint/aztec"
46
+ autoload :Bind, "zint/bind"
47
+ autoload :Box, "zint/box"
48
+ autoload :C25iata, "zint/c25iata"
49
+ autoload :C25ind, "zint/c25ind"
50
+ autoload :C25inter, "zint/c25inter"
51
+ autoload :C25logic, "zint/c25logic"
52
+ autoload :C25matrix, "zint/c25matrix"
53
+ autoload :C25standard, "zint/c25standard"
54
+ autoload :Channel, "zint/channel"
55
+ autoload :Codabar, "zint/codabar"
56
+ autoload :CodablockF, "zint/codablock_f"
57
+ autoload :Code11, "zint/code11"
58
+ autoload :Code128, "zint/code128"
59
+ autoload :Code128b, "zint/code128b"
60
+ autoload :Code16k, "zint/code16k"
61
+ autoload :Code32, "zint/code32"
62
+ autoload :Code39, "zint/code39"
63
+ autoload :Code49, "zint/code49"
64
+ autoload :Code93, "zint/code93"
65
+ autoload :CodeOne, "zint/code_one"
66
+ autoload :Daft, "zint/daft"
67
+ autoload :DataMatrix, "zint/data_matrix"
68
+ autoload :DbarExp, "zint/dbarexp"
69
+ autoload :DbarExpstk, "zint/dbarexpstk"
70
+ autoload :DbarLtd, "zint/dbarltd"
71
+ autoload :DbarOmn, "zint/dbaromn"
72
+ autoload :DbarOmnstk, "zint/dbaromnstk"
73
+ autoload :DbarStk, "zint/dbarstk"
74
+ autoload :DotCode, "zint/dot_code"
75
+ autoload :DottyMode, "zint/dotty_mode"
76
+ autoload :Dpd, "zint/dpd"
77
+ autoload :Dpident, "zint/dpident"
78
+ autoload :Dpleit, "zint/dpleit"
79
+ autoload :Ean128, "zint/ean128"
80
+ autoload :Ean14, "zint/ean14"
81
+ autoload :Eanx, "zint/eanx"
82
+ autoload :EanxChk, "zint/eanxchk"
83
+ autoload :Excode39, "zint/excode39"
84
+ autoload :Fim, "zint/fim"
85
+ autoload :Flat, "zint/flat"
86
+ autoload :GridMatrix, "zint/grid_matrix"
87
+ autoload :Gs1_128, "zint/gs1_128"
88
+ autoload :Hanxin, "zint/hanxin"
89
+ autoload :Hibc128, "zint/hibc128"
90
+ autoload :Hibc39, "zint/hibc39"
91
+ autoload :HibcAztec, "zint/hibcaztec"
92
+ autoload :HibcBlockf, "zint/hibcblockf"
93
+ autoload :HibcDm, "zint/hibcdm"
94
+ autoload :HibcMicpdf, "zint/hibcmicpdf"
95
+ autoload :HibcPdf, "zint/hibcpdf"
96
+ autoload :HibcQr, "zint/hibcqr"
97
+ autoload :Isbnx, "zint/isbnx"
98
+ autoload :Itf14, "zint/itf14"
99
+ autoload :JapanPost, "zint/japan_post"
100
+ autoload :Kix, "zint/kix"
101
+ autoload :KoreaPost, "zint/korea_post"
102
+ autoload :Logmars, "zint/logmars"
103
+ autoload :Mailmark, "zint/mailmark"
104
+ autoload :MaxiCode, "zint/maxi_code"
105
+ autoload :MicroPdf417, "zint/micro_pdf417"
106
+ autoload :MicroQr, "zint/micro_qr"
107
+ autoload :MsiPlessey, "zint/msiplessey"
108
+ autoload :NoAscii, "zint/noascii"
109
+ autoload :Nve18, "zint/nve18"
110
+ autoload :OneCode, "zint/one_code"
111
+ autoload :Pdf417, "zint/pdf417"
112
+ autoload :Pdf417comp, "zint/pdf417comp"
113
+ autoload :Pdf417trunc, "zint/pdf417trunc"
114
+ autoload :Pharma, "zint/pharma"
115
+ autoload :PharmaTwo, "zint/pharmatwo"
116
+ autoload :Planet, "zint/planet"
117
+ autoload :Plessey, "zint/plessey"
118
+ autoload :Postnet, "zint/postnet"
119
+ autoload :Pzn, "zint/pzn"
120
+ autoload :Qr, "zint/qr"
121
+ autoload :Rmqr, "zint/rmqr"
122
+ autoload :Rss14, "zint/rss14"
123
+ autoload :Rss14stack, "zint/rss14stack"
124
+ autoload :Rss14stackOmni, "zint/rss14stackomni"
125
+ autoload :RssExp, "zint/rssexp"
126
+ autoload :RssExpstack, "zint/rssexpstack"
127
+ autoload :RssLtd, "zint/rssltd"
128
+ autoload :Stdout, "zint/stdout"
129
+ autoload :Telepen, "zint/telepen"
130
+ autoload :TelepenNum, "zint/telepennum"
131
+ autoload :Ultra, "zint/ultra"
132
+ autoload :UpcA, "zint/upc_a"
133
+ autoload :UpcAChk, "zint/upc_a_chk"
134
+ autoload :UpcE, "zint/upc_e"
135
+ autoload :UpcEChk, "zint/upc_e_chk"
136
+ autoload :Upnqr, "zint/upnqr"
137
+ autoload :UspsImail, "zint/uspsimail"
138
+ autoload :Vin, "zint/vin"
139
+
140
+ extend FFI::Library
141
+
142
+ class Error < StandardError; end
143
+
144
+ ERROR_CLASS_FOR_RESULT = {}
145
+
146
+ # Define an exception class for each error code
147
+ ERRORS.to_h.each do |k, v|
148
+ klass = Class.new(Error)
149
+ klass.send(:define_method, :code) { v }
150
+ klass_name = k.to_s.split("_").collect(&:capitalize).join
151
+ const_set(klass_name, klass)
152
+ ERROR_CLASS_FOR_RESULT[v] = klass
153
+ end
154
+
155
+ # Raises specific error for API return code
156
+ #
157
+ # @param res [Symbol, Integer] API return code
158
+ # @param text [String] error text
159
+ # @raise [Error]
160
+ def self.raise_error(res, text)
161
+ klass = ERROR_CLASS_FOR_RESULT[res.is_a?(Symbol) ? Zint::ERRORS[res] : res]
162
+ raise klass, text
163
+ end
164
+
165
+ ffi_lib %w[libzint.so.2.10 libzint zint]
166
+
167
+ # Error codes (API return values)
168
+ enum :error_code, [Zint::WARNINGS, Zint::ERRORS].map { |h| h.to_a }.flatten
169
+
170
+ # Aliases for better method signatures
171
+ typedef :pointer, :zint_symbol
172
+ typedef :pointer, :filename
173
+ typedef :int32, :length
174
+ typedef :int32, :rotate_angle
175
+ typedef :int32, :symbol_id
176
+ typedef :uint32, :cap_flag
177
+ typedef :string, :source
178
+
179
+ # Create and initialize a symbol structure
180
+ attach_function(:ZBarcode_Create, :ZBarcode_Create, [], :zint_symbol)
181
+
182
+ # Free any output buffers that may have been created and initialize output fields
183
+ attach_function(:ZBarcode_Clear, :ZBarcode_Clear, [:zint_symbol], :void)
184
+
185
+ # Free a symbol structure, including any output buffers
186
+ attach_function(:ZBarcode_Delete, :ZBarcode_Delete, [:zint_symbol], :void)
187
+
188
+ # Encode a barcode. If `length` is 0, `source` must be NUL-terminated.
189
+ attach_function(:ZBarcode_Encode, :ZBarcode_Encode, [:zint_symbol, :source, :length], :error_code)
190
+
191
+ # Encode a barcode using input data from file `filename`
192
+ attach_function(:ZBarcode_Encode_File, :ZBarcode_Encode_File, [:zint_symbol, :filename], :error_code)
193
+
194
+ # Output a previously encoded symbol to file `symbol->outfile`
195
+ attach_function(:ZBarcode_Print, :ZBarcode_Print, [:zint_symbol, :rotate_angle], :error_code)
196
+
197
+ # Encode and output a symbol to file `symbol->outfile`
198
+ attach_function(:ZBarcode_Encode_and_Print, :ZBarcode_Encode_and_Print, [:zint_symbol, :source, :length, :rotate_angle], :error_code)
199
+
200
+ # Encode a symbol using input data from file `filename` and output to file `symbol->outfile`
201
+ attach_function(:ZBarcode_Encode_File_and_Print, :ZBarcode_Encode_File_and_Print, [:zint_symbol, :filename, :rotate_angle], :error_code)
202
+
203
+ # Output a previously encoded symbol to memory as raster (`symbol->bitmap`)
204
+ attach_function(:ZBarcode_Buffer, :ZBarcode_Buffer, [:zint_symbol, :rotate_angle], :error_code)
205
+
206
+ # Encode and output a symbol to memory as raster (`symbol->bitmap`)
207
+ attach_function(:ZBarcode_Encode_and_Buffer, :ZBarcode_Encode_and_Buffer, [:zint_symbol, :source, :length, :rotate_angle], :error_code)
208
+
209
+ # Encode a symbol using input data from file `filename` and output to memory as raster (`symbol->bitmap`)
210
+ attach_function(:ZBarcode_Encode_File_and_Buffer, :ZBarcode_Encode_File_and_Buffer, [:zint_symbol, :filename, :rotate_angle], :error_code)
211
+
212
+ # Output a previously encoded symbol to memory as vector (`symbol->vector`)
213
+ attach_function(:ZBarcode_Buffer_Vector, :ZBarcode_Buffer_Vector, [:zint_symbol, :rotate_angle], :error_code)
214
+
215
+ # Encode and output a symbol to memory as vector (`symbol->vector`)
216
+ attach_function(:ZBarcode_Encode_and_Buffer_Vector, :ZBarcode_Encode_and_Buffer_Vector, [:zint_symbol, :source, :length, :rotate_angle], :error_code)
217
+
218
+ # Encode a symbol using input data from file `filename` and output to memory as vector (`symbol->vector`)
219
+ attach_function(:ZBarcode_Encode_File_and_Buffer_Vector, :ZBarcode_Encode_File_and_Buffer_Vector, [:zint_symbol, :filename, :rotate_angle], :error_code)
220
+
221
+ # Is `symbol_id` a recognized symbology?
222
+ attach_function(:ZBarcode_ValidID, :ZBarcode_ValidID, [:symbol_id], :bool)
223
+
224
+ # Return the capability flags for symbology `symbol_id` that match `cap_flag`
225
+ attach_function(:ZBarcode_Cap, :ZBarcode_Cap, [:symbol_id, :cap_flag], :uint32)
226
+
227
+ # Return the version of Zint linked to
228
+ attach_function(:ZBarcode_Version, :ZBarcode_Version, [], :int32)
229
+
230
+ # Returns library version of the current zint
231
+ #
232
+ # @return [Integer] library version
233
+ def self.library_version
234
+ Zint.ZBarcode_Version
235
+ end
236
+ end