ipynbdiff 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ipynb_symbol_map.rb +55 -11
- data/lib/transformer.rb +1 -0
- data/lib/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: ef1021a6b462ff49958069aea089dabfacd7ded6858bfc49c581dfcc03330405
|
4
|
+
data.tar.gz: 93ecedada6270a3f217349ef073b8f52950793e2f2197d2a0ca3254a5c2acd02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29cedcb6c846d5d320425e9edf0f5f1a30bbbcdbcfaeb648b6568a6c884d60120c40926a8b30632eeff7d5892654c8b0ebe0433e9a8f03d14d2b8e6ad407ce4d
|
7
|
+
data.tar.gz: 85b7b9e9b3390f1484426bdb75143aebbf1f7bd2083b0c939df7d4e1e83a43f9346231c25f925ef9187ce54612ab7d202327f197c0cdb8916457913d226c9807
|
data/lib/ipynb_symbol_map.rb
CHANGED
@@ -7,8 +7,8 @@ module IpynbDiff
|
|
7
7
|
# Creates a symbol map for a ipynb file (JSON format)
|
8
8
|
class IpynbSymbolMap
|
9
9
|
class << self
|
10
|
-
def parse(notebook)
|
11
|
-
IpynbSymbolMap.new(notebook).parse('')
|
10
|
+
def parse(notebook, objects_to_ignore = [])
|
11
|
+
IpynbSymbolMap.new(notebook, objects_to_ignore).parse('')
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -18,11 +18,12 @@ module IpynbDiff
|
|
18
18
|
|
19
19
|
VALUE_STOPPERS = [',', '[', ']', '{', '}', *WHITESPACE_CHARS].freeze
|
20
20
|
|
21
|
-
def initialize(notebook)
|
21
|
+
def initialize(notebook, objects_to_ignore = [])
|
22
22
|
@chars = notebook.chars
|
23
23
|
@current_line = 0
|
24
24
|
@char_idx = 0
|
25
25
|
@results = {}
|
26
|
+
@objects_to_ignore = objects_to_ignore
|
26
27
|
end
|
27
28
|
|
28
29
|
def parse(prefix = '.')
|
@@ -69,11 +70,7 @@ module IpynbDiff
|
|
69
70
|
loop do
|
70
71
|
break if skip_beginning('}')
|
71
72
|
|
72
|
-
prop_name = parse_string
|
73
|
-
|
74
|
-
new_prefix = "#{prefix}.#{prop_name}"
|
75
|
-
|
76
|
-
add_result(new_prefix, current_line)
|
73
|
+
prop_name = parse_string(return_value: true)
|
77
74
|
|
78
75
|
next_and_skip_whitespaces
|
79
76
|
|
@@ -81,11 +78,19 @@ module IpynbDiff
|
|
81
78
|
|
82
79
|
next_and_skip_whitespaces
|
83
80
|
|
84
|
-
|
81
|
+
if @objects_to_ignore.include? prop_name
|
82
|
+
skip
|
83
|
+
else
|
84
|
+
new_prefix = "#{prefix}.#{prop_name}"
|
85
|
+
|
86
|
+
add_result(new_prefix, current_line)
|
87
|
+
|
88
|
+
parse(new_prefix)
|
89
|
+
end
|
85
90
|
end
|
86
91
|
end
|
87
92
|
|
88
|
-
def parse_string
|
93
|
+
def parse_string(return_value: false)
|
89
94
|
current_should_be '"'
|
90
95
|
init_idx = @char_idx
|
91
96
|
|
@@ -100,7 +105,7 @@ module IpynbDiff
|
|
100
105
|
end
|
101
106
|
end
|
102
107
|
|
103
|
-
@chars[init_idx...@char_idx].join
|
108
|
+
@chars[init_idx...@char_idx].join if return_value
|
104
109
|
end
|
105
110
|
|
106
111
|
def add_result(key, line_number)
|
@@ -143,6 +148,45 @@ module IpynbDiff
|
|
143
148
|
@current_line += 1 if current_char == "\n"
|
144
149
|
end
|
145
150
|
|
151
|
+
def skip
|
152
|
+
skip_whitespaces
|
153
|
+
|
154
|
+
if (c = current_char) == '"'
|
155
|
+
parse_string
|
156
|
+
elsif c == '['
|
157
|
+
skip_array
|
158
|
+
elsif c == '{'
|
159
|
+
skip_object
|
160
|
+
else
|
161
|
+
parse_value
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def skip_array
|
166
|
+
loop do
|
167
|
+
break if skip_beginning(']')
|
168
|
+
|
169
|
+
skip
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def skip_object
|
174
|
+
|
175
|
+
loop do
|
176
|
+
break if skip_beginning('}')
|
177
|
+
|
178
|
+
parse_string
|
179
|
+
|
180
|
+
next_and_skip_whitespaces
|
181
|
+
|
182
|
+
current_should_be ':'
|
183
|
+
|
184
|
+
next_and_skip_whitespaces
|
185
|
+
|
186
|
+
skip
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
146
190
|
def skip_beginning(closing_char)
|
147
191
|
|
148
192
|
check_for_new_line
|
data/lib/transformer.rb
CHANGED
@@ -15,6 +15,7 @@ module IpynbDiff
|
|
15
15
|
include SymbolizedMarkdownHelper
|
16
16
|
|
17
17
|
@include_frontmatter = true
|
18
|
+
@objects_to_ignore = ['application/javascript', 'application/vnd.holoviews_load.v0+json']
|
18
19
|
|
19
20
|
def initialize(include_frontmatter: true)
|
20
21
|
@include_frontmatter = include_frontmatter
|
data/lib/version.rb
CHANGED
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.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Bonet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diffy
|