rescpos 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/README.textile +9 -1
- data/examples/escposes/array_table.escpos.erb +2 -0
- data/examples/escposes/bill_list.escpos.erb +0 -1
- data/examples/escposes/dish_item.escpos.erb +2 -0
- data/examples/print.rb +4 -8
- data/lib/rescpos/printer.rb +9 -6
- data/lib/rescpos/version.rb +1 -1
- data/spec/lib/rescpos/printer_spec.rb +4 -8
- metadata +18 -18
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm use 1.9.2@rescpos
|
1
|
+
rvm use 1.9.2@rescpos --create
|
data/README.textile
CHANGED
@@ -35,7 +35,7 @@ end
|
|
35
35
|
To render the report, you just need to call the render method of the report.
|
36
36
|
|
37
37
|
bc. report = SimpleTitledReport.new('A report with a title')
|
38
|
-
report.render(:template => "<%=
|
38
|
+
report.render(:template => "<%= title %>")
|
39
39
|
# A report with a title
|
40
40
|
|
41
41
|
You can also create a pre-defined template for the report.
|
@@ -73,3 +73,11 @@ In order to print the report, you should create a Rescpos::Printer object and th
|
|
73
73
|
bc. printer = Rescpos::Printer.open('192.168.1.250', 9100)
|
74
74
|
printer.print(report)
|
75
75
|
printer.close
|
76
|
+
|
77
|
+
You can set the options for printing:
|
78
|
+
|
79
|
+
bc. printer.print(report, encoding: 'GBK', cut_mode: :partial_cut)
|
80
|
+
|
81
|
+
* Encoding option could be any valid encoding.
|
82
|
+
* cut_mode option has two values: :full_cut and :partial_cut, by default the mode is set to :partial_cut.
|
83
|
+
|
data/examples/print.rb
CHANGED
@@ -11,12 +11,8 @@ Rescpos.configure do |config|
|
|
11
11
|
config.template_path = File.expand_path(File.join(File.dirname(__FILE__), 'escposes'))
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
printer
|
18
|
-
# printer.print_report(report, :encoding => 'GBK')
|
19
|
-
# print table
|
20
|
-
# printer.print_report(report1, :encoding => 'GBK')
|
21
|
-
printer.print_report(ArrayTableReport.new)
|
14
|
+
printer = Rescpos::Printer.open("192.168.1.4", 9100)
|
15
|
+
printer.print_report(DishItemReport.new)
|
16
|
+
# printer.print_report(BillListReport.new)
|
17
|
+
# printer.print_report(ArrayTableReport.new)
|
22
18
|
printer.close
|
data/lib/rescpos/printer.rb
CHANGED
@@ -16,10 +16,10 @@ module Rescpos
|
|
16
16
|
@socket.close
|
17
17
|
end
|
18
18
|
|
19
|
-
def print(content, opts={:encoding => 'GBK'})
|
20
|
-
content = Iconv.iconv("#{opts[:encoding]}//IGNORE","UTF-8//IGNORE", content)[0]
|
19
|
+
def print(content, opts = { :encoding => 'GBK', :cut_mode => :partial_cut })
|
20
|
+
content = Iconv.iconv("#{ opts[:encoding] || 'GBK' }//IGNORE","UTF-8//IGNORE", content)[0]
|
21
21
|
@socket.send(content, SOCK_FLAG)
|
22
|
-
|
22
|
+
send(opts[:cut_mode] || :partial_cut)
|
23
23
|
end
|
24
24
|
|
25
25
|
def print_report(report, opts={})
|
@@ -31,9 +31,12 @@ module Rescpos
|
|
31
31
|
@socket.send(command, SOCK_FLAG)
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
34
|
+
def partial_cut
|
35
|
+
send_command("\n\n\n\n\x1d\x561\x0c")
|
36
|
+
end
|
37
|
+
|
38
|
+
def full_cut
|
39
|
+
send_command("\n\n\n\n\x1b\x69\x0c")
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|
data/lib/rescpos/version.rb
CHANGED
@@ -18,16 +18,12 @@ module Rescpos
|
|
18
18
|
|
19
19
|
let(:socket) { Object.new }
|
20
20
|
|
21
|
-
it "connects to the printer server" do
|
22
|
-
Printer.open("192.168.1.3", 9100)
|
23
|
-
end
|
24
|
-
|
25
21
|
it "prints the a rendered report" do
|
26
22
|
printer = Printer.open("192.168.1.3", 9100)
|
27
23
|
|
28
24
|
socket.should_receive(:send).with("A title", 0)
|
29
|
-
printer.should_receive(:
|
30
|
-
printer.print(TitledReport.new("A title").render(:
|
25
|
+
printer.should_receive(:send).with(:partial_cut)
|
26
|
+
printer.print(TitledReport.new("A title").render(template: "<%= @title %>"))
|
31
27
|
end
|
32
28
|
|
33
29
|
it "prints the report" do
|
@@ -37,8 +33,8 @@ module Rescpos
|
|
37
33
|
printer = Printer.open("192.168.1.3", 9100)
|
38
34
|
|
39
35
|
socket.should_receive(:send).with("A title\n", 0)
|
40
|
-
printer.should_receive(:
|
41
|
-
printer.print_report(TitledReport.new("A title"))
|
36
|
+
printer.should_receive(:send).with(:full_cut)
|
37
|
+
printer.print_report(TitledReport.new("A title"), cut_mode: :full_cut)
|
42
38
|
end
|
43
39
|
end
|
44
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rescpos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-16 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rb-inotify
|
16
|
-
requirement: &
|
16
|
+
requirement: &13394860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *13394860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: libnotify
|
27
|
-
requirement: &
|
27
|
+
requirement: &13394400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *13394400
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec-instafail
|
38
|
-
requirement: &
|
38
|
+
requirement: &13393880 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *13393880
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: cucumber
|
49
|
-
requirement: &
|
49
|
+
requirement: &13392500 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *13392500
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &13390900 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *13390900
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: guard-bundler
|
71
|
-
requirement: &
|
71
|
+
requirement: &13379700 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *13379700
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: guard-cucumber
|
82
|
-
requirement: &
|
82
|
+
requirement: &13379280 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *13379280
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: guard-rspec
|
93
|
-
requirement: &
|
93
|
+
requirement: &13378860 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *13378860
|
102
102
|
description: Print formatted docs with Winpos WP-800
|
103
103
|
email:
|
104
104
|
- towerhe@gmail.com
|