sheets_db 0.7.0 → 0.8.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.
- checksums.yaml +4 -4
- data/lib/sheets_db/version.rb +1 -1
- data/lib/sheets_db/worksheet/row.rb +2 -2
- data/lib/sheets_db/worksheet.rb +10 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d2784033de71d261f7e29a9f819ee2c8b9ebe8d
|
4
|
+
data.tar.gz: 4eebf8e4ab589e9a4b343c6f963c96df5148fbcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb21d0eff2870d21c7e73acc0cbdd1a19364ceb205f688df194b14ac7a996698eb50b797bf5226194eebbd54e2bc0ac2d098de7f61f90bb2c849b75fc0c53003
|
7
|
+
data.tar.gz: 0df6e44c0dc91bb6b55a3298eb11bb6d21bfe48fdedb69bfad9776a567a001fba237876ca6febc0921a69f07efce25bbd3997007199fbeb0360631017bfcf9a6
|
data/lib/sheets_db/version.rb
CHANGED
@@ -10,8 +10,8 @@ module SheetsDB
|
|
10
10
|
subclass.instance_variable_set(:@attribute_definitions, @attribute_definitions)
|
11
11
|
end
|
12
12
|
|
13
|
-
def attribute(name, type: String, multiple: false, transform: nil, column_name: nil)
|
14
|
-
register_attribute(name, type: type, multiple: multiple, transform: transform, column_name: column_name || name.to_s, association: false)
|
13
|
+
def attribute(name, type: String, multiple: false, transform: nil, column_name: nil, if_column_missing: nil)
|
14
|
+
register_attribute(name, type: type, multiple: multiple, transform: transform, column_name: column_name || name.to_s, association: false, if_column_missing: if_column_missing)
|
15
15
|
|
16
16
|
define_method(name) do
|
17
17
|
begin
|
data/lib/sheets_db/worksheet.rb
CHANGED
@@ -45,17 +45,24 @@ module SheetsDB
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def get_definition_and_column(attribute_name)
|
48
|
-
attribute_definition = attribute_definitions.fetch(attribute_name
|
48
|
+
attribute_definition = attribute_definitions.fetch(attribute_name)
|
49
49
|
column_name = attribute_definition.fetch(:column_name, attribute_name.to_s)
|
50
|
-
raise ColumnNotFoundError, column_name if columns[column_name].nil?
|
51
50
|
[
|
52
51
|
attribute_definition,
|
53
52
|
columns[column_name]
|
54
53
|
]
|
55
54
|
end
|
56
55
|
|
56
|
+
def value_if_column_missing(attribute_definition)
|
57
|
+
unless attribute_definition[:if_column_missing]
|
58
|
+
raise ColumnNotFoundError, attribute_definition[:column_name]
|
59
|
+
end
|
60
|
+
attribute_definition[:if_column_missing].call
|
61
|
+
end
|
62
|
+
|
57
63
|
def attribute_at_row_position(attribute_name, row_position)
|
58
64
|
attribute_definition, column = get_definition_and_column(attribute_name)
|
65
|
+
return value_if_column_missing(attribute_definition) unless column
|
59
66
|
raw_value = read_value_from_google_drive_resource(
|
60
67
|
dimensions: [row_position, column.column_position],
|
61
68
|
attribute_definition: attribute_definition
|
@@ -79,6 +86,7 @@ module SheetsDB
|
|
79
86
|
def update_attributes_at_row_position(staged_attributes, row_position:)
|
80
87
|
staged_attributes.each do |attribute_name, value|
|
81
88
|
attribute_definition, column = get_definition_and_column(attribute_name)
|
89
|
+
raise ColumnNotFoundError, column unless column
|
82
90
|
assignment_value = attribute_definition[:multiple] ? value.join(",") : value
|
83
91
|
google_drive_resource[row_position, column.column_position] = assignment_value
|
84
92
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sheets_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ravi Gadad
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google_drive
|