rqrcode-with-patches 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9965f2b7c2cbdd55f9ec9d1dda4c3f43a97e8d21
4
+ data.tar.gz: 903a0b3a982b79fee602913cd43da9b9f58ecf86
5
+ SHA512:
6
+ metadata.gz: 551a2a6cf4b680b1dbde3a38d8c4d0cf464f3be6824df37bcb71e705e956edca7e58e9a267e865a7734f63db560c923e10111899f9ca22fe4533cc9d7cf4ca98
7
+ data.tar.gz: fd96f3f7bad553f7ebca7f8cbc22e072607dca9304932a66cd8ad0990a0a7d3024e8c1bebb5d3721d7a14b3731b33a7bee1e8e4e626027e1615693fa8b23b0ac
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ *0.5.4* (Nov 11th, 2013)
2
+
3
+ * Added as_html, Big thanks to Jon Evans!
4
+
1
5
  *0.4.2* (Sep 1st, 2011)
2
6
 
3
7
  * Proper namespace CoreExtensions and only extend when needed [https://github.com/metaskills]
data/README.md CHANGED
@@ -84,6 +84,12 @@ td.black { background-color: #000; }
84
84
  td.white { background-color: #fff; }
85
85
  </style>
86
86
 
87
+ <%= raw @qr.as_html %>
88
+ ```
89
+
90
+ If you want to generate the HTML manually for customization, you can start with the following:
91
+
92
+ ```erb
87
93
  <table>
88
94
  <% @qr.modules.each_index do |x| %>
89
95
  <tr>
@@ -152,4 +158,4 @@ Special thanks to the following people for submitting patches:
152
158
 
153
159
  ## Copyright
154
160
 
155
- MIT Licence (http://www.opensource.org/licenses/mit-license.html)
161
+ MIT License (http://www.opensource.org/licenses/mit-license.html)
@@ -13,3 +13,4 @@ require "rqrcode/core_ext"
13
13
  require "rqrcode/qrcode"
14
14
  require 'rqrcode/export/png'
15
15
  require 'rqrcode/export/svg'
16
+ require 'rqrcode/export/html'
@@ -0,0 +1,53 @@
1
+ # Use this module to HTML-ify the QR code if you just want the default HTML
2
+ module RQRCode
3
+ module Export
4
+ module HTML
5
+
6
+ def as_html
7
+ ['<table>', rows.as_html, '</table>'].join
8
+ end
9
+
10
+ private
11
+
12
+ def rows
13
+ Rows.new(self)
14
+ end
15
+
16
+ class Rows < Struct.new(:qr)
17
+ def as_html
18
+ rows.map(&:as_html).join
19
+ end
20
+
21
+ def rows
22
+ qr.modules.each_with_index.map { |qr_module, row_index| Row.new(qr, qr_module, row_index) }
23
+ end
24
+ end
25
+
26
+ class Row < Struct.new(:qr, :qr_module, :row_index)
27
+ def as_html
28
+ ['<tr>', cells.map(&:as_html).join, '</tr>'].join
29
+ end
30
+
31
+ def cells
32
+ qr.modules.each_with_index.map { |qr_module, col_index| Cell.new(qr, col_index, row_index) }
33
+ end
34
+ end
35
+
36
+ class Cell < Struct.new(:qr, :col_index, :row_index)
37
+ def as_html
38
+ "<td class=\"#{html_class}\"></td>"
39
+ end
40
+
41
+ def html_class
42
+ dark? ? 'black' : 'white'
43
+ end
44
+
45
+ def dark?
46
+ qr.dark?(row_index, col_index)
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ RQRCode::QRCode.send :include, RQRCode::Export::HTML
@@ -1,3 +1,3 @@
1
1
  module RQRCode
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
@@ -3,6 +3,7 @@ require 'minitest/autorun'
3
3
 
4
4
  require 'rqrcode/export/png'
5
5
  require 'rqrcode/export/svg'
6
+ require 'rqrcode/export/html'
6
7
 
7
8
  # fix for require_relative in < 1.9
8
9
  unless Kernel.respond_to?(:require_relative)
@@ -18,8 +19,8 @@ require_relative "../lib/rqrcode"
18
19
  describe :QRCodeExportTest do
19
20
  # require_relative "data"
20
21
 
21
- [:svg, :png].each do |ext|
22
- it "must respond_to to #{ext}" do
22
+ [:svg, :png, :html].each do |ext|
23
+ it "must respond_to #{ext}" do
23
24
  RQRCode::QRCode.new('x').must_respond_to :"as_#{ext}"
24
25
  end
25
26
  end
@@ -29,8 +30,11 @@ describe :QRCodeExportTest do
29
30
  end
30
31
 
31
32
  it "must export to svg file" do
32
- RQRCode::QRCode.new('png').as_svg.must_match(/<\/svg>/)
33
+ RQRCode::QRCode.new('svg').as_svg.must_match(/<\/svg>/)
33
34
  end
34
35
 
36
+ it "must export to html" do
37
+ RQRCode::QRCode.new('html').as_html.must_match(/<table>.+<\/table>/)
38
+ end
35
39
 
36
40
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rqrcode-with-patches
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
5
- prerelease:
4
+ version: 0.5.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bjorn Blomqvist and others
@@ -10,63 +9,54 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-05-15 00:00:00.000000000 Z
12
+ date: 2013-11-11 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: chunky_png
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rake
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - '>='
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - '>='
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0'
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: bundler
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - '>='
53
47
  - !ruby/object:Gem::Version
54
48
  version: 1.0.0
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ! '>='
53
+ - - '>='
61
54
  - !ruby/object:Gem::Version
62
55
  version: 1.0.0
63
- description: ! 'rQRCode is a library for encoding QR Codes. The simple
64
-
56
+ description: |
57
+ rQRCode is a library for encoding QR Codes. The simple
65
58
  interface allows you to create QR Code data structures
66
-
67
59
  ready to be displayed in the way you choose.
68
-
69
- '
70
60
  email:
71
61
  - darwin@bits2life.com
72
62
  executables: []
@@ -88,6 +78,7 @@ files:
88
78
  - lib/rqrcode/core_ext/array/behavior.rb
89
79
  - lib/rqrcode/core_ext/integer.rb
90
80
  - lib/rqrcode/core_ext/integer/bitwise.rb
81
+ - lib/rqrcode/export/html.rb
91
82
  - lib/rqrcode/export/png.rb
92
83
  - lib/rqrcode/export/svg.rb
93
84
  - lib/rqrcode/qrcode.rb
@@ -106,30 +97,28 @@ files:
106
97
  - test/test_rqrcode_export.rb
107
98
  homepage: https://github.com/bjornblomqvist/rqrcode
108
99
  licenses: []
100
+ metadata: {}
109
101
  post_install_message:
110
102
  rdoc_options: []
111
103
  require_paths:
112
104
  - lib
113
105
  required_ruby_version: !ruby/object:Gem::Requirement
114
- none: false
115
106
  requirements:
116
- - - ! '>='
107
+ - - '>='
117
108
  - !ruby/object:Gem::Version
118
109
  version: '0'
119
110
  required_rubygems_version: !ruby/object:Gem::Requirement
120
- none: false
121
111
  requirements:
122
- - - ! '>='
112
+ - - '>='
123
113
  - !ruby/object:Gem::Version
124
114
  version: 1.3.6
125
115
  requirements: []
126
116
  rubyforge_project:
127
- rubygems_version: 1.8.24
117
+ rubygems_version: 2.0.6
128
118
  signing_key:
129
- specification_version: 3
119
+ specification_version: 4
130
120
  summary: A library to encode QR Codes
131
121
  test_files:
132
122
  - test/data.rb
133
123
  - test/test_rqrcode.rb
134
124
  - test/test_rqrcode_export.rb
135
- has_rdoc: true