wrap_excel 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wrap_excel/cygwin.rb +40 -0
- data/lib/wrap_excel/range.rb +2 -0
- data/lib/wrap_excel/sheet.rb +10 -0
- data/lib/wrap_excel/version.rb +1 -1
- data/lib/wrap_excel.rb +1 -39
- data/spec/cygwin_spec.rb +1 -1
- data/spec/sheet_spec.rb +50 -0
- data/wrap_excel.gemspec +1 -1
- metadata +22 -25
@@ -0,0 +1,40 @@
|
|
1
|
+
module WrapExcel
|
2
|
+
module Cygwin
|
3
|
+
require 'Win32API'
|
4
|
+
|
5
|
+
@conv_to_full_posix_path =
|
6
|
+
Win32API.new('cygwin1.dll', 'cygwin_conv_to_full_posix_path', 'PP', 'I')
|
7
|
+
@conv_to_posix_path =
|
8
|
+
Win32API.new('cygwin1.dll', 'cygwin_conv_to_posix_path', 'PP', 'I')
|
9
|
+
@conv_to_full_win32_path =
|
10
|
+
Win32API.new('cygwin1.dll', 'cygwin_conv_to_full_win32_path', 'PP', 'I')
|
11
|
+
@conv_to_win32_path =
|
12
|
+
Win32API.new('cygwin1.dll', 'cygwin_conv_to_win32_path', 'PP', 'I')
|
13
|
+
|
14
|
+
def cygpath(options, path)
|
15
|
+
absolute = shortname = false
|
16
|
+
func = nil
|
17
|
+
options.delete(" \t-").chars {|opt|
|
18
|
+
case opt
|
19
|
+
when ?u
|
20
|
+
func = [@conv_to_full_posix_path, @conv_to_posix_path]
|
21
|
+
when ?w
|
22
|
+
func = [@conv_to_full_win32_path, @conv_to_win32_path]
|
23
|
+
when ?a
|
24
|
+
absolute = true
|
25
|
+
when ?s
|
26
|
+
shortname = true
|
27
|
+
end
|
28
|
+
}
|
29
|
+
raise "first argument must contain -u or -w" if func.nil?
|
30
|
+
func = absolute ? func[0] : func[1]
|
31
|
+
buf = "\0" * 300
|
32
|
+
if func.Call(path, buf) == -1
|
33
|
+
raise "cannot convert path name"
|
34
|
+
end
|
35
|
+
buf.delete!("\0")
|
36
|
+
buf
|
37
|
+
end
|
38
|
+
module_function :cygpath
|
39
|
+
end
|
40
|
+
end
|
data/lib/wrap_excel/range.rb
CHANGED
data/lib/wrap_excel/sheet.rb
CHANGED
@@ -71,6 +71,16 @@ module WrapExcel
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
+
def row_range(row, range = nil)
|
75
|
+
range ||= 0..@end_column - 1
|
76
|
+
WrapExcel::Range.new(@sheet.Range(@sheet.Cells(row + 1, range.min + 1), @sheet.Cells(row + 1, range.max + 1)))
|
77
|
+
end
|
78
|
+
|
79
|
+
def col_range(col, range = nil)
|
80
|
+
range ||= 0..@end_row - 1
|
81
|
+
WrapExcel::Range.new(@sheet.Range(@sheet.Cells(range.min + 1, col + 1), @sheet.Cells(range.max + 1, col + 1)))
|
82
|
+
end
|
83
|
+
|
74
84
|
def method_missing(id, *args)
|
75
85
|
@sheet.send(id, *args)
|
76
86
|
end
|
data/lib/wrap_excel/version.rb
CHANGED
data/lib/wrap_excel.rb
CHANGED
@@ -3,47 +3,9 @@ require File.join(File.dirname(__FILE__), 'wrap_excel/book')
|
|
3
3
|
require File.join(File.dirname(__FILE__), 'wrap_excel/sheet')
|
4
4
|
require File.join(File.dirname(__FILE__), 'wrap_excel/cell')
|
5
5
|
require File.join(File.dirname(__FILE__), 'wrap_excel/range')
|
6
|
+
require File.join(File.dirname(__FILE__), 'wrap_excel/cygwin') if RUBY_PLATFORM =~ /cygwin/
|
6
7
|
require "wrap_excel/version"
|
7
8
|
|
8
9
|
module WrapExcel
|
9
10
|
|
10
|
-
module Cygwin
|
11
|
-
require 'Win32API'
|
12
|
-
|
13
|
-
@conv_to_full_posix_path =
|
14
|
-
Win32API.new('cygwin1.dll', 'cygwin_conv_to_full_posix_path', 'PP', 'I')
|
15
|
-
@conv_to_posix_path =
|
16
|
-
Win32API.new('cygwin1.dll', 'cygwin_conv_to_posix_path', 'PP', 'I')
|
17
|
-
@conv_to_full_win32_path =
|
18
|
-
Win32API.new('cygwin1.dll', 'cygwin_conv_to_full_win32_path', 'PP', 'I')
|
19
|
-
@conv_to_win32_path =
|
20
|
-
Win32API.new('cygwin1.dll', 'cygwin_conv_to_win32_path', 'PP', 'I')
|
21
|
-
|
22
|
-
def cygpath(options, path)
|
23
|
-
absolute = shortname = false
|
24
|
-
func = nil
|
25
|
-
options.delete(" \t-").chars {|opt|
|
26
|
-
case opt
|
27
|
-
when ?u
|
28
|
-
func = [@conv_to_full_posix_path, @conv_to_posix_path]
|
29
|
-
when ?w
|
30
|
-
func = [@conv_to_full_win32_path, @conv_to_win32_path]
|
31
|
-
when ?a
|
32
|
-
absolute = true
|
33
|
-
when ?s
|
34
|
-
shortname = true
|
35
|
-
end
|
36
|
-
}
|
37
|
-
raise "first argument must contain -u or -w" if func.nil?
|
38
|
-
func = absolute ? func[0] : func[1]
|
39
|
-
buf = "\0" * 300
|
40
|
-
if func.Call(path, buf) == -1
|
41
|
-
raise "cannot convert path name"
|
42
|
-
end
|
43
|
-
buf.delete!("\0")
|
44
|
-
buf
|
45
|
-
end
|
46
|
-
module_function :cygpath
|
47
|
-
end
|
48
|
-
|
49
11
|
end
|
data/spec/cygwin_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require File.join(File.dirname(__FILE__), './spec_helper')
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe "on cygwin", :if => RUBY_PLATFORM =~ /cygwin/ do
|
5
5
|
describe ".cygpath" do
|
6
6
|
context "cygwin path is '/cygdrive/c/Users'" do
|
7
7
|
context "with '-w' options" do
|
data/spec/sheet_spec.rb
CHANGED
@@ -265,6 +265,56 @@ describe WrapExcel::Sheet do
|
|
265
265
|
end
|
266
266
|
end
|
267
267
|
|
268
|
+
describe "#row_range" do
|
269
|
+
context "with second argument" do
|
270
|
+
before do
|
271
|
+
@row_range = @sheet.row_range(0, 1..2)
|
272
|
+
end
|
273
|
+
|
274
|
+
it { @row_range.should be_kind_of WrapExcel::Range }
|
275
|
+
|
276
|
+
it "should get range cells of second argument" do
|
277
|
+
@row_range.values.should eq ['workbook', 'sheet1']
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
context "without second argument" do
|
282
|
+
before do
|
283
|
+
@row_range = @sheet.row_range(2)
|
284
|
+
end
|
285
|
+
|
286
|
+
it "should get all cells" do
|
287
|
+
@row_range.values.should eq ['matz', 'is', 'nice']
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
end
|
292
|
+
|
293
|
+
describe "#col_range" do
|
294
|
+
context "with second argument" do
|
295
|
+
before do
|
296
|
+
@col_range = @sheet.col_range(0, 1..2)
|
297
|
+
end
|
298
|
+
|
299
|
+
it { @col_range.should be_kind_of WrapExcel::Range }
|
300
|
+
|
301
|
+
it "should get range cells of second argument" do
|
302
|
+
@col_range.values.should eq ['foo', 'matz']
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
context "without second argument" do
|
307
|
+
before do
|
308
|
+
@col_range = @sheet.col_range(1)
|
309
|
+
end
|
310
|
+
|
311
|
+
it "should get all cells" do
|
312
|
+
@col_range.values.should eq ['workbook', nil, 'is']
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
end
|
317
|
+
|
268
318
|
describe "#method_missing" do
|
269
319
|
it "can access COM method" do
|
270
320
|
@sheet.Cells(1,1).Value.should eq 'simple'
|
data/wrap_excel.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wrap_excel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-03-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &19519968 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.9.2
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *19519968
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &19519620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.6.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *19519620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rb-fchange
|
38
|
-
requirement: &
|
38
|
+
requirement: &19535736 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *19535736
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rb-notifu
|
49
|
-
requirement: &
|
49
|
+
requirement: &19535400 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *19535400
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: win32console
|
60
|
-
requirement: &
|
60
|
+
requirement: &19535124 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *19535124
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: guard-rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &19534608 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *19534608
|
80
80
|
description: WrapExcel is to wrap the win32ole, and easy to use Excel operations with
|
81
81
|
ruby. Detailed description please see the README.
|
82
82
|
email:
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/wrap_excel.rb
|
100
100
|
- lib/wrap_excel/book.rb
|
101
101
|
- lib/wrap_excel/cell.rb
|
102
|
+
- lib/wrap_excel/cygwin.rb
|
102
103
|
- lib/wrap_excel/range.rb
|
103
104
|
- lib/wrap_excel/sheet.rb
|
104
105
|
- lib/wrap_excel/version.rb
|
@@ -129,12 +130,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
130
|
- - ! '>='
|
130
131
|
- !ruby/object:Gem::Version
|
131
132
|
version: '0'
|
133
|
+
segments:
|
134
|
+
- 0
|
135
|
+
hash: 703779037
|
132
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
137
|
none: false
|
134
138
|
requirements:
|
135
139
|
- - ! '>='
|
136
140
|
- !ruby/object:Gem::Version
|
137
141
|
version: '0'
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
hash: 703779037
|
138
145
|
requirements: []
|
139
146
|
rubyforge_project: wrap_excel
|
140
147
|
rubygems_version: 1.8.11
|
@@ -142,14 +149,4 @@ signing_key:
|
|
142
149
|
specification_version: 3
|
143
150
|
summary: WrapExcel is a wrapper library that specializes in the operation of Excel
|
144
151
|
win32ole.
|
145
|
-
test_files:
|
146
|
-
- spec/book_spec.rb
|
147
|
-
- spec/cell_spec.rb
|
148
|
-
- spec/cygwin_spec.rb
|
149
|
-
- spec/data/book_with_blank.xls
|
150
|
-
- spec/data/merge_cells.xls
|
151
|
-
- spec/data/protected_sheet.xls
|
152
|
-
- spec/data/simple.xls
|
153
|
-
- spec/range_spec.rb
|
154
|
-
- spec/sheet_spec.rb
|
155
|
-
- spec/spec_helper.rb
|
152
|
+
test_files: []
|