pan_domain 0.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +3 -0
  4. data/Gemfile +6 -0
  5. data/Gemfile.lock +160 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +74 -0
  8. data/Rakefile +21 -0
  9. data/app/models/pan_domain/human/blood_classification_system.rb +35 -0
  10. data/app/models/pan_domain/human/blood_group_name.rb +25 -0
  11. data/bin/console +14 -0
  12. data/bin/pan_domain +4 -0
  13. data/bin/rails +25 -0
  14. data/bin/setup +8 -0
  15. data/db/human_domain/seeds.rb +28 -0
  16. data/db/migrate/human_domain/0001_create_blood_classification_systems.rb +17 -0
  17. data/db/migrate/human_domain/0002_create_blood_group_names.rb +20 -0
  18. data/db/seeds.rb +21 -0
  19. data/lib/generators/human_domain/generate/migrations_generator.rb +49 -0
  20. data/lib/pan_domain.rb +6 -0
  21. data/lib/pan_domain/cli.rb +53 -0
  22. data/lib/pan_domain/engine.rb +5 -0
  23. data/lib/pan_domain/human/engine.rb +11 -0
  24. data/lib/pan_domain/version.rb +3 -0
  25. data/lib/tasks/human_domain.rake +45 -0
  26. data/lib/tasks/pan_domain.rake +23 -0
  27. data/pan_domain.gemspec +44 -0
  28. data/spec/lib/generators/test_generate_migrations_generator.rb +48 -0
  29. data/spec/lib/pan_domain/cli_spec.rb +53 -0
  30. data/spec/pan_domain_spec.rb +5 -0
  31. data/spec/sample_app/app/channels/application_cable/channel.rb +4 -0
  32. data/spec/sample_app/app/channels/application_cable/connection.rb +4 -0
  33. data/spec/sample_app/app/controllers/application_controller.rb +2 -0
  34. data/spec/sample_app/app/helpers/application_helper.rb +2 -0
  35. data/spec/sample_app/app/jobs/application_job.rb +2 -0
  36. data/spec/sample_app/app/mailers/application_mailer.rb +4 -0
  37. data/spec/sample_app/app/models/application_record.rb +3 -0
  38. data/spec/sample_app/config/application.rb +29 -0
  39. data/spec/sample_app/config/boot.rb +5 -0
  40. data/spec/sample_app/config/environment.rb +5 -0
  41. data/spec/sample_app/config/environments/development.rb +61 -0
  42. data/spec/sample_app/config/environments/production.rb +94 -0
  43. data/spec/sample_app/config/environments/test.rb +46 -0
  44. data/spec/sample_app/config/initializers/application_controller_renderer.rb +8 -0
  45. data/spec/sample_app/config/initializers/assets.rb +14 -0
  46. data/spec/sample_app/config/initializers/backtrace_silencers.rb +7 -0
  47. data/spec/sample_app/config/initializers/content_security_policy.rb +25 -0
  48. data/spec/sample_app/config/initializers/cookies_serializer.rb +5 -0
  49. data/spec/sample_app/config/initializers/filter_parameter_logging.rb +4 -0
  50. data/spec/sample_app/config/initializers/inflections.rb +16 -0
  51. data/spec/sample_app/config/initializers/mime_types.rb +4 -0
  52. data/spec/sample_app/config/initializers/wrap_parameters.rb +14 -0
  53. data/spec/sample_app/config/puma.rb +34 -0
  54. data/spec/sample_app/config/routes.rb +3 -0
  55. data/spec/sample_app/config/spring.rb +6 -0
  56. data/spec/sample_app/db/schema.rb +18 -0
  57. data/spec/sample_app/db/seeds.rb +1 -0
  58. data/spec/sample_app/spec/lib/tasks/human_domain_spec.rb +89 -0
  59. data/spec/sample_app/spec/lib/tasks/pan_domain_spec.rb +38 -0
  60. data/spec/sample_app/spec/models/pan_domain/human/blood_classification_system_spec.rb +46 -0
  61. data/spec/sample_app/spec/models/pan_domain/human/blood_group_name_spec.rb +39 -0
  62. data/spec/sample_app/spec/rails_helper.rb +98 -0
  63. data/spec/sample_app/spec/spec_helper.rb +96 -0
  64. data/spec/spec_helper.rb +97 -0
  65. metadata +244 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 80e4e7b0492884556243a6be8f2d01eaffcc534281ae9c7d8d68be880633960a
4
+ data.tar.gz: a43f470f03503d9e26c2f7f75d76d108f8d67a493d09e25e337427433e7b0a18
5
+ SHA512:
6
+ metadata.gz: fc55e4219eede892e4b6ecc9d1795abddc6446e51e68956ca68aed087dbeb11f858114979ff5350d3b73eb170599b3a49f767dc2100cdc673c2e7401197348c5
7
+ data.tar.gz: 005b22812b8d93669181bc0a52a3fc7aaffab7ade2667a7f6fbb4d3fadbdc126ba42f21e8470da32acd8dd0ebc008d96a80deee4e6487ee159d2096c5e2901a1
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/sample_app/db/*.sqlite3
8
+ /spec/sample_app/db/*.sqlite3-journal
9
+ /spec/sample_app/db/log/*.log
10
+ /spec/sample_app/log/*.log
11
+ /spec/sample_app/tmp/
12
+ /spec/sample_app/.sass-cache
13
+ /spec/reports/
14
+ /tmp/
15
+
16
+ # rspec failure tracking
17
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in pan_domain.gemspec
6
+ gemspec
@@ -0,0 +1,160 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pan_domain (0.1.0)
5
+ rails (~> 5.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (5.2.1)
11
+ actionpack (= 5.2.1)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailer (5.2.1)
15
+ actionpack (= 5.2.1)
16
+ actionview (= 5.2.1)
17
+ activejob (= 5.2.1)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.2.1)
21
+ actionview (= 5.2.1)
22
+ activesupport (= 5.2.1)
23
+ rack (~> 2.0)
24
+ rack-test (>= 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.2.1)
28
+ activesupport (= 5.2.1)
29
+ builder (~> 3.1)
30
+ erubi (~> 1.4)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
+ activejob (5.2.1)
34
+ activesupport (= 5.2.1)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.2.1)
37
+ activesupport (= 5.2.1)
38
+ activerecord (5.2.1)
39
+ activemodel (= 5.2.1)
40
+ activesupport (= 5.2.1)
41
+ arel (>= 9.0)
42
+ activestorage (5.2.1)
43
+ actionpack (= 5.2.1)
44
+ activerecord (= 5.2.1)
45
+ marcel (~> 0.3.1)
46
+ activesupport (5.2.1)
47
+ concurrent-ruby (~> 1.0, >= 1.0.2)
48
+ i18n (>= 0.7, < 2)
49
+ minitest (~> 5.1)
50
+ tzinfo (~> 1.1)
51
+ arel (9.0.0)
52
+ builder (3.2.3)
53
+ byebug (10.0.2)
54
+ coderay (1.1.2)
55
+ concurrent-ruby (1.0.5)
56
+ crass (1.0.4)
57
+ diff-lcs (1.3)
58
+ erubi (1.7.1)
59
+ globalid (0.4.1)
60
+ activesupport (>= 4.2.0)
61
+ i18n (1.1.0)
62
+ concurrent-ruby (~> 1.0)
63
+ loofah (2.2.2)
64
+ crass (~> 1.0.2)
65
+ nokogiri (>= 1.5.9)
66
+ mail (2.7.1)
67
+ mini_mime (>= 0.1.1)
68
+ marcel (0.3.3)
69
+ mimemagic (~> 0.3.2)
70
+ method_source (0.9.0)
71
+ mimemagic (0.3.2)
72
+ mini_mime (1.0.1)
73
+ mini_portile2 (2.3.0)
74
+ minitest (5.11.3)
75
+ nio4r (2.3.1)
76
+ nokogiri (1.8.4)
77
+ mini_portile2 (~> 2.3.0)
78
+ pg (1.1.3)
79
+ pry (0.11.3)
80
+ coderay (~> 1.1.0)
81
+ method_source (~> 0.9.0)
82
+ pry-byebug (3.6.0)
83
+ byebug (~> 10.0)
84
+ pry (~> 0.10)
85
+ rack (2.0.5)
86
+ rack-test (1.1.0)
87
+ rack (>= 1.0, < 3)
88
+ rails (5.2.1)
89
+ actioncable (= 5.2.1)
90
+ actionmailer (= 5.2.1)
91
+ actionpack (= 5.2.1)
92
+ actionview (= 5.2.1)
93
+ activejob (= 5.2.1)
94
+ activemodel (= 5.2.1)
95
+ activerecord (= 5.2.1)
96
+ activestorage (= 5.2.1)
97
+ activesupport (= 5.2.1)
98
+ bundler (>= 1.3.0)
99
+ railties (= 5.2.1)
100
+ sprockets-rails (>= 2.0.0)
101
+ rails-dom-testing (2.0.3)
102
+ activesupport (>= 4.2.0)
103
+ nokogiri (>= 1.6)
104
+ rails-html-sanitizer (1.0.4)
105
+ loofah (~> 2.2, >= 2.2.2)
106
+ railties (5.2.1)
107
+ actionpack (= 5.2.1)
108
+ activesupport (= 5.2.1)
109
+ method_source
110
+ rake (>= 0.8.7)
111
+ thor (>= 0.19.0, < 2.0)
112
+ rake (10.5.0)
113
+ rspec-core (3.8.0)
114
+ rspec-support (~> 3.8.0)
115
+ rspec-expectations (3.8.2)
116
+ diff-lcs (>= 1.2.0, < 2.0)
117
+ rspec-support (~> 3.8.0)
118
+ rspec-mocks (3.8.0)
119
+ diff-lcs (>= 1.2.0, < 2.0)
120
+ rspec-support (~> 3.8.0)
121
+ rspec-rails (3.8.0)
122
+ actionpack (>= 3.0)
123
+ activesupport (>= 3.0)
124
+ railties (>= 3.0)
125
+ rspec-core (~> 3.8.0)
126
+ rspec-expectations (~> 3.8.0)
127
+ rspec-mocks (~> 3.8.0)
128
+ rspec-support (~> 3.8.0)
129
+ rspec-support (3.8.0)
130
+ shoulda-matchers (4.0.0.rc1)
131
+ activesupport (>= 4.2.0)
132
+ sprockets (3.7.2)
133
+ concurrent-ruby (~> 1.0)
134
+ rack (> 1, < 3)
135
+ sprockets-rails (3.2.1)
136
+ actionpack (>= 4.0)
137
+ activesupport (>= 4.0)
138
+ sprockets (>= 3.0.0)
139
+ thor (0.20.0)
140
+ thread_safe (0.3.6)
141
+ tzinfo (1.2.5)
142
+ thread_safe (~> 0.1)
143
+ websocket-driver (0.7.0)
144
+ websocket-extensions (>= 0.1.0)
145
+ websocket-extensions (0.1.3)
146
+
147
+ PLATFORMS
148
+ ruby
149
+
150
+ DEPENDENCIES
151
+ bundler (~> 1.16)
152
+ pan_domain!
153
+ pg (~> 1.1)
154
+ pry-byebug (~> 3.6)
155
+ rake (~> 10.0)
156
+ rspec-rails (~> 3.8)
157
+ shoulda-matchers (~> 4.0.0.rc1)
158
+
159
+ BUNDLED WITH
160
+ 1.16.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Yosua Jaya Candra
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.
@@ -0,0 +1,74 @@
1
+ # PanDomain
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'pan_domain'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle install
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install pan_domain
18
+
19
+ ## How to use
20
+
21
+ 1. Install all domains
22
+
23
+ $ pan_domain install
24
+
25
+ or with rake command
26
+
27
+ $ rake pan_domain:install
28
+
29
+ 2. Generate all migrations from all domains
30
+
31
+ $ pan_domain generate_migrations
32
+
33
+ or with rake command
34
+
35
+ $ rake pan_domain:install:migrations
36
+
37
+ 3. Seed all data from all domains
38
+
39
+ $ pan_domain generate_seeds
40
+
41
+ or with rake command
42
+
43
+ $ rake pan_domain:db:seed
44
+
45
+ 4. Install a specific domain (require add ```gem 'pan_domain'``` in the Gemfile)
46
+
47
+ $ rake [domain_name]_domain:install (eg: rake human_domain:install)
48
+
49
+ 5. Generate all migrations from a specific domain (require add ```gem 'pan_domain'``` in the Gemfile)
50
+
51
+ $ rake [domain_name]_domain:generate:migrations (eg: rake human_domain:generate:migrations)
52
+
53
+ 6. Loads all seed data from a specific domain (require add ```gem 'pan_domain'``` in the Gemfile)
54
+
55
+ $ rake [domain_name]_domain:db:seed (eg: rake human_domain:db:seed)
56
+
57
+ 7. List available commands
58
+ $ pan_domain --help
59
+
60
+ ## Test
61
+
62
+ To run all tests, you can use this command in root directory:
63
+
64
+ $ rake spec
65
+
66
+ Note: run `rspec` in root directory will not working.
67
+
68
+ ## Contributing
69
+
70
+ 1. Fork it
71
+ 2. Create your feature branch (git checkout -b my-new-feature)
72
+ 3. Commit your changes (git commit -am 'Add some feature')
73
+ 4. Push to the branch (git push origin my-new-feature)
74
+ 5. Create new Pull Request
@@ -0,0 +1,21 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ task :minitest_specs do
5
+ system 'ruby spec/lib/generators/test_generate_migrations_generator.rb'
6
+ end
7
+
8
+ RSpec::Core::RakeTask.new(:core_specs) do |t|
9
+ t.pattern = 'spec/**/*_spec.rb'
10
+ t.exclude_pattern = 'spec/sample_app/spec/**/*_spec.rb'
11
+ end
12
+
13
+ RSpec::Core::RakeTask.new(:integration_specs) do |t|
14
+ Dir.chdir 'spec/sample_app'
15
+
16
+ t.pattern = Dir.glob('spec/**/*_spec.rb')
17
+ end
18
+
19
+ task spec: [:minitest_specs, :core_specs, :integration_specs]
20
+
21
+ task default: :spec
@@ -0,0 +1,35 @@
1
+ module PanDomain
2
+ module Human
3
+ # Store information about blood clasification systems
4
+ class BloodClassificationSystem < ActiveRecord::Base
5
+ SYSTEMS = [
6
+ {
7
+ name: 'ABO',
8
+ description: 'A system which group human blood with A, B, O, and AB.'
9
+ },
10
+ {
11
+ name: 'Rhesus',
12
+ description: 'A system which group human blood with Rh- and Rh+.'
13
+ }
14
+ ].freeze
15
+
16
+ self.table_name = 'blood_classification_systems'
17
+
18
+ validates :name, :description, presence: true
19
+
20
+ validates_uniqueness_of :name
21
+
22
+ has_many :blood_group_names
23
+
24
+ class << self
25
+ def abo
26
+ @abo ||= find_by(name: 'ABO')
27
+ end
28
+
29
+ def rhesus
30
+ @rhesus ||= find_by(name: 'Rhesus')
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,25 @@
1
+ module PanDomain
2
+ module Human
3
+ # Store information about blood groups
4
+ class BloodGroupName < ActiveRecord::Base
5
+ GROUP_NAMES = [
6
+ { system_name: 'ABO', name: 'A', symbol: 'A' },
7
+ { system_name: 'ABO', name: 'B', symbol: 'B' },
8
+ { system_name: 'ABO', name: 'O', symbol: 'O' },
9
+ { system_name: 'ABO', name: 'AB', symbol: 'AB' },
10
+ { system_name: 'Rhesus', name: 'Rhesus +', symbol: 'Rh+' },
11
+ { system_name: 'Rhesus', name: 'Rhesus -', symbol: 'Rh-' }
12
+ ].freeze
13
+
14
+ self.table_name = 'blood_group_names'
15
+
16
+ validates :name, :symbol,
17
+ presence: true,
18
+ uniqueness: {
19
+ scope: :blood_classification_system_id, case_sensitive: false
20
+ }
21
+
22
+ belongs_to :blood_classification_system
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'pan_domain'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pan_domain'
3
+
4
+ PanDomain::CLI.start(ARGV)
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('..', __dir__)
6
+ ENGINE_PATH = File.expand_path('../lib/pan_domain/engine', __dir__)
7
+ APP_PATH = File.expand_path('../spec/sample_app/config/application', __dir__)
8
+
9
+ # Set up gems listed in the Gemfile.
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
11
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
12
+
13
+ require 'rails'
14
+ # Pick the frameworks you want:
15
+ require 'active_model/railtie'
16
+ require 'active_job/railtie'
17
+ require 'active_record/railtie'
18
+ require 'active_storage/engine'
19
+ require 'action_controller/railtie'
20
+ require 'action_mailer/railtie'
21
+ require 'action_view/railtie'
22
+ require 'action_cable/engine'
23
+ require 'sprockets/railtie'
24
+ # require 'rails/test_unit/railtie'
25
+ require 'rails/engine/commands'
@@ -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,28 @@
1
+ require_dependency File.expand_path('../../app/models/pan_domain/human/blood_classification_system', __dir__)
2
+ require_dependency File.expand_path('../../app/models/pan_domain/human/blood_group_name', __dir__)
3
+
4
+ module PanDomain
5
+ module Human
6
+ if ActiveRecord::Base.connection.table_exists?(BloodClassificationSystem.table_name)
7
+ if BloodClassificationSystem::SYSTEMS.size != BloodClassificationSystem.count
8
+ BloodClassificationSystem::SYSTEMS.each do |system_params|
9
+ BloodClassificationSystem.where(
10
+ name: system_params[:name]
11
+ ).first_or_create(description: system_params[:description])
12
+ end
13
+ end
14
+
15
+ if ActiveRecord::Base.connection.table_exists?(BloodGroupName.table_name)
16
+ if BloodGroupName::GROUP_NAMES.size != BloodGroupName.count
17
+ BloodGroupName::GROUP_NAMES.each do |group_name_params|
18
+ system = BloodClassificationSystem.find_by(name: group_name_params[:system_name])
19
+
20
+ BloodGroupName.where(
21
+ name: group_name_params[:name], symbol: group_name_params[:symbol]
22
+ ).first_or_create(blood_classification_system: system)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end