wizport 0.0.2 → 0.0.3
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.
- data/lib/wizport/document/Rtf/cell.rb +8 -8
- data/lib/wizport/document/Rtf/document.rb +13 -10
- data/lib/wizport/document/Rtf/plaintext.rb +2 -0
- data/lib/wizport/document/Rtf/rtf_builder.rb +1 -0
- data/lib/wizport/document/pdf/element.rb +15 -0
- data/lib/wizport/version.rb +1 -1
- data/lib/wizport.rb +10 -5
- data/spec/wizport/document/rtf/document_spec.rb +13 -0
- data/spec/wizport/document/rtf_spec.rb +2 -2
- metadata +4 -2
@@ -7,7 +7,8 @@ module Wizport
|
|
7
7
|
module Rtf
|
8
8
|
class Cell
|
9
9
|
attr_accessor :col_span, :row_span
|
10
|
-
|
10
|
+
|
11
|
+
def initialize(data, row = nil)
|
11
12
|
@row = row
|
12
13
|
@index = @row.cells.size
|
13
14
|
@col_span = 1
|
@@ -22,12 +23,12 @@ module Wizport
|
|
22
23
|
end
|
23
24
|
|
24
25
|
unless col_spanned?
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
@row.table.elements << Command.new(:celld)
|
27
|
+
@row.table.elements << Command.new(:clvmgf) if @row_span > 1
|
28
|
+
@row.table.elements << Command.new(:clvmrg) if row_spanned?
|
29
|
+
@row.table.elements << Command.new(:cellx, (@index+@col_span)*1000)
|
30
|
+
@row.table.elements << Plaintext.new(@text.to_s)
|
31
|
+
@row.table.elements << Command.new(:cell)
|
31
32
|
end
|
32
33
|
|
33
34
|
#@row.cellx_command Command.new(:clvmgf) if @row_span > 1
|
@@ -52,7 +53,6 @@ module Wizport
|
|
52
53
|
end
|
53
54
|
|
54
55
|
|
55
|
-
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -3,16 +3,6 @@
|
|
3
3
|
# Wizport: A gem for creating reports by specifying columns, groups, styles, etc.
|
4
4
|
# Copyright 2012 by sgzhe@163.com
|
5
5
|
|
6
|
-
require "../../visitor"
|
7
|
-
require "./element"
|
8
|
-
require "./plaintext"
|
9
|
-
require "./command"
|
10
|
-
require "./group"
|
11
|
-
require "./text"
|
12
|
-
require "./cell"
|
13
|
-
require "./row"
|
14
|
-
require "./table"
|
15
|
-
require "./rtf_builder"
|
16
6
|
|
17
7
|
|
18
8
|
module Wizport
|
@@ -21,6 +11,8 @@ module Wizport
|
|
21
11
|
def initialize(file = nil, &block)
|
22
12
|
super()
|
23
13
|
elements << Command.new(:rtf, 1)
|
14
|
+
elements << Command.new(:ansi)
|
15
|
+
elements << Command.new(:ansicpg, 2052)
|
24
16
|
block.arity<1 ? self.instance_eval(&block) : block.call(self) if block_given?
|
25
17
|
save file if file
|
26
18
|
end
|
@@ -67,6 +59,17 @@ module Wizport
|
|
67
59
|
end
|
68
60
|
|
69
61
|
if __FILE__ == $0
|
62
|
+
require "../../visitor"
|
63
|
+
require "./element"
|
64
|
+
require "./plaintext"
|
65
|
+
require "./command"
|
66
|
+
require "./group"
|
67
|
+
require "./text"
|
68
|
+
require "./cell"
|
69
|
+
require "./row"
|
70
|
+
require "./table"
|
71
|
+
require "./rtf_builder"
|
72
|
+
|
70
73
|
d = Wizport::Rtf::Document.new('c:/file.rtf') do
|
71
74
|
text "我们", :align => :center, :size => 48
|
72
75
|
text "春风不度玉门关", :align => :left, :font => 24
|
@@ -9,6 +9,8 @@ module Wizport
|
|
9
9
|
attr_accessor :txt
|
10
10
|
|
11
11
|
def initialize(txt)
|
12
|
+
txt = txt.gsub("{", "\\{").gsub("}", "\\}").gsub("\\", "\\\\")
|
13
|
+
txt = txt.encode("UTF-16LE", :undef=>:replace).each_codepoint.map {|n| n < 128 ? n.chr : "\\u#{n}\\'3f"}.join('')
|
12
14
|
@txt = txt
|
13
15
|
end
|
14
16
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Wizport: A gem for creating reports by specifying columns, groups, styles, etc.
|
4
|
+
# Copyright 2012 by sgzhe@163.com
|
5
|
+
|
6
|
+
module Wizport
|
7
|
+
module Pdf
|
8
|
+
class Element
|
9
|
+
def initialize
|
10
|
+
@id = nil
|
11
|
+
@ver = nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/wizport/version.rb
CHANGED
data/lib/wizport.rb
CHANGED
@@ -5,11 +5,16 @@ require "wizport/version"
|
|
5
5
|
require "wizport/document/pdf"
|
6
6
|
|
7
7
|
require "wizport/visitor"
|
8
|
-
require "wizport/document/
|
9
|
-
require "wizport/document/
|
10
|
-
require "wizport/document/
|
11
|
-
require "wizport/document/
|
12
|
-
require "wizport/document/
|
8
|
+
require "wizport/document/rtf/element"
|
9
|
+
require "wizport/document/rtf/plaintext"
|
10
|
+
require "wizport/document/rtf/command"
|
11
|
+
require "wizport/document/rtf/group"
|
12
|
+
require "wizport/document/rtf/text"
|
13
|
+
require "wizport/document/rtf/cell"
|
14
|
+
require "wizport/document/rtf/row"
|
15
|
+
require "wizport/document/rtf/table"
|
16
|
+
require "wizport/document/rtf/rtf_builder"
|
17
|
+
require "wizport/document/rtf/document"
|
13
18
|
require "wizport/document/rtf"
|
14
19
|
|
15
20
|
require "wizport/builder/pdf"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "../../../../spec/spec_helper"
|
4
|
+
|
5
|
+
describe Wizport::Rtf::Document do
|
6
|
+
|
7
|
+
it "a simple example of Rtf" do
|
8
|
+
rtf = Wizport::Rtf::Document.new
|
9
|
+
rtf.text "学生综合素质评价"
|
10
|
+
rtf.table [[1,1,1,"综合"],[1,1,1,2],[1,1,1,3]]
|
11
|
+
rtf.save('c:/r.rtf')
|
12
|
+
end
|
13
|
+
end
|
@@ -5,10 +5,10 @@
|
|
5
5
|
|
6
6
|
require "../../../spec/spec_helper"
|
7
7
|
|
8
|
-
describe Wizport::Document
|
8
|
+
describe Wizport::Rtf::Document do
|
9
9
|
|
10
10
|
it "a simple example of Rtf" do
|
11
|
-
rtf = Wizport::Document
|
11
|
+
rtf = Wizport::Rtf::Document.new
|
12
12
|
rtf.text "hello sgz"
|
13
13
|
rtf.table [[1,1,1,""],[1,1,1,2],[1,1,1,3]]
|
14
14
|
rtf.save('c:/r.rtf')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wizport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- lib/wizport/document/Rtf/table.rb
|
85
85
|
- lib/wizport/document/Rtf/text.rb
|
86
86
|
- lib/wizport/document/pdf.rb
|
87
|
+
- lib/wizport/document/pdf/element.rb
|
87
88
|
- lib/wizport/document/rtf.rb
|
88
89
|
- lib/wizport/document/txt.rb
|
89
90
|
- lib/wizport/engine/active_source.rb
|
@@ -96,6 +97,7 @@ files:
|
|
96
97
|
- lib/wizport/version.rb
|
97
98
|
- lib/wizport/visitor.rb
|
98
99
|
- spec/spec_helper.rb
|
100
|
+
- spec/wizport/document/rtf/document_spec.rb
|
99
101
|
- spec/wizport/document/rtf/text_spec.rb
|
100
102
|
- spec/wizport/document/rtf_spec.rb
|
101
103
|
- spec/wizport/engine/report_spec.rb
|