mumukit-sync 0.2.1 → 0.3.0
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/inflator/exercise.rb +1 -1
- data/lib/mumukit/sync/store/base.rb +4 -4
- data/lib/mumukit/sync/store/bibliotheca.rb +1 -1
- data/lib/mumukit/sync/store/github.rb +2 -2
- data/lib/mumukit/sync/store/thesaurus.rb +1 -1
- data/lib/mumukit/sync/store/with_filtered_id.rb +5 -0
- data/lib/mumukit/sync/store/with_wrapped_language.rb +2 -2
- data/lib/mumukit/sync/store.rb +1 -1
- data/lib/mumukit/sync/syncer.rb +1 -1
- data/lib/mumukit/sync/version.rb +1 -1
- data/lib/mumukit/sync.rb +7 -9
- data/mumukit-sync.gemspec +1 -1
- metadata +5 -5
- data/lib/mumukit/sync/store/with_id_filtering.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 292bb83cfe620088d9ee13efcc8a839aafc2337813de75f1d5cffb09c6e2cebb
|
4
|
+
data.tar.gz: 384b5cebfec6360b4af095963853016f8410cccfc6edff81d9477eada820c70c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 549c13c8f22fb061d9a229f8d7ae484eddc9e01c9dc22d2d6ac2f082da0143db4c0460f459fa91f4221b1c7849cc33cc2f3b385ed45dbdfa9cf5c3c6cd6558e2
|
7
|
+
data.tar.gz: 7feb1370691b2a0d0158d24d7e4586c3d360b93bf2960bc3720640403f7e83f4eefff84735be79c335f3a6674ddba13d702d9745b6c4094c4bc836a1b6c4be14
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Mumukit::Sync::Inflator
|
2
2
|
class Exercise
|
3
3
|
def inflate!(key, resource_h)
|
4
|
-
return unless key.kind
|
4
|
+
return unless key.kind.like? :guide
|
5
5
|
resource_h[:exercises]&.each do |it|
|
6
6
|
language = it.dig(:language, :name) || resource_h.dig(:language, :name)
|
7
7
|
inflate_exercise! it, language, resource_h
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Mumukit::Sync::Store::Base
|
2
2
|
def read_resource(sync_key)
|
3
|
-
|
3
|
+
transform_after_symbolize sync_key.kind, transform_before_symbolize(sync_key.kind, do_read(sync_key)).deep_symbolize_keys
|
4
4
|
end
|
5
5
|
|
6
6
|
private
|
@@ -8,11 +8,11 @@ class Mumukit::Sync::Store::Base
|
|
8
8
|
# We are assuming rails-like models, that can be whitelisted,
|
9
9
|
# and that resource-hashes resemble the model structure.
|
10
10
|
# The store must ensure that only valid hashes are read
|
11
|
-
def
|
12
|
-
|
11
|
+
def transform_before_symbolize(key, json)
|
12
|
+
key.as_module.whitelist_attributes(json, relations: true)
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def transform_after_symbolize(_key, json)
|
16
16
|
json
|
17
17
|
end
|
18
18
|
end
|
@@ -4,7 +4,7 @@ module Mumukit::Sync::Store
|
|
4
4
|
## from Bibliotheca API
|
5
5
|
class Bibliotheca < Mumukit::Sync::Store::Base
|
6
6
|
include Mumukit::Sync::Store::WithWrappedLanguage
|
7
|
-
include Mumukit::Sync::Store::
|
7
|
+
include Mumukit::Sync::Store::WithFilteredId
|
8
8
|
|
9
9
|
def initialize(bibliotheca_bridge)
|
10
10
|
@bibliotheca_bridge = bibliotheca_bridge
|
@@ -14,7 +14,7 @@ module Mumukit::Sync::Store
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def read_resource(sync_key)
|
17
|
-
return unless sync_key.kind
|
17
|
+
return unless sync_key.kind.like? :guide
|
18
18
|
|
19
19
|
Mumukit::Sync::Store::Github::GuideImport.new(
|
20
20
|
bot: @bot,
|
@@ -23,7 +23,7 @@ module Mumukit::Sync::Store
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def write_resource!(sync_key, resource_h)
|
26
|
-
return unless sync_key.kind
|
26
|
+
return unless sync_key.kind.like? :guide
|
27
27
|
|
28
28
|
Mumukit::Sync::Store::Github::GuideExport.new(
|
29
29
|
slug: sync_key.id,
|
@@ -12,7 +12,7 @@ module Mumukit::Sync::Store
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def do_read(sync_key)
|
15
|
-
return unless sync_key.kind
|
15
|
+
return unless sync_key.kind.like? :language
|
16
16
|
# the only difference between an `importable_info`
|
17
17
|
# and a `resource_h` is the way `runner_url` is named
|
18
18
|
Mumukit::Bridge::Runner.new(sync_key.id)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Mumukit::Sync::Store::WithWrappedLanguage
|
2
|
-
def
|
3
|
-
if key
|
2
|
+
def transform_after_symbolize(key, json)
|
3
|
+
if key.like? :guide
|
4
4
|
guide = json.dup
|
5
5
|
wrap_language! guide
|
6
6
|
guide[:exercises].each { |exercise| wrap_language! exercise }
|
data/lib/mumukit/sync/store.rb
CHANGED
@@ -12,5 +12,5 @@ require_relative './store/github'
|
|
12
12
|
require_relative './store/json'
|
13
13
|
require_relative './store/thesaurus'
|
14
14
|
require_relative './store/with_wrapped_language'
|
15
|
-
require_relative './store/
|
15
|
+
require_relative './store/with_filtered_id'
|
16
16
|
require_relative './store/bibliotheca'
|
data/lib/mumukit/sync/syncer.rb
CHANGED
@@ -12,7 +12,7 @@ module Mumukit::Sync
|
|
12
12
|
def initialize(store, inflators = [], resource_classifier = nil)
|
13
13
|
@store = store
|
14
14
|
@inflators = inflators
|
15
|
-
@resource_classifier ||= proc { |kind|
|
15
|
+
@resource_classifier ||= proc { |kind| kind.as_module }
|
16
16
|
end
|
17
17
|
|
18
18
|
def sync_keys_matching(id_regex = nil)
|
data/lib/mumukit/sync/version.rb
CHANGED
data/lib/mumukit/sync.rb
CHANGED
@@ -6,18 +6,16 @@ require "mumukit/sync/version"
|
|
6
6
|
|
7
7
|
module Mumukit
|
8
8
|
module Sync
|
9
|
-
|
9
|
+
|
10
|
+
# Creates a sync key, composed of a `kind` and `id`
|
11
|
+
#
|
12
|
+
# kind: string|symbol|class
|
13
|
+
# id: object
|
14
|
+
#
|
15
|
+
# Warning: in order to test the `kind`, always use the `like?` message
|
10
16
|
def self.key(kind, id)
|
11
17
|
struct kind: kind, id: id
|
12
18
|
end
|
13
|
-
|
14
|
-
def self.constantize(kind)
|
15
|
-
classify(kind).constantize
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.classify(kind)
|
19
|
-
kind.to_s.classify
|
20
|
-
end
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
data/mumukit-sync.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency 'mumukit-core', '~> 1.
|
24
|
+
spec.add_dependency 'mumukit-core', '~> 1.12'
|
25
25
|
spec.add_dependency 'mumukit-bridge', '~> 3.5'
|
26
26
|
spec.add_dependency 'mumukit-auth', '~> 7.0'
|
27
27
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumukit-sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franco Bulgarelli
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mumukit-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.12'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.12'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mumukit-bridge
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,7 +170,7 @@ files:
|
|
170
170
|
- lib/mumukit/sync/store/json.rb
|
171
171
|
- lib/mumukit/sync/store/null.rb
|
172
172
|
- lib/mumukit/sync/store/thesaurus.rb
|
173
|
-
- lib/mumukit/sync/store/
|
173
|
+
- lib/mumukit/sync/store/with_filtered_id.rb
|
174
174
|
- lib/mumukit/sync/store/with_wrapped_language.rb
|
175
175
|
- lib/mumukit/sync/syncer.rb
|
176
176
|
- lib/mumukit/sync/version.rb
|