semacode-ruby19 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,29 @@
1
+ #ifndef _SEMACODE_H
2
+ #define _SEMACODE_H
3
+
4
+ #include <strings.h>
5
+ #include "iec16022ecc200.h"
6
+
7
+ typedef struct semacode_t {
8
+ int width;
9
+ int height;
10
+ int raw_encoded_length;
11
+ int symbol_capacity;
12
+ int ecc_bytes;
13
+ char *encoding;
14
+ char *data;
15
+ } semacode_t;
16
+
17
+ #ifndef RB_STRING_VALUE
18
+ #define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s)))
19
+ #endif
20
+
21
+ #ifndef StringValuePtr
22
+ #define StringValuePtr(s) RSTRING_LEN(RB_STRING_VALUE(s))
23
+ #endif
24
+
25
+ #ifndef StringValueLen
26
+ #define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s))
27
+ #endif
28
+
29
+ #endif
@@ -0,0 +1 @@
1
+ require 'semacode_native'
@@ -0,0 +1,91 @@
1
+ require 'rubygems'
2
+ require 'semacode'
3
+
4
+ def show_as_text(semacode)
5
+ show = "\n"
6
+ for row in semacode.data
7
+ show += "\t"
8
+ for column in row
9
+ if column
10
+ show += "1"
11
+ else
12
+ show += "0"
13
+ end
14
+ end
15
+ show += "\n"
16
+ end
17
+ show += "\n"
18
+ end
19
+
20
+ def show_as_html(cell_size, prefix, semacode)
21
+ show = ""
22
+ css =<<CSS
23
+ .row { clear: both; }
24
+ .black
25
+ {
26
+ background: black;
27
+ color: white;
28
+ width: #{cell_size}px;
29
+ height: #{cell_size}px;
30
+ padding: 0px;
31
+ margin: 0px;
32
+ border: 0px;
33
+ float: left;
34
+ display: block;
35
+ }
36
+
37
+ .white
38
+ {
39
+ background: white;
40
+ color: black;
41
+ width: #{cell_size}px;
42
+ height: #{cell_size}px;
43
+ padding: 0px;
44
+ margin: 0px;
45
+ border: 0px;
46
+ display: block;
47
+ float: left;
48
+ }
49
+ CSS
50
+ show += "<html><head><style>\n<!-- \n#{css} \n-->\n</style><body>"
51
+ show += "<pre>#{prefix}</pre>"
52
+ for row in semacode.data
53
+ show += "\t<div class='row'>\n"
54
+ for column in row
55
+ if column
56
+ show += "\t\t<div class='black'></div>\n"
57
+ else
58
+ show += "\t\t<div class='white'></div>\n"
59
+ end
60
+ end
61
+ show += "\t</div>\n"
62
+ end
63
+ show += "</body></html>\n"
64
+ end
65
+
66
+ def prelude
67
+ show = "\nSemacodes in Ruby\n\n"
68
+
69
+ semacode = DataMatrix::Encoder.new("http://sohne.net/projects/semafox")
70
+
71
+ show += "width #{semacode.width}\n"
72
+ show += "height #{semacode.height}\n"
73
+ show += "raw_encoded_length #{semacode.raw_encoded_length}\n"
74
+ show += "symbol_size #{semacode.symbol_size}\n"
75
+ show += "ecc_bytes #{semacode.ecc_bytes}\n"
76
+
77
+
78
+ show += "a text representation of a semacode\n\n"
79
+
80
+ text = show + show_as_text(semacode)
81
+
82
+ semacode.encode("http://sohne.net/")
83
+
84
+ html = show_as_html(8, text, semacode)
85
+ end
86
+
87
+ semacode = DataMatrix::Encoder.new "http://www.ruby-lang.org"
88
+ puts show_as_text(semacode)
89
+ # comment line above and uncomment next line
90
+ # to generate HTML instead of plain text
91
+ # puts prelude
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: semacode-ruby19
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.4
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Guido Sohne
9
+ - Tore Darell
10
+ autorequire: semacode
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-08-02 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 0.7.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: 0.7.0
31
+ description: ! " This Ruby extension implements a DataMatrix encoder for Ruby. It
32
+ is typically\n used to create semacodes, which are barcodes, that contain URLs.
33
+ This encoder\n does not create image files or visual representations of the semacode.
34
+ This is\n because it can be used for more than creating images, such as rendering\n
35
+ \ semacodes to HTML, SVG, PDF or even stored in a database or file for later\n use.\n\n
36
+ \ Ruby 1.9 compatibility added by Tore Darell <toredarell@gmail.com>.\n"
37
+ email: guido@sohne.net
38
+ executables: []
39
+ extensions:
40
+ - ext/extconf.rb
41
+ extra_rdoc_files:
42
+ - README
43
+ files:
44
+ - lib/semacode.rb
45
+ - ext/extconf.rb
46
+ - ext/iec16022ecc200.c
47
+ - ext/reedsol.c
48
+ - ext/semacode.c
49
+ - ext/iec16022ecc200.h
50
+ - ext/reedsol.h
51
+ - ext/semacode.h
52
+ - tests/test.rb
53
+ - README
54
+ - CHANGELOG
55
+ - Rakefile
56
+ homepage: http://sohne.net/projects/semafox/
57
+ licenses: []
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project: semacode
76
+ rubygems_version: 1.8.23
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: Create semacodes (2D barcodes) using Ruby.
80
+ test_files:
81
+ - tests/test.rb