mumuki-domain 7.0.2 → 7.0.3

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: 3d28ad86997ca94c1d5a301bb2ffb5729a1ea8b7d345a701668dc6bb76a3b9d4
4
- data.tar.gz: 951bef6f687690e25ceb89fedfb34c23f2dfee1fa0c649a04a36c1dcd7b47e44
3
+ metadata.gz: 110d08769d6933a1f24050a84a55cfbd52635f6f51c6a0bd0c100b5278048bac
4
+ data.tar.gz: 72080c8736a0b180bf1a00b1299a357ab49b889084cdac6038967d32e44f750f
5
5
  SHA512:
6
- metadata.gz: 5f709598d00fed3cdaf355123f16b80dc192cb484c6a2860e1b402ecef517ccad5d6a846783a4b2af2de5c07d4336fb7526f68e8084a7a6224df02b711aeaa60
7
- data.tar.gz: a0dc2166520edb45ff6ef2cc6907c01818ffca73cfdb16518dda08d19e46eb3b98ab01a3d5ab054b5265c25ea447a99e3690c6cebdbdf923be0c5798dc644af8
6
+ metadata.gz: 78522ae785959966a37a4ccb091253a0652cbd0da35108a11cbdb1d2a9ae7f4af6750d32749aa429d736d5057ad6233045119cc0ac7a2f19c1480b3fbd8df0f8
7
+ data.tar.gz: 89d0b2c8e21b779d1ffb46c6623cb7e91e7abd8a1b57c711d33043ef9748a0b1b8cf29c844f5414c88b479ce3e4b6a075617fa0c20c11c552a55b0fbd57ef4fa
@@ -8,11 +8,11 @@ class Content < ApplicationRecord
8
8
  include WithUsages
9
9
  include WithName
10
10
 
11
- def to_resource_h
12
- to_expanded_resource_h.compact
11
+ def to_resource_h(*args)
12
+ to_expanded_resource_h(*args).compact
13
13
  end
14
14
 
15
- def to_expanded_resource_h
15
+ def to_expanded_resource_h(*)
16
16
  as_json(only: [:name, :slug, :description, :locale]).symbolize_keys
17
17
  end
18
18
 
@@ -115,13 +115,13 @@ class Exercise < ApplicationRecord
115
115
  choice_values.index(value)
116
116
  end
117
117
 
118
- def to_resource_h
119
- to_expanded_resource_h.compact
118
+ def to_resource_h(*args)
119
+ to_expanded_resource_h(*args).compact
120
120
  end
121
121
 
122
122
  # Keep this list up to date with
123
- # Mumuki::Domain::Store::ExerciseSchema
124
- def to_expanded_resource_h
123
+ # Mumuki::Domain::Store::Github::ExerciseSchema
124
+ def to_expanded_resource_h(options={})
125
125
  language_resource_h = language.to_embedded_resource_h if language != guide.language
126
126
  as_json(only: BASIC_RESOURCE_FIELDS)
127
127
  .merge(id: bibliotheca_id, language: language_resource_h, type: type.underscore)
@@ -130,6 +130,7 @@ class Exercise < ApplicationRecord
130
130
  .merge(settings: self[:settings])
131
131
  .merge(RANDOMIZED_FIELDS.map { |it| [it, self[it]] }.to_h)
132
132
  .symbolize_keys
133
+ .tap { |it| it.markdownify!(:hint, :corollary, :description, :teacher_info) if options[:markdownified] }
133
134
  end
134
135
 
135
136
  def reset!
@@ -93,23 +93,17 @@ class Guide < Content
93
93
 
94
94
  # Keep this list up to date with
95
95
  # Mumuki::Domain::Store::Github::GuideSchema
96
- def to_expanded_resource_h
96
+ def to_expanded_resource_h(options={})
97
97
  as_json(only: BASIC_RESOURCE_FIELDS)
98
98
  .symbolize_keys
99
99
  .merge(super)
100
- .merge(exercises: exercises.map(&:to_resource_h))
100
+ .merge(exercises: exercises.map { |it| it.to_resource_h(options) })
101
101
  .merge(language: language.to_embedded_resource_h)
102
+ .tap { |it| it.markdownify!(:corollary, :description, :teacher_info) if options[:markdownified] }
102
103
  end
103
104
 
104
105
  def to_markdownified_resource_h
105
- to_resource_h.tap do |guide|
106
- %i(corollary description teacher_info).each do |it|
107
- guide[it] = Mumukit::ContentType::Markdown.to_html(guide[it])
108
- end
109
- %i(hint corollary description teacher_info).each do |it|
110
- guide[:exercises].each { |exercise| exercise[it] = Mumukit::ContentType::Markdown.to_html(exercise[it]) }
111
- end
112
- end
106
+ to_resource_h(markdownified: true)
113
107
  end
114
108
 
115
109
  def as_lesson_of(topic)
@@ -50,7 +50,7 @@ end
50
50
 
51
51
  Mumukit::Sync::Store::Github.configure do |config|
52
52
  config.guide_schema = Mumuki::Domain::Store::Github::GuideSchema
53
- config.exercise_schema = Mumuki::Domain::Store::Thesaurus
53
+ config.exercise_schema = Mumuki::Domain::Store::Github::ExerciseSchema
54
54
  end
55
55
 
56
56
  Mulang::Inspection.register_extension! Mumukit::Inspection::Css
@@ -1,3 +1,4 @@
1
1
  require_relative './extensions/string'
2
2
  require_relative './extensions/array'
3
3
  require_relative './extensions/module'
4
+ require_relative './extensions/hash'
@@ -0,0 +1,5 @@
1
+ class Hash
2
+ def markdownify!(*keys)
3
+ keys.each { |it| self[it] = Mumukit::ContentType::Markdown.to_html(self[it]) }
4
+ end
5
+ end
@@ -15,15 +15,19 @@ module Mumuki::Domain::Seed
15
15
  flbulgarelli
16
16
  )
17
17
 
18
+ def self.contents_syncer
19
+ Mumukit::Sync::Syncer.new(Mumuki::Domain::Store::Bibliotheca.new(Mumukit::Platform.bibliotheca_bridge))
20
+ end
21
+
22
+ def self.languages_syncer
23
+ Mumukit::Sync::Syncer.new(Mumuki::Domain::Store::Thesaurus.new(Mumukit::Platform.thesaurus_bridge))
24
+ end
25
+
18
26
  def self.import_main_contents!
19
- Mumukit::Sync::Syncer.new(
20
- Mumuki::Domain::Store::Bibliotheca.new(
21
- Mumukit::Platform.bibliotheca_bridge)).import_all! /^#{MAIN_CONTENT_ORGANIZATIONS.join('|')}\/.*$/i
27
+ self.contents_syncer.import_all! /^#{MAIN_CONTENT_ORGANIZATIONS.join('|')}\/.*$/i
22
28
  end
23
29
 
24
30
  def self.import_languages!
25
- Mumukit::Sync::Syncer.new(
26
- Mumuki::Domain::Store::Thesaurus.new(
27
- Mumukit::Platform.thesaurus_bridge)).import_all!
31
+ self.languages_syncer.import_all!
28
32
  end
29
33
  end
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Domain
3
- VERSION = '7.0.2'
3
+ VERSION = '7.0.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumuki-domain
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.2
4
+ version: 7.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Leonardo Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-21 00:00:00.000000000 Z
11
+ date: 2019-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.1'
47
+ version: '0.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.1'
54
+ version: '0.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: mumukit-bridge
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -600,6 +600,7 @@ files:
600
600
  - lib/mumuki/domain/exceptions/unauthorized_error.rb
601
601
  - lib/mumuki/domain/extensions.rb
602
602
  - lib/mumuki/domain/extensions/array.rb
603
+ - lib/mumuki/domain/extensions/hash.rb
603
604
  - lib/mumuki/domain/extensions/module.rb
604
605
  - lib/mumuki/domain/extensions/string.rb
605
606
  - lib/mumuki/domain/factories.rb