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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2a95a898833b4c7826367ed7fb20ef55e124bec
4
- data.tar.gz: '018d7296e0b3fac13362e97bdab26721c955a5f6'
3
+ metadata.gz: c269c73190cca2fec43711d25d8749662cd802a2
4
+ data.tar.gz: 5555309cde779f8f2d174ebca78a5076d2437838
5
5
  SHA512:
6
- metadata.gz: b4e942c580ea7479cae4a22da72352721b141f5735e049c2c5423fc27146b5dcb34c70eace69efedb1bd3bdefdb6ee54989719f1a7f0dcf29f21dd1256bd1aee
7
- data.tar.gz: e42b3245e981c6f812fd7a68ef469e730d2efd2be209f6239a9cb1aab451c1a031ccd3809cd1273e5ab2feb2c28fbbe2348bda13d7724ef035d8671a2b56146c
6
+ metadata.gz: 9e9ad1b54e08e8eddd24e0f38f8880dbe4b2d0ce618da21c0dec09508e6764ffd9eba61d27be4151088575318bb3b652ada39ec32b9a7b50001b991ff1c42872
7
+ data.tar.gz: db8a605ec88fd93a193ca18f12db9f96df89b0210b7a025beee13075feae4956ca3140af45a6f42d2c6f5b43cb244c6668e8c207553eda5f41826c3fbf98f1b7
@@ -1,3 +1,3 @@
1
1
  module JupyterToScrapbox
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -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=File.expand_path(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=File.read(@ipynb_path)
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
- my_title=File.basename(@ipynb_path,".ipynb")
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": my_title,
242
- "lines": @sb_json.unshift(my_title)
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.3.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-02 00:00:00.000000000 Z
11
+ date: 2017-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler