rqrcode 0.10.1 → 2.1.1

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 (48) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +28 -0
  3. data/.gitignore +13 -0
  4. data/.rspec +2 -0
  5. data/CHANGELOG.md +54 -0
  6. data/Gemfile +4 -0
  7. data/Gemfile.lock +68 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +223 -135
  10. data/Rakefile +10 -0
  11. data/_config.yml +1 -0
  12. data/bin/console +14 -0
  13. data/bin/setup +8 -0
  14. data/images/ansi-screen-shot.png +0 -0
  15. data/images/github-qrcode.png +0 -0
  16. data/images/github-qrcode.svg +32 -0
  17. data/lib/rqrcode/export/ansi.rb +22 -25
  18. data/lib/rqrcode/export/html.rb +8 -10
  19. data/lib/rqrcode/export/png.rb +62 -45
  20. data/lib/rqrcode/export/svg.rb +180 -24
  21. data/lib/rqrcode/export.rb +6 -0
  22. data/lib/rqrcode/qrcode/qrcode.rb +17 -0
  23. data/lib/rqrcode/qrcode.rb +3 -4
  24. data/lib/rqrcode/version.rb +3 -1
  25. data/lib/rqrcode.rb +8 -19
  26. data/rqrcode.gemspec +39 -0
  27. metadata +91 -60
  28. data/CHANGELOG +0 -97
  29. data/LICENSE +0 -19
  30. data/lib/rqrcode/core_ext/array/behavior.rb +0 -12
  31. data/lib/rqrcode/core_ext/array.rb +0 -5
  32. data/lib/rqrcode/core_ext/integer/bitwise.rb +0 -13
  33. data/lib/rqrcode/core_ext/integer.rb +0 -5
  34. data/lib/rqrcode/core_ext.rb +0 -5
  35. data/lib/rqrcode/qrcode/qr_8bit_byte.rb +0 -36
  36. data/lib/rqrcode/qrcode/qr_alphanumeric.rb +0 -47
  37. data/lib/rqrcode/qrcode/qr_bit_buffer.rb +0 -99
  38. data/lib/rqrcode/qrcode/qr_code.rb +0 -585
  39. data/lib/rqrcode/qrcode/qr_math.rb +0 -63
  40. data/lib/rqrcode/qrcode/qr_numeric.rb +0 -57
  41. data/lib/rqrcode/qrcode/qr_polynomial.rb +0 -78
  42. data/lib/rqrcode/qrcode/qr_rs_block.rb +0 -314
  43. data/lib/rqrcode/qrcode/qr_util.rb +0 -272
  44. data/test/data.rb +0 -25
  45. data/test/test_helper.rb +0 -5
  46. data/test/test_regresions.rb +0 -10
  47. data/test/test_rqrcode.rb +0 -155
  48. data/test/test_rqrcode_export.rb +0 -27
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rqrcode"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
Binary file
Binary file
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0" standalone="yes"?>
2
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" width="174" height="174" shape-rendering="crispEdges">
3
+ <rect width="6" height="6" x="0" y="0" style="fill:#000"/><rect width="6" height="6" x="6" y="0" style="fill:#000"/><rect width="6" height="6" x="12" y="0" style="fill:#000"/><rect width="6" height="6" x="18" y="0" style="fill:#000"/><rect width="6" height="6" x="24" y="0" style="fill:#000"/><rect width="6" height="6" x="30" y="0" style="fill:#000"/><rect width="6" height="6" x="36" y="0" style="fill:#000"/><rect width="6" height="6" x="54" y="0" style="fill:#000"/><rect width="6" height="6" x="60" y="0" style="fill:#000"/><rect width="6" height="6" x="66" y="0" style="fill:#000"/><rect width="6" height="6" x="78" y="0" style="fill:#000"/><rect width="6" height="6" x="108" y="0" style="fill:#000"/><rect width="6" height="6" x="114" y="0" style="fill:#000"/><rect width="6" height="6" x="132" y="0" style="fill:#000"/><rect width="6" height="6" x="138" y="0" style="fill:#000"/><rect width="6" height="6" x="144" y="0" style="fill:#000"/><rect width="6" height="6" x="150" y="0" style="fill:#000"/><rect width="6" height="6" x="156" y="0" style="fill:#000"/><rect width="6" height="6" x="162" y="0" style="fill:#000"/><rect width="6" height="6" x="168" y="0" style="fill:#000"/>
4
+ <rect width="6" height="6" x="0" y="6" style="fill:#000"/><rect width="6" height="6" x="36" y="6" style="fill:#000"/><rect width="6" height="6" x="60" y="6" style="fill:#000"/><rect width="6" height="6" x="66" y="6" style="fill:#000"/><rect width="6" height="6" x="78" y="6" style="fill:#000"/><rect width="6" height="6" x="84" y="6" style="fill:#000"/><rect width="6" height="6" x="90" y="6" style="fill:#000"/><rect width="6" height="6" x="96" y="6" style="fill:#000"/><rect width="6" height="6" x="108" y="6" style="fill:#000"/><rect width="6" height="6" x="120" y="6" style="fill:#000"/><rect width="6" height="6" x="132" y="6" style="fill:#000"/><rect width="6" height="6" x="168" y="6" style="fill:#000"/>
5
+ <rect width="6" height="6" x="0" y="12" style="fill:#000"/><rect width="6" height="6" x="12" y="12" style="fill:#000"/><rect width="6" height="6" x="18" y="12" style="fill:#000"/><rect width="6" height="6" x="24" y="12" style="fill:#000"/><rect width="6" height="6" x="36" y="12" style="fill:#000"/><rect width="6" height="6" x="48" y="12" style="fill:#000"/><rect width="6" height="6" x="54" y="12" style="fill:#000"/><rect width="6" height="6" x="72" y="12" style="fill:#000"/><rect width="6" height="6" x="90" y="12" style="fill:#000"/><rect width="6" height="6" x="108" y="12" style="fill:#000"/><rect width="6" height="6" x="120" y="12" style="fill:#000"/><rect width="6" height="6" x="132" y="12" style="fill:#000"/><rect width="6" height="6" x="144" y="12" style="fill:#000"/><rect width="6" height="6" x="150" y="12" style="fill:#000"/><rect width="6" height="6" x="156" y="12" style="fill:#000"/><rect width="6" height="6" x="168" y="12" style="fill:#000"/>
6
+ <rect width="6" height="6" x="0" y="18" style="fill:#000"/><rect width="6" height="6" x="12" y="18" style="fill:#000"/><rect width="6" height="6" x="18" y="18" style="fill:#000"/><rect width="6" height="6" x="24" y="18" style="fill:#000"/><rect width="6" height="6" x="36" y="18" style="fill:#000"/><rect width="6" height="6" x="48" y="18" style="fill:#000"/><rect width="6" height="6" x="54" y="18" style="fill:#000"/><rect width="6" height="6" x="60" y="18" style="fill:#000"/><rect width="6" height="6" x="78" y="18" style="fill:#000"/><rect width="6" height="6" x="90" y="18" style="fill:#000"/><rect width="6" height="6" x="102" y="18" style="fill:#000"/><rect width="6" height="6" x="114" y="18" style="fill:#000"/><rect width="6" height="6" x="120" y="18" style="fill:#000"/><rect width="6" height="6" x="132" y="18" style="fill:#000"/><rect width="6" height="6" x="144" y="18" style="fill:#000"/><rect width="6" height="6" x="150" y="18" style="fill:#000"/><rect width="6" height="6" x="156" y="18" style="fill:#000"/><rect width="6" height="6" x="168" y="18" style="fill:#000"/>
7
+ <rect width="6" height="6" x="0" y="24" style="fill:#000"/><rect width="6" height="6" x="12" y="24" style="fill:#000"/><rect width="6" height="6" x="18" y="24" style="fill:#000"/><rect width="6" height="6" x="24" y="24" style="fill:#000"/><rect width="6" height="6" x="36" y="24" style="fill:#000"/><rect width="6" height="6" x="60" y="24" style="fill:#000"/><rect width="6" height="6" x="66" y="24" style="fill:#000"/><rect width="6" height="6" x="72" y="24" style="fill:#000"/><rect width="6" height="6" x="78" y="24" style="fill:#000"/><rect width="6" height="6" x="84" y="24" style="fill:#000"/><rect width="6" height="6" x="90" y="24" style="fill:#000"/><rect width="6" height="6" x="96" y="24" style="fill:#000"/><rect width="6" height="6" x="102" y="24" style="fill:#000"/><rect width="6" height="6" x="114" y="24" style="fill:#000"/><rect width="6" height="6" x="132" y="24" style="fill:#000"/><rect width="6" height="6" x="144" y="24" style="fill:#000"/><rect width="6" height="6" x="150" y="24" style="fill:#000"/><rect width="6" height="6" x="156" y="24" style="fill:#000"/><rect width="6" height="6" x="168" y="24" style="fill:#000"/>
8
+ <rect width="6" height="6" x="0" y="30" style="fill:#000"/><rect width="6" height="6" x="36" y="30" style="fill:#000"/><rect width="6" height="6" x="60" y="30" style="fill:#000"/><rect width="6" height="6" x="66" y="30" style="fill:#000"/><rect width="6" height="6" x="90" y="30" style="fill:#000"/><rect width="6" height="6" x="102" y="30" style="fill:#000"/><rect width="6" height="6" x="108" y="30" style="fill:#000"/><rect width="6" height="6" x="132" y="30" style="fill:#000"/><rect width="6" height="6" x="168" y="30" style="fill:#000"/>
9
+ <rect width="6" height="6" x="0" y="36" style="fill:#000"/><rect width="6" height="6" x="6" y="36" style="fill:#000"/><rect width="6" height="6" x="12" y="36" style="fill:#000"/><rect width="6" height="6" x="18" y="36" style="fill:#000"/><rect width="6" height="6" x="24" y="36" style="fill:#000"/><rect width="6" height="6" x="30" y="36" style="fill:#000"/><rect width="6" height="6" x="36" y="36" style="fill:#000"/><rect width="6" height="6" x="48" y="36" style="fill:#000"/><rect width="6" height="6" x="60" y="36" style="fill:#000"/><rect width="6" height="6" x="72" y="36" style="fill:#000"/><rect width="6" height="6" x="84" y="36" style="fill:#000"/><rect width="6" height="6" x="96" y="36" style="fill:#000"/><rect width="6" height="6" x="108" y="36" style="fill:#000"/><rect width="6" height="6" x="120" y="36" style="fill:#000"/><rect width="6" height="6" x="132" y="36" style="fill:#000"/><rect width="6" height="6" x="138" y="36" style="fill:#000"/><rect width="6" height="6" x="144" y="36" style="fill:#000"/><rect width="6" height="6" x="150" y="36" style="fill:#000"/><rect width="6" height="6" x="156" y="36" style="fill:#000"/><rect width="6" height="6" x="162" y="36" style="fill:#000"/><rect width="6" height="6" x="168" y="36" style="fill:#000"/>
10
+ <rect width="6" height="6" x="54" y="42" style="fill:#000"/><rect width="6" height="6" x="72" y="42" style="fill:#000"/><rect width="6" height="6" x="78" y="42" style="fill:#000"/><rect width="6" height="6" x="84" y="42" style="fill:#000"/><rect width="6" height="6" x="114" y="42" style="fill:#000"/>
11
+ <rect width="6" height="6" x="18" y="48" style="fill:#000"/><rect width="6" height="6" x="24" y="48" style="fill:#000"/><rect width="6" height="6" x="36" y="48" style="fill:#000"/><rect width="6" height="6" x="42" y="48" style="fill:#000"/><rect width="6" height="6" x="54" y="48" style="fill:#000"/><rect width="6" height="6" x="72" y="48" style="fill:#000"/><rect width="6" height="6" x="90" y="48" style="fill:#000"/><rect width="6" height="6" x="96" y="48" style="fill:#000"/><rect width="6" height="6" x="108" y="48" style="fill:#000"/><rect width="6" height="6" x="114" y="48" style="fill:#000"/><rect width="6" height="6" x="120" y="48" style="fill:#000"/><rect width="6" height="6" x="150" y="48" style="fill:#000"/><rect width="6" height="6" x="156" y="48" style="fill:#000"/>
12
+ <rect width="6" height="6" x="12" y="54" style="fill:#000"/><rect width="6" height="6" x="18" y="54" style="fill:#000"/><rect width="6" height="6" x="24" y="54" style="fill:#000"/><rect width="6" height="6" x="30" y="54" style="fill:#000"/><rect width="6" height="6" x="54" y="54" style="fill:#000"/><rect width="6" height="6" x="72" y="54" style="fill:#000"/><rect width="6" height="6" x="78" y="54" style="fill:#000"/><rect width="6" height="6" x="84" y="54" style="fill:#000"/><rect width="6" height="6" x="96" y="54" style="fill:#000"/><rect width="6" height="6" x="120" y="54" style="fill:#000"/><rect width="6" height="6" x="132" y="54" style="fill:#000"/><rect width="6" height="6" x="144" y="54" style="fill:#000"/><rect width="6" height="6" x="150" y="54" style="fill:#000"/><rect width="6" height="6" x="162" y="54" style="fill:#000"/>
13
+ <rect width="6" height="6" x="6" y="60" style="fill:#000"/><rect width="6" height="6" x="18" y="60" style="fill:#000"/><rect width="6" height="6" x="36" y="60" style="fill:#000"/><rect width="6" height="6" x="48" y="60" style="fill:#000"/><rect width="6" height="6" x="78" y="60" style="fill:#000"/><rect width="6" height="6" x="108" y="60" style="fill:#000"/><rect width="6" height="6" x="132" y="60" style="fill:#000"/>
14
+ <rect width="6" height="6" x="6" y="66" style="fill:#000"/><rect width="6" height="6" x="12" y="66" style="fill:#000"/><rect width="6" height="6" x="18" y="66" style="fill:#000"/><rect width="6" height="6" x="30" y="66" style="fill:#000"/><rect width="6" height="6" x="42" y="66" style="fill:#000"/><rect width="6" height="6" x="48" y="66" style="fill:#000"/><rect width="6" height="6" x="54" y="66" style="fill:#000"/><rect width="6" height="6" x="72" y="66" style="fill:#000"/><rect width="6" height="6" x="78" y="66" style="fill:#000"/><rect width="6" height="6" x="84" y="66" style="fill:#000"/><rect width="6" height="6" x="96" y="66" style="fill:#000"/><rect width="6" height="6" x="108" y="66" style="fill:#000"/><rect width="6" height="6" x="126" y="66" style="fill:#000"/><rect width="6" height="6" x="150" y="66" style="fill:#000"/><rect width="6" height="6" x="168" y="66" style="fill:#000"/>
15
+ <rect width="6" height="6" x="24" y="72" style="fill:#000"/><rect width="6" height="6" x="36" y="72" style="fill:#000"/><rect width="6" height="6" x="42" y="72" style="fill:#000"/><rect width="6" height="6" x="48" y="72" style="fill:#000"/><rect width="6" height="6" x="54" y="72" style="fill:#000"/><rect width="6" height="6" x="60" y="72" style="fill:#000"/><rect width="6" height="6" x="78" y="72" style="fill:#000"/><rect width="6" height="6" x="90" y="72" style="fill:#000"/><rect width="6" height="6" x="102" y="72" style="fill:#000"/><rect width="6" height="6" x="114" y="72" style="fill:#000"/><rect width="6" height="6" x="126" y="72" style="fill:#000"/><rect width="6" height="6" x="132" y="72" style="fill:#000"/><rect width="6" height="6" x="138" y="72" style="fill:#000"/><rect width="6" height="6" x="150" y="72" style="fill:#000"/><rect width="6" height="6" x="162" y="72" style="fill:#000"/>
16
+ <rect width="6" height="6" x="6" y="78" style="fill:#000"/><rect width="6" height="6" x="12" y="78" style="fill:#000"/><rect width="6" height="6" x="24" y="78" style="fill:#000"/><rect width="6" height="6" x="30" y="78" style="fill:#000"/><rect width="6" height="6" x="78" y="78" style="fill:#000"/><rect width="6" height="6" x="84" y="78" style="fill:#000"/><rect width="6" height="6" x="102" y="78" style="fill:#000"/><rect width="6" height="6" x="132" y="78" style="fill:#000"/><rect width="6" height="6" x="144" y="78" style="fill:#000"/><rect width="6" height="6" x="156" y="78" style="fill:#000"/><rect width="6" height="6" x="168" y="78" style="fill:#000"/>
17
+ <rect width="6" height="6" x="0" y="84" style="fill:#000"/><rect width="6" height="6" x="12" y="84" style="fill:#000"/><rect width="6" height="6" x="18" y="84" style="fill:#000"/><rect width="6" height="6" x="30" y="84" style="fill:#000"/><rect width="6" height="6" x="36" y="84" style="fill:#000"/><rect width="6" height="6" x="42" y="84" style="fill:#000"/><rect width="6" height="6" x="48" y="84" style="fill:#000"/><rect width="6" height="6" x="72" y="84" style="fill:#000"/><rect width="6" height="6" x="78" y="84" style="fill:#000"/><rect width="6" height="6" x="108" y="84" style="fill:#000"/><rect width="6" height="6" x="114" y="84" style="fill:#000"/><rect width="6" height="6" x="120" y="84" style="fill:#000"/><rect width="6" height="6" x="150" y="84" style="fill:#000"/><rect width="6" height="6" x="162" y="84" style="fill:#000"/><rect width="6" height="6" x="168" y="84" style="fill:#000"/>
18
+ <rect width="6" height="6" x="0" y="90" style="fill:#000"/><rect width="6" height="6" x="12" y="90" style="fill:#000"/><rect width="6" height="6" x="30" y="90" style="fill:#000"/><rect width="6" height="6" x="60" y="90" style="fill:#000"/><rect width="6" height="6" x="78" y="90" style="fill:#000"/><rect width="6" height="6" x="102" y="90" style="fill:#000"/><rect width="6" height="6" x="108" y="90" style="fill:#000"/><rect width="6" height="6" x="120" y="90" style="fill:#000"/><rect width="6" height="6" x="150" y="90" style="fill:#000"/><rect width="6" height="6" x="156" y="90" style="fill:#000"/>
19
+ <rect width="6" height="6" x="18" y="96" style="fill:#000"/><rect width="6" height="6" x="24" y="96" style="fill:#000"/><rect width="6" height="6" x="30" y="96" style="fill:#000"/><rect width="6" height="6" x="36" y="96" style="fill:#000"/><rect width="6" height="6" x="48" y="96" style="fill:#000"/><rect width="6" height="6" x="60" y="96" style="fill:#000"/><rect width="6" height="6" x="72" y="96" style="fill:#000"/><rect width="6" height="6" x="78" y="96" style="fill:#000"/><rect width="6" height="6" x="84" y="96" style="fill:#000"/><rect width="6" height="6" x="108" y="96" style="fill:#000"/><rect width="6" height="6" x="114" y="96" style="fill:#000"/><rect width="6" height="6" x="120" y="96" style="fill:#000"/><rect width="6" height="6" x="132" y="96" style="fill:#000"/><rect width="6" height="6" x="138" y="96" style="fill:#000"/><rect width="6" height="6" x="150" y="96" style="fill:#000"/><rect width="6" height="6" x="162" y="96" style="fill:#000"/>
20
+ <rect width="6" height="6" x="0" y="102" style="fill:#000"/><rect width="6" height="6" x="6" y="102" style="fill:#000"/><rect width="6" height="6" x="12" y="102" style="fill:#000"/><rect width="6" height="6" x="18" y="102" style="fill:#000"/><rect width="6" height="6" x="54" y="102" style="fill:#000"/><rect width="6" height="6" x="66" y="102" style="fill:#000"/><rect width="6" height="6" x="96" y="102" style="fill:#000"/><rect width="6" height="6" x="102" y="102" style="fill:#000"/><rect width="6" height="6" x="108" y="102" style="fill:#000"/><rect width="6" height="6" x="120" y="102" style="fill:#000"/><rect width="6" height="6" x="132" y="102" style="fill:#000"/><rect width="6" height="6" x="138" y="102" style="fill:#000"/><rect width="6" height="6" x="144" y="102" style="fill:#000"/>
21
+ <rect width="6" height="6" x="0" y="108" style="fill:#000"/><rect width="6" height="6" x="6" y="108" style="fill:#000"/><rect width="6" height="6" x="18" y="108" style="fill:#000"/><rect width="6" height="6" x="24" y="108" style="fill:#000"/><rect width="6" height="6" x="36" y="108" style="fill:#000"/><rect width="6" height="6" x="60" y="108" style="fill:#000"/><rect width="6" height="6" x="72" y="108" style="fill:#000"/><rect width="6" height="6" x="90" y="108" style="fill:#000"/><rect width="6" height="6" x="120" y="108" style="fill:#000"/><rect width="6" height="6" x="144" y="108" style="fill:#000"/><rect width="6" height="6" x="168" y="108" style="fill:#000"/>
22
+ <rect width="6" height="6" x="0" y="114" style="fill:#000"/><rect width="6" height="6" x="6" y="114" style="fill:#000"/><rect width="6" height="6" x="12" y="114" style="fill:#000"/><rect width="6" height="6" x="18" y="114" style="fill:#000"/><rect width="6" height="6" x="24" y="114" style="fill:#000"/><rect width="6" height="6" x="30" y="114" style="fill:#000"/><rect width="6" height="6" x="42" y="114" style="fill:#000"/><rect width="6" height="6" x="48" y="114" style="fill:#000"/><rect width="6" height="6" x="60" y="114" style="fill:#000"/><rect width="6" height="6" x="72" y="114" style="fill:#000"/><rect width="6" height="6" x="78" y="114" style="fill:#000"/><rect width="6" height="6" x="90" y="114" style="fill:#000"/><rect width="6" height="6" x="126" y="114" style="fill:#000"/><rect width="6" height="6" x="132" y="114" style="fill:#000"/><rect width="6" height="6" x="138" y="114" style="fill:#000"/><rect width="6" height="6" x="156" y="114" style="fill:#000"/><rect width="6" height="6" x="168" y="114" style="fill:#000"/>
23
+ <rect width="6" height="6" x="0" y="120" style="fill:#000"/><rect width="6" height="6" x="6" y="120" style="fill:#000"/><rect width="6" height="6" x="12" y="120" style="fill:#000"/><rect width="6" height="6" x="30" y="120" style="fill:#000"/><rect width="6" height="6" x="36" y="120" style="fill:#000"/><rect width="6" height="6" x="60" y="120" style="fill:#000"/><rect width="6" height="6" x="66" y="120" style="fill:#000"/><rect width="6" height="6" x="72" y="120" style="fill:#000"/><rect width="6" height="6" x="108" y="120" style="fill:#000"/><rect width="6" height="6" x="120" y="120" style="fill:#000"/><rect width="6" height="6" x="126" y="120" style="fill:#000"/><rect width="6" height="6" x="132" y="120" style="fill:#000"/><rect width="6" height="6" x="138" y="120" style="fill:#000"/><rect width="6" height="6" x="144" y="120" style="fill:#000"/><rect width="6" height="6" x="150" y="120" style="fill:#000"/><rect width="6" height="6" x="156" y="120" style="fill:#000"/><rect width="6" height="6" x="162" y="120" style="fill:#000"/><rect width="6" height="6" x="168" y="120" style="fill:#000"/>
24
+ <rect width="6" height="6" x="48" y="126" style="fill:#000"/><rect width="6" height="6" x="60" y="126" style="fill:#000"/><rect width="6" height="6" x="78" y="126" style="fill:#000"/><rect width="6" height="6" x="84" y="126" style="fill:#000"/><rect width="6" height="6" x="120" y="126" style="fill:#000"/><rect width="6" height="6" x="144" y="126" style="fill:#000"/><rect width="6" height="6" x="150" y="126" style="fill:#000"/><rect width="6" height="6" x="156" y="126" style="fill:#000"/>
25
+ <rect width="6" height="6" x="0" y="132" style="fill:#000"/><rect width="6" height="6" x="6" y="132" style="fill:#000"/><rect width="6" height="6" x="12" y="132" style="fill:#000"/><rect width="6" height="6" x="18" y="132" style="fill:#000"/><rect width="6" height="6" x="24" y="132" style="fill:#000"/><rect width="6" height="6" x="30" y="132" style="fill:#000"/><rect width="6" height="6" x="36" y="132" style="fill:#000"/><rect width="6" height="6" x="48" y="132" style="fill:#000"/><rect width="6" height="6" x="66" y="132" style="fill:#000"/><rect width="6" height="6" x="72" y="132" style="fill:#000"/><rect width="6" height="6" x="114" y="132" style="fill:#000"/><rect width="6" height="6" x="120" y="132" style="fill:#000"/><rect width="6" height="6" x="132" y="132" style="fill:#000"/><rect width="6" height="6" x="144" y="132" style="fill:#000"/><rect width="6" height="6" x="156" y="132" style="fill:#000"/>
26
+ <rect width="6" height="6" x="0" y="138" style="fill:#000"/><rect width="6" height="6" x="36" y="138" style="fill:#000"/><rect width="6" height="6" x="60" y="138" style="fill:#000"/><rect width="6" height="6" x="66" y="138" style="fill:#000"/><rect width="6" height="6" x="72" y="138" style="fill:#000"/><rect width="6" height="6" x="78" y="138" style="fill:#000"/><rect width="6" height="6" x="96" y="138" style="fill:#000"/><rect width="6" height="6" x="108" y="138" style="fill:#000"/><rect width="6" height="6" x="114" y="138" style="fill:#000"/><rect width="6" height="6" x="120" y="138" style="fill:#000"/><rect width="6" height="6" x="144" y="138" style="fill:#000"/><rect width="6" height="6" x="150" y="138" style="fill:#000"/><rect width="6" height="6" x="162" y="138" style="fill:#000"/><rect width="6" height="6" x="168" y="138" style="fill:#000"/>
27
+ <rect width="6" height="6" x="0" y="144" style="fill:#000"/><rect width="6" height="6" x="12" y="144" style="fill:#000"/><rect width="6" height="6" x="18" y="144" style="fill:#000"/><rect width="6" height="6" x="24" y="144" style="fill:#000"/><rect width="6" height="6" x="36" y="144" style="fill:#000"/><rect width="6" height="6" x="48" y="144" style="fill:#000"/><rect width="6" height="6" x="54" y="144" style="fill:#000"/><rect width="6" height="6" x="72" y="144" style="fill:#000"/><rect width="6" height="6" x="102" y="144" style="fill:#000"/><rect width="6" height="6" x="108" y="144" style="fill:#000"/><rect width="6" height="6" x="114" y="144" style="fill:#000"/><rect width="6" height="6" x="120" y="144" style="fill:#000"/><rect width="6" height="6" x="126" y="144" style="fill:#000"/><rect width="6" height="6" x="132" y="144" style="fill:#000"/><rect width="6" height="6" x="138" y="144" style="fill:#000"/><rect width="6" height="6" x="144" y="144" style="fill:#000"/><rect width="6" height="6" x="168" y="144" style="fill:#000"/>
28
+ <rect width="6" height="6" x="0" y="150" style="fill:#000"/><rect width="6" height="6" x="12" y="150" style="fill:#000"/><rect width="6" height="6" x="18" y="150" style="fill:#000"/><rect width="6" height="6" x="24" y="150" style="fill:#000"/><rect width="6" height="6" x="36" y="150" style="fill:#000"/><rect width="6" height="6" x="48" y="150" style="fill:#000"/><rect width="6" height="6" x="60" y="150" style="fill:#000"/><rect width="6" height="6" x="66" y="150" style="fill:#000"/><rect width="6" height="6" x="72" y="150" style="fill:#000"/><rect width="6" height="6" x="78" y="150" style="fill:#000"/><rect width="6" height="6" x="84" y="150" style="fill:#000"/><rect width="6" height="6" x="96" y="150" style="fill:#000"/><rect width="6" height="6" x="126" y="150" style="fill:#000"/><rect width="6" height="6" x="138" y="150" style="fill:#000"/><rect width="6" height="6" x="162" y="150" style="fill:#000"/>
29
+ <rect width="6" height="6" x="0" y="156" style="fill:#000"/><rect width="6" height="6" x="12" y="156" style="fill:#000"/><rect width="6" height="6" x="18" y="156" style="fill:#000"/><rect width="6" height="6" x="24" y="156" style="fill:#000"/><rect width="6" height="6" x="36" y="156" style="fill:#000"/><rect width="6" height="6" x="60" y="156" style="fill:#000"/><rect width="6" height="6" x="66" y="156" style="fill:#000"/><rect width="6" height="6" x="72" y="156" style="fill:#000"/><rect width="6" height="6" x="90" y="156" style="fill:#000"/><rect width="6" height="6" x="126" y="156" style="fill:#000"/><rect width="6" height="6" x="144" y="156" style="fill:#000"/><rect width="6" height="6" x="156" y="156" style="fill:#000"/><rect width="6" height="6" x="162" y="156" style="fill:#000"/><rect width="6" height="6" x="168" y="156" style="fill:#000"/>
30
+ <rect width="6" height="6" x="0" y="162" style="fill:#000"/><rect width="6" height="6" x="36" y="162" style="fill:#000"/><rect width="6" height="6" x="54" y="162" style="fill:#000"/><rect width="6" height="6" x="72" y="162" style="fill:#000"/><rect width="6" height="6" x="84" y="162" style="fill:#000"/><rect width="6" height="6" x="114" y="162" style="fill:#000"/><rect width="6" height="6" x="120" y="162" style="fill:#000"/><rect width="6" height="6" x="132" y="162" style="fill:#000"/><rect width="6" height="6" x="144" y="162" style="fill:#000"/><rect width="6" height="6" x="150" y="162" style="fill:#000"/><rect width="6" height="6" x="156" y="162" style="fill:#000"/><rect width="6" height="6" x="168" y="162" style="fill:#000"/>
31
+ <rect width="6" height="6" x="0" y="168" style="fill:#000"/><rect width="6" height="6" x="6" y="168" style="fill:#000"/><rect width="6" height="6" x="12" y="168" style="fill:#000"/><rect width="6" height="6" x="18" y="168" style="fill:#000"/><rect width="6" height="6" x="24" y="168" style="fill:#000"/><rect width="6" height="6" x="30" y="168" style="fill:#000"/><rect width="6" height="6" x="36" y="168" style="fill:#000"/><rect width="6" height="6" x="54" y="168" style="fill:#000"/><rect width="6" height="6" x="84" y="168" style="fill:#000"/><rect width="6" height="6" x="96" y="168" style="fill:#000"/><rect width="6" height="6" x="108" y="168" style="fill:#000"/><rect width="6" height="6" x="120" y="168" style="fill:#000"/><rect width="6" height="6" x="138" y="168" style="fill:#000"/><rect width="6" height="6" x="144" y="168" style="fill:#000"/>
32
+ </svg>
@@ -1,54 +1,51 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RQRCode
2
4
  module Export
3
5
  module ANSI
4
- ##
6
+ #
5
7
  # Returns a string of the QR code as
6
8
  # characters writen with ANSI background set.
7
- #
8
- # Options:
9
+ #
10
+ # Options:
9
11
  # light: Foreground ("\033[47m")
10
- # dark: Background ANSI code. ("\033[47m")
12
+ # dark: Background ANSI code. ("\033[40m")
11
13
  # fill_character: The written character. (' ')
12
14
  # quiet_zone_size: (4)
13
15
  #
14
- def as_ansi(options={})
16
+ def as_ansi(options = {})
15
17
  options = {
16
18
  light: "\033[47m",
17
19
  dark: "\033[40m",
18
- fill_character: ' ',
20
+ fill_character: " ",
19
21
  quiet_zone_size: 4
20
22
  }.merge(options)
21
23
 
22
- normal = "\033[m"
24
+ normal = "\033[m\n"
23
25
  light = options.fetch(:light)
24
26
  dark = options.fetch(:dark)
25
27
  fill_character = options.fetch(:fill_character)
26
28
  quiet_zone_size = options.fetch(:quiet_zone_size)
29
+ output = []
27
30
 
28
- output = ''
29
-
30
- @modules.each_index do |c|
31
-
31
+ @qrcode.modules.each_index do |c|
32
32
  # start row with quiet zone
33
33
  row = light + fill_character * quiet_zone_size
34
34
  previous_dark = false
35
35
 
36
- @modules.each_index do |r|
37
- if is_dark(c, r)
38
- # dark
36
+ @qrcode.modules.each_index do |r|
37
+ if @qrcode.checked?(c, r)
39
38
  if previous_dark != true
40
39
  row << dark
41
40
  previous_dark = true
42
41
  end
43
- row << fill_character
44
- else
42
+ elsif previous_dark != false
45
43
  # light
46
- if previous_dark != false
47
- row << light
48
- previous_dark = false
49
- end
50
- row << fill_character
44
+ row << light
45
+ previous_dark = false
51
46
  end
47
+
48
+ row << fill_character
52
49
  end
53
50
 
54
51
  # add quiet zone
@@ -58,18 +55,18 @@ module RQRCode
58
55
  row << fill_character * quiet_zone_size
59
56
 
60
57
  # always end with reset and newline
61
- row << normal + "\n"
58
+ row << normal
62
59
 
63
60
  output << row
64
61
  end
65
62
 
66
63
  # count the row width so we can add quiet zone rows
67
- width = output.each_line.first.scan(fill_character).length
64
+ width = output.first.scan(fill_character).length
68
65
 
69
- quiet_row = light + fill_character * width + normal + "\n"
66
+ quiet_row = light + fill_character * width + normal
70
67
  quiet_rows = quiet_row * quiet_zone_size
71
68
 
72
- return quiet_rows + output + quiet_rows
69
+ quiet_rows + output.join + quiet_rows
73
70
  end
74
71
  end
75
72
  end
@@ -1,16 +1,18 @@
1
- # Use this module to HTML-ify the QR code if you just want the default HTML
1
+ # frozen_string_literal: true
2
+
2
3
  module RQRCode
3
4
  module Export
4
5
  module HTML
5
-
6
+ #
7
+ # Use this module to HTML-ify the QR code if you just want the default HTML
6
8
  def as_html
7
- ['<table>', rows.as_html, '</table>'].join
9
+ ["<table>", rows.as_html, "</table>"].join
8
10
  end
9
11
 
10
12
  private
11
13
 
12
14
  def rows
13
- Rows.new(self)
15
+ Rows.new(@qrcode)
14
16
  end
15
17
 
16
18
  class Rows < Struct.new(:qr)
@@ -25,7 +27,7 @@ module RQRCode
25
27
 
26
28
  class Row < Struct.new(:qr, :qr_module, :row_index)
27
29
  def as_html
28
- ['<tr>', cells.map(&:as_html).join, '</tr>'].join
30
+ ["<tr>", cells.map(&:as_html).join, "</tr>"].join
29
31
  end
30
32
 
31
33
  def cells
@@ -39,11 +41,7 @@ module RQRCode
39
41
  end
40
42
 
41
43
  def html_class
42
- dark? ? 'black' : 'white'
43
- end
44
-
45
- def dark?
46
- qr.dark?(row_index, col_index)
44
+ qr.checked?(row_index, col_index) ? "black" : "white"
47
45
  end
48
46
  end
49
47
  end
@@ -1,69 +1,81 @@
1
- require 'chunky_png'
1
+ # frozen_string_literal: true
2
+
3
+ require "chunky_png"
2
4
 
3
5
  # This class creates PNG files.
4
6
  # Code from: https://github.com/DCarper/rqrcode
5
7
  module RQRCode
6
8
  module Export
7
9
  module PNG
8
-
9
- # Render the PNG from the Qrcode.
10
+ # Render the PNG from the QR Code.
11
+ #
12
+ # Options:
13
+ # fill - Background ChunkyPNG::Color, defaults to 'white'
14
+ # color - Foreground ChunkyPNG::Color, defaults to 'black'
10
15
  #
11
- # There are two sizing algoritams.
16
+ # When option :file is supplied you can use the following ChunkyPNG constraints
17
+ # color_mode - The color mode to use. Use one of the ChunkyPNG::COLOR_* constants.
18
+ # (defaults to 'ChunkyPNG::COLOR_GRAYSCALE')
19
+ # bit_depth - The bit depth to use. This option is only used for indexed images.
20
+ # (defaults to 1 bit)
21
+ # interlace - Whether to use interlacing (true or false).
22
+ # (defaults to ChunkyPNG default)
23
+ # compression - The compression level for Zlib. This can be a value between 0 and 9, or a
24
+ # Zlib constant like Zlib::BEST_COMPRESSION
25
+ # (defaults to ChunkyPNG default)
26
+ #
27
+ # There are two sizing algorithms.
12
28
  #
13
29
  # - Original that can result in blurry and hard to scan images
14
30
  # - Google's Chart API inspired sizing that resizes the module size to fit within the given image size.
15
- #
16
- # The Googleis one will be used when no options are given or when the new size option is used.
17
31
  #
18
- # Options:
19
- # fill - Background ChunkyPNG::Color, defaults to 'white'
20
- # color - Foreground ChunkyPNG::Color, defaults to 'black'
32
+ # The Googleis one will be used when no options are given or when the new size option is used.
21
33
  #
22
- # *Googleis*
23
- # size - Total size of PNG in pixels. The module size is calculated so it fits. (defaults to 90)
24
- # border_modules - Width of white border around in modules. (defaults to 4).
34
+ # *Google*
35
+ # size - Total size of PNG in pixels. The module size is calculated so it fits.
36
+ # (defaults to 120)
37
+ # border_modules - Width of white border around in modules.
38
+ # (defaults to 4).
25
39
  #
26
40
  # -- DONT USE border_modules OPTION UNLESS YOU KNOW ABOUT THE QUIET ZONE NEEDS OF QR CODES --
27
41
  #
28
42
  # *Original*
29
43
  # module_px_size - Image size, in pixels.
30
- # border - Border thickness, in pixels
44
+ # border - Border thickness, in pixels
31
45
  #
32
46
  # It first creates an image where 1px = 1 module, then resizes.
33
- # Defaults to 90x90 pixels, customizable by option.
47
+ # Defaults to 120x120 pixels, customizable by option.
34
48
  #
35
49
  def as_png(options = {})
36
-
37
50
  default_img_options = {
38
- :resize_gte_to => false,
39
- :resize_exactly_to => false,
40
- :fill => 'white',
41
- :color => 'black',
42
- :size => 120,
43
- :border_modules => 4,
44
- :file => false,
45
- :module_px_size => 6
51
+ bit_depth: 1,
52
+ border_modules: 4,
53
+ color_mode: ChunkyPNG::COLOR_GRAYSCALE,
54
+ color: "black",
55
+ file: false,
56
+ fill: "white",
57
+ module_px_size: 6,
58
+ resize_exactly_to: false,
59
+ resize_gte_to: false,
60
+ size: 120
46
61
  }
47
-
48
- googleis = options.length == 0 || (options[:size] != nil)
49
-
50
- options = default_img_options.merge(options) # reverse_merge
51
62
 
52
- fill = ChunkyPNG::Color(options[:fill])
53
- color = ChunkyPNG::Color(options[:color])
63
+ googleis = options.length == 0 || !options[:size].nil?
64
+ options = default_img_options.merge(options) # reverse_merge
65
+ fill = ChunkyPNG::Color(options[:fill])
66
+ color = ChunkyPNG::Color(options[:color])
54
67
  output_file = options[:file]
55
-
56
68
  module_px_size = nil
57
69
  border_px = nil
58
70
  png = nil
59
-
71
+
60
72
  if googleis
61
73
  total_image_size = options[:size]
62
74
  border_modules = options[:border_modules]
63
75
 
64
- module_px_size = (total_image_size.to_f / (self.module_count + 2 * border_modules).to_f).floor.to_i
76
+ module_px_size = (total_image_size.to_f / (@qrcode.module_count + 2 * border_modules).to_f).floor.to_i
65
77
 
66
- img_size = module_px_size * self.module_count
78
+ img_size = module_px_size * @qrcode.module_count
67
79
 
68
80
  remaining = total_image_size - img_size
69
81
  border_px = (remaining / 2.0).floor.to_i
@@ -73,43 +85,48 @@ module RQRCode
73
85
  border = options[:border_modules]
74
86
  total_border = border * 2
75
87
  module_px_size = if options[:resize_gte_to]
76
- (options[:resize_gte_to].to_f / (self.module_count + total_border).to_f).ceil.to_i
88
+ (options[:resize_gte_to].to_f / (@qrcode.module_count + total_border).to_f).ceil.to_i
77
89
  else
78
90
  options[:module_px_size]
79
91
  end
80
- border_px = border * module_px_size
92
+ border_px = border * module_px_size
81
93
  total_border_px = border_px * 2
82
94
  resize_to = options[:resize_exactly_to]
83
95
 
84
- img_size = module_px_size * self.module_count
96
+ img_size = module_px_size * @qrcode.module_count
85
97
  total_img_size = img_size + total_border_px
86
98
 
87
99
  png = ChunkyPNG::Image.new(total_img_size, total_img_size, fill)
88
100
  end
89
101
 
90
- self.modules.each_index do |x|
91
- self.modules.each_index do |y|
92
- if self.dark?(x, y)
102
+ @qrcode.modules.each_index do |x|
103
+ @qrcode.modules.each_index do |y|
104
+ if @qrcode.checked?(x, y)
93
105
  (0...module_px_size).each do |i|
94
106
  (0...module_px_size).each do |j|
95
- png[(y * module_px_size) + border_px + j , (x * module_px_size) + border_px + i] = color
107
+ png[(y * module_px_size) + border_px + j, (x * module_px_size) + border_px + i] = color
96
108
  end
97
109
  end
98
110
  end
99
111
  end
100
112
  end
101
-
113
+
102
114
  if !googleis && resize_to
103
- png = png.resize(resize_to, resize_to)
115
+ png = png.resize(resize_to, resize_to)
104
116
  end
105
117
 
106
-
107
118
  if output_file
108
- png.save(output_file,{ :color_mode => ChunkyPNG::COLOR_GRAYSCALE, :bit_depth =>1})
119
+ constraints = {
120
+ color_mode: options[:color_mode],
121
+ bit_depth: options[:bit_depth]
122
+ }
123
+ constraints[:interlace] = options[:interlace] if options.has_key?(:interlace)
124
+ constraints[:compression] = options[:compression] if options.has_key?(:compression)
125
+ png.save(output_file, constraints)
109
126
  end
127
+
110
128
  png
111
129
  end
112
-
113
130
  end
114
131
  end
115
132
  end