jupyter_to_scrapbox 0.1.3 → 0.2.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: 9ff45bd5cb4be74deb64b811c66c141b219f242f
4
- data.tar.gz: 76d386b0bd4f176b8bcc325dd88178784379e70b
3
+ metadata.gz: 7d2a15c678c3e7c12eac4b63d04528700b674bb7
4
+ data.tar.gz: c33c25e8f02515aa8f57f23366aa9e59a0d15be4
5
5
  SHA512:
6
- metadata.gz: 1adc76f20790d244bff425f5d73693cbc9714f4097c7b6a7c24e927e125df90d638843cc0a39aada7c6953f27088654519e231dc2a1300c0bf67aa0fb805752c
7
- data.tar.gz: b836e0222848683b28b4b53f09dc26237c4106c1ab86df01ab654e2915c03518d7f1e15b76a95b811320d954f1179437829b5174c2ec191588aec6453e7909e4
6
+ metadata.gz: fa05b8410ece640bcfb1c3dc00144c0f2b392dc8d29f1d6fe8e5e5143b23b81da7ff7197a4021d434602281f9243a086fad63b2a4d641794864a19ade331f719
7
+ data.tar.gz: c8fb5f0a9878dc104c346a3df6e7fd64584bacf5326c36c037144af4ce5d0045d31e37c78ca74d834a2625db5e2d2e6dddcd40a2f55e33a2fb3d0f17e7c2502e
data/README.md CHANGED
@@ -4,17 +4,13 @@ The Jupyter Notebook http://jupyter.org is an open-source web application that a
4
4
 
5
5
  Scrapbox http://scrapbox.io is a novel note-taking service for teams.
6
6
 
7
- This tool converts jupyter notebook file to json file suitable for import to scrapbox.
8
-
9
- TODO: Delete this and the text above, and describe your gem
10
-
11
- Warning : under condtruction. do not believe the instruction below.
7
+ This tool converts jupyter notebook files to json file suitable for import to scrapbox.
12
8
 
13
9
  ## Installation
14
10
 
15
- This tool, written in Ruby, is distributed via rubygem.
11
+ This tool, written in Ruby, is distributed via rubygem. https://rubygems.org/gems/jupyter_to_scrapbox
16
12
 
17
- From command line, invoke gem install command:
13
+ To install, invoke gem install command:
18
14
 
19
15
  ```ruby
20
16
  gem install jupyter_to_scrapbox
@@ -22,12 +18,12 @@ gem install jupyter_to_scrapbox
22
18
 
23
19
  ## Usage
24
20
 
25
- The input file is jupyter notebook (file extension = .ipynb)
21
+ Input files are jupyter notebook files. (file extension = .ipynb)
26
22
 
27
23
  Invoke this tool by:
28
24
 
29
25
  ```ruby
30
- $ bundle exec jupyter_to_scrapbox convert FILE > scrapbox.json
26
+ $ bundle exec jupyter_to_scrapbox convert FILES > scrapbox.json
31
27
  ```
32
28
 
33
29
  To import `scrapbox.json` to scrapbox, follow the instruction of "import pages" tool of "scrapbox" at the url:
@@ -10,14 +10,15 @@ module JupyterToScrapbox
10
10
  class_option :version, type: :boolean, desc: 'version'
11
11
  default_task :help
12
12
 
13
- option :file, type: :string, aliases: '-f', desc: 'specify input jupyter-notebook file (.ipynb)'
14
13
  method_option :verbose, type: :boolean, aliases: '-v', desc: 'verbose message'
15
- desc 'convert FILE [options]', 'Convert jupyter-notebook file to scrapbox-json'
14
+ desc 'converts FILES [options]', 'Convert jupyter-notebook files to scrapbox-json'
16
15
 
17
- def convert(path)
18
- converter=JupyterToScrapbox::Converter.new(path)
19
- converter.set_verbose() if options[:verbose]
20
- converter.start()
16
+ def convert(*paths)
17
+ JupyterToScrapbox::Converter.set_verbose() if options[:verbose]
18
+ paths.each do |path|
19
+ JupyterToScrapbox::Converter.add(path)
20
+ end
21
+ JupyterToScrapbox::Converter.start()
21
22
  # puts "Hello "+path
22
23
  end
23
24
  desc 'version', 'version'
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Hiroharu Sugawara"]
10
10
  spec.email = ["hsugawa@tmu.ac.jp"]
11
11
 
12
- spec.summary = %q{convert jupyter-notebook to scrapbox-import-ready-json}
13
- spec.description = %q{convert jupyter-notebook to scrapbox-import-ready-json}
12
+ spec.summary = %q{convert jupyter-notebook files to scrapbox-import-ready-json}
13
+ spec.description = %q{convert jupyter-notebook files to scrapbox-import-ready-json}
14
14
  spec.homepage = %q{https://github.com/hsugawa8651/jupyter_to_scrapbox_gem}
15
15
  spec.licenses = [ "MIT" ]
16
16
 
@@ -1,3 +1,3 @@
1
1
  module JupyterToScrapbox
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -5,28 +5,47 @@ module JupyterToScrapbox
5
5
  # Your code goes here...
6
6
 
7
7
  class Converter
8
+ @@verbose=false
9
+ @@converters=[]
10
+
11
+ def Converter.set_verbose()
12
+ @@verbose=true
13
+ end
14
+
15
+ def Converter.add(path)
16
+ @@converters.push Converter.new(path)
17
+ end
18
+
19
+ def Converter.start()
20
+ pages=@@converters.collect do |converter|
21
+ converter.start()
22
+ end
23
+
24
+ result={
25
+ "pages": pages
26
+ }
27
+
28
+ puts result.to_json
29
+
30
+ end
31
+
8
32
  def initialize(path)
9
33
  @ipynb_path=File.expand_path(path)
10
34
  @sb_json=[]
11
- @verbose=false
12
35
  @display_input_numbers=false
13
36
  @prefix_comment="#"
14
37
  end
15
38
 
16
- def set_verbose()
17
- @verbose=true
18
- end
19
-
20
39
  def vp(s)
21
- p(s) if @verbose
40
+ p(s) if @@verbose
22
41
  end
23
42
 
24
43
  def vprint(s)
25
- print(s) if @verbose
44
+ print(s) if @@verbose
26
45
  end
27
46
 
28
47
  def vputs(s)
29
- puts(s) if @verbose
48
+ puts(s) if @@verbose
30
49
  end
31
50
 
32
51
  def push_text(s)
@@ -45,7 +64,6 @@ module JupyterToScrapbox
45
64
  end
46
65
  end
47
66
 
48
-
49
67
  def push_texts(ww)
50
68
  ww.each do |s|
51
69
  push_text(s)
@@ -148,14 +166,12 @@ module JupyterToScrapbox
148
166
  parse_ipynb()
149
167
 
150
168
  my_title=File.basename(@ipynb_path,".ipynb")
151
- result={
152
- "pages": [ {
153
- "title": my_title,
154
- "lines": @sb_json.unshift(my_title)
155
- }]
156
- }
157
169
 
158
- puts result.to_json
170
+ page= {
171
+ "title": my_title,
172
+ "lines": @sb_json.unshift(my_title)
173
+ }
174
+ return page
159
175
  end
160
176
 
161
177
  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.1.3
4
+ version: 0.2.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-07-19 00:00:00.000000000 Z
11
+ date: 2017-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: convert jupyter-notebook to scrapbox-import-ready-json
55
+ description: convert jupyter-notebook files to scrapbox-import-ready-json
56
56
  email:
57
57
  - hsugawa@tmu.ac.jp
58
58
  executables:
@@ -94,5 +94,5 @@ rubyforge_project:
94
94
  rubygems_version: 2.6.12
95
95
  signing_key:
96
96
  specification_version: 4
97
- summary: convert jupyter-notebook to scrapbox-import-ready-json
97
+ summary: convert jupyter-notebook files to scrapbox-import-ready-json
98
98
  test_files: []