mumukit-platform 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b089e4ed42661cce634490d1e6d714e33408b31c272e91028ef11e505a4070f4
4
- data.tar.gz: 44a80514586a38975e1d975f25574865c2e6c6c12715949a100a918f65d07411
3
+ metadata.gz: 5eff1d483904e69e76c1114b058358a6d2e5eb3b041a95fda5aa28f441700601
4
+ data.tar.gz: 439d16d1874d455e85b76c53a79d3a147b2ff7ddea45be50e12d62881680940f
5
5
  SHA512:
6
- metadata.gz: d95eab6d563e8a87ecf7a09c0e64950e9c5b4dfdb758a9e3e35b80772913d93529c3e4022a73ddc797d4dde8143b6c6ac2c30242e08b603c8cdd5bf7a3f8fe68
7
- data.tar.gz: 11ed531dbb9b95e89de392f81b445363fda7fdc8a65a55104a14a61169b806730244f96474a1dd019035940e98edeb218d8e653f58be68e78b28afbff96a8f50
6
+ metadata.gz: 2fe97f05b46bc6d60c2df137e5d87b67d2767f1ed36d6505d1f11817428304b61a36279b06e158f9745efaf59697ed3ac127952e03cd21e6996d3078d3805934
7
+ data.tar.gz: 589cf58ab0cffc2e24f61726ddab0e4fc38a52cd4dc8379f8a3b4bb3dc1a3814e3b9649addfc819e00b77b913bf54c2992d89dc892a6e6d5942a2cf690c53330
@@ -1,10 +1,13 @@
1
1
  require 'mumukit/core'
2
2
  require 'mumukit/auth'
3
+ require 'mumukit/nuntius'
3
4
 
4
5
  require_relative './platform/version'
5
6
  require_relative './platform/uri'
6
7
 
7
8
  module Mumukit::Platform
9
+ CORE_MODELS = [:organization, :user, :course]
10
+
8
11
  def self.configure
9
12
  @config ||= defaults
10
13
  yield @config
@@ -28,7 +31,7 @@ module Mumukit::Platform
28
31
  @config
29
32
  end
30
33
 
31
- [:organization, :user].each do |klass|
34
+ CORE_MODELS.each do |klass|
32
35
  define_singleton_method("#{klass}_class") do
33
36
  begin
34
37
  config["#{klass}_class"] ||= config["#{klass}_class_name"].constantize
@@ -39,9 +42,12 @@ module Mumukit::Platform
39
42
  end
40
43
  end
41
44
 
45
+ require_relative './platform/notifiable'
46
+
42
47
  require_relative './platform/domain'
43
48
  require_relative './platform/model'
44
49
  require_relative './platform/locale'
50
+ require_relative './platform/course'
45
51
  require_relative './platform/user'
46
52
  require_relative './platform/organization'
47
53
  require_relative './platform/organization_mapping'
@@ -0,0 +1,7 @@
1
+ module Mumukit::Platform::Course
2
+ def self.find_by_slug!(slug)
3
+ Mumukit::Platform.course_class.find_by_slug!(slug)
4
+ end
5
+ end
6
+
7
+ require_relative './course/helpers'
@@ -0,0 +1,43 @@
1
+ module Mumukit::Platform::Course::Helpers
2
+ include Mumukit::Platform::Notifiable
3
+
4
+ ## Implementors must declare the following methods:
5
+ #
6
+ # * slug
7
+ # * shifts
8
+ # * code
9
+ # * days
10
+ # * period
11
+ # * description
12
+
13
+ def platform_class_name
14
+ :Course
15
+ end
16
+
17
+ ## API Exposure
18
+
19
+ def to_param
20
+ slug
21
+ end
22
+
23
+ ## Platform JSON
24
+
25
+ def self.slice_platform_json(json)
26
+ json.slice(:slug, :shifts, :code, :days, :period, :description)
27
+ end
28
+
29
+ def as_platform_json
30
+ {
31
+ slug: slug,
32
+ shifts: shifts,
33
+ code: code,
34
+ days: days,
35
+ period: period,
36
+ description: description
37
+ }.except(*protected_platform_fields).compact
38
+ end
39
+
40
+ def protected_platform_fields
41
+ []
42
+ end
43
+ end
@@ -0,0 +1,13 @@
1
+ module Mumukit::Platform::Notifiable
2
+ def notify!(event_type = :changed)
3
+ Mumukit::Nuntius.notify_event! platform_event_name(event_type), as_platform_event
4
+ end
5
+
6
+ def platform_event_name(event_type)
7
+ "#{platform_class_name}#{event_type.to_s.titlecase}"
8
+ end
9
+
10
+ def as_platform_event
11
+ { platform_class_name.downcase => as_platform_json }
12
+ end
13
+ end
@@ -1,5 +1,6 @@
1
1
  module Mumukit::Platform::Organization::Helpers
2
2
  extend ActiveSupport::Concern
3
+ include Mumukit::Platform::Notifiable
3
4
 
4
5
  ## Implementors must declare the following methods:
5
6
  #
@@ -54,6 +55,10 @@ module Mumukit::Platform::Organization::Helpers
54
55
 
55
56
  end
56
57
 
58
+ def platform_class_name
59
+ :Organization
60
+ end
61
+
57
62
  def slug
58
63
  Mumukit::Auth::Slug.join_s name
59
64
  end
@@ -108,27 +113,17 @@ module Mumukit::Platform::Organization::Helpers
108
113
 
109
114
  ## Platform JSON
110
115
 
116
+ def self.slice_platform_json(json)
117
+ json.slice(:name, :book, :profile, :settings, :theme)
118
+ end
119
+
111
120
  def as_platform_json
112
121
  {
113
122
  name: name,
114
123
  book: book.slug,
115
- banner_url: banner_url,
116
- breadcrumb_image_url: breadcrumb_image_url,
117
- community_link: community_link,
118
- contact_email: contact_email,
119
- description: description,
120
- extension_javascript: extension_javascript,
121
- favicon_url: favicon_url,
122
- feedback_suggestions_enabled: feedback_suggestions_enabled?,
123
- immersive: immersive?,
124
- locale: locale,
125
- login_methods: login_methods,
126
- logo_url: logo_url,
127
- open_graph_image_url: open_graph_image_url,
128
- public: public?,
129
- raise_hand_enabled: raise_hand_enabled?,
130
- terms_of_service: terms_of_service,
131
- theme_stylesheet: theme_stylesheet
124
+ profile: profile,
125
+ settings: settings,
126
+ theme: theme
132
127
  }.except(*protected_platform_fields).compact
133
128
  end
134
129
 
@@ -144,9 +139,9 @@ module Mumukit::Platform::Organization::Helpers
144
139
  def parse(json)
145
140
  json
146
141
  .slice(:name)
147
- .merge(theme: Mumukit::Platform::Organization::Theme.parse(json))
148
- .merge(settings: Mumukit::Platform::Organization::Settings.parse(json))
149
- .merge(profile: Mumukit::Platform::Organization::Profile.parse(json))
142
+ .merge(theme: Mumukit::Platform::Organization::Theme.parse(json[:theme]))
143
+ .merge(settings: Mumukit::Platform::Organization::Settings.parse(json[:settings]))
144
+ .merge(profile: Mumukit::Platform::Organization::Profile.parse(json[:profile]))
150
145
  end
151
146
  end
152
147
  end
@@ -1,5 +1,6 @@
1
1
  module Mumukit::Platform::User::Helpers
2
2
  include Mumukit::Auth::Roles
3
+ include Mumukit::Platform::Notifiable
3
4
 
4
5
  ## Implementors must declare the following methods:
5
6
  #
@@ -23,6 +24,10 @@ module Mumukit::Platform::User::Helpers
23
24
  :protect_permissions_assignment!,
24
25
  to: :permissions
25
26
 
27
+ def platform_class_name
28
+ :User
29
+ end
30
+
26
31
  def merge_permissions!(new_permissions)
27
32
  self.permissions = permissions.merge(new_permissions)
28
33
  end
@@ -50,6 +55,8 @@ module Mumukit::Platform::User::Helpers
50
55
  "#{first_name} #{last_name}"
51
56
  end
52
57
 
58
+ alias_method :name, :full_name
59
+
53
60
  def profile_completed?
54
61
  [first_name, last_name].all? &:present?
55
62
  end
@@ -90,6 +97,10 @@ module Mumukit::Platform::User::Helpers
90
97
 
91
98
  ## Platform JSON
92
99
 
100
+ def self.slice_platform_json(json)
101
+ json.slice(:uid, :social_id, :image_url, :email, :first_name, :last_name, :permissions)
102
+ end
103
+
93
104
  def as_platform_json
94
105
  {
95
106
  uid: uid,
@@ -1,5 +1,5 @@
1
1
  module Mumukit
2
2
  module Platform
3
- VERSION = '1.2.0'
3
+ VERSION = '1.3.0'
4
4
  end
5
5
  end
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
+ spec.add_dependency 'mumukit-nuntius', '~> 6.0'
24
25
  spec.add_dependency 'mumukit-core', '~> 1.2'
25
26
  spec.add_dependency 'mumukit-auth', '~> 7.0'
26
27
  spec.add_dependency 'activemodel', '>= 4.0'
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumukit-platform
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Leonardo Bulgarelli
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-26 00:00:00.000000000 Z
11
+ date: 2018-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mumukit-nuntius
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '6.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '6.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: mumukit-core
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -114,9 +128,12 @@ files:
114
128
  - bin/setup
115
129
  - lib/mumukit/platform.rb
116
130
  - lib/mumukit/platform/application.rb
131
+ - lib/mumukit/platform/course.rb
132
+ - lib/mumukit/platform/course/helpers.rb
117
133
  - lib/mumukit/platform/domain.rb
118
134
  - lib/mumukit/platform/locale.rb
119
135
  - lib/mumukit/platform/model.rb
136
+ - lib/mumukit/platform/notifiable.rb
120
137
  - lib/mumukit/platform/organization.rb
121
138
  - lib/mumukit/platform/organization/helpers.rb
122
139
  - lib/mumukit/platform/organization/profile.rb