mumukit-platform 5.0.0 → 6.1.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/.travis.yml +1 -1
- data/README.md +0 -1
- data/lib/mumukit/platform.rb +1 -1
- data/lib/mumukit/platform/application.rb +1 -1
- 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 +27 -2
- data/lib/mumukit/platform/uri.rb +4 -4
- data/lib/mumukit/platform/version.rb +1 -1
- data/lib/mumukit/platform/web_framework.rb +1 -1
- data/mumukit-platform.gemspec +3 -3
- metadata +16 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1aa8d319e6390b781d8da0e7d33f720cf6b093c0d43ba432ca27666da514191d
|
4
|
+
data.tar.gz: d124ebd5601c68dcdb97a51de9a0a42319a3f0d83a92a88ab1aa2b8198d8d514
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97fd564e02205ec571c81b12560fa1939dd03bd5cd651ecd17b09c670602ca4a06e8564ee171f6042219fd8f5327974988155611a85c6791b447a3d4536a81d4
|
7
|
+
data.tar.gz: 99c5f0bed18cad1bb402e47371a16ab9b4e9e641471ffaa8414901b55702771df1239f47ab809b0b0333caa40b5e6b071e118301e9e15f67b49a0a3b7e1444fe
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
data/lib/mumukit/platform.rb
CHANGED
@@ -34,7 +34,6 @@ module Mumukit::Platform
|
|
34
34
|
# * `.find_by_name!`
|
35
35
|
#
|
36
36
|
# _user_:
|
37
|
-
# * `.for_profile`
|
38
37
|
# * `.find_by_uid!`
|
39
38
|
#
|
40
39
|
# _course_:
|
@@ -52,6 +51,7 @@ end
|
|
52
51
|
|
53
52
|
require_relative './platform/notifiable'
|
54
53
|
|
54
|
+
require_relative './platform/global'
|
55
55
|
require_relative './platform/domain'
|
56
56
|
require_relative './platform/model'
|
57
57
|
require_relative './platform/locale'
|
@@ -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
|
@@ -38,9 +48,15 @@ module Mumukit::Platform::OrganizationMapping
|
|
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
|
58
83
|
end
|
59
84
|
|
60
85
|
def self.path_under_namespace?(organization_name, path, namespace)
|
data/lib/mumukit/platform/uri.rb
CHANGED
@@ -8,11 +8,11 @@ class URI::HTTP
|
|
8
8
|
rebuild(host: new_host)
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
if path.
|
13
|
-
new_path = "
|
11
|
+
def tenantize(route)
|
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
17
|
rebuild(path: new_path)
|
18
18
|
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
@@ -24,10 +24,10 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency 'mumukit-nuntius', '~> 6.0'
|
25
25
|
spec.add_dependency 'mumukit-core', '~> 1.2'
|
26
26
|
spec.add_dependency 'mumukit-auth', '~> 7.6'
|
27
|
-
spec.add_dependency 'mumukit-bridge', '
|
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'
|
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: 6.1.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: 2020-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mumukit-nuntius
|
@@ -56,16 +56,22 @@ dependencies:
|
|
56
56
|
name: mumukit-bridge
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.5'
|
62
|
+
- - "<"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '5'
|
62
65
|
type: :runtime
|
63
66
|
prerelease: false
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
65
68
|
requirements:
|
66
|
-
- - "
|
69
|
+
- - ">="
|
67
70
|
- !ruby/object:Gem::Version
|
68
71
|
version: '3.5'
|
72
|
+
- - "<"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '5'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: activemodel
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,28 +92,28 @@ dependencies:
|
|
86
92
|
requirements:
|
87
93
|
- - "~>"
|
88
94
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
95
|
+
version: '2.0'
|
90
96
|
type: :development
|
91
97
|
prerelease: false
|
92
98
|
version_requirements: !ruby/object:Gem::Requirement
|
93
99
|
requirements:
|
94
100
|
- - "~>"
|
95
101
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
102
|
+
version: '2.0'
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: rake
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
100
106
|
requirements:
|
101
107
|
- - "~>"
|
102
108
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
109
|
+
version: '12.3'
|
104
110
|
type: :development
|
105
111
|
prerelease: false
|
106
112
|
version_requirements: !ruby/object:Gem::Requirement
|
107
113
|
requirements:
|
108
114
|
- - "~>"
|
109
115
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
116
|
+
version: '12.3'
|
111
117
|
- !ruby/object:Gem::Dependency
|
112
118
|
name: rspec
|
113
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,6 +151,7 @@ files:
|
|
145
151
|
- lib/mumukit/platform/bridge.rb
|
146
152
|
- lib/mumukit/platform/course.rb
|
147
153
|
- lib/mumukit/platform/domain.rb
|
154
|
+
- lib/mumukit/platform/global.rb
|
148
155
|
- lib/mumukit/platform/locale.rb
|
149
156
|
- lib/mumukit/platform/model.rb
|
150
157
|
- lib/mumukit/platform/notifiable.rb
|
@@ -178,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
185
|
- !ruby/object:Gem::Version
|
179
186
|
version: '0'
|
180
187
|
requirements: []
|
181
|
-
rubygems_version: 3.0.
|
188
|
+
rubygems_version: 3.0.8
|
182
189
|
signing_key:
|
183
190
|
specification_version: 4
|
184
191
|
summary: Shared Mumuki Platform Components
|