meibo 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +13 -0
  4. data/CHANGELOG.md +5 -0
  5. data/CODE_OF_CONDUCT.md +84 -0
  6. data/Gemfile +16 -0
  7. data/Gemfile.lock +84 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +41 -0
  10. data/Rakefile +12 -0
  11. data/lib/meibo/academic_session.rb +48 -0
  12. data/lib/meibo/academic_session_set.rb +15 -0
  13. data/lib/meibo/base_profile.rb +37 -0
  14. data/lib/meibo/builder/academic_session_builder.rb +26 -0
  15. data/lib/meibo/builder/base_builder.rb +13 -0
  16. data/lib/meibo/builder/classroom_builder.rb +38 -0
  17. data/lib/meibo/builder/course_builder.rb +32 -0
  18. data/lib/meibo/builder/demographic_builder.rb +22 -0
  19. data/lib/meibo/builder/enrollment_builder.rb +30 -0
  20. data/lib/meibo/builder/organization_builder.rb +34 -0
  21. data/lib/meibo/builder/role_builder.rb +30 -0
  22. data/lib/meibo/builder/user_builder.rb +36 -0
  23. data/lib/meibo/builder/user_profile_builder.rb +22 -0
  24. data/lib/meibo/builder.rb +60 -0
  25. data/lib/meibo/classroom.rb +67 -0
  26. data/lib/meibo/classroom_set.rb +29 -0
  27. data/lib/meibo/converter.rb +259 -0
  28. data/lib/meibo/course.rb +45 -0
  29. data/lib/meibo/course_set.rb +23 -0
  30. data/lib/meibo/data_model.rb +84 -0
  31. data/lib/meibo/data_set.rb +44 -0
  32. data/lib/meibo/demographic.rb +70 -0
  33. data/lib/meibo/demographic_set.rb +18 -0
  34. data/lib/meibo/enrollment.rb +51 -0
  35. data/lib/meibo/enrollment_set.rb +22 -0
  36. data/lib/meibo/errors.rb +13 -0
  37. data/lib/meibo/factory_bot/academic_session.rb +23 -0
  38. data/lib/meibo/factory_bot/all.rb +13 -0
  39. data/lib/meibo/factory_bot/classroom.rb +28 -0
  40. data/lib/meibo/factory_bot/course.rb +21 -0
  41. data/lib/meibo/factory_bot/demographic.rb +16 -0
  42. data/lib/meibo/factory_bot/enrollment.rb +37 -0
  43. data/lib/meibo/factory_bot/manifest.rb +33 -0
  44. data/lib/meibo/factory_bot/memory_package.rb +11 -0
  45. data/lib/meibo/factory_bot/organization.rb +47 -0
  46. data/lib/meibo/factory_bot/role.rb +41 -0
  47. data/lib/meibo/factory_bot/user.rb +22 -0
  48. data/lib/meibo/factory_bot/user_profile.rb +21 -0
  49. data/lib/meibo/japan_profile/academic_session.rb +26 -0
  50. data/lib/meibo/japan_profile/classroom.rb +21 -0
  51. data/lib/meibo/japan_profile/course.rb +18 -0
  52. data/lib/meibo/japan_profile/demographic.rb +15 -0
  53. data/lib/meibo/japan_profile/enrollment.rb +35 -0
  54. data/lib/meibo/japan_profile/organization.rb +20 -0
  55. data/lib/meibo/japan_profile/role.rb +26 -0
  56. data/lib/meibo/japan_profile/user.rb +27 -0
  57. data/lib/meibo/japan_profile/user_profile.rb +7 -0
  58. data/lib/meibo/japan_profile.rb +39 -0
  59. data/lib/meibo/manifest/processing_mode.rb +40 -0
  60. data/lib/meibo/manifest.rb +163 -0
  61. data/lib/meibo/organization.rb +44 -0
  62. data/lib/meibo/organization_set.rb +15 -0
  63. data/lib/meibo/reader.rb +138 -0
  64. data/lib/meibo/role.rb +65 -0
  65. data/lib/meibo/role_set.rb +25 -0
  66. data/lib/meibo/roster.rb +166 -0
  67. data/lib/meibo/user.rb +71 -0
  68. data/lib/meibo/user_profile.rb +42 -0
  69. data/lib/meibo/user_profile_set.rb +18 -0
  70. data/lib/meibo/user_set.rb +24 -0
  71. data/lib/meibo/version.rb +5 -0
  72. data/lib/meibo.rb +17 -0
  73. data/meibo.gemspec +38 -0
  74. data/sig/meibo.rbs +4 -0
  75. metadata +148 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 72db5b95c8207a9f74cc5930da8103632a2f6c51e3d59243fc452ac4ffefa010
4
+ data.tar.gz: bd156f3a9ffb5a367d490b1d755f44ce5af13ec5ca69ed4341fbf6ecfc44fdeb
5
+ SHA512:
6
+ metadata.gz: 7263fac70bb046b9a85088530e8a822e59d15f47ef7d1c809ff4fd8fa26c9927bbf5313db7979fd7613292bf7aa05cce0103659ea4686e39eb8eb21f0f7a2ffe
7
+ data.tar.gz: 1befb3a9401a3d92000282e576b75914c4bffd67788b5ba8853385b85eb691676e9e42cad7e5acf3b65a79cc8a20604be9f2ae574eebb5301dcc715fb60fc365
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-10-13
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at hanachin@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in meibo.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
13
+
14
+ gem "factory_bot"
15
+
16
+ gem "debug"
data/Gemfile.lock ADDED
@@ -0,0 +1,84 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ meibo (0.1.0)
5
+ rubyzip
6
+ zeitwerk
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (7.0.4)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
16
+ ast (2.4.2)
17
+ concurrent-ruby (1.1.10)
18
+ debug (1.6.3)
19
+ irb (>= 1.3.6)
20
+ reline (>= 0.3.1)
21
+ diff-lcs (1.5.0)
22
+ factory_bot (6.2.1)
23
+ activesupport (>= 5.0.0)
24
+ i18n (1.12.0)
25
+ concurrent-ruby (~> 1.0)
26
+ io-console (0.5.11)
27
+ irb (1.4.2)
28
+ reline (>= 0.3.0)
29
+ json (2.6.2)
30
+ minitest (5.16.3)
31
+ parallel (1.22.1)
32
+ parser (3.1.2.1)
33
+ ast (~> 2.4.1)
34
+ rainbow (3.1.1)
35
+ rake (13.0.6)
36
+ regexp_parser (2.6.0)
37
+ reline (0.3.1)
38
+ io-console (~> 0.5)
39
+ rexml (3.2.5)
40
+ rspec (3.11.0)
41
+ rspec-core (~> 3.11.0)
42
+ rspec-expectations (~> 3.11.0)
43
+ rspec-mocks (~> 3.11.0)
44
+ rspec-core (3.11.0)
45
+ rspec-support (~> 3.11.0)
46
+ rspec-expectations (3.11.1)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.11.0)
49
+ rspec-mocks (3.11.1)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.11.0)
52
+ rspec-support (3.11.1)
53
+ rubocop (1.36.0)
54
+ json (~> 2.3)
55
+ parallel (~> 1.10)
56
+ parser (>= 3.1.2.1)
57
+ rainbow (>= 2.2.2, < 4.0)
58
+ regexp_parser (>= 1.8, < 3.0)
59
+ rexml (>= 3.2.5, < 4.0)
60
+ rubocop-ast (>= 1.20.1, < 2.0)
61
+ ruby-progressbar (~> 1.7)
62
+ unicode-display_width (>= 1.4.0, < 3.0)
63
+ rubocop-ast (1.22.0)
64
+ parser (>= 3.1.1.0)
65
+ ruby-progressbar (1.11.0)
66
+ rubyzip (2.3.2)
67
+ tzinfo (2.0.5)
68
+ concurrent-ruby (~> 1.0)
69
+ unicode-display_width (2.3.0)
70
+ zeitwerk (2.6.1)
71
+
72
+ PLATFORMS
73
+ x86_64-linux
74
+
75
+ DEPENDENCIES
76
+ debug
77
+ factory_bot
78
+ meibo!
79
+ rake (~> 13.0)
80
+ rspec (~> 3.0)
81
+ rubocop (~> 1.21)
82
+
83
+ BUNDLED WITH
84
+ 2.3.7
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Seiei Miyagi
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,41 @@
1
+ # Meibo
2
+
3
+ Meibo is a ruby library for OneRoster CSV Binding Japan Profile.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'meibo'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install meibo
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ 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.
28
+
29
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/meibo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/meibo/blob/main/CODE_OF_CONDUCT.md).
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
38
+
39
+ ## Code of Conduct
40
+
41
+ Everyone interacting in the Meibo project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/meibo/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Meibo
4
+ class AcademicSession
5
+ TYPES = {
6
+ grading_period: 'gradingPeriod',
7
+ semester: 'semester',
8
+ school_year: 'schoolYear',
9
+ term: 'term'
10
+ }.freeze
11
+
12
+ DataModel.define(
13
+ self,
14
+ attribute_name_to_header_field_map: {
15
+ sourced_id: 'sourcedId',
16
+ status: 'status',
17
+ date_last_modified: 'dateLastModified',
18
+ title: 'title',
19
+ type: 'type',
20
+ start_date: 'startDate',
21
+ end_date: 'endDate',
22
+ parent_sourced_id: 'parentSourcedId',
23
+ school_year: 'schoolYear'
24
+ }.freeze,
25
+ converters: {
26
+ enum: { type: [*TYPES.values.freeze, ENUM_EXT_PATTERN] }.freeze,
27
+ date: [:start_date, :end_date].freeze,
28
+ datetime: [:date_last_modified].freeze,
29
+ required: [:sourced_id, :title, :type, :start_date, :end_date, :school_year].freeze,
30
+ status: [:status].freeze,
31
+ year: [:school_year].freeze
32
+ }.freeze
33
+ )
34
+
35
+ def initialize(sourced_id:, status: nil, date_last_modified: nil, school_year:, title: nil, type:, start_date:, end_date:, parent_sourced_id: nil, **extension_fields)
36
+ @sourced_id = sourced_id
37
+ @status = status
38
+ @date_last_modified = date_last_modified
39
+ @title = title
40
+ @type = type
41
+ @start_date = start_date
42
+ @end_date = end_date
43
+ @parent_sourced_id = parent_sourced_id
44
+ @school_year = school_year
45
+ @extension_fields = extension_fields
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Meibo
4
+ class AcademicSessionSet < DataSet
5
+ def check_semantically_consistent
6
+ super
7
+
8
+ each do |academic_session|
9
+ next unless academic_session.parent_sourced_id
10
+
11
+ find_by_sourced_id(academic_session.parent_sourced_id)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Meibo
4
+ module BaseProfile
5
+ BUILDERS = {
6
+ academic_session: Builder::AcademicSessionBuilder.create(AcademicSession),
7
+ class: Builder::ClassroomBuilder.create(Classroom),
8
+ course: Builder::CourseBuilder.create(Course),
9
+ demographic: Builder::DemographicBuilder.create(Demographic),
10
+ enrollment: Builder::EnrollmentBuilder.create(Enrollment),
11
+ org: Builder::OrganizationBuilder.create(Organization),
12
+ role: Builder::RoleBuilder.create(Role),
13
+ user: Builder::UserBuilder.create(User),
14
+ user_profile: Builder::UserProfileBuilder.create(UserProfile)
15
+ }
16
+
17
+ DATA_MODELS = {
18
+ file_academic_sessions: Meibo::AcademicSession,
19
+ file_classes: Meibo::Classroom,
20
+ file_courses: Meibo::Course,
21
+ file_demographics: Meibo::Demographic,
22
+ file_enrollments: Meibo::Enrollment,
23
+ file_orgs: Meibo::Organization,
24
+ file_roles: Meibo::Role,
25
+ file_user_profiles: Meibo::UserProfile,
26
+ file_users: Meibo::User
27
+ }
28
+
29
+ def self.builder_for(key)
30
+ BUILDERS[key]
31
+ end
32
+
33
+ def self.data_model_for(file_attribute)
34
+ DATA_MODELS[file_attribute]
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ module Meibo
6
+ class Builder
7
+ module AcademicSessionBuilder
8
+ extend BaseBuilder
9
+
10
+ def self.builder_attribute_names
11
+ [:builder, :parent]
12
+ end
13
+
14
+ def initialize(builder:, sourced_id: SecureRandom.uuid, parent: nil, **kw)
15
+ super(
16
+ sourced_id: sourced_id,
17
+ parent_sourced_id: parent&.sourced_id,
18
+ **kw
19
+ )
20
+ @builder = builder
21
+ @parent = parent
22
+ builder.academic_sessions << self
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,13 @@
1
+ module Meibo
2
+ class Builder
3
+ module BaseBuilder
4
+ def create(klass)
5
+ builder_klass = Class.new(klass)
6
+ builder_klass.prepend(self)
7
+ builder_klass.attr_reader(*self.builder_attribute_names)
8
+ builder_klass
9
+ end
10
+ end
11
+ end
12
+ end
13
+
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ module Meibo
6
+ class Builder
7
+ module ClassroomBuilder
8
+ extend BaseBuilder
9
+
10
+ def self.builder_attribute_names
11
+ [:builder, :course, :school, :terms]
12
+ end
13
+
14
+ def initialize(builder:, sourced_id: SecureRandom.uuid, course:, school:, terms:, **kw)
15
+ super(
16
+ sourced_id: sourced_id,
17
+ course_sourced_id: course.sourced_id,
18
+ school_sourced_id: school.sourced_id,
19
+ term_sourced_ids: terms.map(&:sourced_id),
20
+ **kw
21
+ )
22
+ @builder = builder
23
+ @course = course
24
+ @school = school
25
+ @terms = terms
26
+ builder.classes << self
27
+ end
28
+
29
+ def build_enrollment(**kw)
30
+ builder.build_enrollment(
31
+ classroom: self,
32
+ school: school,
33
+ **kw
34
+ )
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ module Meibo
6
+ class Builder
7
+ module CourseBuilder
8
+ extend BaseBuilder
9
+
10
+ def self.builder_attribute_names
11
+ [:builder, :school_year, :organization]
12
+ end
13
+
14
+ def initialize(builder:, sourced_id: SecureRandom.uuid, school_year: nil, organization:, **kw)
15
+ super(
16
+ sourced_id: sourced_id,
17
+ school_year_sourced_id: school_year&.sourced_id,
18
+ org_sourced_id: organization.sourced_id,
19
+ **kw
20
+ )
21
+ @builder = builder
22
+ @school_year = school_year
23
+ @organization = organization
24
+ builder.courses << self
25
+ end
26
+
27
+ def build_classroom(**kw)
28
+ builder.build_classroom(course: self, school: organization, **kw)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ module Meibo
6
+ class Builder
7
+ module DemographicBuilder
8
+ extend BaseBuilder
9
+
10
+ def self.builder_attribute_names
11
+ [:builder, :user]
12
+ end
13
+
14
+ def initialize(builder:, user:, **kw)
15
+ super(sourced_id: user.sourced_id, **kw)
16
+ @builder = builder
17
+ @user = user
18
+ builder.demographics << self
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ module Meibo
6
+ class Builder
7
+ module EnrollmentBuilder
8
+ extend BaseBuilder
9
+
10
+ def self.builder_attribute_names
11
+ [:builder, :classroom, :school, :user]
12
+ end
13
+
14
+ def initialize(builder:, sourced_id: SecureRandom.uuid, classroom:, school:, user:, **kw)
15
+ super(
16
+ sourced_id: sourced_id,
17
+ class_sourced_id: classroom.sourced_id,
18
+ school_sourced_id: school.sourced_id,
19
+ user_sourced_id: user.sourced_id,
20
+ **kw
21
+ )
22
+ @builder = builder
23
+ @classroom = classroom
24
+ @school = school
25
+ @user = user
26
+ builder.enrollments << self
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ module Meibo
6
+ class Builder
7
+ module OrganizationBuilder
8
+ extend BaseBuilder
9
+
10
+ def self.builder_attribute_names
11
+ [:builder, :parent]
12
+ end
13
+
14
+ def initialize(builder:, sourced_id: SecureRandom.uuid, parent: nil, **kw)
15
+ super(sourced_id: sourced_id, parent_sourced_id: parent&.sourced_id, **kw)
16
+ @builder = builder
17
+ @parent = parent
18
+ builder.organizations << self
19
+ end
20
+
21
+ def build_course(**kw)
22
+ builder.build_course(organization: self, **kw)
23
+ end
24
+
25
+ def build_user(**kw)
26
+ builder.build_user(primary_organization: self, **kw)
27
+ end
28
+
29
+ def build_role(**kw)
30
+ builder.build_role(organization: self, **kw)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ module Meibo
6
+ class Builder
7
+ module RoleBuilder
8
+ extend BaseBuilder
9
+
10
+ def self.builder_attribute_names
11
+ [:builder, :user, :organization, :user_profile]
12
+ end
13
+
14
+ def initialize(builder:, sourced_id: SecureRandom.uuid, user:, organization:, user_profile: nil, **kw)
15
+ super(
16
+ sourced_id: sourced_id,
17
+ user_sourced_id: user.sourced_id,
18
+ org_sourced_id: organization.sourced_id,
19
+ user_profile_sourced_id: user_profile&.sourced_id,
20
+ **kw
21
+ )
22
+ @builder = builder
23
+ @user = user
24
+ @organization = organization
25
+ @user_profile = user_profile
26
+ builder.roles << self
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ module Meibo
6
+ class Builder
7
+ module UserBuilder
8
+ extend BaseBuilder
9
+
10
+ def self.builder_attribute_names
11
+ [:builder, :agents, :primary_organization]
12
+ end
13
+
14
+ def initialize(builder:, sourced_id: SecureRandom.uuid, agents: nil, primary_organization: nil, **kw)
15
+ super(
16
+ sourced_id: sourced_id,
17
+ agent_sourced_ids: agents&.map(&:sourced_id),
18
+ primary_org_sourced_id: primary_organization&.sourced_id,
19
+ **kw
20
+ )
21
+ @builder = builder
22
+ @agents = agents
23
+ @primary_organization = primary_organization
24
+ builder.users << self
25
+ end
26
+
27
+ def build_demographic(**kw)
28
+ builder.build_demographic(user: self, **kw)
29
+ end
30
+
31
+ def build_profile(**kw)
32
+ builder.build_user_profile(user: self, **kw)
33
+ end
34
+ end
35
+ end
36
+ end