sheet_mapper 0.1.2 → 0.2.0
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/README.md +1 -1
- data/lib/sheet_mapper/collection.rb +11 -5
- data/lib/sheet_mapper/version.rb +1 -1
- data/test/spreadsheet_test.rb +1 -2
- metadata +4 -4
data/README.md
CHANGED
|
@@ -95,7 +95,7 @@ collection.cell(1, 2) => "foo"
|
|
|
95
95
|
SheetMapper was created by [Nathan Esquenazi](http://github.com/nesquena) at Miso in 2012. The following users
|
|
96
96
|
contributed to the project:
|
|
97
97
|
|
|
98
|
-
*
|
|
98
|
+
* [Derek Lindahl](https://github.com/dlindahl) - Added simple delegation to collections
|
|
99
99
|
|
|
100
100
|
## Tasks
|
|
101
101
|
|
|
@@ -4,7 +4,8 @@ module SheetMapper
|
|
|
4
4
|
class CollectionNotFound < StandardError; end
|
|
5
5
|
|
|
6
6
|
class Collection < SimpleDelegator
|
|
7
|
-
attr_reader :
|
|
7
|
+
attr_reader :worksheet
|
|
8
|
+
attr_writer :mapper
|
|
8
9
|
|
|
9
10
|
# spreadsheet is a SheetMapper::Spreadsheet
|
|
10
11
|
# SheetMapper::Collection.new(@sheet, @work)
|
|
@@ -12,7 +13,12 @@ module SheetMapper
|
|
|
12
13
|
@spreadsheet = spreadsheet
|
|
13
14
|
@worksheet = worksheet
|
|
14
15
|
@mapper = @spreadsheet.mapper
|
|
15
|
-
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Returns the processed records
|
|
19
|
+
# @collection.records => [<SheetMapper::Base>, ...]
|
|
20
|
+
def records
|
|
21
|
+
@records ||= process_records!
|
|
16
22
|
end
|
|
17
23
|
|
|
18
24
|
# Returns an array of mapped records
|
|
@@ -38,11 +44,11 @@ module SheetMapper
|
|
|
38
44
|
# Reload worksheet discarding changes not saved
|
|
39
45
|
def reload
|
|
40
46
|
@worksheet.reload
|
|
41
|
-
@records =
|
|
47
|
+
@records = nil
|
|
42
48
|
end
|
|
43
49
|
|
|
44
50
|
def __getobj__
|
|
45
|
-
|
|
51
|
+
records
|
|
46
52
|
end
|
|
47
53
|
|
|
48
54
|
protected
|
|
@@ -58,4 +64,4 @@ module SheetMapper
|
|
|
58
64
|
records
|
|
59
65
|
end
|
|
60
66
|
end
|
|
61
|
-
end
|
|
67
|
+
end
|
data/lib/sheet_mapper/version.rb
CHANGED
data/test/spreadsheet_test.rb
CHANGED
|
@@ -29,7 +29,6 @@ describe "Spreadsheet" do
|
|
|
29
29
|
@sheet = SheetMapper::Spreadsheet.new(:mapper => Object, :key => 'foo', :login => 'login', :password => 'pass')
|
|
30
30
|
@work_stub = stub(:worksheet)
|
|
31
31
|
@work_stub.expects(:title).returns("FOO")
|
|
32
|
-
@work_stub.expects(:rows).returns([])
|
|
33
32
|
@sheet_stub.expects(:worksheets).returns([@work_stub])
|
|
34
33
|
@collection = @sheet.find_collection_by_title("foo")
|
|
35
34
|
end
|
|
@@ -39,4 +38,4 @@ describe "Spreadsheet" do
|
|
|
39
38
|
assert_equal @work_stub, @collection.worksheet
|
|
40
39
|
end
|
|
41
40
|
end # find_collection_by_title
|
|
42
|
-
end # Spreadsheet
|
|
41
|
+
end # Spreadsheet
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sheet_mapper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 23
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
- 1
|
|
9
8
|
- 2
|
|
10
|
-
|
|
9
|
+
- 0
|
|
10
|
+
version: 0.2.0
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Nathan Esquenazi
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2012-
|
|
18
|
+
date: 2012-08-07 00:00:00 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: google-spreadsheet-ruby
|