jupyter_to_scrapbox 0.4.1 → 0.4.2

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
  SHA1:
3
- metadata.gz: 6b73710b6759b77ed57157cb8a30fc0d495fe99f
4
- data.tar.gz: 92d353994fdc69575fcd63a16dac9f0e2ed200b3
3
+ metadata.gz: 9a348d21b2862a5fbc1e57fc3464f8d4d09c8e4b
4
+ data.tar.gz: 28b280bac91c3d3eeea06d0b26578d11a061ae49
5
5
  SHA512:
6
- metadata.gz: 35398afc188e81d37ca211af569b3b4cf3bcc607d73e738a0fa221f11fa400083e2ba402e212259e814655d25e455d6fd3a9855662df1640fc1a78b4cb520bf8
7
- data.tar.gz: d13592bdd81aea8509806aae4e367e2f30878d361ea12f1bce9eeac10f33b9d6d5b8d665d219c09b2ee36c214f824b582ba076b130bdb0a64b62bfccf092e722
6
+ metadata.gz: f386387964a95167a162d1c9b81d5bdf567af673a6928e783f252ee01edff8fe21a0c19d3ea5eaf69c41af65a44ee5ff35e75762c271ce11f9e62ebbb01cfd5c
7
+ data.tar.gz: 35a4c3818b3d4524bf721087485b818d508b8c54e26a35121c1a886cc96c405693b7395e91ced3bf8d04a1e2d988f7507bf59225817529be5b41dd29f313c592
data/lib/cli.rb CHANGED
@@ -19,8 +19,14 @@ module JupyterToScrapbox
19
19
  JupyterToScrapbox::Converter.set_verbose(options[:verbose])
20
20
  JupyterToScrapbox::Converter.set_register_images(options[:image])
21
21
  JupyterToScrapbox::Converter.set_parse_markdown(options[:markdown])
22
- paths.each do |path|
23
- JupyterToScrapbox::Converter.add(path)
22
+ if paths.length > 0
23
+ paths.each do |path|
24
+ JupyterToScrapbox::Converter.add(path)
25
+ end
26
+ else
27
+ while path=$stdin.gets
28
+ JupyterToScrapbox::Converter.add(path.chomp)
29
+ end
24
30
  end
25
31
  JupyterToScrapbox::Converter.perform()
26
32
  end
@@ -76,12 +76,20 @@ module JupyterToScrapbox
76
76
  end
77
77
 
78
78
  def initialize(path)
79
- @ipynb_path=path
80
79
  @page_title=""
81
80
  @last_modified=nil
82
81
  @sb_json=[]
83
82
  @display_input_numbers=false
84
83
  @prefix_comment="#"
84
+
85
+ @offline=true
86
+ @ipynb_path=path.chomp
87
+ case @ipynb_path
88
+ when %r!^https?://!i, %r!^ftp://!i
89
+ @offline=false
90
+ else
91
+ @ipynb_path=File.expand_path(@ipynb_path)
92
+ end
85
93
  end
86
94
 
87
95
  def vp(s)
@@ -220,14 +228,11 @@ module JupyterToScrapbox
220
228
  def parse_ipynb()
221
229
  @texts=""
222
230
  open(@ipynb_path) do |f|
223
- case @ipynb_path
224
- when %r!^https?://!i, %r!^ftp://!i
225
- @last_modified=f.last_modified
226
- unless @last_modified
227
- @last_modified=Time.now
228
- end
229
- else
231
+ if @offline
230
232
  @last_modified=f.mtime
233
+ else
234
+ @last_modified=f.last_modified
235
+ @last_modified=Time.now unless @last_modified
231
236
  end
232
237
  @texts=f.read
233
238
  end
@@ -235,7 +240,10 @@ module JupyterToScrapbox
235
240
  js=JSON.parse(@texts)
236
241
  vp js.length
237
242
 
238
- @file_extension=js["metadata"]["language_info"]["file_extension"]
243
+ begin
244
+ @file_extension=js["metadata"]["language_info"]["file_extension"]
245
+ rescue
246
+ end
239
247
  vp @file_extension
240
248
 
241
249
  if %r!\.(jl|py|rb)!i =~ @file_extension
@@ -253,18 +261,7 @@ module JupyterToScrapbox
253
261
  end
254
262
 
255
263
  def page()
256
- =begin
257
- case @ipynb_path
258
- when %r!^https?://!i, %r!^ftp://!i
259
- uri=URI.parse(@ipynb_path)
260
- @uri=uri.path
261
- else
262
- @uri=@ipynb_path
263
- end
264
- @page_title=File.basename(@uri,".ipynb")
265
- =end
266
264
  @page_title=@last_modified.to_s
267
-
268
265
  @sb_json.unshift("")
269
266
  @sb_json.unshift(@ipynb_path)
270
267
  @sb_json.unshift(@page_title)
@@ -1,3 +1,3 @@
1
1
  module JupyterToScrapbox
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  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.1
4
+ version: 0.4.2
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 00:00:00.000000000 Z
11
+ date: 2017-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -83,7 +83,6 @@ files:
83
83
  - exe/jupyter_to_scrapbox
84
84
  - jupyter_to_scrapbox.gemspec
85
85
  - lib/cli.rb
86
- - lib/gyazo_ext.rb
87
86
  - lib/jupyter_to_scrapbox.rb
88
87
  - lib/jupyter_to_scrapbox/version.rb
89
88
  homepage: https://github.com/hsugawa8651/jupyter_to_scrapbox_gem
@@ -1,30 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'JSON'
4
- require 'gyazo'
5
-
6
- module Gyazo
7
-
8
- class Client
9
-
10
- def upload_image(imagedata,params={})
11
- url = "https://upload.gyazo.com/api/upload"
12
- time = params[:time] || params[:created_at] || Time.now
13
- res = HTTMultiParty.post url, {
14
- :query => {
15
- :access_token => @access_token,
16
- :imagedata => imagedata,
17
- :created_at => time.to_i,
18
- :referer_url => params[:referer_url] || params[:url] || '',
19
- :title => params[:title] || '',
20
- :desc => params[:desc] || ''
21
- },
22
- :header => {
23
- 'User-Agent' => @user_agent
24
- }
25
- }
26
- raise Gyazo::Error, res.body unless res.code == 200
27
- return JSON.parse res.body
28
- end
29
- end
30
- end