excel_walker 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/lib/excel_walker/reader/hook.rb +5 -2
- data/lib/excel_walker/version.rb +1 -1
- data/spec/excel_walker/reader/hook_spec.rb +8 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MWQxMjliODUwNzc5OGQ2MDE2Y2RmYzhmMTZmMjc4MGNiNzUyY2Y1MQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 426c578333d13905dc0c41fc2cb3cd19798fd3be
|
4
|
+
data.tar.gz: 163a6946907dd428f92656bb4125453daef894d6
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NThmZGE0OWFjZDJjNWIxMmE0Yjg0NzQ5NTQ2NDE3MjFkMTdmMzQwN2UzMDU0
|
11
|
-
YmFkODExODQyZTZlOWZmOGY1NjBlNThjYjA2ZjI5ZTU5YzJmZmU=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZWM3YzEwYjMwMGM2NjRjYzMxNWY0MWFlMDI3OTc1OTQyYmY0Y2FhNTA3ZTNi
|
14
|
-
NmZkY2Y2YjRhMWMzMWQ4YTQxMWJhMTY1MzQyYTczZjRiYzY3MWU5MWNkM2Jm
|
15
|
-
ZjIyZWU0NWY5MTliNjY1MjRmNWFjZGRmNTczMmEwYmFhMTRhMzQ=
|
6
|
+
metadata.gz: fe7ce7e90a081fa0e79ca1caee973d41ad4631658a5e3e01bfa60fb1bd36f9f996ca1f71da65bbb5e18db2810fba814fad339be764db7fbcc6fd0f561f2c84a9
|
7
|
+
data.tar.gz: 118abd8e4f1e14876f9e963681f07b7f9d52eb58a0d41762839ea8b1aa26ca6f919ec951f2793a159ca9c1535fb633e465910c674f67f9a8b2b3a834d9b70c6d
|
@@ -20,14 +20,17 @@ module ExcelWalker
|
|
20
20
|
@cols_extractor =
|
21
21
|
case true
|
22
22
|
when cols_matcher.is_a?(Array)
|
23
|
-
|
24
|
-
proc { |row| row.select.with_index { |_, idx| cols_set.include?(idx + 1) } }
|
23
|
+
proc { |row| cols_matcher.collect{|idx| row[idx - 1]} }
|
25
24
|
when cols_matcher.is_a?(Fixnum)
|
26
25
|
proc { |row| row[cols_matcher - 1] }
|
27
26
|
when cols_matcher.is_a?(Range)
|
28
27
|
proc { |row| row[(cols_matcher.min - 1)..(cols_matcher.max - 1)] }
|
29
28
|
when cols_matcher.is_a?(Proc)
|
30
29
|
proc { |row| cols_matcher[row] }
|
30
|
+
when cols_matcher.is_a?(Hash)
|
31
|
+
cols_idxs = cols_matcher.values
|
32
|
+
cols_names = cols_matcher.keys
|
33
|
+
proc { |row| Hash[cols_names.zip(cols_idxs.collect{|idx| row[idx - 1]})] }
|
31
34
|
else
|
32
35
|
raise ArgumentError.new('Can only take Array, Number, Range or a Block')
|
33
36
|
end
|
data/lib/excel_walker/version.rb
CHANGED
@@ -91,6 +91,14 @@ module ExcelWalker::Reader
|
|
91
91
|
subject.call(collection, 'b', 'c', 'd')
|
92
92
|
end
|
93
93
|
end
|
94
|
+
|
95
|
+
context 'hash column matcher' do
|
96
|
+
subject { hook.columns(first: 1, second: 2, twentieth: 20, last: 100) }
|
97
|
+
it 'sends correct data to the hooked block' do
|
98
|
+
hook_block.should_receive(:call).with({first: 1, second: 2, twentieth: 20, last: 100}, 'b', 'c', 'd')
|
99
|
+
subject.call(collection, 'b', 'c', 'd')
|
100
|
+
end
|
101
|
+
end
|
94
102
|
end
|
95
103
|
|
96
104
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excel_walker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shadab Ahmed
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: creek
|
@@ -42,14 +42,14 @@ dependencies:
|
|
42
42
|
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>'
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 3.0.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>'
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -70,14 +70,14 @@ dependencies:
|
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: A declarative parser and builder for Excel Files
|
@@ -124,12 +124,12 @@ require_paths:
|
|
124
124
|
- lib
|
125
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
|
-
- -
|
127
|
+
- - '>='
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '0'
|
130
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
131
|
requirements:
|
132
|
-
- -
|
132
|
+
- - '>='
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|