cnfs-organization 0.0.1.alpha

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e4601c4b25b01aceef9ee56dbd1db890bac6454a7482e763c186353afd321490
4
+ data.tar.gz: 0f3ae2bc20e586ded4a3a1250ade966a38ebbc10624d2acc1b8d73ca637db073
5
+ SHA512:
6
+ metadata.gz: d386e79236317ef3758e993185541f7f09f59d2bf97d779760717827aa612582181d60985d04352e865ebdf4747ed132f33e684515b32a6d235728b3a9d12625
7
+ data.tar.gz: 88c04ff3370cb46c4bd7023a797f15b4cb08d886a3997454a92b986e77c35242d3f8c2fe1c9fd4df0bcdbd8f00708ee228a518fa79713849e3993e19800e5e52
@@ -0,0 +1,20 @@
1
+ Copyright 2019 TODO: Write your name
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Organization
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'organization'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install organization
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
29
+
30
+ # Documentation
31
+ [Rails on Services Guides](https://guides.rails-on-services.org)
@@ -0,0 +1,22 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Organization'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class BranchesController < Organization::ApplicationController
4
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Organization
4
+ class ApplicationController < ::ApplicationController
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class OrgsController < Organization::ApplicationController
4
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Organization
4
+ class ApplicationJob < ::ApplicationJob
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Branch < Organization::ApplicationRecord
4
+ belongs_to :org, inverse_of: :branches
5
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Org < Organization::ApplicationRecord
4
+ has_many :branches, dependent: :destroy, inverse_of: :org
5
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Organization
4
+ class ApplicationRecord < ::ApplicationRecord
5
+ self.abstract_class = true
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Tenant < Organization::ApplicationRecord
4
+ include Ros::TenantConcern
5
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class BranchPolicy < Organization::ApplicationPolicy
4
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class OrgPolicy < Organization::ApplicationPolicy
4
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Organization
4
+ class ApplicationPolicy < ::ApplicationPolicy
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class BranchResource < Organization::ApplicationResource
4
+ attributes :name, :properties
5
+
6
+ belongs_to :org
7
+
8
+ filter :org_id
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class OrgResource < Organization::ApplicationResource
4
+ attributes :name, :description, :properties
5
+
6
+ has_many :branches
7
+
8
+ filter :name, apply: ->(records, value, _options) { records.where('name ILIKE ?', "%#{value[0]}%") }
9
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Organization
4
+ class ApplicationResource < ::ApplicationResource
5
+ abstract
6
+ end
7
+ end
File without changes
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ Ros::Organization::Engine.routes.draw do
4
+ jsonapi_resources :branches
5
+ jsonapi_resources :orgs
6
+ end
@@ -0,0 +1,3 @@
1
+ ---
2
+ :queues:
3
+ - organization_default
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ Spring.application_root = './spec/dummy'
@@ -0,0 +1,11 @@
1
+ class CreateOrgs < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :orgs do |t|
4
+ t.string :name
5
+ t.string :description
6
+ t.jsonb :properties, null: false, default: {}
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ class CreateBranches < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :branches do |t|
4
+ t.references :org, foreign_key: true
5
+
6
+ t.string :name
7
+ t.jsonb :properties, null: false, default: {}
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Lint/UselessAssignment
4
+ after 'development:tenants' do
5
+ Tenant.all.each do |tenant|
6
+ is_even = (tenant.id % 2).zero?
7
+ next if tenant.id.eql? 1
8
+
9
+ tenant.switch do
10
+ first_org = FactoryBot.create(:org)
11
+ FactoryBot.create(:branch, org: first_org)
12
+ end
13
+ end
14
+ end
15
+ # rubocop:enable Lint/UselessAssignment
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ Tenant.create(schema_name: 'public')
4
+
5
+ 1.upto(7) do |id|
6
+ Tenant.create!(schema_name: Tenant.account_id_to_schema(id.to_s * 9))
7
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ros/core'
4
+ require 'ros/organization/engine'
5
+
6
+ module Ros
7
+ module Organization
8
+ # Your code goes here...
9
+ end
10
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ros
4
+ module Organization
5
+ class Engine < ::Rails::Engine
6
+ config.generators.api_only = true
7
+ config.generators do |g|
8
+ g.test_framework :rspec, fixture: true
9
+ g.fixture_replacement :factory_bot, dir: 'spec/factories'
10
+ end
11
+
12
+ initializer 'service.set_platform_config', before: 'ros_core.load_platform_config' do |_app|
13
+ settings_path = root.join('config/settings.yml')
14
+ Settings.prepend_source!(settings_path) if File.exist? settings_path
15
+ name = self.class.module_parent.name.demodulize.underscore
16
+ Settings.prepend_source!(service: { name: name, policy_name: name.capitalize })
17
+ end
18
+
19
+ # Adds this gem's db/migrations path to the enclosing application's migraations_path array
20
+ # if the gem has been included in an application, i.e. it is not running in the dummy app
21
+ # https://github.com/rails/rails/issues/22261
22
+ initializer 'service.configure_migrations' do |app|
23
+ unless Rails.root.to_s.end_with?('spec/dummy')
24
+ config.paths['db/migrate'].expanded.each do |expanded_path|
25
+ app.config.paths['db/migrate'] << expanded_path
26
+ ActiveRecord::Migrator.migrations_paths << expanded_path
27
+ end
28
+ end
29
+ end
30
+
31
+ initializer 'service.set_factory_paths', after: 'ros_core.set_factory_paths' do
32
+ if defined?(FactoryBot) && !Rails.env.production?
33
+ FactoryBot.definition_file_paths.prepend(Pathname.new(__FILE__).join('../../../../spec/factories'))
34
+ end
35
+ end
36
+
37
+ initializer 'service.configure_event_logging' do |_app|
38
+ if Settings.event_logging.enabled
39
+ Settings.event_logging.config.schemas_path = root.join(Settings.event_logging.config.schemas_path)
40
+ end
41
+ end
42
+
43
+ # initializer 'service.initialize_infra_services', after: 'ros_core.initialize_infra_services' do |app|
44
+ # end
45
+
46
+ initializer 'service.configure_console_methods', before: 'ros_core.configure_console_methods' do |_app|
47
+ require_relative 'console' if Rails.env.development? && !Rails.const_defined?('Server') && File.exist?('console.rb')
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ros
4
+ module Organization
5
+ VERSION = '0.0.1.alpha'
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :ros do
4
+ namespace :organization do
5
+ namespace :db do
6
+ desc 'Load engine seeds'
7
+ task :seed do
8
+ seedbank_root = Seedbank.seeds_root
9
+ Seedbank.seeds_root = File.expand_path('db/seeds', Ros::Organization::Engine.root)
10
+ Seedbank.load_tasks
11
+ Rake::Task['db:seed'].invoke
12
+ Seedbank.seeds_root = seedbank_root
13
+ end
14
+ end
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cnfs-organization
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.alpha
5
+ platform: ruby
6
+ authors:
7
+ - Robert Roach
8
+ - Rui Baltazar
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2020-01-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 6.0.2.1
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 6.0.2.1
28
+ - !ruby/object:Gem::Dependency
29
+ name: cnfs-core
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '='
33
+ - !ruby/object:Gem::Version
34
+ version: 0.0.1alpha
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '='
40
+ - !ruby/object:Gem::Version
41
+ version: 0.0.1alpha
42
+ - !ruby/object:Gem::Dependency
43
+ name: cnfs_sdk
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '='
47
+ - !ruby/object:Gem::Version
48
+ version: 0.0.1alpha
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '='
54
+ - !ruby/object:Gem::Version
55
+ version: 0.0.1alpha
56
+ description: Description of Organization.
57
+ email:
58
+ - rjayroach@gmail.com
59
+ - rui.p.baltazar@gmail.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - MIT-LICENSE
65
+ - README.md
66
+ - Rakefile
67
+ - app/controllers/branches_controller.rb
68
+ - app/controllers/organization/application_controller.rb
69
+ - app/controllers/orgs_controller.rb
70
+ - app/jobs/organization/application_job.rb
71
+ - app/models/branch.rb
72
+ - app/models/org.rb
73
+ - app/models/organization/application_record.rb
74
+ - app/models/tenant.rb
75
+ - app/policies/branch_policy.rb
76
+ - app/policies/org_policy.rb
77
+ - app/policies/organization/application_policy.rb
78
+ - app/resources/branch_resource.rb
79
+ - app/resources/org_resource.rb
80
+ - app/resources/organization/application_resource.rb
81
+ - config/environment.rb
82
+ - config/routes.rb
83
+ - config/sidekiq.yml
84
+ - config/spring.rb
85
+ - db/migrate/20190828151554_create_orgs.rb
86
+ - db/migrate/20190902123256_create_branches.rb
87
+ - db/seeds/development/data.seeds.rb
88
+ - db/seeds/development/tenants.seeds.rb
89
+ - lib/ros/organization.rb
90
+ - lib/ros/organization/engine.rb
91
+ - lib/ros/organization/version.rb
92
+ - lib/tasks/organization_tasks.rake
93
+ homepage: http://guides.rails-on-services.org/
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">"
104
+ - !ruby/object:Gem::Version
105
+ version: 2.6.0
106
+ - - "<"
107
+ - !ruby/object:Gem::Version
108
+ version: '2.7'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">"
112
+ - !ruby/object:Gem::Version
113
+ version: 1.3.1
114
+ requirements: []
115
+ rubygems_version: 3.0.3
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Summary of Organization.
119
+ test_files: []