-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d6a3fd0
Showing
32 changed files
with
762 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/.bundle/ | ||
/doc/ | ||
/log/*.log | ||
/pkg/ | ||
/tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
source "https://rubygems.org" | ||
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | ||
|
||
gem 'faker', '~> 3.2.1' | ||
gem 'resource_api', git: 'https://github.com/performant-software/resource-api.git', tag: 'v0.4.5' | ||
|
||
gem 'sqlite3' | ||
|
||
# Specify your gem's dependencies in core_data_connector.gemspec. | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
GIT | ||
remote: https://github.com/performant-software/resource-api.git | ||
revision: ebfc4357bdfd13ae863f1e1aebdcc637be2ff6de | ||
tag: v0.4.5 | ||
specs: | ||
resource_api (0.1.0) | ||
pagy (~> 5.10) | ||
rails (>= 7.0, < 8) | ||
|
||
PATH | ||
remote: . | ||
specs: | ||
core_data_connector (0.1.0) | ||
rails (>= 6.0.3.2, < 8) | ||
resource_api | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
actioncable (7.0.7) | ||
actionpack (= 7.0.7) | ||
activesupport (= 7.0.7) | ||
nio4r (~> 2.0) | ||
websocket-driver (>= 0.6.1) | ||
actionmailbox (7.0.7) | ||
actionpack (= 7.0.7) | ||
activejob (= 7.0.7) | ||
activerecord (= 7.0.7) | ||
activestorage (= 7.0.7) | ||
activesupport (= 7.0.7) | ||
mail (>= 2.7.1) | ||
net-imap | ||
net-pop | ||
net-smtp | ||
actionmailer (7.0.7) | ||
actionpack (= 7.0.7) | ||
actionview (= 7.0.7) | ||
activejob (= 7.0.7) | ||
activesupport (= 7.0.7) | ||
mail (~> 2.5, >= 2.5.4) | ||
net-imap | ||
net-pop | ||
net-smtp | ||
rails-dom-testing (~> 2.0) | ||
actionpack (7.0.7) | ||
actionview (= 7.0.7) | ||
activesupport (= 7.0.7) | ||
rack (~> 2.0, >= 2.2.4) | ||
rack-test (>= 0.6.3) | ||
rails-dom-testing (~> 2.0) | ||
rails-html-sanitizer (~> 1.0, >= 1.2.0) | ||
actiontext (7.0.7) | ||
actionpack (= 7.0.7) | ||
activerecord (= 7.0.7) | ||
activestorage (= 7.0.7) | ||
activesupport (= 7.0.7) | ||
globalid (>= 0.6.0) | ||
nokogiri (>= 1.8.5) | ||
actionview (7.0.7) | ||
activesupport (= 7.0.7) | ||
builder (~> 3.1) | ||
erubi (~> 1.4) | ||
rails-dom-testing (~> 2.0) | ||
rails-html-sanitizer (~> 1.1, >= 1.2.0) | ||
activejob (7.0.7) | ||
activesupport (= 7.0.7) | ||
globalid (>= 0.3.6) | ||
activemodel (7.0.7) | ||
activesupport (= 7.0.7) | ||
activerecord (7.0.7) | ||
activemodel (= 7.0.7) | ||
activesupport (= 7.0.7) | ||
activestorage (7.0.7) | ||
actionpack (= 7.0.7) | ||
activejob (= 7.0.7) | ||
activerecord (= 7.0.7) | ||
activesupport (= 7.0.7) | ||
marcel (~> 1.0) | ||
mini_mime (>= 1.1.0) | ||
activesupport (7.0.7) | ||
concurrent-ruby (~> 1.0, >= 1.0.2) | ||
i18n (>= 1.6, < 2) | ||
minitest (>= 5.1) | ||
tzinfo (~> 2.0) | ||
builder (3.2.4) | ||
concurrent-ruby (1.2.2) | ||
crass (1.0.6) | ||
date (3.3.3) | ||
erubi (1.12.0) | ||
globalid (1.1.0) | ||
activesupport (>= 5.0) | ||
i18n (1.14.1) | ||
concurrent-ruby (~> 1.0) | ||
loofah (2.21.3) | ||
crass (~> 1.0.2) | ||
nokogiri (>= 1.12.0) | ||
mail (2.8.1) | ||
mini_mime (>= 0.1.1) | ||
net-imap | ||
net-pop | ||
net-smtp | ||
marcel (1.0.2) | ||
method_source (1.0.0) | ||
mini_mime (1.1.5) | ||
minitest (5.19.0) | ||
net-imap (0.3.7) | ||
date | ||
net-protocol | ||
net-pop (0.1.2) | ||
net-protocol | ||
net-protocol (0.2.1) | ||
timeout | ||
net-smtp (0.3.3) | ||
net-protocol | ||
nio4r (2.5.9) | ||
nokogiri (1.15.3-x86_64-darwin) | ||
racc (~> 1.4) | ||
pagy (5.10.1) | ||
activesupport | ||
racc (1.7.1) | ||
rack (2.2.8) | ||
rack-test (2.1.0) | ||
rack (>= 1.3) | ||
rails (7.0.7) | ||
actioncable (= 7.0.7) | ||
actionmailbox (= 7.0.7) | ||
actionmailer (= 7.0.7) | ||
actionpack (= 7.0.7) | ||
actiontext (= 7.0.7) | ||
actionview (= 7.0.7) | ||
activejob (= 7.0.7) | ||
activemodel (= 7.0.7) | ||
activerecord (= 7.0.7) | ||
activestorage (= 7.0.7) | ||
activesupport (= 7.0.7) | ||
bundler (>= 1.15.0) | ||
railties (= 7.0.7) | ||
rails-dom-testing (2.2.0) | ||
activesupport (>= 5.0.0) | ||
minitest | ||
nokogiri (>= 1.6) | ||
rails-html-sanitizer (1.6.0) | ||
loofah (~> 2.21) | ||
nokogiri (~> 1.14) | ||
railties (7.0.7) | ||
actionpack (= 7.0.7) | ||
activesupport (= 7.0.7) | ||
method_source | ||
rake (>= 12.2) | ||
thor (~> 1.0) | ||
zeitwerk (~> 2.5) | ||
rake (13.0.6) | ||
sqlite3 (1.6.3-x86_64-darwin) | ||
thor (1.2.2) | ||
timeout (0.4.0) | ||
tzinfo (2.0.6) | ||
concurrent-ruby (~> 1.0) | ||
websocket-driver (0.7.6) | ||
websocket-extensions (>= 0.1.0) | ||
websocket-extensions (0.1.5) | ||
zeitwerk (2.6.11) | ||
|
||
PLATFORMS | ||
x86_64-darwin-19 | ||
|
||
DEPENDENCIES | ||
core_data_connector! | ||
resource_api! | ||
sqlite3 | ||
|
||
BUNDLED WITH | ||
2.3.16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright 2023 Derek Leadbetter | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# CoreDataConnector | ||
Short description and motivation. | ||
|
||
## Usage | ||
How to use my plugin. | ||
|
||
## Installation | ||
Add this line to your application's Gemfile: | ||
|
||
```ruby | ||
gem "core_data_connector" | ||
``` | ||
|
||
And then execute: | ||
```bash | ||
$ bundle | ||
``` | ||
|
||
Or install it yourself as: | ||
```bash | ||
$ gem install core_data_connector | ||
``` | ||
|
||
## Contributing | ||
Contribution directions go here. | ||
|
||
## License | ||
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require "bundler/setup" | ||
|
||
load "rails/tasks/statistics.rake" | ||
|
||
require "bundler/gem_tasks" |
Empty file.
17 changes: 17 additions & 0 deletions
17
app/controllers/core_data_connector/application_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module CoreDataConnector | ||
class ApplicationController < CoreDataConnector.config.base_controller_class.constantize | ||
def current_user | ||
return super if defined?(super) | ||
|
||
nil | ||
end | ||
|
||
def item_class | ||
"CoreDataConnector::#{controller_name.singularize.classify}".constantize | ||
end | ||
|
||
def serializer_class | ||
"CoreDataConnector::#{"#{controller_name}_serializer".classify}".constantize | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module CoreDataConnector | ||
class PlacesController < ApplicationController | ||
# Search attributes | ||
search_attributes 'core_data_connector_place_names.name' | ||
|
||
# Left joins | ||
left_joins :primary_name | ||
|
||
# Preloads | ||
preloads :primary_name | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module CoreDataConnector | ||
class AnalyzeTablesJob < ApplicationJob | ||
|
||
# Analyzes all foreign tables to keep statistics up to date | ||
def perform | ||
postgres = Postgres.new | ||
postgres.analyze_tables | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module CoreDataConnector | ||
class ApplicationJob < ActiveJob::Base | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module CoreDataConnector | ||
class ApplicationMailer < ActionMailer::Base | ||
default from: "[email protected]" | ||
layout "mailer" | ||
end | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module CoreDataConnector | ||
module Locateable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
# Relationships | ||
has_many :locations, as: :locateable, dependent: :destroy, class_name: Location.to_s | ||
|
||
# Nested attributes | ||
accepts_nested_attributes_for :locations, allow_destroy: true | ||
|
||
# Resourceable parameters | ||
allow_params locations_attributes: [:id, :place_id, :_destroy] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module CoreDataConnector | ||
class ApplicationRecord < ActiveRecord::Base | ||
self.abstract_class = true | ||
|
||
# Includes | ||
include Resourceable | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module CoreDataConnector | ||
class Location < ApplicationRecord | ||
self.primary_key = :id | ||
|
||
# Relationships | ||
belongs_to :place | ||
belongs_to :locateable, polymorphic: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module CoreDataConnector | ||
class Place < ApplicationRecord | ||
self.primary_key = :id | ||
|
||
# Relationships | ||
has_many :place_names, dependent: :destroy | ||
has_one :primary_name, -> { where(primary: true) }, class_name: 'PlaceName' | ||
|
||
# Nested attributes | ||
accepts_nested_attributes_for :place_names, allow_destroy: true | ||
|
||
# Resourceable parameters | ||
allow_params place_names_attributes: [:id, :name, :primary, :_destroy] | ||
|
||
def name | ||
primary_name&.name | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module CoreDataConnector | ||
class PlaceName < ApplicationRecord | ||
self.primary_key = :id | ||
|
||
# Relationships | ||
belongs_to :place | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module CoreDataConnector | ||
class PlacesSerializer < BaseSerializer | ||
index_attributes :id, :name | ||
show_attributes :id, place_names: [:id, :name, :primary] | ||
end | ||
end |
Oops, something went wrong.