ipynbdiff 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/output_transformer.rb +6 -2
- data/lib/transformer.rb +4 -3
- 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: fbeaad80969c974720e75336301dc02822fbf183b278d8e5ddd5dd18c65ddde1
|
4
|
+
data.tar.gz: c186fa7fac873dff429cf3fd24c4a5cb61901670270850fd3d623c363db21182
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23e6a0c192d671fdcb394334a89d40eef9a58e39d934d1138e0ba37943c928d035d2f471e868b2af3d7f24a02f77d927b1e72d8cd3dd8df1f6ef9616796a8ab0
|
7
|
+
data.tar.gz: 9632766d4dd4e6e57775d59d7a14d01fb664156bd3c41b1af894481f4bf33f807b54ebad0f664184f606c37a6b8f818326e7238e320ba06135f192753c659f20
|
data/lib/output_transformer.rb
CHANGED
@@ -49,13 +49,17 @@ module IpynbDiff
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def transform_svg(image_content)
|
52
|
-
|
52
|
+
lines = image_content.is_a?(Array) ? image_content : [image_content]
|
53
|
+
|
54
|
+
single_line = lines.map(&:strip).join('').gsub(/\s+/, ' ')
|
53
55
|
|
54
56
|
[" ![](data:image/svg+xml;utf8,#{single_line})", "\n"]
|
55
57
|
end
|
56
58
|
|
57
59
|
def transform_text(text_content)
|
58
|
-
text_content.
|
60
|
+
lines = text_content.is_a?(Array) ? text_content : [text_content]
|
61
|
+
|
62
|
+
lines.map { |line| " #{line}" }.append("\n")
|
59
63
|
end
|
60
64
|
end
|
61
65
|
end
|
data/lib/transformer.rb
CHANGED
@@ -23,7 +23,7 @@ module IpynbDiff
|
|
23
23
|
def validate_notebook(notebook)
|
24
24
|
notebook_json = JSON.parse(notebook)
|
25
25
|
|
26
|
-
return notebook_json if notebook_json.key?('cells')
|
26
|
+
return notebook_json if notebook_json.key?('cells')
|
27
27
|
|
28
28
|
raise InvalidNotebookError
|
29
29
|
rescue JSON::ParserError
|
@@ -69,7 +69,7 @@ module IpynbDiff
|
|
69
69
|
|
70
70
|
def transform_code_cell(cell, notebook)
|
71
71
|
[
|
72
|
-
%(``` #{notebook
|
72
|
+
%(``` #{notebook.dig('metadata', 'kernelspec', 'language') || ''}\n),
|
73
73
|
*cell['source'],
|
74
74
|
"\n```\n",
|
75
75
|
*cell['outputs'].map { |output| transform_output(output) }
|
@@ -83,7 +83,8 @@ module IpynbDiff
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def transform_text_cell(cell)
|
86
|
-
cell['source']
|
86
|
+
source = cell['source']
|
87
|
+
(source.is_a?(Array) ? source : [source]).append("\n")
|
87
88
|
end
|
88
89
|
|
89
90
|
def transform_metadata(notebook_json)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ipynbdiff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Bonet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diffy
|