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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24615c877db39efeb4b4d0effe014db5a7734f6be88385aaf73bc00622075ca8
4
- data.tar.gz: 2aca335aa15c5e413eaa23d197f3f9a0f73d6415adbafcb419cf7764eb983e89
3
+ metadata.gz: fbeaad80969c974720e75336301dc02822fbf183b278d8e5ddd5dd18c65ddde1
4
+ data.tar.gz: c186fa7fac873dff429cf3fd24c4a5cb61901670270850fd3d623c363db21182
5
5
  SHA512:
6
- metadata.gz: 280688c5f5f722cea1868963dcf49eefdb3c35374fad96522d7f8b8a7c77b902d11db1b2b5dd1cde3370065159cee4f1c1f252b1a15f585c589abdc9ede02e1f
7
- data.tar.gz: 50de3ac58248b4af0e67d2e68a476a3c8395753a47638c7ca2015d7c909d55031f605f5334be54d909fd40e5728912623909b7fc3f73f8544b0828dd1e9e6a1a
6
+ metadata.gz: 23e6a0c192d671fdcb394334a89d40eef9a58e39d934d1138e0ba37943c928d035d2f471e868b2af3d7f24a02f77d927b1e72d8cd3dd8df1f6ef9616796a8ab0
7
+ data.tar.gz: 9632766d4dd4e6e57775d59d7a14d01fb664156bd3c41b1af894481f4bf33f807b54ebad0f664184f606c37a6b8f818326e7238e320ba06135f192753c659f20
@@ -49,13 +49,17 @@ module IpynbDiff
49
49
  end
50
50
 
51
51
  def transform_svg(image_content)
52
- single_line = image_content.map(&:strip).join('').gsub(/\s+/, ' ')
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.map { |line| " #{line}" }.append("\n")
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') && notebook_json.key?('metadata')
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['metadata']['kernelspec']['language']}\n),
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'].append("\n")
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.7
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-04 00:00:00.000000000 Z
11
+ date: 2021-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diffy