mumukit-platform 5.0.0 → 6.1.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: a1e1ce06ac9d7055da2a3f86b3a865630a7788e182e0c021485c9b2b638df543
4
- data.tar.gz: d1ab26c3c29648fea155c0aef57315b57e1405efab03b44fadfa2f8e06c0724c
3
+ metadata.gz: 1aa8d319e6390b781d8da0e7d33f720cf6b093c0d43ba432ca27666da514191d
4
+ data.tar.gz: d124ebd5601c68dcdb97a51de9a0a42319a3f0d83a92a88ab1aa2b8198d8d514
5
5
  SHA512:
6
- metadata.gz: 74adaec00a74e0774e0136b6295462a0f47d26380b915cdef19e04a1a7458de90987a599c25c6843362d21bd1626819e5fcfaed6b23d21e9f0b109d4eae77dac
7
- data.tar.gz: d40805aa710719fef5c0a78a306787946f312e8d685ed927501696045e1754a3a6f56c855ec3d8f8e9fe02c1a92fd1bf9b8661a00b373576a22ccd0bba65d7b5
6
+ metadata.gz: 97fd564e02205ec571c81b12560fa1939dd03bd5cd651ecd17b09c670602ca4a06e8564ee171f6042219fd8f5327974988155611a85c6791b447a3d4536a81d4
7
+ data.tar.gz: 99c5f0bed18cad1bb402e47371a16ab9b4e9e641471ffaa8414901b55702771df1239f47ab809b0b0333caa40b5e6b071e118301e9e15f67b49a0a3b7e1444fe
@@ -2,7 +2,7 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.6.3
5
- before_install: gem install bundler -v 1.14.2
5
+ before_install: gem install bundler -v 2.0.2
6
6
  deploy:
7
7
  provider: rubygems
8
8
  api_key:
data/README.md CHANGED
@@ -33,7 +33,6 @@ In order to properly use this gem, you must declare _organization_, _course_ and
33
33
  * `.find_by_name!`
34
34
 
35
35
  _user_:
36
- * `.for_profile`
37
36
  * `.find_by_uid!`
38
37
 
39
38
  _course_:
@@ -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'
@@ -53,4 +53,4 @@ class Mumukit::Platform::Application
53
53
  organization_mapping.organic_uri(uri, organization)
54
54
  end
55
55
  end
56
- end
56
+ end
@@ -1,5 +1,11 @@
1
1
  module Mumukit::Platform::Course
2
+ extend Mumukit::Platform::Global
3
+
2
4
  def self.find_by_slug!(slug)
3
5
  Mumukit::Platform.course_class.find_by_slug!(slug)
4
6
  end
7
+
8
+ def self.__global_thread_variable_key__
9
+ :course
10
+ end
5
11
  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
- def self.switch!(organization)
3
- raise 'Organization must not be nil' unless organization
4
- Thread.current[:organization] = organization
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.leave!
8
- Thread.current[:organization] = nil
8
+ def self.find_by_name!(name)
9
+ Mumukit::Platform.organization_class.find_by_name!(name)
9
10
  end
10
11
 
11
- def self.current
12
- Thread.current[:organization] || raise('organization not selected')
12
+ def self.__global_thread_variable_key__
13
+ :organization
13
14
  end
14
15
 
15
- def self.current?
16
- !!Thread.current[:organization]
16
+ ## Name validation
17
+
18
+ def self.valid_name?(name)
19
+ !!(name =~ anchored_valid_name_regex)
17
20
  end
18
21
 
19
- def self.current_locale
20
- Thread.current[:organization]&.locale || 'en'
22
+ def self.anchored_valid_name_regex
23
+ /\A#{valid_name_regex}\z/
21
24
  end
22
25
 
23
- def self.find_by_name!(name)
24
- Mumukit::Platform.organization_class.find_by_name!(name)
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.path.split('/')[1]
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.subroute(organization)
82
+ uri.tenantize organization
58
83
  end
59
84
 
60
85
  def self.path_under_namespace?(organization_name, path, namespace)
@@ -8,11 +8,11 @@ class URI::HTTP
8
8
  rebuild(host: new_host)
9
9
  end
10
10
 
11
- def subroute(route)
12
- if path.start_with? '/'
13
- new_path = "/#{route}#{path}"
11
+ def tenantize(route)
12
+ if path.end_with? '/'
13
+ new_path = "#{path}#{route}/"
14
14
  else
15
- new_path = "/#{route}/#{path}"
15
+ new_path = "#{path}/#{route}/"
16
16
  end
17
17
  rebuild(path: new_path)
18
18
  end
@@ -1,5 +1,5 @@
1
1
  module Mumukit
2
2
  module Platform
3
- VERSION = '5.0.0'
3
+ VERSION = '6.1.0'
4
4
  end
5
5
  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::Helpers.valid_name_regex }
24
+ constraints: { tenant: Mumukit::Platform::Organization.valid_name_regex }
25
25
  }
26
26
  end
27
27
  end
@@ -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', '~> 3.5'
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', '~> 1.14'
31
- spec.add_development_dependency 'rake', '~> 10.0'
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: 5.0.0
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: 2019-07-04 00:00:00.000000000 Z
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: '1.14'
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: '1.14'
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: '10.0'
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: '10.0'
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.4
188
+ rubygems_version: 3.0.8
182
189
  signing_key:
183
190
  specification_version: 4
184
191
  summary: Shared Mumuki Platform Components