libexcel 0.1.1 → 0.1.4

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.
@@ -0,0 +1,17 @@
1
+ A small ruby library to create Excel XML spreadsheets.
2
+
3
+ by: Silas Baronda <silas.baronda@REMOVE_MEgmail.com>
4
+
5
+ == Build it
6
+
7
+ Download source
8
+
9
+ git clone git://github.com/silasb/libexcel.git
10
+
11
+ Now you need to build it:
12
+
13
+ gem build libexcel.gemspec
14
+
15
+ Now install:
16
+
17
+ gem install libexcel-0.1.1.gem
data/Rakefile CHANGED
@@ -2,23 +2,6 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'rake/testtask'
4
4
 
5
- begin
6
- require 'jeweler'
7
- Jeweler::Tasks.new do |gem|
8
- gem.name = "libexcel"
9
- gem.summary = "A library that create Xml Excel documents"
10
- gem.description = "A library that create Xml Excel documents"
11
- gem.email = "silas.baronda@gmail.com"
12
- gem.homepage = "http://github.com/silasb/libexcel"
13
- gem.authors = ["Silas Baronda"]
14
- gem.add_development_dependency "shoulda"
15
- gem.add_dependency('libxml-ruby', '>= 1.1.3')
16
- end
17
- Jeweler::GemcutterTasks.new
18
- rescue LoadError
19
- puts "Jewler (or a dependency) not available. Install it with: gem install jeweler"
20
- end
21
-
22
5
  desc "Run tests"
23
6
  Rake::TestTask.new(:test) do |t|
24
7
  t.libs << 'lib'
@@ -18,7 +18,7 @@ module LibExcel
18
18
  def initialize(name)
19
19
  super('Worksheet')
20
20
  # Excel complains if the name is more than 31 chars.
21
- self['ss:Name'] = name[0..30]
21
+ self.name = name
22
22
  self.append table
23
23
  @f_column = XML::Node.new('Column')
24
24
  @f_column['ss:Width'] = DEFAULT_COLUMN_WIDTH
@@ -35,7 +35,7 @@ module LibExcel
35
35
 
36
36
  # Sets the +name+ and retuncates it to 31 chars.
37
37
  def name=(name)
38
- self['ss:Name'] = name[0..30]
38
+ self['ss:Name'] = name.truncate
39
39
  end
40
40
 
41
41
  def f_column=(value)
@@ -99,3 +99,23 @@ module LibExcel
99
99
  end
100
100
  end
101
101
  end
102
+
103
+ class String
104
+ def truncate
105
+ return self if self.length <= 30
106
+
107
+ half_length = self.length / 2
108
+ lstring = self[0, half_length].rtruncate(half_length-(half_length-13))
109
+ rstring = self[half_length, self.length].ltruncate(half_length-13)
110
+ lstring << (self.length % 2 != 0 ? "..." : "....") << rstring
111
+ lstring
112
+ end
113
+
114
+ def rtruncate(to)
115
+ self[0,to]
116
+ end
117
+
118
+ def ltruncate(to)
119
+ self[to, self.length]
120
+ end
121
+ end
@@ -1,26 +1,23 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
5
2
 
6
3
  Gem::Specification.new do |s|
7
- s.name = %q{libexcel}
8
- s.version = "0.1.1"
4
+ s.name = "libexcel"
5
+ s.version = "0.1.4"
9
6
 
10
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
8
  s.authors = ["Silas Baronda"]
12
- s.date = %q{2010-02-28}
13
- s.description = %q{A library that create Xml Excel documents}
14
- s.email = %q{silas.baronda@gmail.com}
9
+ s.email = ["silas.baronda@gmail.com"]
10
+ s.date = %q{2010-06-03}
11
+ s.description = "A library that create Xml Excel documents"
12
+ s.summary = "A library that create Xml Excel documents"
15
13
  s.extra_rdoc_files = [
16
- "README"
14
+ "README.rdoc"
17
15
  ]
18
16
  s.files = [
19
17
  ".autotest",
20
18
  ".gitignore",
21
- "README",
19
+ "README.rdoc",
22
20
  "Rakefile",
23
- "VERSION",
24
21
  "lib/libexcel.rb",
25
22
  "lib/libexcel/document.rb",
26
23
  "lib/libexcel/formula.rb",
@@ -36,7 +33,6 @@ Gem::Specification.new do |s|
36
33
  s.rdoc_options = ["--charset=UTF-8"]
37
34
  s.require_paths = ["lib"]
38
35
  s.rubygems_version = %q{1.3.6}
39
- s.summary = %q{A library that create Xml Excel documents}
40
36
  s.test_files = [
41
37
  "test/document_test.rb",
42
38
  "test/helper.rb",
@@ -30,9 +30,9 @@ class WorksheetTest < Test::Unit::TestCase
30
30
 
31
31
  should 'truncate name 31 chars' do
32
32
  @worksheet.name = '12345678901234567890123456789012' # 31
33
- assert_equal '1234567890123456789012345678901', @worksheet.name
33
+ assert_equal '1234567890123....0123456789012', @worksheet.name
34
34
  @worksheet.name = '123456789012345678901234567890112312312312312312312'
35
- assert_equal '1234567890123456789012345678901', @worksheet.name
35
+ assert_equal '1234567890123...12312312312312', @worksheet.name
36
36
  @worksheet.name = '1'
37
37
  assert_equal '1', @worksheet.name
38
38
  end
@@ -89,9 +89,26 @@ class WorksheetTest < Test::Unit::TestCase
89
89
  assert_equal 'New Name', @work.name
90
90
  end
91
91
 
92
- should 'make sure that you can not add a name over 30 chars' do
93
- @work.name='ThisStringIsClearlyOverThirtyChars'
94
- assert_equal 'ThisStringIsClearlyOverThirtyCh', @work.name
92
+ context 'assigning a name over 30 chars' do
93
+ should 'make sure that you can not add a name over 30 chars' do
94
+ @work.name='ThisStringIsClearlyOverThirtyChars'
95
+ assert_equal 'ThisStringIsC....erThirtyChars', @work.name
96
+ end
97
+
98
+ should 'make sure that it gives 3 dots when odd' do
99
+ @work.name='ThisStringIsClearlyOverThirtyCharss'
100
+ assert_equal 'ThisStringIsC...erThirtyCharss', @work.name
101
+ end
102
+
103
+ should 'make sure that it gives 4 dots when even' do
104
+ @work.name='ThisStringIsClearlyOverThirtyCha'
105
+ assert_equal 'ThisStringIsC....OverThirtyCha', @work.name
106
+ end
107
+
108
+ should 'be less than 30 chars' do
109
+ @work.name='ThisStringIsClearlyOver'
110
+ assert_equal 'ThisStringIsClearlyOver', @work.name
111
+ end
95
112
  end
96
113
 
97
114
  should 'return its column width' do
@@ -148,11 +165,11 @@ class WorksheetTest < Test::Unit::TestCase
148
165
  end
149
166
 
150
167
  should 'have its name set to 30 chars' do
151
- assert_equal 'ThisStringIsClearlyOverThirtyCh', @work.name
168
+ assert_equal 'ThisStringIsC....erThirtyChars', @work.name
152
169
  end
153
170
 
154
171
  should 'make a reference that has its name set to 30 chars' do
155
- assert_equal 'ThisStringIsClearlyOverThirtyCh',
172
+ assert_equal 'ThisStringIsC....erThirtyChars',
156
173
  @work.reference(:row => 1).xml['ss:Formula'].split("'")[1]
157
174
  end
158
175
 
@@ -162,5 +179,26 @@ class WorksheetTest < Test::Unit::TestCase
162
179
  @work.reference(:row => 1).xml['ss:Formula'].split("'")[1]
163
180
  end
164
181
  end
165
-
182
+
183
+ context 'creating a worksheet with a name over 30 chars' do
184
+ should 'make sure that you can not add a name over 30 chars' do
185
+ @work = LibExcel::Worksheet.new('ThisStringIsClearlyOverThirtyChars')
186
+ assert_equal 'ThisStringIsC....erThirtyChars', @work.name
187
+ end
188
+
189
+ should 'make sure that it gives 3 dots when odd' do
190
+ @work = LibExcel::Worksheet.new('ThisStringIsClearlyOverThirtyCharss')
191
+ assert_equal 'ThisStringIsC...erThirtyCharss', @work.name
192
+ end
193
+
194
+ should 'make sure that it gives 4 dots when even' do
195
+ @work = LibExcel::Worksheet.new('ThisStringIsClearlyOverThirtyCha')
196
+ assert_equal 'ThisStringIsC....OverThirtyCha', @work.name
197
+ end
198
+
199
+ should 'be less than 30 chars' do
200
+ @work = LibExcel::Worksheet.new('ThisStringIsClearlyOver')
201
+ assert_equal 'ThisStringIsClearlyOver', @work.name
202
+ end
203
+ end
166
204
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libexcel
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 1
9
- version: 0.1.1
9
+ - 4
10
+ version: 0.1.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - Silas Baronda
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-02-28 00:00:00 -05:00
18
+ date: 2010-06-03 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: shoulda
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -33,9 +36,11 @@ dependencies:
33
36
  name: libxml-ruby
34
37
  prerelease: false
35
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
36
40
  requirements:
37
41
  - - ">="
38
42
  - !ruby/object:Gem::Version
43
+ hash: 21
39
44
  segments:
40
45
  - 1
41
46
  - 1
@@ -44,19 +49,19 @@ dependencies:
44
49
  type: :runtime
45
50
  version_requirements: *id002
46
51
  description: A library that create Xml Excel documents
47
- email: silas.baronda@gmail.com
52
+ email:
53
+ - silas.baronda@gmail.com
48
54
  executables: []
49
55
 
50
56
  extensions: []
51
57
 
52
58
  extra_rdoc_files:
53
- - README
59
+ - README.rdoc
54
60
  files:
55
61
  - .autotest
56
62
  - .gitignore
57
- - README
63
+ - README.rdoc
58
64
  - Rakefile
59
- - VERSION
60
65
  - lib/libexcel.rb
61
66
  - lib/libexcel/document.rb
62
67
  - lib/libexcel/formula.rb
@@ -77,23 +82,27 @@ rdoc_options:
77
82
  require_paths:
78
83
  - lib
79
84
  required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
80
86
  requirements:
81
87
  - - ">="
82
88
  - !ruby/object:Gem::Version
89
+ hash: 3
83
90
  segments:
84
91
  - 0
85
92
  version: "0"
86
93
  required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
87
95
  requirements:
88
96
  - - ">="
89
97
  - !ruby/object:Gem::Version
98
+ hash: 3
90
99
  segments:
91
100
  - 0
92
101
  version: "0"
93
102
  requirements: []
94
103
 
95
104
  rubyforge_project:
96
- rubygems_version: 1.3.6
105
+ rubygems_version: 1.3.7
97
106
  signing_key:
98
107
  specification_version: 3
99
108
  summary: A library that create Xml Excel documents
data/README DELETED
@@ -1,3 +0,0 @@
1
- A small ruby library to create Excel XML spreadsheets.
2
-
3
- by: Silas Baronda <silas.baronda@REMOVE_MEgmail.com>
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.1