ruby-zint 1.5.0-x86_64-linux-gnu

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 (135) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +9 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +146 -0
  5. data/ext/ruby-zint/extconf.rb +113 -0
  6. data/lib/3.4/libzint.so +0 -0
  7. data/lib/ruby-zint.rb +1 -0
  8. data/lib/zint/aus_post.rb +8 -0
  9. data/lib/zint/aus_redirect.rb +8 -0
  10. data/lib/zint/aus_reply.rb +8 -0
  11. data/lib/zint/aus_route.rb +8 -0
  12. data/lib/zint/azrune.rb +8 -0
  13. data/lib/zint/aztec.rb +8 -0
  14. data/lib/zint/barcode.rb +550 -0
  15. data/lib/zint/bc_412.rb +8 -0
  16. data/lib/zint/bitmap.rb +4 -0
  17. data/lib/zint/bitmap_pixel.rb +4 -0
  18. data/lib/zint/c25iata.rb +8 -0
  19. data/lib/zint/c25ind.rb +8 -0
  20. data/lib/zint/c25inter.rb +8 -0
  21. data/lib/zint/c25logic.rb +8 -0
  22. data/lib/zint/c25matrix.rb +8 -0
  23. data/lib/zint/c25standard.rb +8 -0
  24. data/lib/zint/cep_net.rb +8 -0
  25. data/lib/zint/channel.rb +8 -0
  26. data/lib/zint/codabar.rb +8 -0
  27. data/lib/zint/codablock_f.rb +8 -0
  28. data/lib/zint/code11.rb +8 -0
  29. data/lib/zint/code128.rb +8 -0
  30. data/lib/zint/code128ab.rb +8 -0
  31. data/lib/zint/code128b.rb +5 -0
  32. data/lib/zint/code16k.rb +8 -0
  33. data/lib/zint/code32.rb +8 -0
  34. data/lib/zint/code39.rb +8 -0
  35. data/lib/zint/code49.rb +8 -0
  36. data/lib/zint/code93.rb +8 -0
  37. data/lib/zint/code_one.rb +8 -0
  38. data/lib/zint/constants/capability_flags.rb +21 -0
  39. data/lib/zint/constants/debug_flags.rb +9 -0
  40. data/lib/zint/constants/errors.rb +20 -0
  41. data/lib/zint/constants/input_data_types.rb +16 -0
  42. data/lib/zint/constants/output_options.rb +24 -0
  43. data/lib/zint/constants/specific_options.rb +13 -0
  44. data/lib/zint/constants/symbologies.rb +138 -0
  45. data/lib/zint/constants/warn_levels.rb +9 -0
  46. data/lib/zint/constants/warnings.rb +12 -0
  47. data/lib/zint/daft.rb +8 -0
  48. data/lib/zint/data_matrix.rb +19 -0
  49. data/lib/zint/dbarexp.rb +8 -0
  50. data/lib/zint/dbarexpstk.rb +8 -0
  51. data/lib/zint/dbarltd.rb +8 -0
  52. data/lib/zint/dbaromn.rb +8 -0
  53. data/lib/zint/dbaromnstk.rb +8 -0
  54. data/lib/zint/dbarstk.rb +8 -0
  55. data/lib/zint/dependencies.rb +15 -0
  56. data/lib/zint/dot_code.rb +8 -0
  57. data/lib/zint/dpd.rb +8 -0
  58. data/lib/zint/dpident.rb +8 -0
  59. data/lib/zint/dpleit.rb +8 -0
  60. data/lib/zint/dxfilmedge.rb +8 -0
  61. data/lib/zint/ean128.rb +8 -0
  62. data/lib/zint/ean14.rb +8 -0
  63. data/lib/zint/eanx.rb +8 -0
  64. data/lib/zint/eanxchk.rb +8 -0
  65. data/lib/zint/excode39.rb +8 -0
  66. data/lib/zint/fim.rb +8 -0
  67. data/lib/zint/flat.rb +8 -0
  68. data/lib/zint/grid_matrix.rb +8 -0
  69. data/lib/zint/gs1_128.rb +10 -0
  70. data/lib/zint/hanxin.rb +8 -0
  71. data/lib/zint/hibc128.rb +8 -0
  72. data/lib/zint/hibc39.rb +8 -0
  73. data/lib/zint/hibcaztec.rb +8 -0
  74. data/lib/zint/hibcblockf.rb +8 -0
  75. data/lib/zint/hibcdm.rb +8 -0
  76. data/lib/zint/hibcmicpdf.rb +8 -0
  77. data/lib/zint/hibcpdf.rb +8 -0
  78. data/lib/zint/hibcqr.rb +8 -0
  79. data/lib/zint/isbnx.rb +8 -0
  80. data/lib/zint/itf14.rb +8 -0
  81. data/lib/zint/japan_post.rb +8 -0
  82. data/lib/zint/kix.rb +8 -0
  83. data/lib/zint/korea_post.rb +8 -0
  84. data/lib/zint/logmars.rb +8 -0
  85. data/lib/zint/mailmark.rb +8 -0
  86. data/lib/zint/mailmark_2d.rb +8 -0
  87. data/lib/zint/mailmark_4s.rb +8 -0
  88. data/lib/zint/maxi_code.rb +8 -0
  89. data/lib/zint/micro_pdf417.rb +8 -0
  90. data/lib/zint/micro_qr.rb +8 -0
  91. data/lib/zint/msiplessey.rb +8 -0
  92. data/lib/zint/native.rb +106 -0
  93. data/lib/zint/nve18.rb +8 -0
  94. data/lib/zint/one_code.rb +8 -0
  95. data/lib/zint/pdf417.rb +8 -0
  96. data/lib/zint/pdf417comp.rb +8 -0
  97. data/lib/zint/pdf417trunc.rb +8 -0
  98. data/lib/zint/pharma.rb +8 -0
  99. data/lib/zint/pharmatwo.rb +8 -0
  100. data/lib/zint/planet.rb +8 -0
  101. data/lib/zint/plessey.rb +8 -0
  102. data/lib/zint/postnet.rb +8 -0
  103. data/lib/zint/pzn.rb +8 -0
  104. data/lib/zint/qr.rb +18 -0
  105. data/lib/zint/rmqr.rb +8 -0
  106. data/lib/zint/rss14.rb +8 -0
  107. data/lib/zint/rss14stack.rb +8 -0
  108. data/lib/zint/rss14stackomni.rb +8 -0
  109. data/lib/zint/rssexp.rb +8 -0
  110. data/lib/zint/rssexpstack.rb +8 -0
  111. data/lib/zint/rssltd.rb +8 -0
  112. data/lib/zint/structs/seg.rb +26 -0
  113. data/lib/zint/structs/structapp.rb +25 -0
  114. data/lib/zint/structs/symbol.rb +57 -0
  115. data/lib/zint/structs/vector.rb +54 -0
  116. data/lib/zint/structs/vector_circle.rb +32 -0
  117. data/lib/zint/structs/vector_hexagon.rb +31 -0
  118. data/lib/zint/structs/vector_rect.rb +37 -0
  119. data/lib/zint/structs/vector_string.rb +50 -0
  120. data/lib/zint/telepen.rb +8 -0
  121. data/lib/zint/telepennum.rb +8 -0
  122. data/lib/zint/ultra.rb +8 -0
  123. data/lib/zint/upc_a.rb +8 -0
  124. data/lib/zint/upc_a_chk.rb +8 -0
  125. data/lib/zint/upc_e.rb +8 -0
  126. data/lib/zint/upc_e_chk.rb +8 -0
  127. data/lib/zint/upnqr.rb +8 -0
  128. data/lib/zint/upu_s10.rb +8 -0
  129. data/lib/zint/uspsimail.rb +8 -0
  130. data/lib/zint/version.rb +3 -0
  131. data/lib/zint/vin.rb +8 -0
  132. data/lib/zint/zint_recipe.rb +31 -0
  133. data/lib/zint.rb +170 -0
  134. data/ruby-zint.gemspec +43 -0
  135. metadata +305 -0
@@ -0,0 +1,31 @@
1
+ module Zint
2
+ module Structs
3
+ class VectorHexagon < FFI::Struct
4
+ layout :x, :float,
5
+ :y, :float,
6
+ :diameter, :float,
7
+ :rotation, :int, # 0, 90, 180, 270 degrees
8
+ :next, VectorHexagon.by_ref # Pointer to next hexagon
9
+
10
+ # x position
11
+ def x
12
+ self[:x]
13
+ end
14
+
15
+ # y position
16
+ def y
17
+ self[:y]
18
+ end
19
+
20
+ # diameter
21
+ def diameter
22
+ self[:diameter]
23
+ end
24
+
25
+ # 0, 90, 180, 270 degrees
26
+ def rotation
27
+ self[:rotation]
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,37 @@
1
+ module Zint
2
+ module Structs
3
+ class VectorRect < FFI::Struct
4
+ layout :x, :float,
5
+ :y, :float,
6
+ :height, :float,
7
+ :width, :float,
8
+ :colour, :int, # -1 for foreground, 1-8 for Cyan, Blue, Magenta, Red, Yellow, Green, Black, White
9
+ :next, VectorRect.by_ref # Pointer to next rectangle
10
+
11
+ # x position
12
+ def x
13
+ self[:x]
14
+ end
15
+
16
+ # y position
17
+ def y
18
+ self[:y]
19
+ end
20
+
21
+ # height
22
+ def height
23
+ self[:height]
24
+ end
25
+
26
+ # width
27
+ def width
28
+ self[:width]
29
+ end
30
+
31
+ # -1 for foreground, 1-8 for Cyan, Blue, Magenta, Red, Yellow, Green, Black, White
32
+ def colour
33
+ self[:colour]
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,50 @@
1
+ module Zint
2
+ module Structs
3
+ class VectorString < FFI::Struct
4
+ layout :x, :float, # x, y position relative to halign
5
+ :y, :float,
6
+ :fsize, :float, # font size
7
+ :width, :float, # Suggested string width, may be 0 if none recommended
8
+ :length, :int, # Number of characters
9
+ :rotation, :int, # 0, 90, 180, 270 degrees
10
+ :halign, :int, # Horizontal alignment: 0 for centre, 1 for left, 2 for right (end)
11
+ :text, :pointer, # the text string to be printed
12
+ :next, VectorString.by_ref # Pointer to next string
13
+
14
+ # x position relative to halign
15
+ def x
16
+ self[:x]
17
+ end
18
+
19
+ # y position
20
+ def y
21
+ self[:y]
22
+ end
23
+
24
+ # font size
25
+ def fsize
26
+ self[:fsize]
27
+ end
28
+
29
+ # Suggested string width, may be 0 if none recommended
30
+ def width
31
+ self[:width]
32
+ end
33
+
34
+ # 0, 90, 180, 270 degrees
35
+ def rotation
36
+ self[:rotation]
37
+ end
38
+
39
+ # Horizontal alignment: 0 for centre, 1 for left, 2 for right (end)
40
+ def halign
41
+ self[:halign]
42
+ end
43
+
44
+ # the text string to be printed
45
+ def text
46
+ self[:text].read_bytes(self[:length])
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Telepen Alpha
3
+ class Telepen < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_TELEPEN, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Telepen Numeric
3
+ class TelepenNum < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_TELEPEN_NUM, **kwargs)
6
+ end
7
+ end
8
+ end
data/lib/zint/ultra.rb ADDED
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Ultracode
3
+ class Ultra < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_ULTRA, **kwargs)
6
+ end
7
+ end
8
+ end
data/lib/zint/upc_a.rb ADDED
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # UPC-A
3
+ class UpcA < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_UPCA, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # UPC-A + Check Digit
3
+ class UpcAChk < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_UPCA_CHK, **kwargs)
6
+ end
7
+ end
8
+ end
data/lib/zint/upc_e.rb ADDED
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # UPC-E
3
+ class UpcE < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_UPCE, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # UPC-E + Check Digit
3
+ class UpcEChk < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_UPCE_CHK, **kwargs)
6
+ end
7
+ end
8
+ end
data/lib/zint/upnqr.rb ADDED
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # UPNQR (Univerzalnega Plačilnega Naloga QR)
3
+ class Upnqr < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_UPNQR, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Universal Postal Union S10
3
+ class UpuS10 < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_UPU_S10, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # USPS Intelligent Mail (OneCode)
3
+ class UspsImail < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_USPS_IMAIL, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module Zint
2
+ VERSION = "1.5.0"
3
+ end
data/lib/zint/vin.rb ADDED
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # Vehicle Identification Number
3
+ class Vin < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_VIN, **kwargs)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,31 @@
1
+ require_relative "dependencies"
2
+ require "rubygems"
3
+ # Keep the version constraint in sync with libusb.gemspec
4
+ gem "mini_portile2", Zint::MINI_PORTILE_VERSION
5
+ require "mini_portile2"
6
+
7
+ module Zint
8
+ class ZintRecipe < MiniPortileCMake
9
+ ROOT = File.expand_path("../../..", __FILE__)
10
+
11
+ def initialize(name, vers, url, sha1)
12
+ super(name, vers)
13
+ self.target = File.join(ROOT, "ports")
14
+ self.files = [url: url, sha1: sha1]
15
+ end
16
+
17
+ def port_path
18
+ "#{target}/#{RUBY_PLATFORM}"
19
+ end
20
+
21
+ def cook_and_activate
22
+ checkpoint = File.join(target, "#{name}-#{version}-#{RUBY_PLATFORM}.installed")
23
+ unless File.exist?(checkpoint)
24
+ cook
25
+ FileUtils.touch checkpoint
26
+ end
27
+ activate
28
+ self
29
+ end
30
+ end
31
+ end
data/lib/zint.rb ADDED
@@ -0,0 +1,170 @@
1
+ require "ffi"
2
+
3
+ require "zint/version"
4
+ require "zint/dependencies"
5
+
6
+ # Zint constants
7
+ require "zint/constants/capability_flags"
8
+ require "zint/constants/debug_flags"
9
+ require "zint/constants/errors"
10
+ require "zint/constants/input_data_types"
11
+ require "zint/constants/output_options"
12
+ require "zint/constants/specific_options"
13
+ require "zint/constants/symbologies"
14
+ require "zint/constants/warn_levels"
15
+ require "zint/constants/warnings"
16
+
17
+ # Zint structs
18
+ require "zint/structs/vector_circle"
19
+ require "zint/structs/vector_hexagon"
20
+ require "zint/structs/vector_rect"
21
+ require "zint/structs/vector_string"
22
+ require "zint/structs/vector"
23
+ require "zint/structs/seg"
24
+ require "zint/structs/structapp"
25
+ require "zint/structs/symbol"
26
+ require "zint/native"
27
+
28
+ module Zint
29
+ # Zint constants
30
+ include Constants::CapabilityFlags
31
+ include Constants::DebugFlags
32
+ include Constants::Errors
33
+ include Constants::InputDataTypes
34
+ include Constants::OutputOptions
35
+ include Constants::SpecificOptions
36
+ include Constants::Symbologies
37
+ include Constants::WarnLevels
38
+ include Constants::Warnings
39
+
40
+ # Barcode
41
+ autoload :Bc412, "zint/bc_412"
42
+ autoload :Bitmap, "zint/bitmap"
43
+ autoload :BitmapPixel, "zint/bitmap_pixel"
44
+ autoload :Barcode, "zint/barcode"
45
+ autoload :AusPost, "zint/aus_post"
46
+ autoload :AusRedirect, "zint/aus_redirect"
47
+ autoload :AusReply, "zint/aus_reply"
48
+ autoload :AusRoute, "zint/aus_route"
49
+ autoload :Azrune, "zint/azrune"
50
+ autoload :Aztec, "zint/aztec"
51
+ autoload :Bind, "zint/bind"
52
+ autoload :Box, "zint/box"
53
+ autoload :C25iata, "zint/c25iata"
54
+ autoload :C25ind, "zint/c25ind"
55
+ autoload :C25inter, "zint/c25inter"
56
+ autoload :C25logic, "zint/c25logic"
57
+ autoload :C25matrix, "zint/c25matrix"
58
+ autoload :C25standard, "zint/c25standard"
59
+ autoload :CepNet, "zint/cep_net"
60
+ autoload :Channel, "zint/channel"
61
+ autoload :Codabar, "zint/codabar"
62
+ autoload :CodablockF, "zint/codablock_f"
63
+ autoload :Code11, "zint/code11"
64
+ autoload :Code128, "zint/code128"
65
+ autoload :Code128AB, "zint/code128ab"
66
+ autoload :Code128B, "zint/code128b"
67
+ autoload :Code16k, "zint/code16k"
68
+ autoload :Code32, "zint/code32"
69
+ autoload :Code39, "zint/code39"
70
+ autoload :Code49, "zint/code49"
71
+ autoload :Code93, "zint/code93"
72
+ autoload :CodeOne, "zint/code_one"
73
+ autoload :Daft, "zint/daft"
74
+ autoload :DataMatrix, "zint/data_matrix"
75
+ autoload :DbarExp, "zint/dbarexp"
76
+ autoload :DbarExpstk, "zint/dbarexpstk"
77
+ autoload :DbarLtd, "zint/dbarltd"
78
+ autoload :DbarOmn, "zint/dbaromn"
79
+ autoload :DbarOmnstk, "zint/dbaromnstk"
80
+ autoload :DbarStk, "zint/dbarstk"
81
+ autoload :DotCode, "zint/dot_code"
82
+ autoload :DottyMode, "zint/dotty_mode"
83
+ autoload :Dpd, "zint/dpd"
84
+ autoload :Dpident, "zint/dpident"
85
+ autoload :Dpleit, "zint/dpleit"
86
+ autoload :Dxfilmedge, "zint/dxfilmedge"
87
+ autoload :Ean128, "zint/ean128"
88
+ autoload :Ean14, "zint/ean14"
89
+ autoload :Eanx, "zint/eanx"
90
+ autoload :EanxChk, "zint/eanxchk"
91
+ autoload :Excode39, "zint/excode39"
92
+ autoload :Fim, "zint/fim"
93
+ autoload :Flat, "zint/flat"
94
+ autoload :GridMatrix, "zint/grid_matrix"
95
+ autoload :Gs1_128, "zint/gs1_128"
96
+ autoload :Hanxin, "zint/hanxin"
97
+ autoload :Hibc128, "zint/hibc128"
98
+ autoload :Hibc39, "zint/hibc39"
99
+ autoload :HibcAztec, "zint/hibcaztec"
100
+ autoload :HibcBlockf, "zint/hibcblockf"
101
+ autoload :HibcDm, "zint/hibcdm"
102
+ autoload :HibcMicpdf, "zint/hibcmicpdf"
103
+ autoload :HibcPdf, "zint/hibcpdf"
104
+ autoload :HibcQr, "zint/hibcqr"
105
+ autoload :Isbnx, "zint/isbnx"
106
+ autoload :Itf14, "zint/itf14"
107
+ autoload :JapanPost, "zint/japan_post"
108
+ autoload :Kix, "zint/kix"
109
+ autoload :KoreaPost, "zint/korea_post"
110
+ autoload :Logmars, "zint/logmars"
111
+ autoload :Mailmark, "zint/mailmark"
112
+ autoload :Mailmark2D, "zint/mailmark_2d"
113
+ autoload :Mailmark4S, "zint/mailmark_4s"
114
+ autoload :MaxiCode, "zint/maxi_code"
115
+ autoload :MicroPdf417, "zint/micro_pdf417"
116
+ autoload :MicroQr, "zint/micro_qr"
117
+ autoload :MsiPlessey, "zint/msiplessey"
118
+ autoload :NoAscii, "zint/noascii"
119
+ autoload :Nve18, "zint/nve18"
120
+ autoload :OneCode, "zint/one_code"
121
+ autoload :Pdf417, "zint/pdf417"
122
+ autoload :Pdf417comp, "zint/pdf417comp"
123
+ autoload :Pdf417trunc, "zint/pdf417trunc"
124
+ autoload :Pharma, "zint/pharma"
125
+ autoload :PharmaTwo, "zint/pharmatwo"
126
+ autoload :Planet, "zint/planet"
127
+ autoload :Plessey, "zint/plessey"
128
+ autoload :Postnet, "zint/postnet"
129
+ autoload :Pzn, "zint/pzn"
130
+ autoload :Qr, "zint/qr"
131
+ autoload :Rmqr, "zint/rmqr"
132
+ autoload :Rss14, "zint/rss14"
133
+ autoload :Rss14stack, "zint/rss14stack"
134
+ autoload :Rss14stackOmni, "zint/rss14stackomni"
135
+ autoload :RssExp, "zint/rssexp"
136
+ autoload :RssExpstack, "zint/rssexpstack"
137
+ autoload :RssLtd, "zint/rssltd"
138
+ autoload :Stdout, "zint/stdout"
139
+ autoload :Telepen, "zint/telepen"
140
+ autoload :TelepenNum, "zint/telepennum"
141
+ autoload :Ultra, "zint/ultra"
142
+ autoload :UpcA, "zint/upc_a"
143
+ autoload :UpcAChk, "zint/upc_a_chk"
144
+ autoload :UpcE, "zint/upc_e"
145
+ autoload :UpcEChk, "zint/upc_e_chk"
146
+ autoload :Upnqr, "zint/upnqr"
147
+ autoload :UpuS10, "zint/upu_s10"
148
+ autoload :UspsImail, "zint/uspsimail"
149
+ autoload :Vin, "zint/vin"
150
+
151
+ class Error < StandardError; end
152
+
153
+ ERROR_CLASS_FOR_RESULT = {}
154
+
155
+ # Define an exception class for each error code
156
+ ERRORS.to_h.each do |k, v|
157
+ klass = Class.new(Error)
158
+ klass.send(:define_method, :code) { v }
159
+ klass_name = k.to_s.split("_").collect(&:capitalize).join
160
+ const_set(klass_name, klass)
161
+ ERROR_CLASS_FOR_RESULT[v] = klass
162
+ end
163
+
164
+ # Returns library version of the current zint
165
+ #
166
+ # @return [Integer] library version
167
+ def self.library_version
168
+ Native.ZBarcode_Version
169
+ end
170
+ end
data/ruby-zint.gemspec ADDED
@@ -0,0 +1,43 @@
1
+ require_relative "lib/zint/version"
2
+ require_relative "lib/zint/dependencies"
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "ruby-zint"
6
+ spec.version = Zint::VERSION
7
+ spec.authors = ["Elias Fröhner"]
8
+ spec.email = ["apiwalker96@gmail.com"]
9
+
10
+ spec.summary = "Ruby FFI binding for libzint"
11
+ spec.homepage = "https://github.com/eliasfroehner/ruby-zint"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = ">= 2.6.0"
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = spec.homepage
17
+ spec.metadata["msys2_mingw_dependencies"] = "cmake libpng"
18
+ spec.metadata["documentation_uri"] = "https://rubydoc.info/gems/ruby-zint"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor .standard.yml .rspec Rakefile Gemfile rakelib])
25
+ end
26
+ end
27
+ spec.files << "ports/archives/zlib-#{Zint::LIBZ_VERSION}.tar.gz"
28
+ spec.files << "ports/archives/libpng-#{Zint::LIBPNG_VERSION}.tar.xz"
29
+ spec.files << "ports/archives/zint-#{Zint::ZINT_VERSION}-src.tar.gz"
30
+
31
+ spec.require_paths = ["lib"]
32
+ spec.extensions = ["ext/ruby-zint/extconf.rb"]
33
+
34
+ spec.add_dependency "ffi", "~> 1.15"
35
+ spec.add_dependency "mini_portile2", Zint::MINI_PORTILE_VERSION
36
+
37
+ yardopts = File.read(".yardopts")
38
+ spec.rdoc_options = ["--main", "README.md",
39
+ "--title", "Ruby FFI binding for libzint",
40
+ "--exclude", "/ext.ruby-zint/"]
41
+ docfiles = yardopts.lines.map(&:strip).select { |r| r =~ /^[^-]/ }
42
+ spec.extra_rdoc_files = `git ls-files -z #{docfiles.join(" ")}`.split("\x0")
43
+ end