sheets_db 0.8.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/README.md +4 -0
- data/documentation/usage.md +1 -1
- data/lib/sheets_db/version.rb +1 -1
- data/lib/sheets_db/worksheet.rb +9 -3
- data/lib/sheets_db/worksheet/row.rb +9 -2
- data/sheets_db.gemspec +1 -1
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b8a5cac35efcf2dcd1004cc00a4bf9514f3a3277121c092d4d6254ba1fbbd3c2
|
4
|
+
data.tar.gz: b164e80699e1a418ff1c47040406a26a1c9972f5f3d4c62d000b500ec1f92c23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55d17b3592389692de9b89d6abb924c3084468a783abbcccd0898830a006ed640b22cd029cb01042ebf31f96b87eec96ccab437d59229132076b92eefe5d5060
|
7
|
+
data.tar.gz: 0f7a4c45a8c1c762de11ea6b5962b138841b7452a51742dc6dc795b5797c03c35a6607a7963d781c9b901a6d9ebb4823aaa711d389b89b1ec69abde3a213f0b0
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.
|
data/README.md
CHANGED
@@ -30,6 +30,10 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
30
30
|
|
31
31
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
32
|
|
33
|
+
## Releasing
|
34
|
+
|
35
|
+
We use [Semantic Versioning](https://semver.org/) system. [RubyGems](https://guides.rubygems.org/publishing/) documents on how to publish a release.
|
36
|
+
|
33
37
|
## Contributing
|
34
38
|
|
35
39
|
Bug reports and pull requests are welcome on GitHub at https://github.com/ablschools/sheets_db. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/documentation/usage.md
CHANGED
@@ -169,7 +169,7 @@ end
|
|
169
169
|
|
170
170
|
The only required argument to the `attribute` class method is the name of the column itself. All other options are optional:
|
171
171
|
|
172
|
-
`type`: The `attribute` method currently supports
|
172
|
+
`type`: The `attribute` method currently supports five types: `Integer`, `Float`, `DateTime`, `Boolean` and the default `String`. Any other value given to the `type` option will be ignored and the default will be used. (Note that the `Boolean` type must be specified as a string or symbol (`type: :Boolean`) since there is no actual `Boolean` class in Ruby.)
|
173
173
|
|
174
174
|
`multiple`: This option defaults to false. If true, it tells SheetsDB to parse the value as a comma-separated list of values, and return an array by splitting on the comma (if no comma is found, it will return a single element array).
|
175
175
|
|
data/lib/sheets_db/version.rb
CHANGED
data/lib/sheets_db/worksheet.rb
CHANGED
@@ -40,16 +40,20 @@ module SheetsDB
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
def column_names
|
44
|
+
columns.keys
|
45
|
+
end
|
46
|
+
|
43
47
|
def attribute_definitions
|
44
48
|
type.attribute_definitions
|
45
49
|
end
|
46
50
|
|
47
51
|
def get_definition_and_column(attribute_name)
|
48
52
|
attribute_definition = attribute_definitions.fetch(attribute_name)
|
49
|
-
column_name = attribute_definition.fetch(:column_name, attribute_name
|
53
|
+
column_name = attribute_definition.fetch(:column_name, attribute_name)
|
50
54
|
[
|
51
55
|
attribute_definition,
|
52
|
-
columns[column_name]
|
56
|
+
columns[column_name.to_s]
|
53
57
|
]
|
54
58
|
end
|
55
59
|
|
@@ -57,7 +61,7 @@ module SheetsDB
|
|
57
61
|
unless attribute_definition[:if_column_missing]
|
58
62
|
raise ColumnNotFoundError, attribute_definition[:column_name]
|
59
63
|
end
|
60
|
-
attribute_definition[:if_column_missing]
|
64
|
+
instance_exec(&attribute_definition[:if_column_missing])
|
61
65
|
end
|
62
66
|
|
63
67
|
def attribute_at_row_position(attribute_name, row_position)
|
@@ -167,6 +171,8 @@ module SheetsDB
|
|
167
171
|
converted_value = case attribute_definition[:type].to_s
|
168
172
|
when "Integer"
|
169
173
|
raw_value.to_i
|
174
|
+
when "Float"
|
175
|
+
raw_value.to_f
|
170
176
|
when "DateTime"
|
171
177
|
DateTime.strptime(raw_value, "%m/%d/%Y %H:%M:%S")
|
172
178
|
when "Boolean"
|
@@ -7,11 +7,14 @@ module SheetsDB
|
|
7
7
|
class << self
|
8
8
|
def inherited(subclass)
|
9
9
|
super
|
10
|
-
subclass.instance_variable_set(
|
10
|
+
subclass.instance_variable_set(
|
11
|
+
:@attribute_definitions,
|
12
|
+
Marshal.load(Marshal.dump(@attribute_definitions))
|
13
|
+
)
|
11
14
|
end
|
12
15
|
|
13
16
|
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)
|
17
|
+
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
18
|
|
16
19
|
define_method(name) do
|
17
20
|
begin
|
@@ -110,6 +113,10 @@ module SheetsDB
|
|
110
113
|
@changed_foreign_items = []
|
111
114
|
end
|
112
115
|
|
116
|
+
def column_names
|
117
|
+
worksheet.column_names
|
118
|
+
end
|
119
|
+
|
113
120
|
def new_row?
|
114
121
|
row_position.nil?
|
115
122
|
end
|
data/sheets_db.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "google_drive", "~>
|
21
|
+
spec.add_dependency "google_drive", "~> 3.0"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.12"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
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.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ravi Gadad
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google_drive
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description:
|
83
|
+
description:
|
84
84
|
email:
|
85
85
|
- ravi@ablschools.com
|
86
86
|
executables: []
|
@@ -123,7 +123,7 @@ homepage: https://github.com/ablschools/sheets_db
|
|
123
123
|
licenses:
|
124
124
|
- MIT
|
125
125
|
metadata: {}
|
126
|
-
post_install_message:
|
126
|
+
post_install_message:
|
127
127
|
rdoc_options: []
|
128
128
|
require_paths:
|
129
129
|
- lib
|
@@ -138,9 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
140
|
requirements: []
|
141
|
-
|
142
|
-
|
143
|
-
signing_key:
|
141
|
+
rubygems_version: 3.0.3
|
142
|
+
signing_key:
|
144
143
|
specification_version: 4
|
145
144
|
summary: Adapter for pseudo-relational data stored in Google Sheets
|
146
145
|
test_files: []
|