barby 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/lib/barby/outputter/html_outputter.rb +88 -0
- data/lib/barby/version.rb +1 -1
- metadata +5 -34
- data/vendor/rqrcode/CHANGELOG +0 -34
- data/vendor/rqrcode/COPYING +0 -19
- data/vendor/rqrcode/README +0 -96
- data/vendor/rqrcode/Rakefile +0 -63
- data/vendor/rqrcode/lib/rqrcode.rb +0 -13
- data/vendor/rqrcode/lib/rqrcode/core_ext.rb +0 -5
- data/vendor/rqrcode/lib/rqrcode/core_ext/array.rb +0 -5
- data/vendor/rqrcode/lib/rqrcode/core_ext/array/behavior.rb +0 -9
- data/vendor/rqrcode/lib/rqrcode/core_ext/integer.rb +0 -5
- data/vendor/rqrcode/lib/rqrcode/core_ext/integer/bitwise.rb +0 -11
- data/vendor/rqrcode/lib/rqrcode/qrcode.rb +0 -4
- data/vendor/rqrcode/lib/rqrcode/qrcode/qr_8bit_byte.rb +0 -37
- data/vendor/rqrcode/lib/rqrcode/qrcode/qr_bit_buffer.rb +0 -56
- data/vendor/rqrcode/lib/rqrcode/qrcode/qr_code.rb +0 -423
- data/vendor/rqrcode/lib/rqrcode/qrcode/qr_math.rb +0 -63
- data/vendor/rqrcode/lib/rqrcode/qrcode/qr_polynomial.rb +0 -78
- data/vendor/rqrcode/lib/rqrcode/qrcode/qr_rs_block.rb +0 -313
- data/vendor/rqrcode/lib/rqrcode/qrcode/qr_util.rb +0 -254
- data/vendor/rqrcode/test/runtest.rb +0 -98
- data/vendor/rqrcode/test/test_data.rb +0 -21
data/CHANGELOG
CHANGED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'barby/outputter'
|
2
|
+
|
3
|
+
module Barby
|
4
|
+
|
5
|
+
# Outputs an HTML representation of the barcode.
|
6
|
+
#
|
7
|
+
# Registers to_html
|
8
|
+
#
|
9
|
+
# Allowed options include.
|
10
|
+
# :width - Applied to parent element's style attribute. Default 100.
|
11
|
+
# :height - Applied to parent element's style attribute. Default 100.
|
12
|
+
# :css - Include Barby::HtmlOutputter.css in output's style tag. If you pass false
|
13
|
+
# you can include the output of Barby::HtmlOutputter.css in single place like
|
14
|
+
# your own stylesheet on once on the page. Default true.
|
15
|
+
# :parent_style - Include inline style for things like width and height on parent element.
|
16
|
+
# Useful if you want to style these attributes elsewhere globally. Default true.
|
17
|
+
class HtmlOutputter < Outputter
|
18
|
+
|
19
|
+
register :to_html
|
20
|
+
|
21
|
+
def self.css
|
22
|
+
<<-CSS
|
23
|
+
table.barby_code {
|
24
|
+
border: 0 none transparent !important;
|
25
|
+
border-collapse: collapse !important;
|
26
|
+
}
|
27
|
+
table.barby_code tr.barby_row {
|
28
|
+
border: 0 none transparent !important;
|
29
|
+
border-collapse: collapse !important;
|
30
|
+
margin: 0 !important;
|
31
|
+
padding: 0 !important;
|
32
|
+
}
|
33
|
+
table.barby_code tr.barby_row td { border: 0 none transparent !important; }
|
34
|
+
table.barby_code tr.barby_row td.barby_black { background-color: black !important; }
|
35
|
+
table.barby_code tr.barby_row td.barby_white { background-color: white !important; }
|
36
|
+
CSS
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_html(options={})
|
40
|
+
default_options = {:width => 100, :height => 100, :css => true, :parent_style => :true}
|
41
|
+
options = default_options.merge(options)
|
42
|
+
elements = if barcode.two_dimensional?
|
43
|
+
booleans.map do |bools|
|
44
|
+
line_to_elements_row(bools, options)
|
45
|
+
end.join("\n")
|
46
|
+
else
|
47
|
+
line_to_elements_row(booleans, options)
|
48
|
+
end
|
49
|
+
html = %|<#{parent_element} class="barby_code" #{parent_style_attribute(options)}>\n#{elements}\n</#{parent_element}>|
|
50
|
+
options[:css] ? "<style>#{self.class.css}</style>\n#{html}" : html
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def line_to_elements_row(bools, options)
|
57
|
+
elements = bools.map{ |b| b ? black_tag : white_tag }.join
|
58
|
+
Array(%|<#{row_element} class="barby_row">#{elements}</#{row_element}>|)
|
59
|
+
end
|
60
|
+
|
61
|
+
def black_tag
|
62
|
+
'<td class="barby_black"></td>'
|
63
|
+
end
|
64
|
+
|
65
|
+
def white_tag
|
66
|
+
'<td class="barby_white"></td>'
|
67
|
+
end
|
68
|
+
|
69
|
+
def row_element
|
70
|
+
'tr'
|
71
|
+
end
|
72
|
+
|
73
|
+
def parent_element
|
74
|
+
'table'
|
75
|
+
end
|
76
|
+
|
77
|
+
def parent_style_attribute(options)
|
78
|
+
return unless options[:parent_style]
|
79
|
+
s = ''
|
80
|
+
s << "width: #{options[:width]}px; " if options[:width]
|
81
|
+
s << "height: #{options[:height]}px; " if options[:height]
|
82
|
+
s.strip!
|
83
|
+
s.empty? ? nil : %|style="#{s}"|
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
data/lib/barby/version.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 4
|
8
|
-
- 3
|
9
|
-
version: 0.4.3
|
4
|
+
prerelease:
|
5
|
+
version: 0.4.4
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Tore Darell
|
@@ -14,8 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
18
|
-
default_executable:
|
13
|
+
date: 2011-08-13 00:00:00 Z
|
19
14
|
dependencies: []
|
20
15
|
|
21
16
|
description: Barby creates barcodes.
|
@@ -47,6 +42,7 @@ files:
|
|
47
42
|
- lib/barby/barcode.rb
|
48
43
|
- lib/barby/outputter/ascii_outputter.rb
|
49
44
|
- lib/barby/outputter/cairo_outputter.rb
|
45
|
+
- lib/barby/outputter/html_outputter.rb
|
50
46
|
- lib/barby/outputter/pdfwriter_outputter.rb
|
51
47
|
- lib/barby/outputter/png_outputter.rb
|
52
48
|
- lib/barby/outputter/prawn_outputter.rb
|
@@ -58,28 +54,7 @@ files:
|
|
58
54
|
- lib/barby.rb
|
59
55
|
- vendor/Pdf417lib-java-0.91/lib/Pdf417lib.jar
|
60
56
|
- vendor/Pdf417lib-java-0.91/lib/Pdf417lib.java
|
61
|
-
- vendor/rqrcode/CHANGELOG
|
62
|
-
- vendor/rqrcode/COPYING
|
63
|
-
- vendor/rqrcode/lib/rqrcode/core_ext/array/behavior.rb
|
64
|
-
- vendor/rqrcode/lib/rqrcode/core_ext/array.rb
|
65
|
-
- vendor/rqrcode/lib/rqrcode/core_ext/integer/bitwise.rb
|
66
|
-
- vendor/rqrcode/lib/rqrcode/core_ext/integer.rb
|
67
|
-
- vendor/rqrcode/lib/rqrcode/core_ext.rb
|
68
|
-
- vendor/rqrcode/lib/rqrcode/qrcode/qr_8bit_byte.rb
|
69
|
-
- vendor/rqrcode/lib/rqrcode/qrcode/qr_bit_buffer.rb
|
70
|
-
- vendor/rqrcode/lib/rqrcode/qrcode/qr_code.rb
|
71
|
-
- vendor/rqrcode/lib/rqrcode/qrcode/qr_math.rb
|
72
|
-
- vendor/rqrcode/lib/rqrcode/qrcode/qr_polynomial.rb
|
73
|
-
- vendor/rqrcode/lib/rqrcode/qrcode/qr_rs_block.rb
|
74
|
-
- vendor/rqrcode/lib/rqrcode/qrcode/qr_util.rb
|
75
|
-
- vendor/rqrcode/lib/rqrcode/qrcode.rb
|
76
|
-
- vendor/rqrcode/lib/rqrcode.rb
|
77
|
-
- vendor/rqrcode/Rakefile
|
78
|
-
- vendor/rqrcode/README
|
79
|
-
- vendor/rqrcode/test/runtest.rb
|
80
|
-
- vendor/rqrcode/test/test_data.rb
|
81
57
|
- bin/barby
|
82
|
-
has_rdoc: true
|
83
58
|
homepage: http://toretore.github.com/barby
|
84
59
|
licenses: []
|
85
60
|
|
@@ -93,21 +68,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
68
|
requirements:
|
94
69
|
- - ">="
|
95
70
|
- !ruby/object:Gem::Version
|
96
|
-
segments:
|
97
|
-
- 0
|
98
71
|
version: "0"
|
99
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
73
|
none: false
|
101
74
|
requirements:
|
102
75
|
- - ">="
|
103
76
|
- !ruby/object:Gem::Version
|
104
|
-
segments:
|
105
|
-
- 0
|
106
77
|
version: "0"
|
107
78
|
requirements: []
|
108
79
|
|
109
80
|
rubyforge_project: barby
|
110
|
-
rubygems_version: 1.
|
81
|
+
rubygems_version: 1.8.5
|
111
82
|
signing_key:
|
112
83
|
specification_version: 3
|
113
84
|
summary: The Ruby barcode generator
|
data/vendor/rqrcode/CHANGELOG
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
*0.3.3* (Feb 1st, 2011)
|
2
|
-
|
3
|
-
* check to see if the level is valid
|
4
|
-
* fix for 'rszf' bug by [Rob la Lau https://github.com/ohreally]
|
5
|
-
|
6
|
-
*0.3.2* (Mar 15th, 2009)
|
7
|
-
|
8
|
-
* Ruby 1.9 fixes by [Tore Darell http://tore.darell.no] [Chris Mowforth http://blog.99th.st]
|
9
|
-
|
10
|
-
*0.3.1* (Nov 24th, 2008)
|
11
|
-
|
12
|
-
* expanded RS block table to QRcode version 40 [Vladislav Gorodetskiy]
|
13
|
-
|
14
|
-
*0.3.0* (Feb 28th, 2008)
|
15
|
-
|
16
|
-
* added more documentation
|
17
|
-
* changed to_console to to_s (what was I thinking)
|
18
|
-
* add more tests
|
19
|
-
|
20
|
-
*0.2.1* (Feb 24th, 2008)
|
21
|
-
|
22
|
-
* small changes to rakefile and readme
|
23
|
-
* small change to to_console method
|
24
|
-
* make console_count method private (use modules.size instead)
|
25
|
-
* slowy updating rdocs
|
26
|
-
|
27
|
-
*0.2.0* (Feb 23rd, 2008)
|
28
|
-
|
29
|
-
* Split files up [DR]
|
30
|
-
* added rdoc comment ... more to do there
|
31
|
-
|
32
|
-
*0.1.0* (Feb 22rd, 2008)
|
33
|
-
|
34
|
-
* Initial Release [DR]
|
data/vendor/rqrcode/COPYING
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
Copyright (c) 2008 Duncan Robertson
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
of this software and associated documentation files (the "Software"), to
|
5
|
-
deal in the Software without restriction, including without limitation the
|
6
|
-
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7
|
-
sell copies of the Software, and to permit persons to whom the Software is
|
8
|
-
furnished to do so, subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
11
|
-
all copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
16
|
-
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
|
-
|
data/vendor/rqrcode/README
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
== rQRCode, Encode QRCodes
|
2
|
-
|
3
|
-
rQRCode is a library for encoding QR Codes in Ruby. It has a simple interface with all the standard qrcode options. It was adapted from the Javascript library by Kazuhiko Arase.
|
4
|
-
|
5
|
-
== An Overview
|
6
|
-
|
7
|
-
Let's clear up some rQRCode stuff.
|
8
|
-
|
9
|
-
# rQRCode is a *standalone library*. It requires no other libraries. Just Ruby!
|
10
|
-
# It is an encoding library. You can't decode QR codes with it.
|
11
|
-
# The interface is simple and assumes you just want to encode a string into a QR code
|
12
|
-
# QR code is trademarked by Denso Wave inc
|
13
|
-
|
14
|
-
== Resources
|
15
|
-
|
16
|
-
wikipedia:: http://en.wikipedia.org/wiki/QR_Code
|
17
|
-
Denso-Wave website:: http://www.denso-wave.com/qrcode/index-e.html
|
18
|
-
kaywa:: http://qrcode.kaywa.com
|
19
|
-
|
20
|
-
|
21
|
-
== Installing
|
22
|
-
|
23
|
-
You may get the latest stable version from Rubyforge.
|
24
|
-
|
25
|
-
$ gem install rqrcode
|
26
|
-
|
27
|
-
You can also get the source from http://github.com/whomwah/rqrcode/tree/master
|
28
|
-
|
29
|
-
$ git clone git://github.com/whomwah/rqrcode.git
|
30
|
-
|
31
|
-
|
32
|
-
=== Loading rQRCode Itself
|
33
|
-
|
34
|
-
You have installed the gem already, yeah?
|
35
|
-
|
36
|
-
require 'rubygems'
|
37
|
-
require 'rqrcode'
|
38
|
-
|
39
|
-
=== Simple QRCode generation to screen
|
40
|
-
|
41
|
-
qr = RQRCode::QRCode.new( 'my string to generate', :size => 4, :level => :h )
|
42
|
-
puts qr.to_s
|
43
|
-
#
|
44
|
-
# Prints:
|
45
|
-
# xxxxxxx x x x x x xx xxxxxxx
|
46
|
-
# x x xxx xxxxxx xxx x x
|
47
|
-
# x xxx x xxxxx x xx x xxx x
|
48
|
-
# ... etc
|
49
|
-
|
50
|
-
=== Simple QRCode generation to view (RubyOnRails)
|
51
|
-
|
52
|
-
<b>Controller:</b>
|
53
|
-
@qr = RQRCode::QRCode.new( 'my string to generate', :size => 4, :level => :h )
|
54
|
-
|
55
|
-
<b>View: (minimal styling added)</b>
|
56
|
-
<style type="text/css">
|
57
|
-
table {
|
58
|
-
border-width: 0;
|
59
|
-
border-style: none;
|
60
|
-
border-color: #0000ff;
|
61
|
-
border-collapse: collapse;
|
62
|
-
}
|
63
|
-
td {
|
64
|
-
border-width: 0;
|
65
|
-
border-style: none;
|
66
|
-
border-color: #0000ff;
|
67
|
-
border-collapse: collapse;
|
68
|
-
padding: 0;
|
69
|
-
margin: 0;
|
70
|
-
width: 10px;
|
71
|
-
height: 10px;
|
72
|
-
}
|
73
|
-
td.black { background-color: #000; }
|
74
|
-
td.white { background-color: #fff; }
|
75
|
-
</style>
|
76
|
-
|
77
|
-
<table>
|
78
|
-
<% @qr.modules.each_index do |x| %>
|
79
|
-
<tr>
|
80
|
-
<% @qr.modules.each_index do |y| %>
|
81
|
-
<% if @qr.is_dark(x,y) %>
|
82
|
-
<td class="black"/>
|
83
|
-
<% else %>
|
84
|
-
<td class="white"/>
|
85
|
-
<% end %>
|
86
|
-
<% end %>
|
87
|
-
</tr>
|
88
|
-
<% end %>
|
89
|
-
</table>
|
90
|
-
|
91
|
-
== Contact
|
92
|
-
|
93
|
-
Author:: Duncan Robertson
|
94
|
-
Email:: duncan@whomwah.com
|
95
|
-
Home Page:: http://whomwah.com
|
96
|
-
License:: MIT Licence (http://www.opensource.org/licenses/mit-license.html)
|
data/vendor/rqrcode/Rakefile
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'rake/clean'
|
4
|
-
require 'rake/gempackagetask'
|
5
|
-
require 'rake/rdoctask'
|
6
|
-
require 'rake/testtask'
|
7
|
-
|
8
|
-
NAME = "rqrcode"
|
9
|
-
VERS = "0.3.3"
|
10
|
-
CLEAN.include ['pkg', 'rdoc']
|
11
|
-
|
12
|
-
spec = Gem::Specification.new do |s|
|
13
|
-
s.name = NAME
|
14
|
-
s.version = VERS
|
15
|
-
s.author = "Duncan Robertson"
|
16
|
-
s.email = "duncan@whomwah.com"
|
17
|
-
s.homepage = "http://whomwah.github.com/rqrcode/"
|
18
|
-
s.platform = Gem::Platform::RUBY
|
19
|
-
s.summary = "A library to encode QR Codes"
|
20
|
-
s.rubyforge_project = NAME
|
21
|
-
s.description = <<EOF
|
22
|
-
rQRCode is a library for encoding QR Codes. The simple
|
23
|
-
interface allows you to create QR Code data structures
|
24
|
-
ready to be displayed in the way you choose.
|
25
|
-
EOF
|
26
|
-
s.files = FileList["lib/**/*", "test/*"].exclude("rdoc").to_a
|
27
|
-
s.require_path = "lib"
|
28
|
-
s.has_rdoc = true
|
29
|
-
s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"]
|
30
|
-
s.test_file = "test/runtest.rb"
|
31
|
-
end
|
32
|
-
|
33
|
-
task :build_package => [:repackage]
|
34
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
35
|
-
#pkg.need_zip = true
|
36
|
-
#pkg.need_tar = true
|
37
|
-
pkg.gem_spec = spec
|
38
|
-
end
|
39
|
-
|
40
|
-
desc "Default: run unit tests."
|
41
|
-
task :default => :test
|
42
|
-
|
43
|
-
desc "Run all the tests"
|
44
|
-
Rake::TestTask.new(:test) do |t|
|
45
|
-
t.libs << "lib"
|
46
|
-
t.pattern = "test/runtest.rb"
|
47
|
-
t.verbose = true
|
48
|
-
end
|
49
|
-
|
50
|
-
desc "Generate documentation for the library"
|
51
|
-
Rake::RDocTask.new("rdoc") { |rdoc|
|
52
|
-
rdoc.rdoc_dir = 'rdoc'
|
53
|
-
rdoc.title = "rQRCode Documentation"
|
54
|
-
rdoc.template = "~/bin/jamis.rb"
|
55
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
56
|
-
rdoc.main = "README"
|
57
|
-
rdoc.rdoc_files.include("README", "CHANGELOG", "COPYING", 'lib/**/*.rb')
|
58
|
-
}
|
59
|
-
|
60
|
-
desc "rdoc to rubyforge"
|
61
|
-
task :rubyforge => [:rdoc] do
|
62
|
-
sh %{/usr/bin/scp -r -p rdoc/* rubyforge:/var/www/gforge-projects/rqrcode}
|
63
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
#--
|
4
|
-
# Copyright 2008 by Duncan Robertson (duncan@whomwah.com).
|
5
|
-
# All rights reserved.
|
6
|
-
|
7
|
-
# Permission is granted for use, copying, modification, distribution,
|
8
|
-
# and distribution of modified versions of this work as long as the
|
9
|
-
# above copyright notice is included.
|
10
|
-
#++
|
11
|
-
|
12
|
-
require "rqrcode/core_ext"
|
13
|
-
require "rqrcode/qrcode"
|