meibo 0.13.0 → 0.15.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: 2fed6d292ab3d38301370ef4d6238d4ddc470d8ae380e1e8bdf8f6d88822aaf0
4
- data.tar.gz: d364e20a7336ad702b4d3434efefe800bed8a971f0cc02177c817398fa79982d
3
+ metadata.gz: 0f093d7946a8add1449f8ae9c89c94a47431f36386c598dfeb21ca225ca9c167
4
+ data.tar.gz: facfe3ab95a9e3c4f61885afedea7df1c8f657725f4e61b6918da4e58f0375ec
5
5
  SHA512:
6
- metadata.gz: bb712c2090b7cc03708a4c8b302e187357db4f2bf260e62486f79072ba646371368c6968baaa022c472774b6a09c0aba3a7f1716b1b074e6fcb2ab6ab6e19935
7
- data.tar.gz: dd2f31087c8b28e02b9e257dcb405cb1eec588d5a576c120cdcadcb0402743cb7a02f6e62262ca1c932f93c8f119839d95eb505ce44534a04a478883e0d966af
6
+ metadata.gz: c472f7f3874f886ae4c27b9fb93b8a8024f820b1a6172b04b54efcfcaca5672faca6d1235845d9bad8daf63fa9a277714140ee9114ca537ced93e584a6c45d55
7
+ data.tar.gz: 0220f2730b1ee389f13e7c114a87964a82a7777e3c1662963c04977f74a9bfa85b0c5afbacd2701a483aef3c9ba6f30c1f4be8d6722081334288b4d5bb590864
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- meibo (0.13.0)
4
+ meibo (0.15.0)
5
5
  rubyzip
6
6
  zeitwerk
7
7
 
@@ -45,6 +45,10 @@ module Meibo
45
45
  @extension_fields = extension_fields
46
46
  end
47
47
 
48
+ def collection
49
+ Meibo.current_roster.academic_sessions
50
+ end
51
+
48
52
  def grading_period?
49
53
  type == TYPES[:grading_period]
50
54
  end
@@ -62,7 +66,11 @@ module Meibo
62
66
  end
63
67
 
64
68
  def parent
65
- Meibo.current_roster.academic_sessions.find(parent_sourced_id)
69
+ parent_sourced_id && collection.find(parent_sourced_id)
70
+ end
71
+
72
+ def children
73
+ collection.where(parent_sourced_id: sourced_id)
66
74
  end
67
75
  end
68
76
  end
@@ -64,6 +64,10 @@ module Meibo
64
64
  @extension_fields = extension_fields
65
65
  end
66
66
 
67
+ def collection
68
+ Meibo.current_roster.classes
69
+ end
70
+
67
71
  def homeroom?
68
72
  class_type == TYPES[:homeroom]
69
73
  end
@@ -83,5 +87,9 @@ module Meibo
83
87
  def terms
84
88
  term_sourced_ids.map {|term_sourced_id| Meibo.current_roster.academic_sessions.find(term_sourced_id) }
85
89
  end
90
+
91
+ def enrollments
92
+ Meibo.current_roster.enrollments.where(class_sourced_id: sourced_id)
93
+ end
86
94
  end
87
95
  end
data/lib/meibo/course.rb CHANGED
@@ -42,6 +42,10 @@ module Meibo
42
42
  @extension_fields = extension_fields
43
43
  end
44
44
 
45
+ def collection
46
+ Meibo.current_roster.courses
47
+ end
48
+
45
49
  def organization
46
50
  Meibo.current_roster.organizations.find(org_sourced_id)
47
51
  end
@@ -49,5 +53,9 @@ module Meibo
49
53
  def school_year
50
54
  Meibo.current_roster.academic_sessions.find(school_year_sourced_id)
51
55
  end
56
+
57
+ def classes
58
+ Meibo.current_roster.classes.where(course_sourced_id: sourced_id)
59
+ end
52
60
  end
53
61
  end
@@ -61,6 +61,10 @@ module Meibo
61
61
  klass.define_singleton_method(:write_converters) { write_converter }
62
62
  end
63
63
 
64
+ def lineno
65
+ collection.lineno(self)
66
+ end
67
+
64
68
  def to_csv(...)
65
69
  to_a.to_csv(...)
66
70
  end
@@ -42,19 +42,22 @@ module Meibo
42
42
  raise DataNotFoundError, "sourcedId: #{sourced_id} が見つかりません"
43
43
  end
44
44
 
45
- def by_organization(org_sourced_id)
46
- data_by_org_sourced_id[org_sourced_id]
45
+ def lineno(datum)
46
+ # NOTE: add one for one-based, and add one for header line
47
+ find_index(datum)&.+(2)
47
48
  end
48
49
 
49
- def by_user(user_sourced_id)
50
- data_by_user_sourced_id[user_sourced_id]
50
+ def where(**conditions)
51
+ group_cache[conditions.keys.sort][conditions.values]
51
52
  end
52
53
 
53
54
  private
54
55
 
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)]
56
+ def group_cache
57
+ @cache[:group_cache] ||= Hash.new do |hash, keys|
58
+ hash[keys] = @data.group_by {|datum| keys.map {|attribute| datum.public_send(attribute) } }.to_h do |values, data|
59
+ [values, new(data)]
60
+ end
58
61
  end
59
62
  end
60
63
 
@@ -62,12 +65,6 @@ module Meibo
62
65
  @cache[:data_by_sourced_id] ||= @data.to_h {|datum| [datum.sourced_id, datum] }
63
66
  end
64
67
 
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
68
  def new(data)
72
69
  self.class.new(data, roster: roster)
73
70
  end
@@ -67,6 +67,10 @@ module Meibo
67
67
  @extension_fields = extension_fields
68
68
  end
69
69
 
70
+ def collection
71
+ Meibo.current_roster.demographics
72
+ end
73
+
70
74
  def male?
71
75
  sex == SEX[:male]
72
76
  end
@@ -46,6 +46,10 @@ module Meibo
46
46
  @extension_fields = extension_fields
47
47
  end
48
48
 
49
+ def collection
50
+ Meibo.current_roster.enrollments
51
+ end
52
+
49
53
  def administrator?
50
54
  role == ROLES[:administrator]
51
55
  end
@@ -41,6 +41,10 @@ module Meibo
41
41
  @extension_fields = extension_fields
42
42
  end
43
43
 
44
+ def collection
45
+ Meibo.current_roster.organizations
46
+ end
47
+
44
48
  def department?
45
49
  type == TYPES[:department]
46
50
  end
@@ -66,7 +70,27 @@ module Meibo
66
70
  end
67
71
 
68
72
  def parent
69
- parent_sourced_id && Meibo.current_roster.organizations.find(parent_sourced_id)
73
+ parent_sourced_id && collection.find(parent_sourced_id)
74
+ end
75
+
76
+ def children
77
+ collection.where(parent_sourced_id: sourced_id)
78
+ end
79
+
80
+ def enrollments
81
+ Meibo.current_roster.enrollments.where(school_sourced_id: sourced_id)
82
+ end
83
+
84
+ def classes
85
+ Meibo.current_roster.classes.where(school_sourced_id: sourced_id)
86
+ end
87
+
88
+ def courses
89
+ Meibo.current_roster.courses.where(org_sourced_id: sourced_id)
90
+ end
91
+
92
+ def roles
93
+ Meibo.current_roster.roles.where(org_sourced_id: sourced_id)
70
94
  end
71
95
  end
72
96
  end
data/lib/meibo/role.rb CHANGED
@@ -62,6 +62,10 @@ module Meibo
62
62
  @extension_fields = extension_fields
63
63
  end
64
64
 
65
+ def collection
66
+ Meibo.current_roster.roles
67
+ end
68
+
65
69
  def primary?
66
70
  @role_type == TYPES[:primary]
67
71
  end
data/lib/meibo/user.rb CHANGED
@@ -68,6 +68,10 @@ module Meibo
68
68
  @extension_fields = extension_fields
69
69
  end
70
70
 
71
+ def collection
72
+ Meibo.current_roster.users
73
+ end
74
+
71
75
  def agents
72
76
  agent_sourced_ids.map {|agent_sourced_id| Meibo.current_roster.users.find(agent_sourced_id) }
73
77
  end
@@ -79,7 +83,7 @@ module Meibo
79
83
  end
80
84
 
81
85
  def enrollments
82
- Meibo.current_roster.enrollments.by_user(sourced_id)
86
+ Meibo.current_roster.enrollments.where(user_sourced_id: sourced_id)
83
87
  end
84
88
 
85
89
  def primary_organization
@@ -87,17 +91,17 @@ module Meibo
87
91
  end
88
92
 
89
93
  def primary_role_in(org)
90
- Meibo.current_roster.roles.by_user(sourced_id).detect do |role|
94
+ Meibo.current_roster.roles.where(user_sourced_id: sourced_id).detect do |role|
91
95
  role.primary? && role.org_sourced_id == org.sourced_id
92
96
  end
93
97
  end
94
98
 
95
99
  def roles
96
- Meibo.current_roster.roles.by_user(sourced_id)
100
+ Meibo.current_roster.roles.where(user_sourced_id: sourced_id)
97
101
  end
98
102
 
99
103
  def user_profiles
100
- Meibo.current_roster.user_profiles.by_user(sourced_id)
104
+ Meibo.current_roster.user_profiles.where(user_sourced_id: sourced_id)
101
105
  end
102
106
  end
103
107
  end
@@ -39,8 +39,16 @@ module Meibo
39
39
  @extension_fields = extension_fields
40
40
  end
41
41
 
42
+ def collection
43
+ Meibo.current_roster.user_profiles
44
+ end
45
+
42
46
  def user
43
47
  Meibo.current_roster.users.find(user_sourced_id)
44
48
  end
49
+
50
+ def role
51
+ Meibo.current_roster.roles.where(user_profile_sourced_id: sourced_id).first
52
+ end
45
53
  end
46
54
  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.13.0"
4
+ VERSION = "0.15.0"
5
5
  end
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.13.0
4
+ version: 0.15.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-15 00:00:00.000000000 Z
11
+ date: 2022-11-21 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.13.0/CHANGELOG.md
128
+ changelog_uri: https://github.com/hanachin/meibo/blob/meibo/v0.15.0/CHANGELOG.md
129
129
  post_install_message:
130
130
  rdoc_options: []
131
131
  require_paths: