jupyter_to_scrapbox 0.2.1 → 0.2.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: 6440292ab6d8a4baef46db1db99a9c1929f505aa
4
- data.tar.gz: 700b0fe22a7b4ee0025f6d4846310e4b4acab625
3
+ metadata.gz: 8135362fc30d17c36825811d9aecd21ef2df236e
4
+ data.tar.gz: ac1583ba61a9f384c03bc1426666983fa42e540f
5
5
  SHA512:
6
- metadata.gz: 3b0a86f60698038fcce4632445ad5ed77b5b41dcee5aae8be77359b4ce204fca90a2a08616167a6f2561cb3dc20063c864597a72989b5ff2a46baaea01b2deb9
7
- data.tar.gz: 8431644eaff652863c7e6bc3cc0ff413a1aa6105894e10e56212d4f3adf7f00e9b9f2f2aa8a9da190977e5b5e0fec7abefd58ccfd6b8da07a64d08a61b287a87
6
+ metadata.gz: bb0799206638fcab8bb4ad97c10d82576951d624def15c8ade2c1a6402eef064b420fae455180724b210959c3d3d7d07268afa40aefe900cb6a6eb20ff502968
7
+ data.tar.gz: 84cdfbfc78b482ea6ba117fee81d8c9ba1b92aebdde840cf9c9f07f14699b0074472d3c607f413ce61deefb44bff350b2166456ed0af5c63615ab6eefc142c3c
@@ -1,33 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # coding: utf-8
3
3
 
4
- require "jupyter_to_scrapbox"
5
- require 'thor'
6
-
7
- module JupyterToScrapbox
8
- class CLI < Thor
9
- class_option :help, type: :boolean, aliases: '-h', desc: 'help message.'
10
- class_option :version, type: :boolean, desc: 'version'
11
- default_task :help
12
-
13
- method_option :verbose, type: :boolean, aliases: '-v', desc: 'verbose message'
14
- method_option :moderate, type: :boolean, aliases: '-m', desc: 'moderate mode: do not convert markdown notations'
15
- desc 'converts FILES [options]', 'Convert jupyter-notebook files to scrapbox-json'
16
-
17
- def convert(*paths)
18
- JupyterToScrapbox::Converter.set_verbose() if options[:verbose]
19
- JupyterToScrapbox::Converter.set_moderate() if options[:moderate]
20
- paths.each do |path|
21
- JupyterToScrapbox::Converter.add(path)
22
- end
23
- JupyterToScrapbox::Converter.start()
24
- # puts "Hello "+path
25
- end
26
- desc 'version', 'version'
27
- def version
28
- p JupyterToScrapbox::VERSION
29
- end
30
- end
31
- end
4
+ require "cli"
32
5
 
33
6
  JupyterToScrapbox::CLI.start(ARGV)
@@ -1,3 +1,3 @@
1
1
  module JupyterToScrapbox
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -3,27 +3,32 @@ require "JSON"
3
3
 
4
4
  module JupyterToScrapbox
5
5
  # Your code goes here...
6
-
7
6
  class Converter
8
7
  @@verbose=false
9
- @@converters=[]
8
+ @@register_images=false
10
9
  @@parse_markdown_notations=true
10
+ @@converters=[]
11
11
 
12
- def Converter.set_verbose()
13
- @@verbose=true
12
+ def Converter.set_verbose(v)
13
+ @@verbose=v
14
14
  end
15
15
 
16
- def Converter.set_moderate()
17
- @@parse_markdown_notations=false
16
+ def Converter.set_register_images(v)
17
+ @@register_images=v
18
+ end
19
+
20
+ def Converter.set_parse_markdown(v)
21
+ @@parse_markdown_notations=v
18
22
  end
19
23
 
20
24
  def Converter.add(path)
21
25
  @@converters.push Converter.new(path)
22
26
  end
23
27
 
24
- def Converter.start()
25
- pages=@@converters.collect do |converter|
26
- converter.start()
28
+ def Converter.perform()
29
+ pages=@@converters.collect do |c|
30
+ c.start()
31
+ c.page()
27
32
  end
28
33
 
29
34
  result={
@@ -102,6 +107,16 @@ module JupyterToScrapbox
102
107
  end
103
108
  end
104
109
 
110
+ def parse_image_png(v)
111
+ vputs v
112
+ push_text("code:output.txt")
113
+ push_code("image/png")
114
+ if @@register_images
115
+ push_text(v)
116
+ end
117
+ push_empty_text()
118
+ end
119
+
105
120
  def parse_cell_code(code)
106
121
  vputs "-- source"
107
122
  vputs code["source"]
@@ -130,10 +145,7 @@ module JupyterToScrapbox
130
145
  vputs "-- outputs #{out_data_c} inner data => #{out_data_k}"
131
146
  case out_data_k
132
147
  when "image/png"
133
- vputs out_data_v
134
- push_text("code:output.txt")
135
- push_code("image/png")
136
- push_empty_text()
148
+ parse_image_png(out_data_v)
137
149
  when "text/plain"
138
150
  vputs out_data_v
139
151
  push_text("code:output.txt")
@@ -184,9 +196,10 @@ module JupyterToScrapbox
184
196
 
185
197
  def start()
186
198
  parse_ipynb()
199
+ end
187
200
 
201
+ def page()
188
202
  my_title=File.basename(@ipynb_path,".ipynb")
189
-
190
203
  page= {
191
204
  "title": my_title,
192
205
  "lines": @sb_json.unshift(my_title)
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.2.1
4
+ version: 0.2.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-07-21 00:00:00.000000000 Z
11
+ date: 2017-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -62,7 +62,6 @@ extra_rdoc_files: []
62
62
  files:
63
63
  - ".gitignore"
64
64
  - Gemfile
65
- - LICENSE
66
65
  - README.md
67
66
  - Rakefile
68
67
  - bin/console
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2013 Thomas Park
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
22
-