mumukit-sync 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mumukit/sync/store.rb +2 -0
- data/lib/mumukit/sync/store/base.rb +15 -0
- data/lib/mumukit/sync/store/bibliotheca.rb +4 -2
- data/lib/mumukit/sync/store/json.rb +3 -11
- data/lib/mumukit/sync/store/thesaurus.rb +3 -2
- data/lib/mumukit/sync/store/with_wrapped_language.rb +16 -0
- data/lib/mumukit/sync/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7a1457a5247f650784ffc17df986bda74d269a00f12ab97e0061a263b91d4a6
|
4
|
+
data.tar.gz: 13727e5936569ed91bed1f94aaeb3eb70d4abd9ffc33a3ff44b57f5e67c91bf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fffc5c4909b2c879054ee8e758f014e1aa20540b3442629c9bf84e719fb3261a914d20282125333b4697ec4d120175cb26e931e525e795b06030b944e6a9800d
|
7
|
+
data.tar.gz: 8252258f93539ab08f53a85cd7e2624e524950e2b20394871a5be6ba840f50a6704c1bc6e72b7a33e033205775be5f25a06832b69b9a28c2ebb837754af94562
|
data/lib/mumukit/sync/store.rb
CHANGED
@@ -6,7 +6,9 @@ module Mumukit::Sync
|
|
6
6
|
end
|
7
7
|
|
8
8
|
|
9
|
+
require_relative './store/base'
|
9
10
|
require_relative './store/github'
|
10
11
|
require_relative './store/json'
|
11
12
|
require_relative './store/thesaurus'
|
13
|
+
require_relative './store/with_wrapped_language'
|
12
14
|
require_relative './store/bibliotheca'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Mumukit::Sync::Store::Base
|
2
|
+
def read_resource(sync_key)
|
3
|
+
post_transform sync_key.kind, pre_transform(sync_key.kind, do_read(sync_key)).deep_symbolize_keys
|
4
|
+
end
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def pre_transform(key, json)
|
9
|
+
Mumukit::Sync.constantize(key).whitelist_attributes(json, relations: true)
|
10
|
+
end
|
11
|
+
|
12
|
+
def post_transform(_key, json)
|
13
|
+
json
|
14
|
+
end
|
15
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Mumukit::Sync::Store
|
2
|
-
class Bibliotheca
|
2
|
+
class Bibliotheca < Mumukit::Sync::Store::Base
|
3
|
+
include Mumukit::Sync::Store::WithWrappedLanguage
|
4
|
+
|
3
5
|
def initialize(bibliotheca_bridge)
|
4
6
|
@bibliotheca_bridge = bibliotheca_bridge
|
5
7
|
end
|
@@ -12,7 +14,7 @@ module Mumukit::Sync::Store
|
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
15
|
-
def
|
17
|
+
def do_read(sync_key)
|
16
18
|
@bibliotheca_bridge.send(sync_key.kind, sync_key.id)
|
17
19
|
end
|
18
20
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Mumukit::Sync::Store
|
2
|
-
class Json
|
2
|
+
class Json < Mumukit::Sync::Store::Base
|
3
3
|
def initialize(json)
|
4
4
|
@json = json
|
5
5
|
end
|
@@ -8,20 +8,12 @@ module Mumukit::Sync::Store
|
|
8
8
|
raise 'Non-discoverable store'
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def do_read(_sync_key)
|
12
|
+
@json
|
13
13
|
end
|
14
14
|
|
15
15
|
def write_resource!(*)
|
16
16
|
raise 'Read-only store'
|
17
17
|
end
|
18
|
-
|
19
|
-
def pre_transform(kind, json)
|
20
|
-
json
|
21
|
-
end
|
22
|
-
|
23
|
-
def post_transform(kind, json)
|
24
|
-
json
|
25
|
-
end
|
26
18
|
end
|
27
19
|
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
module Mumukit::Sync::Store
|
2
|
-
class Thesaurus
|
2
|
+
class Thesaurus < Mumukit::Sync::Store::Base
|
3
3
|
def initialize(thesaurus_bridge)
|
4
4
|
@thesaurus_bridge = thesaurus_bridge
|
5
5
|
end
|
6
|
+
|
6
7
|
def sync_keys
|
7
8
|
@thesaurus_bridge.runners.map { |it| Mumukit::Sync.key(:language, it) }
|
8
9
|
end
|
9
10
|
|
10
|
-
def
|
11
|
+
def do_read(sync_key)
|
11
12
|
return unless sync_key.kind == :language
|
12
13
|
Mumukit::Bridge::Runner.new(runner_url).importable_info
|
13
14
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Mumukit::Sync::Store::WithWrappedLanguage
|
2
|
+
def post_transform(key, json)
|
3
|
+
if key == :guide
|
4
|
+
guide = json.dup
|
5
|
+
wrap_language! guide
|
6
|
+
guide[:exercises].each { |exercise| wrap_language! exercise }
|
7
|
+
guide
|
8
|
+
else
|
9
|
+
json
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def wrap_language!(hash)
|
14
|
+
hash[:language] &&= { name: hash[:language] }
|
15
|
+
end
|
16
|
+
end
|
data/lib/mumukit/sync/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumukit-sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franco Bulgarelli
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- lib/mumukit/sync/inflator/multiple_choice.rb
|
148
148
|
- lib/mumukit/sync/inflator/single_choice.rb
|
149
149
|
- lib/mumukit/sync/store.rb
|
150
|
+
- lib/mumukit/sync/store/base.rb
|
150
151
|
- lib/mumukit/sync/store/bibliotheca.rb
|
151
152
|
- lib/mumukit/sync/store/github.rb
|
152
153
|
- lib/mumukit/sync/store/github/bot.rb
|
@@ -168,6 +169,7 @@ files:
|
|
168
169
|
- lib/mumukit/sync/store/github/with_file_reading.rb
|
169
170
|
- lib/mumukit/sync/store/json.rb
|
170
171
|
- lib/mumukit/sync/store/thesaurus.rb
|
172
|
+
- lib/mumukit/sync/store/with_wrapped_language.rb
|
171
173
|
- lib/mumukit/sync/syncer.rb
|
172
174
|
- lib/mumukit/sync/version.rb
|
173
175
|
- mumukit-sync.gemspec
|