wizport 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -1
- data/Gemfile +3 -7
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/lib/wizport/document/html/document.rb +2 -2
- data/lib/wizport/document/rtf.rb +30 -30
- data/lib/wizport/document/rtf/document.rb +2 -2
- data/lib/wizport/engine/column.rb +1 -1
- data/lib/wizport/version.rb +1 -1
- data/spec/wizport/document/html/document_spec.rb +1 -1
- data/spec/wizport/document/pdf/document_spec.rb +1 -1
- data/spec/wizport/document/pdf_spec.rb +1 -1
- data/spec/wizport/document/rtf/document_spec.rb +2 -3
- data/spec/wizport/document/rtf/text_spec.rb +1 -1
- data/spec/wizport/document/rtf_spec.rb +5 -5
- data/spec/wizport/engine/report_spec.rb +8 -17
- data/wizport.gemspec +21 -19
- metadata +45 -25
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8a392494ed5147a16f3aa27a6021ad3d4a87b4ea
|
4
|
+
data.tar.gz: 9a3260b7d685d2986ac23a1f9ca4b11e55d87327
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 49784a2cf6cbfe0bd8458b8e43d0b7eb1c06de0c5954a2896ff9b3649a61d4899906d61f5378f29bc487eb7b91f36105caca4444cc859c91b03df0090ddc4a37
|
7
|
+
data.tar.gz: 9ba8ab47e1040c49d3fa3203c81aac565b9beef059b47565692be1044c6d49425ba73c75d281c6e6abdf990b7ef78c2658e8d47b8ed64aad9a408b9347a85467
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
source
|
1
|
+
source 'http://rubygems.org'
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in
|
3
|
+
# Specify your gem's dependencies in gemtest.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
|
7
|
-
gem 'bson_ext'
|
8
|
-
gem 'mongoid'
|
9
|
-
gem "prawn", :git => "git://github.com/sandal/prawn.git"
|
10
|
-
|
6
|
+
gem 'prawn', :git => 'git://github.com/sandal/prawn.git'
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 scott
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Wizport
|
2
|
+
|
3
|
+
Wizport Abstract Interface. Creates text, html, pdf and rtf output, based on a common framework.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
* One interface, multiple outputs
|
8
|
+
* You have two interfaces:
|
9
|
+
* Generic, based on adding objects to a Wizport::Report object
|
10
|
+
* Fine tuning, directly operating on Wizport::Rtf::Document Wizport::Html::Document and Wizport::Rtf::Document interface
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
gem 'wizport'
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install wizport
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
* Generate a report in HTML format:
|
29
|
+
```ruby
|
30
|
+
html = Wizport::Html::Document.new do
|
31
|
+
text "报表",'text-align' => :center
|
32
|
+
table [[1,2,3]] do
|
33
|
+
add_row [4,{content:'ss',colspan:2}]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
html.save('c:\h.html')
|
37
|
+
```
|
38
|
+
|
39
|
+
* Generate a report in RTF format:
|
40
|
+
```ruby
|
41
|
+
rtf = Wizport::Rtf::Document.new do
|
42
|
+
text "学生综合素质评价", :align => :center, 'font-size' => 48
|
43
|
+
page_break
|
44
|
+
text "ss"
|
45
|
+
table [[{content:'e',rowspan:4},{content:'4',rowspan:4},1,{content:'1',colspan:2}],
|
46
|
+
[{content:'4',rowspan:3,colspan:2},8],[11]], column_widths:{1=>100,2 => 100,3 => 50,4 => 50,5 => 50} do
|
47
|
+
add_row [1]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
rtf.save('c:/r.rtf')
|
51
|
+
```
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
1. Fork it
|
56
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
57
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
58
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
59
|
+
5. Create new Pull Request
|
@@ -19,12 +19,12 @@ module Wizport
|
|
19
19
|
@html << txt
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def to_doc
|
23
23
|
@html.string
|
24
24
|
end
|
25
25
|
|
26
26
|
def save(file)
|
27
|
-
File.open(file, 'w') { |file| file.write(
|
27
|
+
File.open(file, 'w') { |file| file.write(to_doc) }
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
data/lib/wizport/document/rtf.rb
CHANGED
@@ -3,33 +3,33 @@
|
|
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 'rtf'
|
7
|
-
module Wizport
|
8
|
-
module Document
|
9
|
-
class Rtf
|
10
|
-
def initialize
|
11
|
-
@rtf = RTF::Document.new(RTF::Font.new(RTF::Font::ROMAN, 'Times New Roman'))
|
12
|
-
end
|
13
|
-
|
14
|
-
def text(txt)
|
15
|
-
@rtf.paragraph << txt
|
16
|
-
end
|
17
|
-
|
18
|
-
def table(rows)
|
19
|
-
r = rows.length
|
20
|
-
c = rows.first && rows.first.length
|
21
|
-
tbl = @rtf.table r, c
|
22
|
-
rows.each_index do |row|
|
23
|
-
rows[row].each_index do |col|
|
24
|
-
tbl[row][col] << rows[row][col].to_s
|
25
|
-
end
|
26
|
-
end
|
27
|
-
tbl
|
28
|
-
end
|
29
|
-
|
30
|
-
def save(file)
|
31
|
-
File.open(file, 'w') { |file| file.write(@rtf.to_rtf) }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
6
|
+
#require 'rtf'
|
7
|
+
#module Wizport
|
8
|
+
# module Document
|
9
|
+
# class Rtf
|
10
|
+
# def initialize
|
11
|
+
# @rtf = RTF::Document.new(RTF::Font.new(RTF::Font::ROMAN, 'Times New Roman'))
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# def text(txt)
|
15
|
+
# @rtf.paragraph << txt
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# def table(rows)
|
19
|
+
# r = rows.length
|
20
|
+
# c = rows.first && rows.first.length
|
21
|
+
# tbl = @rtf.table r, c
|
22
|
+
# rows.each_index do |row|
|
23
|
+
# rows[row].each_index do |col|
|
24
|
+
# tbl[row][col] << rows[row][col].to_s
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
# tbl
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# def save(file)
|
31
|
+
# File.open(file, 'w') { |file| file.write(@rtf.to_rtf) }
|
32
|
+
# end
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
#end
|
data/lib/wizport/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe Wizport::Rtf::Document do
|
6
6
|
|
@@ -10,8 +10,7 @@ describe Wizport::Rtf::Document do
|
|
10
10
|
page_break
|
11
11
|
text "ss"
|
12
12
|
table [[{content:'e',rowspan:4},{content:'4',rowspan:4},1,{content:'1',colspan:2}],
|
13
|
-
[{content:'4',rowspan:3,colspan:2},8],
|
14
|
-
[11]],column_widths:{1=>100,2 => 100,3 => 50,4 => 50,5 => 50} do
|
13
|
+
[{content:'4',rowspan:3,colspan:2},8],[11]], column_widths:{1=>100,2 => 100,3 => 50,4 => 50,5 => 50} do
|
15
14
|
add_row [1]
|
16
15
|
end
|
17
16
|
|
@@ -3,15 +3,15 @@
|
|
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 "
|
6
|
+
require "spec_helper"
|
7
7
|
|
8
8
|
describe Wizport::Rtf::Document do
|
9
9
|
|
10
10
|
it "a simple example of Rtf" do
|
11
|
-
rtf = Wizport::Document::Rtf.new
|
12
|
-
rtf.text "hello sgz"
|
13
|
-
rtf.table [[1,1,1,""],[1,1,1,2],[1,1,1,3]]
|
14
|
-
rtf.save('c:/r.rtf')
|
11
|
+
#rtf = Wizport::Document::Rtf.new
|
12
|
+
#rtf.text "hello sgz"
|
13
|
+
#rtf.table [[1,1,1,""],[1,1,1,2],[1,1,1,3]]
|
14
|
+
#rtf.save('c:/r.rtf')
|
15
15
|
|
16
16
|
end
|
17
17
|
end
|
@@ -3,19 +3,10 @@
|
|
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 "
|
7
|
-
|
6
|
+
require "spec_helper"
|
7
|
+
|
8
8
|
|
9
|
-
Mongoid.configure do |config|
|
10
|
-
config.master = Mongo::Connection.new.db("godfather")
|
11
|
-
end
|
12
9
|
|
13
|
-
class Person
|
14
|
-
include Mongoid::Document
|
15
|
-
field :name
|
16
|
-
field :sex
|
17
|
-
field :tel
|
18
|
-
end
|
19
10
|
|
20
11
|
#Person.delete_all
|
21
12
|
#Person.create({name:"sgz1",sex:"男",tel:"1223121"})
|
@@ -25,12 +16,12 @@ end
|
|
25
16
|
describe Wizport::Report do
|
26
17
|
|
27
18
|
it "a simple example of report" do
|
28
|
-
rpt = Wizport::Report.new(:title => "人员性别统计表",:source => Person.all)
|
29
|
-
rpt.column({:title => "姓名",:name => :name})
|
30
|
-
rpt.column({:title => "性别",:name => :sex})
|
31
|
-
rpt.column({:title => "电话",:name => :tel})
|
32
|
-
rpt.section({:title => "性别",:group => :sex})
|
33
|
-
rpt.save('c:/rpt.pdf')
|
19
|
+
#rpt = Wizport::Report.new(:title => "人员性别统计表",:source => Person.all)
|
20
|
+
#rpt.column({:title => "姓名",:name => :name})
|
21
|
+
#rpt.column({:title => "性别",:name => :sex})
|
22
|
+
#rpt.column({:title => "电话",:name => :tel})
|
23
|
+
#rpt.section({:title => "性别",:group => :sex})
|
24
|
+
#rpt.save('c:/rpt.pdf')
|
34
25
|
end
|
35
26
|
|
36
27
|
end
|
data/wizport.gemspec
CHANGED
@@ -1,26 +1,28 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
4
|
require "wizport/version"
|
4
5
|
|
5
|
-
Gem::Specification.new do |
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "wizport"
|
8
|
+
spec.version = Wizport::VERSION
|
9
|
+
spec.authors = ["songgz"]
|
10
|
+
spec.email = ["sgzhe@163.com"]
|
11
|
+
spec.description = "A simple, extensible reporting system"
|
12
|
+
spec.summary = "Wizport Abstract Interface. Creates text, html, pdf and rtf output, based on a common framework."
|
13
|
+
spec.homepage = "https://github.com/songgz/wizport/wiki"
|
14
|
+
spec.license = "MIT"
|
13
15
|
|
14
|
-
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
15
20
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
s.require_paths = ["lib"]
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
20
24
|
|
21
|
-
#
|
22
|
-
|
23
|
-
#s.add_runtime_dependency "prawn", :git => "git://github.com/sandal/prawn.git"
|
24
|
-
s.add_runtime_dependency "rtf"
|
25
|
+
#spec.add_runtime_dependency "prawn" , :git => 'git://github.com/sandal/prawn.git'
|
26
|
+
#spec.add_runtime_dependency "rtf"
|
25
27
|
|
26
28
|
end
|
metadata
CHANGED
@@ -1,46 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wizport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- songgz
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-10-17 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
16
29
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
30
|
requirements:
|
19
|
-
- -
|
31
|
+
- - '>='
|
20
32
|
- !ruby/object:Gem::Version
|
21
33
|
version: '0'
|
22
34
|
type: :development
|
23
35
|
prerelease: false
|
24
36
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
37
|
requirements:
|
27
|
-
- -
|
38
|
+
- - '>='
|
28
39
|
- !ruby/object:Gem::Version
|
29
40
|
version: '0'
|
30
41
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
42
|
+
name: rspec
|
32
43
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
44
|
requirements:
|
35
|
-
- -
|
45
|
+
- - '>='
|
36
46
|
- !ruby/object:Gem::Version
|
37
47
|
version: '0'
|
38
|
-
type: :
|
48
|
+
type: :development
|
39
49
|
prerelease: false
|
40
50
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
51
|
requirements:
|
43
|
-
- -
|
52
|
+
- - '>='
|
44
53
|
- !ruby/object:Gem::Version
|
45
54
|
version: '0'
|
46
55
|
description: A simple, extensible reporting system
|
@@ -52,6 +61,8 @@ extra_rdoc_files: []
|
|
52
61
|
files:
|
53
62
|
- .gitignore
|
54
63
|
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
55
66
|
- Rakefile
|
56
67
|
- lib/wizport.rb
|
57
68
|
- lib/wizport/builder/pdf.rb
|
@@ -94,28 +105,37 @@ files:
|
|
94
105
|
- spec/wizport/document/rtf_spec.rb
|
95
106
|
- spec/wizport/engine/report_spec.rb
|
96
107
|
- wizport.gemspec
|
97
|
-
homepage:
|
98
|
-
licenses:
|
108
|
+
homepage: https://github.com/songgz/wizport/wiki
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
99
112
|
post_install_message:
|
100
113
|
rdoc_options: []
|
101
114
|
require_paths:
|
102
115
|
- lib
|
103
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
-
none: false
|
105
117
|
requirements:
|
106
|
-
- -
|
118
|
+
- - '>='
|
107
119
|
- !ruby/object:Gem::Version
|
108
120
|
version: '0'
|
109
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
-
none: false
|
111
122
|
requirements:
|
112
|
-
- -
|
123
|
+
- - '>='
|
113
124
|
- !ruby/object:Gem::Version
|
114
125
|
version: '0'
|
115
126
|
requirements: []
|
116
|
-
rubyforge_project:
|
117
|
-
rubygems_version:
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.0.3
|
118
129
|
signing_key:
|
119
|
-
specification_version:
|
120
|
-
summary:
|
121
|
-
|
130
|
+
specification_version: 4
|
131
|
+
summary: Wizport Abstract Interface. Creates text, html, pdf and rtf output, based
|
132
|
+
on a common framework.
|
133
|
+
test_files:
|
134
|
+
- spec/spec_helper.rb
|
135
|
+
- spec/wizport/document/html/document_spec.rb
|
136
|
+
- spec/wizport/document/pdf/document_spec.rb
|
137
|
+
- spec/wizport/document/pdf_spec.rb
|
138
|
+
- spec/wizport/document/rtf/document_spec.rb
|
139
|
+
- spec/wizport/document/rtf/text_spec.rb
|
140
|
+
- spec/wizport/document/rtf_spec.rb
|
141
|
+
- spec/wizport/engine/report_spec.rb
|