meibo 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/meibo/academic_session.rb +4 -0
- data/lib/meibo/academic_session_set.rb +16 -0
- data/lib/meibo/classroom.rb +12 -0
- data/lib/meibo/classroom_set.rb +8 -0
- data/lib/meibo/course.rb +8 -0
- data/lib/meibo/data_set.rb +36 -6
- data/lib/meibo/demographic.rb +4 -0
- data/lib/meibo/demographic_set.rb +16 -0
- data/lib/meibo/enrollment.rb +12 -0
- data/lib/meibo/enrollment_set.rb +16 -0
- data/lib/meibo/japan_profile/user.rb +4 -0
- data/lib/meibo/organization.rb +4 -0
- data/lib/meibo/organization_set.rb +24 -0
- data/lib/meibo/role.rb +12 -0
- data/lib/meibo/role_set.rb +56 -0
- data/lib/meibo/user.rb +32 -0
- data/lib/meibo/user_profile.rb +4 -0
- data/lib/meibo/version.rb +1 -1
- data/lib/meibo.rb +18 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fed6d292ab3d38301370ef4d6238d4ddc470d8ae380e1e8bdf8f6d88822aaf0
|
4
|
+
data.tar.gz: d364e20a7336ad702b4d3434efefe800bed8a971f0cc02177c817398fa79982d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb712c2090b7cc03708a4c8b302e187357db4f2bf260e62486f79072ba646371368c6968baaa022c472774b6a09c0aba3a7f1716b1b074e6fcb2ab6ab6e19935
|
7
|
+
data.tar.gz: dd2f31087c8b28e02b9e257dcb405cb1eec588d5a576c120cdcadcb0402743cb7a02f6e62262ca1c932f93c8f119839d95eb505ce44534a04a478883e0d966af
|
data/Gemfile.lock
CHANGED
@@ -11,5 +11,21 @@ module Meibo
|
|
11
11
|
find(academic_session.parent_sourced_id)
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
def grading_period
|
16
|
+
@cache[:grading_period] ||= new(select(&:grading_period?))
|
17
|
+
end
|
18
|
+
|
19
|
+
def semester
|
20
|
+
@cache[:semester] ||= new(select(&:semester?))
|
21
|
+
end
|
22
|
+
|
23
|
+
def school_year
|
24
|
+
@cache[:school_year] ||= new(select(&:school_year?))
|
25
|
+
end
|
26
|
+
|
27
|
+
def term
|
28
|
+
@cache[:term] ||= new(select(&:term?))
|
29
|
+
end
|
14
30
|
end
|
15
31
|
end
|
data/lib/meibo/classroom.rb
CHANGED
@@ -71,5 +71,17 @@ module Meibo
|
|
71
71
|
def scheduled?
|
72
72
|
class_type == TYPES[:scheduled]
|
73
73
|
end
|
74
|
+
|
75
|
+
def course
|
76
|
+
Meibo.current_roster.courses.find(course_sourced_id)
|
77
|
+
end
|
78
|
+
|
79
|
+
def school
|
80
|
+
Meibo.current_roster.organizations.find(school_sourced_id)
|
81
|
+
end
|
82
|
+
|
83
|
+
def terms
|
84
|
+
term_sourced_ids.map {|term_sourced_id| Meibo.current_roster.academic_sessions.find(term_sourced_id) }
|
85
|
+
end
|
74
86
|
end
|
75
87
|
end
|
data/lib/meibo/classroom_set.rb
CHANGED
data/lib/meibo/course.rb
CHANGED
@@ -41,5 +41,13 @@ module Meibo
|
|
41
41
|
@subject_codes = subject_codes
|
42
42
|
@extension_fields = extension_fields
|
43
43
|
end
|
44
|
+
|
45
|
+
def organization
|
46
|
+
Meibo.current_roster.organizations.find(org_sourced_id)
|
47
|
+
end
|
48
|
+
|
49
|
+
def school_year
|
50
|
+
Meibo.current_roster.academic_sessions.find(school_year_sourced_id)
|
51
|
+
end
|
44
52
|
end
|
45
53
|
end
|
data/lib/meibo/data_set.rb
CHANGED
@@ -6,24 +6,24 @@ module Meibo
|
|
6
6
|
|
7
7
|
def initialize(data, roster:)
|
8
8
|
@data = data
|
9
|
-
@data_hash = data.to_h {|datum| [datum.sourced_id, datum] }
|
10
9
|
@roster = roster
|
10
|
+
@cache = {}
|
11
11
|
end
|
12
12
|
|
13
13
|
def <<(new_data)
|
14
14
|
raise DataNotFoundError, "sourcedIdがありません" unless new_data.sourced_id
|
15
|
-
raise SourcedIdDuplicatedError, 'sourcedIdが重複しています' if
|
15
|
+
raise SourcedIdDuplicatedError, 'sourcedIdが重複しています' if data_by_sourced_id.key?(new_data.sourced_id)
|
16
16
|
|
17
17
|
@data << new_data
|
18
|
-
@
|
18
|
+
@cache.clear
|
19
19
|
end
|
20
20
|
|
21
21
|
def check_semantically_consistent
|
22
|
-
unless @data.size ==
|
22
|
+
unless @data.size == data_by_sourced_id.size
|
23
23
|
raise SourcedIdDuplicatedError, 'sourcedIdが重複しています'
|
24
24
|
end
|
25
25
|
|
26
|
-
unless
|
26
|
+
unless data_by_sourced_id[nil].nil?
|
27
27
|
raise DataNotFoundError, "sourcedIdがありません"
|
28
28
|
end
|
29
29
|
end
|
@@ -37,9 +37,39 @@ module Meibo
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def find(sourced_id)
|
40
|
-
|
40
|
+
data_by_sourced_id.fetch(sourced_id)
|
41
41
|
rescue KeyError
|
42
42
|
raise DataNotFoundError, "sourcedId: #{sourced_id} が見つかりません"
|
43
43
|
end
|
44
|
+
|
45
|
+
def by_organization(org_sourced_id)
|
46
|
+
data_by_org_sourced_id[org_sourced_id]
|
47
|
+
end
|
48
|
+
|
49
|
+
def by_user(user_sourced_id)
|
50
|
+
data_by_user_sourced_id[user_sourced_id]
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def data_by_org_sourced_id
|
56
|
+
@cache[:data_by_org_sourced_id] ||= @data.group_by(&:data_by_org_sourced_id).to_h do |org_sourced_id, data|
|
57
|
+
[org_sourced_id, new(data)]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def data_by_sourced_id
|
62
|
+
@cache[:data_by_sourced_id] ||= @data.to_h {|datum| [datum.sourced_id, datum] }
|
63
|
+
end
|
64
|
+
|
65
|
+
def data_by_user_sourced_id
|
66
|
+
@cache[:data_by_user_sourced_id] ||= @data.group_by(&:user_sourced_id).to_h do |user_sourced_id, data|
|
67
|
+
[user_sourced_id, new(data)]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def new(data)
|
72
|
+
self.class.new(data, roster: roster)
|
73
|
+
end
|
44
74
|
end
|
45
75
|
end
|
data/lib/meibo/demographic.rb
CHANGED
@@ -9,5 +9,21 @@ module Meibo
|
|
9
9
|
roster.users.find(demographic.sourced_id)
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
def male
|
14
|
+
@cache[:male] ||= new(select(&:male?))
|
15
|
+
end
|
16
|
+
|
17
|
+
def female
|
18
|
+
@cache[:female] ||= new(select(&:female?))
|
19
|
+
end
|
20
|
+
|
21
|
+
def unspecified
|
22
|
+
@cache[:unspecified] ||= new(select(&:unspecified?))
|
23
|
+
end
|
24
|
+
|
25
|
+
def other
|
26
|
+
@cache[:other] ||= new(select(&:other?))
|
27
|
+
end
|
12
28
|
end
|
13
29
|
end
|
data/lib/meibo/enrollment.rb
CHANGED
@@ -61,5 +61,17 @@ module Meibo
|
|
61
61
|
def teacher?
|
62
62
|
role == ROLES[:teacher]
|
63
63
|
end
|
64
|
+
|
65
|
+
def classroom
|
66
|
+
Meibo.current_roster.classes.find(class_sourced_id)
|
67
|
+
end
|
68
|
+
|
69
|
+
def school
|
70
|
+
Meibo.current_roster.organizations.find(school_sourced_id)
|
71
|
+
end
|
72
|
+
|
73
|
+
def user
|
74
|
+
Meibo.current_roster.users.find(user_sourced_id)
|
75
|
+
end
|
64
76
|
end
|
65
77
|
end
|
data/lib/meibo/enrollment_set.rb
CHANGED
@@ -11,5 +11,21 @@ module Meibo
|
|
11
11
|
roster.users.find(enrollment.user_sourced_id)
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
def administrator
|
16
|
+
@cache[:administrator] ||= new(select(&:administrator?))
|
17
|
+
end
|
18
|
+
|
19
|
+
def proctor
|
20
|
+
@cache[:proctor] ||= new(select(&:proctor?))
|
21
|
+
end
|
22
|
+
|
23
|
+
def student
|
24
|
+
@cache[:student] ||= new(select(&:student?))
|
25
|
+
end
|
26
|
+
|
27
|
+
def teacher
|
28
|
+
@cache[:teacher] ||= new(select(&:teacher?))
|
29
|
+
end
|
14
30
|
end
|
15
31
|
end
|
data/lib/meibo/organization.rb
CHANGED
@@ -11,5 +11,29 @@ module Meibo
|
|
11
11
|
find(organization.parent_sourced_id)
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
def department
|
16
|
+
@cache[:department] ||= new(select(&:department?))
|
17
|
+
end
|
18
|
+
|
19
|
+
def school
|
20
|
+
@cache[:school] ||= new(select(&:school?))
|
21
|
+
end
|
22
|
+
|
23
|
+
def district
|
24
|
+
@cache[:district] ||= new(select(&:district?))
|
25
|
+
end
|
26
|
+
|
27
|
+
def local
|
28
|
+
@cache[:local] ||= new(select(&:local?))
|
29
|
+
end
|
30
|
+
|
31
|
+
def state
|
32
|
+
@cache[:state] ||= new(select(&:state?))
|
33
|
+
end
|
34
|
+
|
35
|
+
def national
|
36
|
+
@cache[:national] ||= new(select(&:national?))
|
37
|
+
end
|
14
38
|
end
|
15
39
|
end
|
data/lib/meibo/role.rb
CHANGED
@@ -117,5 +117,17 @@ module Meibo
|
|
117
117
|
def teacher?
|
118
118
|
role == ROLES[:teacher]
|
119
119
|
end
|
120
|
+
|
121
|
+
def organization
|
122
|
+
Meibo.current_roster.organizations.find(org_sourced_id)
|
123
|
+
end
|
124
|
+
|
125
|
+
def user
|
126
|
+
Meibo.current_roster.users.find(user_sourced_id)
|
127
|
+
end
|
128
|
+
|
129
|
+
def user_profile
|
130
|
+
user_profile_sourced_id && Meibo.current_roster.user_profiles.find(user_profile_sourced_id)
|
131
|
+
end
|
120
132
|
end
|
121
133
|
end
|
data/lib/meibo/role_set.rb
CHANGED
@@ -14,5 +14,61 @@ module Meibo
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
def primary
|
19
|
+
@cache[:primary] ||= new(select(&:primary?))
|
20
|
+
end
|
21
|
+
|
22
|
+
def secondary
|
23
|
+
@cache[:secondary] ||= new(select(&:secondary?))
|
24
|
+
end
|
25
|
+
|
26
|
+
def aide
|
27
|
+
@cache[:aide] ||= new(select(&:aide?))
|
28
|
+
end
|
29
|
+
|
30
|
+
def counselor
|
31
|
+
@cache[:counselor] ||= new(select(&:counselor?))
|
32
|
+
end
|
33
|
+
|
34
|
+
def district_administrator
|
35
|
+
@cache[:district_administrator] ||= new(select(&:district_administrator?))
|
36
|
+
end
|
37
|
+
|
38
|
+
def guardian
|
39
|
+
@cache[:guardian] ||= new(select(&:guardian?))
|
40
|
+
end
|
41
|
+
|
42
|
+
def parent
|
43
|
+
@cache[:parent] ||= new(select(&:parent?))
|
44
|
+
end
|
45
|
+
|
46
|
+
def principal
|
47
|
+
@cache[:principal] ||= new(select(&:principal?))
|
48
|
+
end
|
49
|
+
|
50
|
+
def proctor
|
51
|
+
@cache[:proctor] ||= new(select(&:proctor?))
|
52
|
+
end
|
53
|
+
|
54
|
+
def relative
|
55
|
+
@cache[:relative] ||= new(select(&:relative?))
|
56
|
+
end
|
57
|
+
|
58
|
+
def site_administrator
|
59
|
+
@cache[:site_administrator] ||= new(select(&:site_administrator?))
|
60
|
+
end
|
61
|
+
|
62
|
+
def student
|
63
|
+
@cache[:student] ||= new(select(&:student?))
|
64
|
+
end
|
65
|
+
|
66
|
+
def system_administrator
|
67
|
+
@cache[:system_administrator] ||= new(select(&:system_administrator?))
|
68
|
+
end
|
69
|
+
|
70
|
+
def teacher
|
71
|
+
@cache[:teacher] ||= new(select(&:teacher?))
|
72
|
+
end
|
17
73
|
end
|
18
74
|
end
|
data/lib/meibo/user.rb
CHANGED
@@ -67,5 +67,37 @@ module Meibo
|
|
67
67
|
@pronouns = pronouns
|
68
68
|
@extension_fields = extension_fields
|
69
69
|
end
|
70
|
+
|
71
|
+
def agents
|
72
|
+
agent_sourced_ids.map {|agent_sourced_id| Meibo.current_roster.users.find(agent_sourced_id) }
|
73
|
+
end
|
74
|
+
|
75
|
+
def demographic
|
76
|
+
Meibo.current_roster.demographics.find(sourced_id)
|
77
|
+
rescue DataNotFoundError
|
78
|
+
nil
|
79
|
+
end
|
80
|
+
|
81
|
+
def enrollments
|
82
|
+
Meibo.current_roster.enrollments.by_user(sourced_id)
|
83
|
+
end
|
84
|
+
|
85
|
+
def primary_organization
|
86
|
+
primary_org_sourced_id && Meibo.current_roster.organizations.find(primary_org_sourced_id)
|
87
|
+
end
|
88
|
+
|
89
|
+
def primary_role_in(org)
|
90
|
+
Meibo.current_roster.roles.by_user(sourced_id).detect do |role|
|
91
|
+
role.primary? && role.org_sourced_id == org.sourced_id
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def roles
|
96
|
+
Meibo.current_roster.roles.by_user(sourced_id)
|
97
|
+
end
|
98
|
+
|
99
|
+
def user_profiles
|
100
|
+
Meibo.current_roster.user_profiles.by_user(sourced_id)
|
101
|
+
end
|
70
102
|
end
|
71
103
|
end
|
data/lib/meibo/user_profile.rb
CHANGED
data/lib/meibo/version.rb
CHANGED
data/lib/meibo.rb
CHANGED
@@ -15,6 +15,24 @@ module Meibo
|
|
15
15
|
|
16
16
|
class << self
|
17
17
|
attr_accessor :default_profile
|
18
|
+
|
19
|
+
def current_roster
|
20
|
+
thread_local_data[:roster]
|
21
|
+
end
|
22
|
+
|
23
|
+
def with_roster(roster)
|
24
|
+
orig_roster = thread_local_data[:roster]
|
25
|
+
thread_local_data[:roster] = roster
|
26
|
+
yield
|
27
|
+
ensure
|
28
|
+
thread_local_data[:roster] = orig_roster
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def thread_local_data
|
34
|
+
Thread.current[:__meibo] ||= {}
|
35
|
+
end
|
18
36
|
end
|
19
37
|
end
|
20
38
|
|
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.
|
4
|
+
version: 0.13.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: 2022-11-
|
11
|
+
date: 2022-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -125,7 +125,7 @@ metadata:
|
|
125
125
|
allowed_push_host: https://rubygems.org/
|
126
126
|
homepage_uri: https://github.com/hanachin/meibo
|
127
127
|
source_code_uri: https://github.com/hanachin/meibo
|
128
|
-
changelog_uri: https://github.com/hanachin/meibo/blob/meibo/v0.
|
128
|
+
changelog_uri: https://github.com/hanachin/meibo/blob/meibo/v0.13.0/CHANGELOG.md
|
129
129
|
post_install_message:
|
130
130
|
rdoc_options: []
|
131
131
|
require_paths:
|