jupyter_to_scrapbox 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jupyter_to_scrapbox/version.rb +1 -1
- data/lib/jupyter_to_scrapbox.rb +20 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c269c73190cca2fec43711d25d8749662cd802a2
|
4
|
+
data.tar.gz: 5555309cde779f8f2d174ebca78a5076d2437838
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e9ad1b54e08e8eddd24e0f38f8880dbe4b2d0ce618da21c0dec09508e6764ffd9eba61d27be4151088575318bb3b652ada39ec32b9a7b50001b991ff1c42872
|
7
|
+
data.tar.gz: db8a605ec88fd93a193ca18f12db9f96df89b0210b7a025beee13075feae4956ca3140af45a6f42d2c6f5b43cb244c6668e8c207553eda5f41826c3fbf98f1b7
|
data/lib/jupyter_to_scrapbox.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require "jupyter_to_scrapbox/version"
|
2
2
|
require "rest-client"
|
3
|
+
require "open-uri"
|
4
|
+
require "uri"
|
3
5
|
require "JSON"
|
4
6
|
require 'base64'
|
5
7
|
|
@@ -74,7 +76,8 @@ module JupyterToScrapbox
|
|
74
76
|
end
|
75
77
|
|
76
78
|
def initialize(path)
|
77
|
-
@ipynb_path=
|
79
|
+
@ipynb_path=path
|
80
|
+
@page_title=""
|
78
81
|
@sb_json=[]
|
79
82
|
@display_input_numbers=false
|
80
83
|
@prefix_comment="#"
|
@@ -214,10 +217,14 @@ module JupyterToScrapbox
|
|
214
217
|
end
|
215
218
|
|
216
219
|
def parse_ipynb()
|
217
|
-
texts=
|
220
|
+
@texts=""
|
221
|
+
open(@ipynb_path) do |f|
|
222
|
+
@texts=f.read
|
223
|
+
end
|
218
224
|
# vputs texts
|
219
|
-
js=JSON.parse(texts)
|
225
|
+
js=JSON.parse(@texts)
|
220
226
|
vp js.length
|
227
|
+
|
221
228
|
@file_extension=js["metadata"]["language_info"]["file_extension"]
|
222
229
|
vp @file_extension
|
223
230
|
|
@@ -236,10 +243,17 @@ module JupyterToScrapbox
|
|
236
243
|
end
|
237
244
|
|
238
245
|
def page()
|
239
|
-
|
246
|
+
case @ipynb_path
|
247
|
+
when %r!^https?://!i, %r!^ftp://!i
|
248
|
+
uri=URI.parse(@ipynb_path)
|
249
|
+
@uri=uri.path
|
250
|
+
else
|
251
|
+
@uri=@ipynb_path
|
252
|
+
end
|
253
|
+
@page_title=File.basename(@uri,".ipynb")
|
240
254
|
page= {
|
241
|
-
"title":
|
242
|
-
"lines": @sb_json.unshift(
|
255
|
+
"title": @page_title,
|
256
|
+
"lines": @sb_json.unshift(@ipynb_path)
|
243
257
|
}
|
244
258
|
return page
|
245
259
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jupyter_to_scrapbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroharu Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|