firestore-odm 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +118 -0
- data/LICENSE +25 -0
- data/README.md +33 -0
- data/firestore-odm.gemspec +14 -0
- data/test.rb +72 -0
- metadata +30 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b530cba51bdd238e2599633f45d66c50945548a60c6b37e18d33d8e2f56aac4
|
4
|
+
data.tar.gz: 0b1ca53aa593fd9a028bcf83bc28f14e9eb3033484e33801512cf6f6f818df31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16380f656883a44abcc3b73092df5f0ec621ba8b5a70354485f6af24787e0731d46583f1a4dd562a42f496803369a3b2739cc8c5250eab0ecc4f7b2820be9bff
|
7
|
+
data.tar.gz: be54202ae93445c1b6b3d5f2e020211592572096a670e2245517ab081980ec25ce0cae2c71cfe4add5d6292cfb1a551bea37711a3576090107c6965bc9ebf23c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
firestore-odm (0.1.3)
|
5
|
+
google-cloud-firestore (~> 1.4, >= 1.4.3)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.7.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
ast (2.4.0)
|
13
|
+
backport (1.1.2)
|
14
|
+
benchmark (0.1.0)
|
15
|
+
concurrent-ruby (1.1.6)
|
16
|
+
e2mmap (0.1.0)
|
17
|
+
faraday (1.0.1)
|
18
|
+
multipart-post (>= 1.2, < 3)
|
19
|
+
google-cloud-core (1.5.0)
|
20
|
+
google-cloud-env (~> 1.0)
|
21
|
+
google-cloud-errors (~> 1.0)
|
22
|
+
google-cloud-env (1.3.1)
|
23
|
+
faraday (>= 0.17.3, < 2.0)
|
24
|
+
google-cloud-errors (1.0.0)
|
25
|
+
google-cloud-firestore (1.4.3)
|
26
|
+
concurrent-ruby (~> 1.0)
|
27
|
+
google-cloud-core (~> 1.2)
|
28
|
+
google-gax (~> 1.8)
|
29
|
+
googleapis-common-protos (>= 1.3.9, < 2.0)
|
30
|
+
googleapis-common-protos-types (>= 1.0.4, < 2.0)
|
31
|
+
rbtree (~> 0.4.2)
|
32
|
+
google-gax (1.8.1)
|
33
|
+
google-protobuf (~> 3.9)
|
34
|
+
googleapis-common-protos (>= 1.3.9, < 2.0)
|
35
|
+
googleauth (~> 0.9)
|
36
|
+
grpc (~> 1.24)
|
37
|
+
rly (~> 0.2.3)
|
38
|
+
google-protobuf (3.12.1-universal-darwin)
|
39
|
+
googleapis-common-protos (1.3.10)
|
40
|
+
google-protobuf (~> 3.11)
|
41
|
+
googleapis-common-protos-types (>= 1.0.5, < 2.0)
|
42
|
+
grpc (~> 1.27)
|
43
|
+
googleapis-common-protos-types (1.0.5)
|
44
|
+
google-protobuf (~> 3.11)
|
45
|
+
googleauth (0.12.0)
|
46
|
+
faraday (>= 0.17.3, < 2.0)
|
47
|
+
jwt (>= 1.4, < 3.0)
|
48
|
+
memoist (~> 0.16)
|
49
|
+
multi_json (~> 1.11)
|
50
|
+
os (>= 0.9, < 2.0)
|
51
|
+
signet (~> 0.14)
|
52
|
+
grpc (1.28.0-universal-darwin)
|
53
|
+
google-protobuf (~> 3.11)
|
54
|
+
googleapis-common-protos-types (~> 1.0)
|
55
|
+
jaro_winkler (1.5.4)
|
56
|
+
jwt (2.2.1)
|
57
|
+
maruku (0.7.3)
|
58
|
+
memoist (0.16.2)
|
59
|
+
mini_portile2 (2.4.0)
|
60
|
+
multi_json (1.14.1)
|
61
|
+
multipart-post (2.1.1)
|
62
|
+
nokogiri (1.10.9)
|
63
|
+
mini_portile2 (~> 2.4.0)
|
64
|
+
os (1.1.0)
|
65
|
+
parallel (1.19.1)
|
66
|
+
parser (2.7.1.2)
|
67
|
+
ast (~> 2.4.0)
|
68
|
+
public_suffix (4.0.5)
|
69
|
+
rainbow (3.0.0)
|
70
|
+
rbtree (0.4.2)
|
71
|
+
reverse_markdown (1.4.0)
|
72
|
+
nokogiri
|
73
|
+
rexml (3.2.4)
|
74
|
+
rly (0.2.3)
|
75
|
+
rubocop (0.84.0)
|
76
|
+
parallel (~> 1.10)
|
77
|
+
parser (>= 2.7.0.1)
|
78
|
+
rainbow (>= 2.2.2, < 4.0)
|
79
|
+
rexml
|
80
|
+
rubocop-ast (>= 0.0.3)
|
81
|
+
ruby-progressbar (~> 1.7)
|
82
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
83
|
+
rubocop-ast (0.0.3)
|
84
|
+
parser (>= 2.7.0.1)
|
85
|
+
ruby-progressbar (1.10.1)
|
86
|
+
signet (0.14.0)
|
87
|
+
addressable (~> 2.3)
|
88
|
+
faraday (>= 0.17.3, < 2.0)
|
89
|
+
jwt (>= 1.5, < 3.0)
|
90
|
+
multi_json (~> 1.10)
|
91
|
+
solargraph (0.39.8)
|
92
|
+
backport (~> 1.1)
|
93
|
+
benchmark
|
94
|
+
bundler (>= 1.17.2)
|
95
|
+
e2mmap
|
96
|
+
jaro_winkler (~> 1.5)
|
97
|
+
maruku (~> 0.7, >= 0.7.3)
|
98
|
+
nokogiri (~> 1.9, >= 1.9.1)
|
99
|
+
parser (~> 2.3)
|
100
|
+
reverse_markdown (>= 1.0.5, < 3)
|
101
|
+
rubocop (~> 0.52)
|
102
|
+
thor (~> 1.0)
|
103
|
+
tilt (~> 2.0)
|
104
|
+
yard (~> 0.9, >= 0.9.24)
|
105
|
+
thor (1.0.1)
|
106
|
+
tilt (2.0.10)
|
107
|
+
unicode-display_width (1.7.0)
|
108
|
+
yard (0.9.25)
|
109
|
+
|
110
|
+
PLATFORMS
|
111
|
+
ruby
|
112
|
+
|
113
|
+
DEPENDENCIES
|
114
|
+
firestore-odm!
|
115
|
+
solargraph
|
116
|
+
|
117
|
+
BUNDLED WITH
|
118
|
+
2.1.4
|
data/LICENSE
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
BSD 2-Clause License
|
2
|
+
|
3
|
+
Copyright (c) 2020, Felipe Cabrera
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
8
|
+
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
10
|
+
list of conditions and the following disclaimer.
|
11
|
+
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
14
|
+
and/or other materials provided with the distribution.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
20
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
21
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
22
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
23
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
24
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
25
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Firestore ODM
|
2
|
+
|
3
|
+
## Configure
|
4
|
+
Add `gem 'firestore-odm'` to your Gemfile, or from the terminal
|
5
|
+
```
|
6
|
+
gem install firestore-odm
|
7
|
+
```
|
8
|
+
|
9
|
+
Then type
|
10
|
+
```
|
11
|
+
export GOOGLE_CLOUD_CREDENTIALS=<path_to_google_cloud_credentials>
|
12
|
+
```
|
13
|
+
|
14
|
+
## How to use
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
require 'firestore-odm'
|
18
|
+
|
19
|
+
class Account < FirestoreODM::Model
|
20
|
+
path :accounts
|
21
|
+
|
22
|
+
field :name, String
|
23
|
+
field :email, String
|
24
|
+
end
|
25
|
+
|
26
|
+
account = Account.create do |doc|
|
27
|
+
doc.name = 'John Smith'
|
28
|
+
doc.email = 'john.smith@example.com'
|
29
|
+
end
|
30
|
+
|
31
|
+
puts account.path #=> accounts/<document_id>
|
32
|
+
puts account.to_json #=> {"name": "John Smith", "email": "john.smith@example.com"}
|
33
|
+
```
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = 'firestore-odm'
|
3
|
+
spec.version = '0.1.4'
|
4
|
+
spec.licenses = 'BSD-2-Clause'
|
5
|
+
spec.summary = 'ODM for Firestore in Ruby'
|
6
|
+
spec.description = ''
|
7
|
+
spec.author = 'Felipe Cabrera'
|
8
|
+
spec.email = 'fecabrera0@outlook.com'
|
9
|
+
spec.files = `git ls-files`.split("\n")
|
10
|
+
spec.homepage = 'https://github.com/fecabrera/firestore-odm'
|
11
|
+
spec.metadata = {"source_code_uri" => "https://github.com/fecabrera/firestore-odm"}
|
12
|
+
|
13
|
+
spec.add_dependency 'google-cloud-firestore', '~> 1.4', '>= 1.4.3'
|
14
|
+
end
|
data/test.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
$:.unshift File.join(Dir.pwd, 'lib')
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'firestore-odm'
|
5
|
+
|
6
|
+
class Post < FirestoreODM::Model
|
7
|
+
path :posts
|
8
|
+
|
9
|
+
field :content, String
|
10
|
+
field :created_at, DateTime
|
11
|
+
end
|
12
|
+
|
13
|
+
class Account < FirestoreODM::Model
|
14
|
+
path :info
|
15
|
+
|
16
|
+
field :first_name, String
|
17
|
+
field :last_name, String
|
18
|
+
field :birthday, Date, :max => Proc.new { Date.today.prev_year(18) }
|
19
|
+
field :updated_at, DateTime
|
20
|
+
end
|
21
|
+
|
22
|
+
class User < FirestoreODM::Model
|
23
|
+
path :users
|
24
|
+
|
25
|
+
field :name, String
|
26
|
+
field :created_at, DateTime
|
27
|
+
|
28
|
+
contains Post, Account
|
29
|
+
end
|
30
|
+
|
31
|
+
puts Account.parse_birthday(Date.parse('2001-12-02'))
|
32
|
+
puts Account.parse_birthday(Date.parse('2002-12-02'))
|
33
|
+
puts Account.parse_birthday(Date.parse('2003-12-02'))
|
34
|
+
|
35
|
+
begin
|
36
|
+
user = User.create_with_id 'john.smith' do |doc|
|
37
|
+
doc.name = 'John Smith'
|
38
|
+
doc.created_at = DateTime.now
|
39
|
+
end
|
40
|
+
|
41
|
+
puts "#{user.path}: #{user.to_json}"
|
42
|
+
|
43
|
+
begin
|
44
|
+
user.create_account_with_id 'account' do |doc|
|
45
|
+
doc.first_name = 'John'
|
46
|
+
doc.last_name = 'Smith'
|
47
|
+
doc.birthday = Date.parse('1981-06-25')
|
48
|
+
doc.updated_at = DateTime.now
|
49
|
+
end
|
50
|
+
|
51
|
+
begin
|
52
|
+
account = user.account_from_id 'account'
|
53
|
+
|
54
|
+
puts "#{account.path}: #{account.to_json}"
|
55
|
+
ensure
|
56
|
+
account.delete
|
57
|
+
end
|
58
|
+
|
59
|
+
post = user.create_post do |doc|
|
60
|
+
doc.content = 'Hello world!'
|
61
|
+
doc.created_at = DateTime.now
|
62
|
+
end
|
63
|
+
|
64
|
+
begin
|
65
|
+
puts "#{post.path}: #{post.to_json}"
|
66
|
+
ensure
|
67
|
+
post.delete
|
68
|
+
end
|
69
|
+
ensure
|
70
|
+
user.delete
|
71
|
+
end
|
72
|
+
end
|
metadata
CHANGED
@@ -1,26 +1,53 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firestore-odm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felipe Cabrera
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
12
|
-
dependencies:
|
11
|
+
date: 2020-06-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: google-cloud-firestore
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.4.3
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.4'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.4.3
|
13
33
|
description: ''
|
14
34
|
email: fecabrera0@outlook.com
|
15
35
|
executables: []
|
16
36
|
extensions: []
|
17
37
|
extra_rdoc_files: []
|
18
38
|
files:
|
39
|
+
- ".gitignore"
|
40
|
+
- Gemfile
|
41
|
+
- Gemfile.lock
|
42
|
+
- LICENSE
|
43
|
+
- README.md
|
44
|
+
- firestore-odm.gemspec
|
19
45
|
- lib/firestore-odm.rb
|
20
46
|
- lib/firestore-odm/collection.rb
|
21
47
|
- lib/firestore-odm/document.rb
|
22
48
|
- lib/firestore-odm/model.rb
|
23
49
|
- lib/firestore-odm/schema.rb
|
50
|
+
- test.rb
|
24
51
|
homepage: https://github.com/fecabrera/firestore-odm
|
25
52
|
licenses:
|
26
53
|
- BSD-2-Clause
|