osheet-xmlss 1.0.0.rc.1
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/.gitignore +20 -0
- data/Gemfile +9 -0
- data/LICENSE +22 -0
- data/README.md +131 -0
- data/Rakefile +49 -0
- data/bench/bench_runner.rb +91 -0
- data/bench/profiler.rb +6 -0
- data/bench/profiler_1000.xls +17015 -0
- data/bench/profiler_runner.rb +40 -0
- data/examples/basic.rb +77 -0
- data/examples/basic.xls +2 -0
- data/examples/basic_with_templates.rb +87 -0
- data/examples/basic_with_templates.xls +93 -0
- data/examples/formats.rb +370 -0
- data/examples/formats.xls +768 -0
- data/examples/formula.rb +42 -0
- data/examples/formula.xls +36 -0
- data/examples/styles.rb +255 -0
- data/examples/styles.xls +343 -0
- data/examples/trivial.rb +25 -0
- data/examples/trivial.xls +18 -0
- data/lib/osheet/xmlss/style_cache.rb +63 -0
- data/lib/osheet/xmlss/style_settings.rb +148 -0
- data/lib/osheet/xmlss/version.rb +4 -0
- data/lib/osheet/xmlss.rb +7 -0
- data/lib/osheet/xmlss_writer.rb +143 -0
- data/osheet-xmlss.gemspec +24 -0
- data/test/helper.rb +17 -0
- data/test/irb.rb +9 -0
- data/test/xmlss/api_test.rb +139 -0
- data/test/xmlss/style_cache_test.rb +65 -0
- data/test/xmlss/style_settings_test.rb +263 -0
- data/test/xmlss/styles_test.rb +340 -0
- data/test/xmlss_writer_test.rb +92 -0
- metadata +157 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
require "assert"
|
2
|
+
|
3
|
+
require 'osheet/xmlss_writer'
|
4
|
+
|
5
|
+
module Osheet::Xmlss
|
6
|
+
|
7
|
+
class WriterTests < Assert::Context
|
8
|
+
desc "the xmlss writer"
|
9
|
+
before do
|
10
|
+
@writer = Osheet::XmlssWriter.new
|
11
|
+
@workbook = Osheet::Workbook.new(@writer)
|
12
|
+
end
|
13
|
+
subject { @writer }
|
14
|
+
|
15
|
+
should have_reader :style_cache, :xmlss_workbook
|
16
|
+
should have_instance_methods :bind, :to_s, :to_data, :to_file
|
17
|
+
|
18
|
+
should have_instance_methods :worksheet, :column, :row, :cell
|
19
|
+
should have_instance_methods :style
|
20
|
+
should have_instance_methods :name
|
21
|
+
should have_instance_methods :width, :height
|
22
|
+
should have_instance_methods :autofit, :autofit?, :hidden, :hidden?
|
23
|
+
should have_instance_methods :data, :format, :href, :formula
|
24
|
+
should have_instance_methods :index, :rowspan, :colspan
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
class WorkbookTests < WriterTests
|
29
|
+
before do
|
30
|
+
@workbook.worksheet("testsheet1")
|
31
|
+
end
|
32
|
+
|
33
|
+
should "not allow multiple worksheets with the same name" do
|
34
|
+
assert_raises ArgumentError do
|
35
|
+
subject.worksheet(Osheet::Worksheet.new("testsheet1"))
|
36
|
+
end
|
37
|
+
assert_nothing_raised do
|
38
|
+
subject.worksheet(Osheet::Worksheet.new("testsheet2"))
|
39
|
+
subject.worksheet(Osheet::Worksheet.new) {
|
40
|
+
subject.name 'testsheet3'
|
41
|
+
}
|
42
|
+
subject.worksheet(Osheet::Worksheet.new) {
|
43
|
+
subject.name 'testsheet4'
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
class ToFileTests < WriterTests
|
51
|
+
desc "used with a workbook"
|
52
|
+
before do
|
53
|
+
Osheet::Workbook.new(@writer) {
|
54
|
+
title "written"
|
55
|
+
worksheet {
|
56
|
+
name "Test!"
|
57
|
+
column
|
58
|
+
row {
|
59
|
+
cell {
|
60
|
+
data 1
|
61
|
+
format :number
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
should "write workbook markup" do
|
69
|
+
assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"><Styles><Style ss:ID=\"..number_none_0_nocomma_black\"><NumberFormat ss:Format=\"0\" /></Style></Styles><Worksheet ss:Name=\"Test!\"><Table><Column /><Row><Cell ss:StyleID=\"..number_none_0_nocomma_black\"><Data ss:Type=\"Number\">1</Data></Cell></Row></Table></Worksheet></Workbook>", @writer.to_s
|
70
|
+
end
|
71
|
+
|
72
|
+
should "return string xml data" do
|
73
|
+
xml_data = subject.to_s
|
74
|
+
assert_kind_of ::String, xml_data
|
75
|
+
assert_match /^<\?xml/, xml_data
|
76
|
+
assert_equal xml_data, subject.to_data
|
77
|
+
end
|
78
|
+
|
79
|
+
should "write xml data to a file path" do
|
80
|
+
path = subject.to_file("./tmp/base_test.xls")
|
81
|
+
assert_kind_of ::String, path
|
82
|
+
assert_equal './tmp/base_test.xls', path
|
83
|
+
assert File.exists?(path)
|
84
|
+
|
85
|
+
File.open(path) do |f|
|
86
|
+
assert_equal subject.to_data, f.read
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: osheet-xmlss
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15424055
|
5
|
+
prerelease: 6
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
- rc
|
11
|
+
- 1
|
12
|
+
version: 1.0.0.rc.1
|
13
|
+
platform: ruby
|
14
|
+
authors:
|
15
|
+
- Kelly Redding
|
16
|
+
autorequire:
|
17
|
+
bindir: bin
|
18
|
+
cert_chain: []
|
19
|
+
|
20
|
+
date: 2012-03-20 00:00:00 Z
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
type: :development
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
name: assert
|
34
|
+
version_requirements: *id001
|
35
|
+
prerelease: false
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
type: :runtime
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 15424049
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 0
|
47
|
+
- 0
|
48
|
+
- rc
|
49
|
+
- 2
|
50
|
+
version: 1.0.0.rc.2
|
51
|
+
name: osheet
|
52
|
+
version_requirements: *id002
|
53
|
+
prerelease: false
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
type: :runtime
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 7712010
|
62
|
+
segments:
|
63
|
+
- 1
|
64
|
+
- 0
|
65
|
+
- 0
|
66
|
+
- rc
|
67
|
+
version: 1.0.0.rc
|
68
|
+
name: xmlss
|
69
|
+
version_requirements: *id003
|
70
|
+
prerelease: false
|
71
|
+
description: An Osheet writer (https://github.com/kellyredding/osheet) for the XMLSS format (https://github.com/kellyredding/xmlss)
|
72
|
+
email:
|
73
|
+
- kelly@kellyredding.com
|
74
|
+
executables: []
|
75
|
+
|
76
|
+
extensions: []
|
77
|
+
|
78
|
+
extra_rdoc_files: []
|
79
|
+
|
80
|
+
files:
|
81
|
+
- .gitignore
|
82
|
+
- Gemfile
|
83
|
+
- LICENSE
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bench/bench_runner.rb
|
87
|
+
- bench/profiler.rb
|
88
|
+
- bench/profiler_1000.xls
|
89
|
+
- bench/profiler_runner.rb
|
90
|
+
- examples/basic.rb
|
91
|
+
- examples/basic.xls
|
92
|
+
- examples/basic_with_templates.rb
|
93
|
+
- examples/basic_with_templates.xls
|
94
|
+
- examples/formats.rb
|
95
|
+
- examples/formats.xls
|
96
|
+
- examples/formula.rb
|
97
|
+
- examples/formula.xls
|
98
|
+
- examples/styles.rb
|
99
|
+
- examples/styles.xls
|
100
|
+
- examples/trivial.rb
|
101
|
+
- examples/trivial.xls
|
102
|
+
- lib/osheet/xmlss.rb
|
103
|
+
- lib/osheet/xmlss/style_cache.rb
|
104
|
+
- lib/osheet/xmlss/style_settings.rb
|
105
|
+
- lib/osheet/xmlss/version.rb
|
106
|
+
- lib/osheet/xmlss_writer.rb
|
107
|
+
- osheet-xmlss.gemspec
|
108
|
+
- test/helper.rb
|
109
|
+
- test/irb.rb
|
110
|
+
- test/xmlss/api_test.rb
|
111
|
+
- test/xmlss/style_cache_test.rb
|
112
|
+
- test/xmlss/style_settings_test.rb
|
113
|
+
- test/xmlss/styles_test.rb
|
114
|
+
- test/xmlss_writer_test.rb
|
115
|
+
homepage: http://github.com/kellyredding/osheet-xmlss
|
116
|
+
licenses: []
|
117
|
+
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
hash: 3
|
129
|
+
segments:
|
130
|
+
- 0
|
131
|
+
version: "0"
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
134
|
+
requirements:
|
135
|
+
- - ">"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
hash: 25
|
138
|
+
segments:
|
139
|
+
- 1
|
140
|
+
- 3
|
141
|
+
- 1
|
142
|
+
version: 1.3.1
|
143
|
+
requirements: []
|
144
|
+
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 1.8.11
|
147
|
+
signing_key:
|
148
|
+
specification_version: 3
|
149
|
+
summary: An Osheet writer (https://github.com/kellyredding/osheet) for the XMLSS format (https://github.com/kellyredding/xmlss)
|
150
|
+
test_files:
|
151
|
+
- test/helper.rb
|
152
|
+
- test/irb.rb
|
153
|
+
- test/xmlss/api_test.rb
|
154
|
+
- test/xmlss/style_cache_test.rb
|
155
|
+
- test/xmlss/style_settings_test.rb
|
156
|
+
- test/xmlss/styles_test.rb
|
157
|
+
- test/xmlss_writer_test.rb
|