mumukit-sync 0.3.5 → 0.4.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.rb +3 -0
- data/lib/mumukit/sync/store.rb +7 -0
- data/lib/mumukit/sync/store/bibliotheca.rb +1 -1
- data/lib/mumukit/sync/store/github.rb +1 -1
- data/lib/mumukit/sync/store/github/bot.rb +2 -2
- data/lib/mumukit/sync/store/github/guide_builder.rb +2 -0
- data/lib/mumukit/sync/store/github/guide_export.rb +1 -1
- data/lib/mumukit/sync/store/github/guide_reader.rb +13 -6
- data/lib/mumukit/sync/store/github/schema.rb +15 -4
- data/lib/mumukit/sync/store/github/schema/guide.rb +7 -1
- data/lib/mumukit/sync/store/json.rb +2 -2
- data/lib/mumukit/sync/store/null.rb +1 -1
- data/lib/mumukit/sync/store/thesaurus.rb +1 -1
- data/lib/mumukit/sync/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7feb07d1901e4d169f61f50b7d9d5e5b002ef659d7315fd78f06ca5506886e0a
|
4
|
+
data.tar.gz: dc32e9012638c59634d1e509ae95259e03353fc3301feaf94f3adc9effd29dd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e12bc3c131aaa6f6aa623613daa615490b56d93b52c6a952eee900a91f6f30f65736e0c0d62a05e1da6d0169b40f6c6d8f2cf2fd368eec9fad6760029b4e9d8
|
7
|
+
data.tar.gz: 1bd94411302041cb9fa4c303a7ed7adfa58e67a7c5ef4d0d9d6a706c21b2e4c94112e8d94891c9606c4b5a1555bd3c617cafd677506362e8d7212582c315cbf5
|
data/lib/mumukit/sync.rb
CHANGED
data/lib/mumukit/sync/store.rb
CHANGED
@@ -2,6 +2,13 @@ require 'mumukit/bridge'
|
|
2
2
|
|
3
3
|
module Mumukit::Sync
|
4
4
|
module Store
|
5
|
+
def self.non_discoverable!
|
6
|
+
raise Mumukit::Sync::SyncError, 'Non-discoverable store'
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.read_only!
|
10
|
+
raise Mumukit::Sync::SyncError, 'Read-only store'
|
11
|
+
end
|
5
12
|
end
|
6
13
|
end
|
7
14
|
|
@@ -19,8 +19,8 @@ class Mumukit::Sync::Store::Github
|
|
19
19
|
local_repo.config('user.email', email)
|
20
20
|
yield dir, local_repo
|
21
21
|
rescue Git::GitExecuteError => e
|
22
|
-
raise 'Repository is private or does not exist' if private_repo_error(e.message)
|
23
|
-
raise e
|
22
|
+
raise Mumukit::Sync::SyncError, 'Repository is private or does not exist' if private_repo_error(e.message)
|
23
|
+
raise Mumukit::Sync::SyncError, e
|
24
24
|
end
|
25
25
|
|
26
26
|
def register_post_commit_hook!(slug, web_hook_base_url)
|
@@ -39,7 +39,7 @@ class Mumukit::Sync::Store::Github
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def clear_repo(local_repo)
|
42
|
-
local_repo.remove
|
42
|
+
local_repo.remove Mumukit::Sync::Store::Github::Schema::Guide.file_patterns
|
43
43
|
rescue Git::GitExecuteError => e
|
44
44
|
puts 'Nothing to clean, repo seems to be empty'
|
45
45
|
end
|
@@ -12,9 +12,9 @@ class Mumukit::Sync::Store::Github
|
|
12
12
|
def read_guide!
|
13
13
|
builder = GuideBuilder.new(@slug)
|
14
14
|
|
15
|
-
|
15
|
+
read_guide_meta! builder
|
16
16
|
Mumukit::Sync::Store::Github::Schema::Guide.file_fields.each do |it|
|
17
|
-
value = it.read_field_file
|
17
|
+
value = it.read_field_file 'guide', dir
|
18
18
|
builder[it.reverse_name] = value
|
19
19
|
end
|
20
20
|
read_exercises! builder
|
@@ -22,10 +22,17 @@ class Mumukit::Sync::Store::Github
|
|
22
22
|
builder.build
|
23
23
|
end
|
24
24
|
|
25
|
-
def read_meta!(
|
25
|
+
def read_meta!(description, dir)
|
26
26
|
meta = read_yaml_file(File.join(dir, 'meta.yml'))
|
27
|
+
raise Mumukit::Sync::SyncError, "Missing #{description} meta.yml" unless meta
|
27
28
|
|
28
|
-
|
29
|
+
meta
|
30
|
+
rescue Psych::SyntaxError
|
31
|
+
raise Mumukit::Sync::SyncError, "Bad #{description} metadata syntax"
|
32
|
+
end
|
33
|
+
|
34
|
+
def read_guide_meta!(builder)
|
35
|
+
meta = read_meta! 'guide', dir
|
29
36
|
|
30
37
|
builder.language = { name: meta['language'] }
|
31
38
|
builder.locale = meta['locale']
|
@@ -60,7 +67,7 @@ class Mumukit::Sync::Store::Github
|
|
60
67
|
each_exercise_file do |root, position, id, name|
|
61
68
|
builder = ExerciseBuilder.new
|
62
69
|
|
63
|
-
meta =
|
70
|
+
meta = read_meta! "exercise #{name}", root
|
64
71
|
meta['language'] &&= { name: meta['language'] }
|
65
72
|
|
66
73
|
builder.meta = meta
|
@@ -68,7 +75,7 @@ class Mumukit::Sync::Store::Github
|
|
68
75
|
builder.name = meta['name'] || name
|
69
76
|
|
70
77
|
Mumukit::Sync::Store::Github::Schema::Exercise.file_fields.each do |it|
|
71
|
-
value = it.read_field_file
|
78
|
+
value = it.read_field_file "exercise #{name}", root
|
72
79
|
builder[it.reverse_name] = value
|
73
80
|
end
|
74
81
|
yield builder
|
@@ -32,6 +32,14 @@ class Mumukit::Sync::Store::Github
|
|
32
32
|
fields.select { |it| it.kind == :file }
|
33
33
|
end
|
34
34
|
|
35
|
+
def file_patterns
|
36
|
+
file_fields.map(&:get_file_pattern) + fixed_file_patterns
|
37
|
+
end
|
38
|
+
|
39
|
+
def fixed_file_patterns
|
40
|
+
[]
|
41
|
+
end
|
42
|
+
|
35
43
|
def fields
|
36
44
|
@field ||= fields_schema.map { |it| new_field(it) }
|
37
45
|
end
|
@@ -74,6 +82,9 @@ class Mumukit::Sync::Store::Github
|
|
74
82
|
end
|
75
83
|
|
76
84
|
## Writing fields to Github
|
85
|
+
def get_file_pattern
|
86
|
+
get_file_name extension: '*', test_extension: '*'
|
87
|
+
end
|
77
88
|
|
78
89
|
def get_file_name(language)
|
79
90
|
"#{name}.#{get_file_extension(language)}"
|
@@ -100,19 +111,19 @@ class Mumukit::Sync::Store::Github
|
|
100
111
|
|
101
112
|
## Reading fields from Github
|
102
113
|
|
103
|
-
def find_file_name(root)
|
114
|
+
def find_file_name(description, root)
|
104
115
|
files = Dir.glob("#{root}/#{name}.*")
|
105
116
|
if files.length == 1
|
106
117
|
files[0]
|
107
118
|
elsif files.empty? && required
|
108
|
-
raise "Missing #{name} file"
|
119
|
+
raise Mumukit::Sync::SyncError, "Missing #{description} #{name} file"
|
109
120
|
else
|
110
121
|
nil
|
111
122
|
end
|
112
123
|
end
|
113
124
|
|
114
|
-
def read_field_file(root)
|
115
|
-
find_file_name(root).try { |it| safe_transform.from.call it }
|
125
|
+
def read_field_file(description, root)
|
126
|
+
find_file_name(description, root).try { |it| safe_transform.from.call it }
|
116
127
|
end
|
117
128
|
|
118
129
|
end
|
@@ -16,13 +16,19 @@ module Mumukit::Sync::Store::Github::Schema::Guide
|
|
16
16
|
{name: :id_format, kind: :metadata},
|
17
17
|
{name: :order, kind: :metadata, transform: with { |it| it.map { |e| e[:id] } }, reverse: :exercises},
|
18
18
|
{name: :private, kind: :metadata},
|
19
|
-
{name: :expectations},
|
20
19
|
|
20
|
+
{name: :expectations, kind: :file, extension: 'yml', transform: yaml_list('expectations')},
|
21
21
|
{name: :description, kind: :file, extension: 'md', required: true},
|
22
22
|
{name: :corollary, kind: :file, extension: 'md'},
|
23
|
+
{name: :sources, kind: :file, extension: 'md'},
|
24
|
+
{name: :learn_more, kind: :file, extension: 'md'},
|
23
25
|
{name: :extra, kind: :file, extension: :code},
|
24
26
|
{name: :AUTHORS, kind: :file, extension: 'txt', reverse: :authors},
|
25
27
|
{name: :COLLABORATORS, kind: :file, extension: 'txt', reverse: :collaborators}
|
26
28
|
]
|
27
29
|
end
|
30
|
+
|
31
|
+
def self.fixed_file_patterns
|
32
|
+
%w(LICENSE.txt README.md COPYRIGHT.txt meta.yml *_*/*)
|
33
|
+
end
|
28
34
|
end
|
@@ -5,7 +5,7 @@ module Mumukit::Sync::Store
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def sync_keys
|
8
|
-
|
8
|
+
Mumukit::Sync::Store.non_discoverable!
|
9
9
|
end
|
10
10
|
|
11
11
|
def do_read(_sync_key)
|
@@ -13,7 +13,7 @@ module Mumukit::Sync::Store
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def write_resource!(*)
|
16
|
-
|
16
|
+
Mumukit::Sync::Store.read_only!
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/mumukit/sync/version.rb
CHANGED
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.4.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: 2019-01-
|
11
|
+
date: 2019-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mumukit-core
|