meibo 0.20.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc0e6ff7941064a1b88f274b279de43425b975e2c05c746a074d8a7608be5d74
4
- data.tar.gz: 2ce52a6e624ea7cf0d83a46474c3f467a3d2994caf374cd80196a43ea6410e2f
3
+ metadata.gz: 6a33eff8e804e9e53783c3362da8d3cc6808a728915cfd03f9ac11387c30f7fe
4
+ data.tar.gz: 2a981345145594726702674e49e8c471b15cf4fc915beb047428e2736289a597
5
5
  SHA512:
6
- metadata.gz: b5c1fd5fa4c0cd95512d72053baa4561c9a9a8e8f610eeb22b99b792976acbb288396aa84492635658604931b2c3fb189b36373c6d7736e9a52b37153697fba2
7
- data.tar.gz: 63e1b1e294ac266ae94689f474e719ca246e71fb7559324f1b647af1ba6abc2fda1c515294bf076f41c6400acc0d7457e9f053834d2efbf2e4c17de1cf81a167
6
+ metadata.gz: efc2d0285dd92b3f78caf114f0457f469d1ced8fb14afc1994d0800d2d94504f5978bfab5beb6cca01e1758277245c65177e49a90c72e9ba329a37e21c82d686
7
+ data.tar.gz: 12e6995e8e4176926375b166b7cd1762f8ecc7466ee51d8faaf9808ddf81bdb99a34cc420e1ee16e880de757d3c27fe81eb71f4fccaafa916427dfa03ae5e944
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- meibo (0.20.0)
4
+ meibo (0.22.0)
5
5
  csv (>= 3.1.4)
6
6
  rubyzip
7
7
  zeitwerk
data/lib/meibo/builder.rb CHANGED
@@ -11,7 +11,7 @@ module Meibo
11
11
  def_delegators :@roster, :academic_sessions, :classes, :courses, :demographics, :enrollments, :organizations,
12
12
  :roles, :users, :user_profiles
13
13
 
14
- def initialize(roster:, profile: Meibo.default_profile)
14
+ def initialize(roster:, profile: Meibo.current_profile)
15
15
  @roster = roster
16
16
  @profile = profile
17
17
  end
@@ -52,7 +52,7 @@ module Meibo
52
52
  end
53
53
  lambda do |field, field_info|
54
54
  # NOTE: convert blank sourcedId to nil
55
- field = nil if field_info.index.zero? && field.empty?
55
+ field = nil if field.respond_to?(:empty?) && field.empty?
56
56
  converter_list.each { |converter| field = converter[field, field_info] }
57
57
  field
58
58
  end
@@ -8,16 +8,22 @@ module Meibo
8
8
  def parse(csv)
9
9
  return to_enum(:parse, csv) unless block_given?
10
10
 
11
- actual_headers = CSV.parse_line(csv)
12
- missing_headers = header_fields - actual_headers
13
- raise MissingHeadersError, "missing headers: #{missing_headers.join(",")}" unless missing_headers.empty?
14
- raise ScrambledHeadersError unless actual_headers.take(header_fields.size) == header_fields
11
+ validate_header_fields(CSV.parse_line(csv))
15
12
 
16
13
  CSV.parse(csv, encoding: Meibo::CSV_ENCODING, headers: true, converters: parser_converters,
17
14
  header_converters: header_converters).each do |row|
18
15
  yield new(**row.to_h)
19
16
  end
20
17
  end
18
+
19
+ def validate_header_fields(actual_header_fields)
20
+ missing_header_fields = header_fields - actual_header_fields
21
+ unless missing_header_fields.empty?
22
+ message = "missing header fields: #{missing_header_fields.join(",")}"
23
+ raise MissingHeaderFieldsError.new(message, missing_header_fields: missing_header_fields)
24
+ end
25
+ raise ScrambledHeaderFieldsError unless actual_header_fields.take(header_fields.size) == header_fields
26
+ end
21
27
  end
22
28
 
23
29
  def self.define(klass, attribute_name_to_header_field_map:, converters: {})
data/lib/meibo/errors.rb CHANGED
@@ -6,8 +6,17 @@ module Meibo
6
6
  class DataNotFoundError < Error; end
7
7
  class InvalidDataTypeError < Error; end
8
8
  class MissingDataError < Error; end
9
- class MissingHeadersError < Error; end
9
+
10
+ class MissingHeaderFieldsError < Error
11
+ attr_reader :missing_header_fields
12
+
13
+ def initialize(message = nil, missing_header_fields:)
14
+ super(message)
15
+ @missing_header_fields = missing_header_fields
16
+ end
17
+ end
18
+
10
19
  class NotSupportedError < Error; end
11
- class ScrambledHeadersError < Error; end
20
+ class ScrambledHeaderFieldsError < Error; end
12
21
  class SourcedIdDuplicatedError < Error; end
13
22
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meibo
4
- class JapanProfile < ::Meibo::Profile
4
+ module JapanProfile
5
5
  class AcademicSession < ::Meibo::AcademicSession
6
6
  TYPES = { school_year: "schoolYear" }.freeze
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meibo
4
- class JapanProfile < ::Meibo::Profile
4
+ module JapanProfile
5
5
  class Classroom < ::Meibo::Classroom
6
6
  DataModel.define(
7
7
  self,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meibo
4
- class JapanProfile < ::Meibo::Profile
4
+ module JapanProfile
5
5
  class Course < ::Meibo::Course
6
6
  DataModel.define(
7
7
  self,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meibo
4
- class JapanProfile < ::Meibo::Profile
4
+ module JapanProfile
5
5
  class Demographic < ::Meibo::Demographic
6
6
  DataModel.define(
7
7
  self,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meibo
4
- class JapanProfile < ::Meibo::Profile
4
+ module JapanProfile
5
5
  class Enrollment < ::Meibo::Enrollment
6
6
  ROLES = {
7
7
  student: "student",
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meibo
4
- class JapanProfile < ::Meibo::Profile
4
+ module JapanProfile
5
5
  class Organization < ::Meibo::Organization
6
6
  TYPES = {
7
7
  district: "district",
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meibo
4
- class JapanProfile < ::Meibo::Profile
5
- class Role < ::Meibo::Role
4
+ module JapanProfile
5
+ class RoleJpM0 < ::Meibo::Role
6
6
  # NOTE: roleは固定
7
7
  # - 児童生徒の場合student
8
8
  # - 教職員の場合teacher
@@ -1,32 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meibo
4
- class JapanProfile < ::Meibo::Profile
4
+ module JapanProfile
5
5
  class User < ::Meibo::User
6
- DataModel.define(
7
- self,
8
- attribute_name_to_header_field_map: superclass.attribute_name_to_header_field_map.merge(
9
- kana_given_name: "metadata.jp.kanaGivenName",
10
- kana_family_name: "metadata.jp.kanaFamilyName",
11
- kana_middle_name: "metadata.jp.kanaMiddleName",
12
- home_class: "metadata.jp.homeClass"
13
- ).freeze,
14
- converters: superclass.converters
15
- )
16
-
17
- # NOTE: enabled_userは必須ではないが固定
18
- def initialize(enabled_user: true, kana_given_name: nil, kana_family_name: nil, kana_middle_name: nil,
19
- home_class: nil, **other_fields)
20
- super(enabled_user: enabled_user, **other_fields)
21
- @kana_given_name = kana_given_name
22
- @kana_family_name = kana_family_name
23
- @kana_middle_name = kana_middle_name
24
- @home_class = home_class
6
+ module ClassMethods
7
+ def define_additional_definition(klass)
8
+ DataModel.define(
9
+ klass,
10
+ attribute_name_to_header_field_map: klass.superclass.attribute_name_to_header_field_map.merge(
11
+ kana_given_name: "metadata.jp.kanaGivenName",
12
+ kana_family_name: "metadata.jp.kanaFamilyName",
13
+ kana_middle_name: "metadata.jp.kanaMiddleName",
14
+ home_class: "metadata.jp.homeClass"
15
+ ).freeze,
16
+ converters: klass.superclass.converters
17
+ )
18
+ end
25
19
  end
26
20
 
27
- def home_classroom
28
- home_class && Meibo.current_roster.classes.find(home_class)
21
+ module InstanceMethods
22
+ # NOTE: enabled_userは必須ではないが固定
23
+ def initialize(enabled_user: true, kana_given_name: nil, kana_family_name: nil, kana_middle_name: nil,
24
+ home_class: nil, **other_fields)
25
+ super(enabled_user: enabled_user, **other_fields)
26
+ @kana_given_name = kana_given_name
27
+ @kana_family_name = kana_family_name
28
+ @kana_middle_name = kana_middle_name
29
+ @home_class = home_class
30
+ end
31
+
32
+ def home_classroom
33
+ home_class && Meibo.current_roster.classes.find(home_class)
34
+ end
29
35
  end
36
+
37
+ include InstanceMethods
38
+ extend ClassMethods
39
+
40
+ define_additional_definition(self)
30
41
  end
31
42
  end
32
43
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Meibo
4
+ module JapanProfile
5
+ class UserM0 < ::Meibo::UserM0
6
+ include User::InstanceMethods
7
+ extend User::ClassMethods
8
+
9
+ define_additional_definition(self)
10
+ end
11
+ end
12
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meibo
4
- class JapanProfile < ::Meibo::Profile
4
+ module JapanProfile
5
5
  class UserSet < ::Meibo::UserSet
6
6
  def check_semantically_consistent
7
7
  super
data/lib/meibo/profile.rb CHANGED
@@ -2,45 +2,9 @@
2
2
 
3
3
  module Meibo
4
4
  class Profile
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
- }.freeze
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
- }.freeze
28
-
29
- DATA_SET = {
30
- academic_sessions: Meibo::AcademicSessionSet,
31
- classes: Meibo::ClassroomSet,
32
- courses: Meibo::CourseSet,
33
- demographics: Meibo::DemographicSet,
34
- enrollments: Meibo::EnrollmentSet,
35
- orgs: Meibo::OrganizationSet,
36
- roles: Meibo::RoleSet,
37
- user_profiles: Meibo::UserProfileSet,
38
- users: Meibo::UserSet
39
- }.freeze
40
-
41
5
  attr_reader :builders, :data_models, :data_set
42
6
 
43
- def initialize(builders: BUILDERS, data_models: DATA_MODELS, data_set: DATA_SET)
7
+ def initialize(builders:, data_models:, data_set:)
44
8
  @builders = builders
45
9
  @data_models = data_models
46
10
  @data_set = data_set
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Meibo
4
+ module Profiles
5
+ profile121 = Profile.new(
6
+ builders: {
7
+ academic_session: Builder::AcademicSessionBuilder.create(AcademicSession),
8
+ class: Builder::ClassroomBuilder.create(Classroom),
9
+ course: Builder::CourseBuilder.create(Course),
10
+ demographic: Builder::DemographicBuilder.create(Demographic),
11
+ enrollment: Builder::EnrollmentBuilder.create(Enrollment),
12
+ org: Builder::OrganizationBuilder.create(Organization),
13
+ role: Builder::RoleBuilder.create(Role),
14
+ user: Builder::UserBuilder.create(User),
15
+ user_profile: Builder::UserProfileBuilder.create(UserProfile)
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
+ data_set: {
29
+ academic_sessions: Meibo::AcademicSessionSet,
30
+ classes: Meibo::ClassroomSet,
31
+ courses: Meibo::CourseSet,
32
+ demographics: Meibo::DemographicSet,
33
+ enrollments: Meibo::EnrollmentSet,
34
+ orgs: Meibo::OrganizationSet,
35
+ roles: Meibo::RoleSet,
36
+ user_profiles: Meibo::UserProfileSet,
37
+ users: Meibo::UserSet
38
+ }
39
+ )
40
+
41
+ profile120 = Profile.new(
42
+ builders: profile121.builders.merge(
43
+ user: Builder::UserBuilder.create(UserM0)
44
+ ),
45
+ data_models: profile121.data_models.merge(
46
+ file_users: UserM0
47
+ ),
48
+ data_set: profile121.data_set
49
+ )
50
+
51
+ japan_profile121_v11 = Profile.new(
52
+ builders: profile121.builders.merge(
53
+ academic_session: Builder::AcademicSessionBuilder.create(JapanProfile::AcademicSession),
54
+ class: Builder::ClassroomBuilder.create(JapanProfile::Classroom),
55
+ course: Builder::CourseBuilder.create(JapanProfile::Course),
56
+ demographic: Builder::DemographicBuilder.create(JapanProfile::Demographic),
57
+ enrollment: Builder::EnrollmentBuilder.create(JapanProfile::Enrollment),
58
+ org: Builder::OrganizationBuilder.create(JapanProfile::Organization),
59
+ user: Builder::UserBuilder.create(JapanProfile::User)
60
+ ),
61
+ data_models: profile121.data_models.merge(
62
+ file_academic_sessions: JapanProfile::AcademicSession,
63
+ file_classes: JapanProfile::Classroom,
64
+ file_courses: JapanProfile::Course,
65
+ file_demographics: JapanProfile::Demographic,
66
+ file_enrollments: JapanProfile::Enrollment,
67
+ file_orgs: JapanProfile::Organization,
68
+ file_users: JapanProfile::User
69
+ ),
70
+ data_set: profile121.data_set.merge(
71
+ users: JapanProfile::UserSet
72
+ )
73
+ )
74
+
75
+ japan_profile120_v11 = Profile.new(
76
+ builders: japan_profile121_v11.builders.merge(
77
+ user: Builder::UserBuilder.create(JapanProfile::UserM0)
78
+ ),
79
+ data_models: japan_profile121_v11.data_models.merge(
80
+ file_users: JapanProfile::UserM0
81
+ ),
82
+ data_set: japan_profile121_v11.data_set
83
+ )
84
+
85
+ japan_profile120_v10 = Profile.new(
86
+ builders: japan_profile120_v11.builders.merge(
87
+ role: Builder::UserBuilder.create(JapanProfile::RoleJpM0)
88
+ ),
89
+ data_models: japan_profile120_v11.data_models.merge(
90
+ file_roles: JapanProfile::RoleJpM0
91
+ ),
92
+ data_set: japan_profile120_v11.data_set
93
+ )
94
+
95
+ PROFILES = {
96
+ "v1.2" => profile121,
97
+ "v1.2.1" => profile121,
98
+ "v1.2.0" => profile120,
99
+ "v1.2.0 jp v1.0" => japan_profile120_v10,
100
+ "v1.2.0 jp v1.1" => japan_profile120_v11,
101
+ "v1.2.1 jp v1.1" => japan_profile121_v11
102
+ }.freeze
103
+
104
+ def self.use(profile_name, &block)
105
+ Meibo.with_profile(self[profile_name], &block)
106
+ end
107
+
108
+ def self.[](profile_name)
109
+ PROFILES.fetch(profile_name)
110
+ end
111
+ end
112
+ end
data/lib/meibo/reader.rb CHANGED
@@ -5,13 +5,13 @@ require "zip"
5
5
 
6
6
  module Meibo
7
7
  class Reader
8
- def self.open(file_path, profile: Meibo.default_profile)
8
+ def self.open(file_path, profile: Meibo.current_profile)
9
9
  Zip::File.open(file_path) do |zipfile|
10
10
  yield new(zipfile: zipfile, profile: profile)
11
11
  end
12
12
  end
13
13
 
14
- def self.open_buffer(io, profile: Meibo.default_profile)
14
+ def self.open_buffer(io, profile: Meibo.current_profile)
15
15
  Zip::File.open_buffer(io) do |zipfile|
16
16
  yield new(zipfile: zipfile, profile: profile)
17
17
  end
data/lib/meibo/roster.rb CHANGED
@@ -6,13 +6,13 @@ require "csv"
6
6
  module Meibo
7
7
  class Roster
8
8
  class << self
9
- def from_file(file_path, profile: Meibo.default_profile)
9
+ def from_file(file_path, profile: Meibo.current_profile)
10
10
  Reader.open(file_path, profile: profile) do |reader|
11
11
  return read_data(reader, profile)
12
12
  end
13
13
  end
14
14
 
15
- def from_buffer(io, profile: Meibo.default_profile)
15
+ def from_buffer(io, profile: Meibo.current_profile)
16
16
  Reader.open_buffer(io, profile: profile) do |reader|
17
17
  return read_data(reader, profile)
18
18
  end
@@ -86,7 +86,7 @@ module Meibo
86
86
  attr_reader :profile, :manifest_properties, :academic_sessions, :classes, :courses, :demographics, :enrollments,
87
87
  :organizations, :roles, :user_profiles, :users
88
88
 
89
- def initialize(profile: Meibo.default_profile, manifest_properties: {}, academic_sessions: [], classes: [],
89
+ def initialize(profile: Meibo.current_profile, manifest_properties: {}, academic_sessions: [], classes: [],
90
90
  courses: [], demographics: [], enrollments: [], organizations: [], roles: [], user_profiles: [], users: [])
91
91
  @profile = profile
92
92
  @manifest_properties = manifest_properties
data/lib/meibo/user.rb CHANGED
@@ -24,7 +24,6 @@ module Meibo
24
24
  grades: "grades",
25
25
  password: "password",
26
26
  user_master_identifier: "userMasterIdentifier",
27
- resource_sourced_ids: "resourceSourcedIds",
28
27
  preferred_given_name: "preferredGivenName",
29
28
  preferred_middle_name: "preferredMiddleName",
30
29
  preferred_family_name: "preferredFamilyName",
@@ -34,7 +33,7 @@ module Meibo
34
33
  converters: {
35
34
  boolean: [:enabled_user].freeze,
36
35
  datetime: [:date_last_modified].freeze,
37
- list: %i[user_ids agent_sourced_ids grades resource_sourced_ids].freeze,
36
+ list: %i[user_ids agent_sourced_ids grades].freeze,
38
37
  required: %i[sourced_id enabled_user username given_name family_name].freeze,
39
38
  status: [:status].freeze,
40
39
  user_ids: [:user_ids].freeze
@@ -42,7 +41,7 @@ module Meibo
42
41
  )
43
42
 
44
43
  def initialize(sourced_id:, username:, given_name:, family_name:, status: nil, date_last_modified: nil,
45
- enabled_user: nil, user_ids: nil, middle_name: nil, identifier: nil, email: nil, sms: nil, phone: nil, agent_sourced_ids: [], grades: nil, password: nil, user_master_identifier: nil, resource_sourced_ids: nil, preferred_given_name: nil, preferred_middle_name: nil, preferred_family_name: nil, primary_org_sourced_id: nil, pronouns: nil, **extension_fields)
44
+ enabled_user: nil, user_ids: nil, middle_name: nil, identifier: nil, email: nil, sms: nil, phone: nil, agent_sourced_ids: [], grades: nil, password: nil, user_master_identifier: nil, preferred_given_name: nil, preferred_middle_name: nil, preferred_family_name: nil, primary_org_sourced_id: nil, pronouns: nil, **extension_fields)
46
45
  @sourced_id = sourced_id
47
46
  @status = status
48
47
  @date_last_modified = date_last_modified
@@ -60,7 +59,6 @@ module Meibo
60
59
  @grades = grades
61
60
  @password = password
62
61
  @user_master_identifier = user_master_identifier
63
- @resource_sourced_ids = resource_sourced_ids
64
62
  @preferred_given_name = preferred_given_name
65
63
  @preferred_middle_name = preferred_middle_name
66
64
  @preferred_family_name = preferred_family_name
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Meibo
4
+ class UserM0 < ::Meibo::User
5
+ DataModel.define(
6
+ self,
7
+ attribute_name_to_header_field_map: {
8
+ sourced_id: "sourcedId",
9
+ status: "status",
10
+ date_last_modified: "dateLastModified",
11
+ enabled_user: "enabledUser",
12
+ username: "username",
13
+ user_ids: "userIds",
14
+ given_name: "givenName",
15
+ family_name: "familyName",
16
+ middle_name: "middleName",
17
+ identifier: "identifier",
18
+ email: "email",
19
+ sms: "sms",
20
+ phone: "phone",
21
+ agent_sourced_ids: "agentSourcedIds",
22
+ grades: "grades",
23
+ password: "password",
24
+ user_master_identifier: "userMasterIdentifier",
25
+ resource_sourced_ids: "resourceSourcedIds",
26
+ preferred_given_name: "preferredGivenName",
27
+ preferred_middle_name: "preferredMiddleName",
28
+ preferred_family_name: "preferredFamilyName",
29
+ primary_org_sourced_id: "primaryOrgSourcedId",
30
+ pronouns: "pronouns"
31
+ }.freeze,
32
+ converters: superclass.converters.merge(
33
+ list: %i[user_ids agent_sourced_ids grades resource_sourced_ids].freeze
34
+ )
35
+ )
36
+
37
+ # NOTE: enabled_userは必須ではないが固定
38
+ def initialize(resource_sourced_ids: nil, **other_fields)
39
+ super(**other_fields)
40
+ @resource_sourced_ids = resource_sourced_ids
41
+ end
42
+
43
+ def home_classroom
44
+ home_class && Meibo.current_roster.classes.find(home_class)
45
+ end
46
+ end
47
+ end
data/lib/meibo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meibo
4
- VERSION = "0.20.0"
4
+ VERSION = "0.22.0"
5
5
  end
data/lib/meibo.rb CHANGED
@@ -16,10 +16,22 @@ module Meibo
16
16
  class << self
17
17
  attr_accessor :default_profile
18
18
 
19
+ def current_profile
20
+ thread_local_data[:current_profile] || default_profile
21
+ end
22
+
19
23
  def current_roster
20
24
  thread_local_data[:roster]
21
25
  end
22
26
 
27
+ def with_profile(default_profile)
28
+ orig_default_profile = thread_local_data[:current_profile]
29
+ thread_local_data[:current_profile] = default_profile
30
+ yield
31
+ ensure
32
+ thread_local_data[:current_profile] = orig_default_profile
33
+ end
34
+
23
35
  def with_roster(roster)
24
36
  orig_roster = thread_local_data[:roster]
25
37
  thread_local_data[:roster] = roster
@@ -38,4 +50,4 @@ end
38
50
 
39
51
  loader.eager_load
40
52
 
41
- Meibo.default_profile = Meibo::Profile.new
53
+ Meibo.default_profile = Meibo::Profiles["v1.2"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meibo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seiei Miyagi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-05 00:00:00.000000000 Z
11
+ date: 2023-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: csv
@@ -107,26 +107,28 @@ files:
107
107
  - lib/meibo/factory_bot/roster.rb
108
108
  - lib/meibo/factory_bot/user.rb
109
109
  - lib/meibo/factory_bot/user_profile.rb
110
- - lib/meibo/japan_profile.rb
111
110
  - lib/meibo/japan_profile/academic_session.rb
112
111
  - lib/meibo/japan_profile/classroom.rb
113
112
  - lib/meibo/japan_profile/course.rb
114
113
  - lib/meibo/japan_profile/demographic.rb
115
114
  - lib/meibo/japan_profile/enrollment.rb
116
115
  - lib/meibo/japan_profile/organization.rb
117
- - lib/meibo/japan_profile/role.rb
116
+ - lib/meibo/japan_profile/role_jp_m0.rb
118
117
  - lib/meibo/japan_profile/user.rb
118
+ - lib/meibo/japan_profile/user_m0.rb
119
119
  - lib/meibo/japan_profile/user_set.rb
120
120
  - lib/meibo/manifest.rb
121
121
  - lib/meibo/manifest/processing_mode.rb
122
122
  - lib/meibo/organization.rb
123
123
  - lib/meibo/organization_set.rb
124
124
  - lib/meibo/profile.rb
125
+ - lib/meibo/profiles.rb
125
126
  - lib/meibo/reader.rb
126
127
  - lib/meibo/role.rb
127
128
  - lib/meibo/role_set.rb
128
129
  - lib/meibo/roster.rb
129
130
  - lib/meibo/user.rb
131
+ - lib/meibo/user_m0.rb
130
132
  - lib/meibo/user_profile.rb
131
133
  - lib/meibo/user_profile_set.rb
132
134
  - lib/meibo/user_set.rb
@@ -140,7 +142,7 @@ metadata:
140
142
  allowed_push_host: https://rubygems.org/
141
143
  homepage_uri: https://github.com/hanachin/meibo
142
144
  source_code_uri: https://github.com/hanachin/meibo
143
- changelog_uri: https://github.com/hanachin/meibo/blob/meibo/v0.20.0/CHANGELOG.md
145
+ changelog_uri: https://github.com/hanachin/meibo/blob/meibo/v0.22.0/CHANGELOG.md
144
146
  rubygems_mfa_required: 'true'
145
147
  post_install_message:
146
148
  rdoc_options: []
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Meibo
4
- class JapanProfile < ::Meibo::Profile
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
- }.freeze
16
-
17
- DATA_MODELS = {
18
- file_academic_sessions: AcademicSession,
19
- file_classes: Classroom,
20
- file_courses: Course,
21
- file_demographics: Demographic,
22
- file_enrollments: Enrollment,
23
- file_orgs: Organization,
24
- file_roles: Role,
25
- file_user_profiles: UserProfile,
26
- file_users: User
27
- }.freeze
28
-
29
- DATA_SET = ::Meibo::Profile::DATA_SET.merge(
30
- users: UserSet
31
- )
32
-
33
- def initialize(builders: BUILDERS, data_models: DATA_MODELS, data_set: DATA_SET)
34
- super
35
- end
36
- end
37
- end