mumukit-platform 5.0.1 → 7.0.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 +4 -4
- data/.github/workflows/test_and_deploy.yml +32 -0
- data/lib/mumukit/platform.rb +8 -4
- data/lib/mumukit/platform/application.rb +10 -2
- data/lib/mumukit/platform/course.rb +6 -0
- data/lib/mumukit/platform/global.rb +19 -0
- data/lib/mumukit/platform/locale.rb +1 -0
- data/lib/mumukit/platform/organization.rb +16 -13
- data/lib/mumukit/platform/organization_mapping.rb +28 -3
- data/lib/mumukit/platform/uri.rb +16 -9
- data/lib/mumukit/platform/version.rb +1 -1
- data/lib/mumukit/platform/web_framework.rb +1 -1
- data/mumukit-platform.gemspec +2 -2
- metadata +15 -8
- data/.travis.yml +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39a52de81a0b2c6efb83bcc9a7e23b8e59715c42f83cd667813ea00c34fe1880
|
4
|
+
data.tar.gz: 6ba950cc3889ca4aedae2f48ad94c3011ebb8196bd57f8aed9ef48509a5f947c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c434715414edfa1af06bafe9a92e6c1a5fd23435e7c7408bc70005c84f90a7bc5512597c8f0aaa2188bb71aa12f60c5b1f610fdf59d21e2447e598184eb4d58
|
7
|
+
data.tar.gz: f4142a30260afa2b54d7addb7fd48ffd4a523e71948f4243c4088043cad49851cdfe8549b1abc06ba9253701c4c7a54eb03e54e66dc501551116de4ae762682d
|
@@ -0,0 +1,32 @@
|
|
1
|
+
name: Test and deploy
|
2
|
+
|
3
|
+
on:
|
4
|
+
- push
|
5
|
+
- workflow_dispatch
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
test_and_deploy:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v2
|
12
|
+
- name: Set up Ruby
|
13
|
+
uses: ruby/setup-ruby@21351ecc0a7c196081abca5dc55b08f085efe09a
|
14
|
+
with:
|
15
|
+
ruby-version: 2.6.3
|
16
|
+
bundler: 2.1.4
|
17
|
+
- name: Install dependencies
|
18
|
+
run: bundle install
|
19
|
+
- name: Run tests
|
20
|
+
run: bundle exec rake
|
21
|
+
- name: Deploy
|
22
|
+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
23
|
+
run: |
|
24
|
+
mkdir -p $HOME/.gem
|
25
|
+
touch $HOME/.gem/credentials
|
26
|
+
chmod 0600 $HOME/.gem/credentials
|
27
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
28
|
+
gem build *.gemspec
|
29
|
+
gem push *.gem
|
30
|
+
env:
|
31
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
32
|
+
|
data/lib/mumukit/platform.rb
CHANGED
@@ -17,9 +17,9 @@ module Mumukit::Platform
|
|
17
17
|
|
18
18
|
config.laboratory_url = ENV['MUMUKI_LABORATORY_URL'] || "http://#{domain}"
|
19
19
|
config.thesaurus_url = ENV['MUMUKI_THESAURUS_URL'] || "http://thesaurus.#{domain}"
|
20
|
-
config.bibliotheca_ui_url = ENV['MUMUKI_BIBLIOTHECA_UI_URL'] || "http://bibliotheca.#{domain}"
|
20
|
+
config.bibliotheca_ui_url = ENV['MUMUKI_BIBLIOTHECA_UI_URL'] || "http://bibliotheca.#{domain}/#/"
|
21
21
|
config.bibliotheca_api_url = ENV['MUMUKI_BIBLIOTHECA_API_URL'] || "http://bibliotheca-api.#{domain}"
|
22
|
-
config.classroom_ui_url = ENV['MUMUKI_CLASSROOM_UI_URL'] || "http://classroom.#{domain}"
|
22
|
+
config.classroom_ui_url = ENV['MUMUKI_CLASSROOM_UI_URL'] || "http://classroom.#{domain}/#/"
|
23
23
|
config.classroom_api_url = ENV['MUMUKI_CLASSROOM_API_URL'] || "http://classroom-api.#{domain}"
|
24
24
|
config.organization_mapping = Mumukit::Platform::OrganizationMapping.from_env
|
25
25
|
end
|
@@ -41,8 +41,11 @@ module Mumukit::Platform
|
|
41
41
|
#
|
42
42
|
define_singleton_method("#{klass}_class") do
|
43
43
|
begin
|
44
|
-
config["#{klass}_class"]
|
45
|
-
|
44
|
+
return config["#{klass}_class"] if config["#{klass}_class"].present?
|
45
|
+
config["#{klass}_class_name"].to_s.constantize.tap do |klass_instance|
|
46
|
+
config["#{klass}_class"] = klass_instance unless %w(RACK_ENV RAILS_ENV).any? { |it| ENV[it] == 'development' }
|
47
|
+
end
|
48
|
+
rescue NameError => e
|
46
49
|
raise "You must configure your #{klass} class first"
|
47
50
|
end
|
48
51
|
end
|
@@ -51,6 +54,7 @@ end
|
|
51
54
|
|
52
55
|
require_relative './platform/notifiable'
|
53
56
|
|
57
|
+
require_relative './platform/global'
|
54
58
|
require_relative './platform/domain'
|
55
59
|
require_relative './platform/model'
|
56
60
|
require_relative './platform/locale'
|
@@ -28,7 +28,15 @@ class Mumukit::Platform::Application
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def organic_url_for(organization, path)
|
31
|
-
organic_uri(organization)
|
31
|
+
uri = organic_uri(organization)
|
32
|
+
# warning: this code is tightly
|
33
|
+
# coupled to the fact that applications can only rebuild urls
|
34
|
+
# in fragmented-mode
|
35
|
+
if uri.fragment
|
36
|
+
uri.to_s + relative_path(path)
|
37
|
+
else
|
38
|
+
uri.url_for(relative_path path)
|
39
|
+
end
|
32
40
|
end
|
33
41
|
|
34
42
|
def relative_path(path)
|
@@ -53,4 +61,4 @@ class Mumukit::Platform::Application
|
|
53
61
|
organization_mapping.organic_uri(uri, organization)
|
54
62
|
end
|
55
63
|
end
|
56
|
-
end
|
64
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Mumukit::Platform::Global
|
2
|
+
def switch!(global)
|
3
|
+
raise "#{__global_thread_variable_key__} must not be nil" unless global
|
4
|
+
Thread.current[__global_thread_variable_key__] = global
|
5
|
+
end
|
6
|
+
|
7
|
+
def leave!
|
8
|
+
Thread.current[__global_thread_variable_key__] = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def current
|
12
|
+
Thread.current[__global_thread_variable_key__] || raise("#{__global_thread_variable_key__} not selected")
|
13
|
+
end
|
14
|
+
|
15
|
+
def current?
|
16
|
+
!!Thread.current[__global_thread_variable_key__]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -2,6 +2,7 @@ module Mumukit::Platform::Locale
|
|
2
2
|
SPECS = {
|
3
3
|
en: { facebook_code: :en_US, auth0_code: :en, name: 'English' },
|
4
4
|
es: { facebook_code: :es_LA, auth0_code: :es, name: 'Español' },
|
5
|
+
'es-CL': { facebook_code: :es_LA, auth0_code: :es, name: 'Español chileno' },
|
5
6
|
pt: { facebook_code: :pt_BR, auth0_code: 'pt-br', name: 'Português' }
|
6
7
|
}.with_indifferent_access
|
7
8
|
|
@@ -1,27 +1,30 @@
|
|
1
1
|
module Mumukit::Platform::Organization
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
extend Mumukit::Platform::Global
|
3
|
+
|
4
|
+
def self.current_locale
|
5
|
+
Thread.current[:organization]&.locale || 'en'
|
5
6
|
end
|
6
7
|
|
7
|
-
def self.
|
8
|
-
|
8
|
+
def self.find_by_name!(name)
|
9
|
+
Mumukit::Platform.organization_class.find_by_name!(name)
|
9
10
|
end
|
10
11
|
|
11
|
-
def self.
|
12
|
-
|
12
|
+
def self.__global_thread_variable_key__
|
13
|
+
:organization
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
## Name validation
|
17
|
+
|
18
|
+
def self.valid_name?(name)
|
19
|
+
!!(name =~ anchored_valid_name_regex)
|
17
20
|
end
|
18
21
|
|
19
|
-
def self.
|
20
|
-
|
22
|
+
def self.anchored_valid_name_regex
|
23
|
+
/\A#{valid_name_regex}\z/
|
21
24
|
end
|
22
25
|
|
23
|
-
def self.
|
24
|
-
|
26
|
+
def self.valid_name_regex
|
27
|
+
/([-a-z0-9_]+(\.[-a-z0-9_]+)*)?/
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
module Mumukit::Platform::OrganizationMapping
|
2
4
|
def self.from_env
|
3
5
|
if ENV['RACK_ENV'] == 'test' || ENV['RAILS_ENV'] == 'test'
|
@@ -18,7 +20,15 @@ module Mumukit::Platform::OrganizationMapping
|
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
23
|
+
module Base
|
24
|
+
def path_for(request)
|
25
|
+
request.path_info
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
21
29
|
module Subdomain
|
30
|
+
extend Base
|
31
|
+
|
22
32
|
def self.implicit_organization?(request, domain)
|
23
33
|
request.empty_subdomain_after?(domain)
|
24
34
|
end
|
@@ -32,15 +42,21 @@ module Mumukit::Platform::OrganizationMapping
|
|
32
42
|
end
|
33
43
|
|
34
44
|
def self.organic_uri(uri, organization)
|
35
|
-
uri.subdominate(organization)
|
45
|
+
uri.subdominate(organization, fragmented: true)
|
36
46
|
end
|
37
47
|
|
38
48
|
def self.path_under_namespace?(_organization_name, path, namespace)
|
39
49
|
path.start_with? "/#{namespace}/"
|
40
50
|
end
|
51
|
+
|
52
|
+
def self.inorganic_path_for(request)
|
53
|
+
path_for(request)
|
54
|
+
end
|
41
55
|
end
|
42
56
|
|
43
57
|
module Path
|
58
|
+
extend Base
|
59
|
+
|
44
60
|
def self.implicit_organization?(_request, _domain)
|
45
61
|
false
|
46
62
|
end
|
@@ -49,12 +65,21 @@ module Mumukit::Platform::OrganizationMapping
|
|
49
65
|
framework.configure_tenant_path_routes! native, &block
|
50
66
|
end
|
51
67
|
|
68
|
+
def self.path_composition_for(request)
|
69
|
+
organization, *path_parts = Pathname(path_for(request)).each_filename.to_a
|
70
|
+
[organization, path_parts.join('/')]
|
71
|
+
end
|
72
|
+
|
52
73
|
def self.organization_name(request, _domain)
|
53
|
-
request.
|
74
|
+
path_composition_for(request).first
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.inorganic_path_for(request)
|
78
|
+
path_composition_for(request).second
|
54
79
|
end
|
55
80
|
|
56
81
|
def self.organic_uri(uri, organization)
|
57
|
-
uri.
|
82
|
+
uri.tenantize organization, fragmented: true
|
58
83
|
end
|
59
84
|
|
60
85
|
def self.path_under_namespace?(organization_name, path, namespace)
|
data/lib/mumukit/platform/uri.rb
CHANGED
@@ -1,23 +1,30 @@
|
|
1
1
|
class URI::HTTP
|
2
|
-
def subdominate(subdomain)
|
2
|
+
def subdominate(subdomain, **options)
|
3
3
|
if host.start_with? 'www.'
|
4
4
|
new_host = host.gsub('www.', "www.#{subdomain}.")
|
5
5
|
else
|
6
6
|
new_host = "#{subdomain}.#{host}"
|
7
7
|
end
|
8
|
-
rebuild(host: new_host)
|
8
|
+
rebuild({host: new_host}, **options)
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
if path.
|
13
|
-
new_path = "
|
11
|
+
def tenantize(route, **options)
|
12
|
+
if path.end_with? '/'
|
13
|
+
new_path = "#{path}#{route}/"
|
14
14
|
else
|
15
|
-
new_path = "
|
15
|
+
new_path = "#{path}/#{route}/"
|
16
16
|
end
|
17
|
-
rebuild(path: new_path)
|
17
|
+
rebuild({path: new_path}, **options)
|
18
18
|
end
|
19
19
|
|
20
|
-
def rebuild(updates)
|
20
|
+
def rebuild(updates, fragmented: false)
|
21
|
+
if fragmented && fragment
|
22
|
+
fragment = "#{self.fragment}/#{updates[:path]}/".squeeze('/')
|
23
|
+
updates = updates.except(:path)
|
24
|
+
else
|
25
|
+
fragment = self.fragment
|
26
|
+
end
|
27
|
+
|
21
28
|
self.class.build({
|
22
29
|
scheme: scheme,
|
23
30
|
host: host,
|
@@ -30,4 +37,4 @@ class URI::HTTP
|
|
30
37
|
def url_for(path)
|
31
38
|
URI.join(self, path).to_s
|
32
39
|
end
|
33
|
-
end
|
40
|
+
end
|
@@ -21,7 +21,7 @@ module Mumukit::Platform::WebFramework
|
|
21
21
|
def self.tenant_scope_options
|
22
22
|
{
|
23
23
|
defaults: { tenant: lazy_string { Mumukit::Platform.current_organization_name } },
|
24
|
-
constraints: { tenant: Mumukit::Platform::Organization
|
24
|
+
constraints: { tenant: Mumukit::Platform::Organization.valid_name_regex }
|
25
25
|
}
|
26
26
|
end
|
27
27
|
end
|
data/mumukit-platform.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_dependency 'mumukit-bridge', '>= 3.5', '< 5'
|
28
28
|
spec.add_dependency 'activemodel', '>= 4.0'
|
29
29
|
|
30
|
-
spec.add_development_dependency 'bundler', '~>
|
31
|
-
spec.add_development_dependency 'rake', '~>
|
30
|
+
spec.add_development_dependency 'bundler', '~> 2.0', '< 2.2'
|
31
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
32
32
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumukit-platform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.0.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:
|
11
|
+
date: 2021-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mumukit-nuntius
|
@@ -92,28 +92,34 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
95
|
+
version: '2.0'
|
96
|
+
- - "<"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '2.2'
|
96
99
|
type: :development
|
97
100
|
prerelease: false
|
98
101
|
version_requirements: !ruby/object:Gem::Requirement
|
99
102
|
requirements:
|
100
103
|
- - "~>"
|
101
104
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
105
|
+
version: '2.0'
|
106
|
+
- - "<"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '2.2'
|
103
109
|
- !ruby/object:Gem::Dependency
|
104
110
|
name: rake
|
105
111
|
requirement: !ruby/object:Gem::Requirement
|
106
112
|
requirements:
|
107
113
|
- - "~>"
|
108
114
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
115
|
+
version: '12.3'
|
110
116
|
type: :development
|
111
117
|
prerelease: false
|
112
118
|
version_requirements: !ruby/object:Gem::Requirement
|
113
119
|
requirements:
|
114
120
|
- - "~>"
|
115
121
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
122
|
+
version: '12.3'
|
117
123
|
- !ruby/object:Gem::Dependency
|
118
124
|
name: rspec
|
119
125
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,10 +141,10 @@ executables: []
|
|
135
141
|
extensions: []
|
136
142
|
extra_rdoc_files: []
|
137
143
|
files:
|
144
|
+
- ".github/workflows/test_and_deploy.yml"
|
138
145
|
- ".gitignore"
|
139
146
|
- ".rspec"
|
140
147
|
- ".ruby-version"
|
141
|
-
- ".travis.yml"
|
142
148
|
- CODE_OF_CONDUCT.md
|
143
149
|
- Gemfile
|
144
150
|
- LICENSE.txt
|
@@ -151,6 +157,7 @@ files:
|
|
151
157
|
- lib/mumukit/platform/bridge.rb
|
152
158
|
- lib/mumukit/platform/course.rb
|
153
159
|
- lib/mumukit/platform/domain.rb
|
160
|
+
- lib/mumukit/platform/global.rb
|
154
161
|
- lib/mumukit/platform/locale.rb
|
155
162
|
- lib/mumukit/platform/model.rb
|
156
163
|
- lib/mumukit/platform/notifiable.rb
|
@@ -184,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
191
|
- !ruby/object:Gem::Version
|
185
192
|
version: '0'
|
186
193
|
requirements: []
|
187
|
-
rubygems_version: 3.0.
|
194
|
+
rubygems_version: 3.0.3
|
188
195
|
signing_key:
|
189
196
|
specification_version: 4
|
190
197
|
summary: Shared Mumuki Platform Components
|
data/.travis.yml
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.6.3
|
5
|
-
before_install: gem install bundler -v 1.14.2
|
6
|
-
deploy:
|
7
|
-
provider: rubygems
|
8
|
-
api_key:
|
9
|
-
secure: peqcsnX2NXwCvy20HfitFl7Dhhi4jrkeu2ZuJz6eEVml5xkkGOuTiAXiSFMvysuV1uCueWNKvQJzNl6u82cwM/InYjFj1kG3SRLIZCkEKks2tOxtJmky7CpIh9jI5SZKOL/DKuMRIuYJwhN0WURi58aCybqyhAsh0XQYGN0EFo6jwnJHehe1KEwgxaTFFB1Q1bn41o+7LWw4r39j7mj28x+WTnl11iM/CRndrQj/YSB8Xk92il8W2vfEWbn4xY2rK/joQ9Doi+rbrW90J7ArGkiMbbsofKkt2snOjrO5UDqqDGWi1/iQmBwtf2qgqB+TmTELrqd4ehRraq4P7dgW3uWGQe/0gR5xoYDusimcBQ5N+JDZbac/YKMRYG0+Ce09ggIaGjq2iEyn9zus00aaaoEGixqVtTwMtkvApmlM/c7CaeSmKSUhYdYE8ayOuCqHgIhCKoZPhADylTc3NL5qizk3/3/wrCyAf9Slq/Oa04Wa4NRXfC5yDkdJggaIzYwq03mc1diechM1ZrovZHNOWznbtjq1JrbEDQk95A29BsrTRLCk98QnChaTHrGmwvlk7g40iUurDplfg5IpUHnSc9BBQg+hcKd5IjKVkrHH5cUHq+U8pXIXgf4vs8cYFX8B1asIO7ApiSABxnC8bsjBZx4ccu303LWILiFBurQQn7w=
|
10
|
-
gem: mumukit-platform
|
11
|
-
on:
|
12
|
-
tags: true
|
13
|
-
repo: mumuki/mumukit-platform
|