activefire 0.0.1.pre.dev

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 33613352f995c575b9f1e6b3258f2212686bfeb59a071fc722d0d967da78fe4d
4
+ data.tar.gz: 2b5ef072c5f913a046d4448f8b0d205f82f9a9dff5c328b8726a098abd3b1dcd
5
+ SHA512:
6
+ metadata.gz: e846079efb208a360b0735b660f5c424923000529e1931ae44ad5ad1f52171f5f91cd536ff926affd1ff126a7c90509a28fa32a7c26269de6a67aea3266f6f2e
7
+ data.tar.gz: 237f008c9930f8eb9f27d42a54c645422763207557e6eabf8193c7363e5cdef07ef680bfaa7396d6c149046db97d0077e3cf42f8df1d34d9b4c66fae4e6065dc
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /private
10
+ .env
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.5
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in activefire.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,126 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ activefire (0.0.1.pre.dev)
5
+ google-cloud-firestore (~> 2.7)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.8.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ ast (2.4.2)
13
+ concurrent-ruby (1.1.10)
14
+ diff-lcs (1.5.0)
15
+ dotenv (2.7.6)
16
+ faraday (2.3.0)
17
+ faraday-net_http (~> 2.0)
18
+ ruby2_keywords (>= 0.0.4)
19
+ faraday-net_http (2.0.3)
20
+ faraday-retry (2.0.0)
21
+ faraday (~> 2.0)
22
+ gapic-common (0.10.0)
23
+ faraday (>= 1.9, < 3.a)
24
+ faraday-retry (>= 1.0, < 3.a)
25
+ google-protobuf (~> 3.14)
26
+ googleapis-common-protos (>= 1.3.12, < 2.a)
27
+ googleapis-common-protos-types (>= 1.3.1, < 2.a)
28
+ googleauth (~> 1.0)
29
+ grpc (~> 1.36)
30
+ google-cloud-core (1.6.0)
31
+ google-cloud-env (~> 1.0)
32
+ google-cloud-errors (~> 1.0)
33
+ google-cloud-env (1.6.0)
34
+ faraday (>= 0.17.3, < 3.0)
35
+ google-cloud-errors (1.2.0)
36
+ google-cloud-firestore (2.7.1)
37
+ concurrent-ruby (~> 1.0)
38
+ google-cloud-core (~> 1.5)
39
+ google-cloud-firestore-v1 (~> 0.0)
40
+ rbtree (~> 0.4.2)
41
+ google-cloud-firestore-v1 (0.7.0)
42
+ gapic-common (>= 0.10, < 2.a)
43
+ google-cloud-errors (~> 1.0)
44
+ google-protobuf (3.21.2-x86_64-darwin)
45
+ googleapis-common-protos (1.3.12)
46
+ google-protobuf (~> 3.14)
47
+ googleapis-common-protos-types (~> 1.2)
48
+ grpc (~> 1.27)
49
+ googleapis-common-protos-types (1.3.2)
50
+ google-protobuf (~> 3.14)
51
+ googleauth (1.2.0)
52
+ faraday (>= 0.17.3, < 3.a)
53
+ jwt (>= 1.4, < 3.0)
54
+ memoist (~> 0.16)
55
+ multi_json (~> 1.11)
56
+ os (>= 0.9, < 2.0)
57
+ signet (>= 0.16, < 2.a)
58
+ grpc (1.47.0-x86_64-darwin)
59
+ google-protobuf (~> 3.19)
60
+ googleapis-common-protos-types (~> 1.0)
61
+ json (2.6.2)
62
+ jwt (2.4.1)
63
+ kwalify (0.7.2)
64
+ memoist (0.16.2)
65
+ multi_json (1.15.0)
66
+ os (1.1.4)
67
+ parallel (1.22.1)
68
+ parser (3.1.2.0)
69
+ ast (~> 2.4.1)
70
+ public_suffix (4.0.7)
71
+ rainbow (3.1.1)
72
+ rake (12.3.3)
73
+ rbtree (0.4.5)
74
+ reek (6.1.1)
75
+ kwalify (~> 0.7.0)
76
+ parser (~> 3.1.0)
77
+ rainbow (>= 2.0, < 4.0)
78
+ regexp_parser (2.5.0)
79
+ rexml (3.2.5)
80
+ rspec (3.11.0)
81
+ rspec-core (~> 3.11.0)
82
+ rspec-expectations (~> 3.11.0)
83
+ rspec-mocks (~> 3.11.0)
84
+ rspec-core (3.11.0)
85
+ rspec-support (~> 3.11.0)
86
+ rspec-expectations (3.11.0)
87
+ diff-lcs (>= 1.2.0, < 2.0)
88
+ rspec-support (~> 3.11.0)
89
+ rspec-mocks (3.11.1)
90
+ diff-lcs (>= 1.2.0, < 2.0)
91
+ rspec-support (~> 3.11.0)
92
+ rspec-support (3.11.0)
93
+ rubocop (1.31.2)
94
+ json (~> 2.3)
95
+ parallel (~> 1.10)
96
+ parser (>= 3.1.0.0)
97
+ rainbow (>= 2.2.2, < 4.0)
98
+ regexp_parser (>= 1.8, < 3.0)
99
+ rexml (>= 3.2.5, < 4.0)
100
+ rubocop-ast (>= 1.18.0, < 2.0)
101
+ ruby-progressbar (~> 1.7)
102
+ unicode-display_width (>= 1.4.0, < 3.0)
103
+ rubocop-ast (1.19.1)
104
+ parser (>= 3.1.1.0)
105
+ ruby-progressbar (1.11.0)
106
+ ruby2_keywords (0.0.5)
107
+ signet (0.17.0)
108
+ addressable (~> 2.8)
109
+ faraday (>= 0.17.5, < 3.a)
110
+ jwt (>= 1.5, < 3.0)
111
+ multi_json (~> 1.10)
112
+ unicode-display_width (2.2.0)
113
+
114
+ PLATFORMS
115
+ ruby
116
+
117
+ DEPENDENCIES
118
+ activefire!
119
+ dotenv (~> 2.7)
120
+ rake (~> 12.0)
121
+ reek (~> 6.1)
122
+ rspec (~> 3.0)
123
+ rubocop (~> 1.31)
124
+
125
+ BUNDLED WITH
126
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Jonathan Duarte
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # ActiveFire
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/activefire`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'activefire'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install activefire
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
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
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/activefire.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,34 @@
1
+ require_relative 'lib/active_fire/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'activefire'
5
+ spec.version = ActiveFire::VERSION
6
+ spec.authors = ['Jonathan Duarte']
7
+ spec.email = ['jonathan.duarte@rocketmail.com']
8
+
9
+ spec.summary = 'ActiveRecord for Firebase'
10
+ spec.description = 'Ruby ODM framework for Firebase '
11
+ spec.homepage = 'https://github.com/jonduarte/activefire'
12
+ spec.license = 'MIT'
13
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
14
+
15
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/jonduarte/activefire'
19
+ spec.metadata['changelog_uri'] = 'https://github.com/jonduarte/activefire/blob/master/CHANGELOG.md'
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+ spec.add_dependency 'google-cloud-firestore', '~> 2.7'
30
+
31
+ spec.add_development_dependency 'dotenv', '~> 2.7'
32
+ spec.add_development_dependency 'rubocop', '~> 1.31'
33
+ spec.add_development_dependency 'reek', '~> 6.1'
34
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'dotenv/load'
5
+ require 'active_fire'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ module ActiveFire
2
+ VERSION = "0.0.1-dev"
3
+ end
@@ -0,0 +1,70 @@
1
+ require 'active_fire/version'
2
+ require 'google/cloud/firestore'
3
+
4
+ module ActiveFire
5
+ class Error < StandardError; end
6
+
7
+ class Client
8
+ attr_reader :firestore
9
+
10
+ def initialize
11
+ @firestore = Google::Cloud::Firestore.new(
12
+ project_id: ENV.fetch('PROJECT_NAME'),
13
+ credentials: ENV.fetch('CREDENTIALS_FILE')
14
+ )
15
+ end
16
+ end
17
+
18
+ module ActiveFire::Naming
19
+ def table_name
20
+ name
21
+ end
22
+
23
+ def __private_types
24
+ @__private_types ||= {}
25
+ end
26
+
27
+ def field(name, type:)
28
+ if type == nil
29
+ type = String
30
+ end
31
+ __private_types[name] = type
32
+
33
+ define_method name do
34
+ data[name]
35
+ end
36
+
37
+ define_method("#{name}=") do |value|
38
+ casted = value
39
+ cast = self.class.__private_types[name]
40
+ if !value.is_a?(cast)
41
+ puts "casted to: #{cast}"
42
+ cast = eval("#{cast}(\"#{value}\")")
43
+ end
44
+
45
+ puts "Value: #{value}"
46
+ end
47
+ end
48
+ end
49
+
50
+ class Base
51
+ extend ActiveFire::Naming
52
+
53
+ def initialize(ref)
54
+ @ref = ref
55
+ end
56
+
57
+ def data
58
+ @ref.data
59
+ end
60
+ end
61
+ end
62
+
63
+ a = ActiveFire::Client.new
64
+ col = a.firestore.col('players').doc('oPBVulSlZEAXNJrjEOJX')
65
+
66
+ class Player < ActiveFire::Base
67
+ field :name, type: Integer
68
+ end
69
+
70
+ PLAYER = Player.new(col.get)
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activefire
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre.dev
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Duarte
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-07-18 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: '2.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dotenv
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.31'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.31'
55
+ - !ruby/object:Gem::Dependency
56
+ name: reek
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '6.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '6.1'
69
+ description: 'Ruby ODM framework for Firebase '
70
+ email:
71
+ - jonathan.duarte@rocketmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - activefire.gemspec
85
+ - bin/console
86
+ - bin/setup
87
+ - lib/active_fire.rb
88
+ - lib/active_fire/version.rb
89
+ homepage: https://github.com/jonduarte/activefire
90
+ licenses:
91
+ - MIT
92
+ metadata:
93
+ homepage_uri: https://github.com/jonduarte/activefire
94
+ source_code_uri: https://github.com/jonduarte/activefire
95
+ changelog_uri: https://github.com/jonduarte/activefire/blob/master/CHANGELOG.md
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 2.3.0
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">"
108
+ - !ruby/object:Gem::Version
109
+ version: 1.3.1
110
+ requirements: []
111
+ rubygems_version: 3.1.6
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: ActiveRecord for Firebase
115
+ test_files: []