rusk 0.0.1 → 0.0.2

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/Guardfile CHANGED
@@ -2,9 +2,9 @@
2
2
  # A sample Guardfile
3
3
  # More info at https://github.com/guard/guard#readme
4
4
 
5
- guard 'rspec', :version => 2, :cli => '--color', :all_after_pass => false, :all_on_start => false do
5
+ guard 'rspec', :cli => '--color', :all_after_pass => false, :all_on_start => false do
6
6
  watch(%r{^spec/.+_spec\.rb$})
7
- watch(%r{^lib/goblin/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch(%r{^lib/rusk/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
8
8
  watch('lib/goblin.rb') { "spec" }
9
9
  watch('spec/spec_helper.rb') { "spec" }
10
10
  end
data/lib/rusk/cell.rb CHANGED
@@ -34,6 +34,15 @@ module Rusk
34
34
  else
35
35
  @content["office:value-type"] = 'string'
36
36
  end
37
+
38
+ if @content.xpath("text:p").children.empty?
39
+ Nokogiri::XML::Text.new("\n", @content).parent = @content
40
+ textp = Nokogiri::XML::Node.new("text:p", @content)
41
+ Nokogiri::XML::Text.new("", @content).parent = textp
42
+ textp.parent = @content
43
+ Nokogiri::XML::Text.new("\n", @content).parent = @content
44
+ end
45
+
37
46
  @content.xpath("text:p").children.first.content = value
38
47
  end
39
48
 
data/lib/rusk/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rusk
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/rusk.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.version = Rusk::VERSION
17
17
 
18
18
  gem.add_runtime_dependency 'rubyzip', '~> 0.9.0'
19
- gem.add_runtime_dependency 'nokogiri', '~> 1.5.6'
19
+ gem.add_runtime_dependency 'nokogiri', '~> 1.5.8'
20
20
  gem.add_development_dependency "rake", '~> 0.9'
21
21
  gem.add_development_dependency 'rspec', '~> 2.11.0'
22
22
  gem.add_development_dependency 'rb-fsevent', '~> 0.9.0'
data/spec/cell_spec.rb CHANGED
@@ -215,16 +215,7 @@ describe Rusk::Cell do
215
215
  describe "#value=" do
216
216
  context "'mruby' changed to 'cruby'(string cell changed to string)" do
217
217
  before do
218
- Rusk::Book.open(@tmp_file) do |book|
219
- sheet = book[0]
220
- sheet[0,1].value = "cruby"
221
- book.save
222
- end
223
-
224
- Rusk::Book.open(@tmp_file) do |book|
225
- sheet = book[0]
226
- @cell = sheet[0,1]
227
- end
218
+ @cell = set(0, 1, "cruby")
228
219
  end
229
220
 
230
221
  it { @cell.value.should eq "cruby" }
@@ -232,16 +223,7 @@ describe Rusk::Cell do
232
223
 
233
224
  context "string cell changed to date" do
234
225
  before do
235
- Rusk::Book.open(@tmp_file) do |book|
236
- sheet = book[0]
237
- sheet[0,1].value = Date.new(2012,5,7)
238
- book.save
239
- end
240
-
241
- Rusk::Book.open(@tmp_file) do |book|
242
- sheet = book[0]
243
- @cell = sheet[0,1]
244
- end
226
+ @cell = set(0, 1, Date.new(2012,5,7))
245
227
  end
246
228
 
247
229
  it { @cell.value.should eq Date.new(2012,5,07) }
@@ -250,22 +232,33 @@ describe Rusk::Cell do
250
232
 
251
233
  context "string cell changed to float" do
252
234
  before do
253
- Rusk::Book.open(@tmp_file) do |book|
254
- sheet = book[0]
255
- sheet[0,1].value = 500.1
256
- book.save
257
- end
258
-
259
- Rusk::Book.open(@tmp_file) do |book|
260
- sheet = book[0]
261
- @cell = sheet[0,1]
262
- end
235
+ @cell = set(0, 1, 500.1)
263
236
  end
264
237
 
265
238
  it { @cell.value.should eq 500.1 }
266
239
  it { @cell.value_type.should eq 'float' }
267
240
  end
268
241
 
242
+ context "set to blank cell" do
243
+ context "set string" do
244
+ before do
245
+ @cell = set(10, 0, "set string")
246
+ end
247
+
248
+ it { @cell.value.should eq "set string" }
249
+ it { @cell.value_type.should eq 'string' }
250
+ end
251
+
252
+ context "set float" do
253
+ before do
254
+ @cell = set(10, 0, 10)
255
+ end
256
+
257
+ it { @cell.value.should eq 10.0 }
258
+ it { @cell.value_type.should eq 'float' }
259
+ end
260
+ end
261
+
269
262
  end
270
263
  end
271
264
 
data/spec/spec_helper.rb CHANGED
@@ -19,6 +19,19 @@ module Rusk::SpecHelpers
19
19
  FileUtils.rm "#{dir}/tmp_#{file}"
20
20
  end
21
21
 
22
+ def set(row, col, value)
23
+ cell = nil
24
+ Rusk::Book.open(@tmp_file) do |book|
25
+ book[0][row, col].value = value
26
+ book.save
27
+ end
28
+
29
+ Rusk::Book.open(@tmp_file) do |book|
30
+ cell = book[0][row, col]
31
+ end
32
+ cell
33
+ end
34
+
22
35
  end
23
36
 
24
37
  RSpec.configure do |config|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rusk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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: 2013-03-07 00:00:00.000000000 Z
12
+ date: 2013-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubyzip
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 1.5.6
37
+ version: 1.5.8
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 1.5.6
45
+ version: 1.5.8
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rake
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -196,7 +196,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
196
196
  version: '0'
197
197
  segments:
198
198
  - 0
199
- hash: 3352198063863070839
199
+ hash: -883949039905815181
200
200
  required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  none: false
202
202
  requirements:
@@ -205,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  version: '0'
206
206
  segments:
207
207
  - 0
208
- hash: 3352198063863070839
208
+ hash: -883949039905815181
209
209
  requirements: []
210
210
  rubyforge_project:
211
211
  rubygems_version: 1.8.24