qiita_org 0.1.23 → 0.1.24

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
  SHA256:
3
- metadata.gz: beffdb8ca4472a742773b3f18ef4358be70621d887be94f0cc4d7db4bf703f4e
4
- data.tar.gz: a9f1c37a7511ec9ed355c39f587511e96dac790b3be07198b54182f8ad94782b
3
+ metadata.gz: ff5afe51529883ef3f843cc85608ea5eb112c97d9bee65ad71eee130e93ee3d1
4
+ data.tar.gz: b5945826738b2719a6dc861d60c920edc012db5d49e5c55d8cd464e608c9aab5
5
5
  SHA512:
6
- metadata.gz: 9b5a5ae877e5c0329f15285cc5de0e9382b485204825e4ecdd3a2c6234e9ee9c9b3bc108f867743ee8795672e8ae302085073e32455f600aee9be71b0c627195
7
- data.tar.gz: cdba09e7aee71b7c21b6897e6131bad6013213abc91a407a5a6f0ce2d34125e1331755d7c7935fa5de11168c97e2674200370bb7bb0dfb99b9601052001ed690
6
+ metadata.gz: 8c7513a96480af4381e23b729a4308265d91721f3d75984cc7d3f28a756f8a386d5aa3d49fffbd00a8f946e2fbc6c77759bb8f61df9544d415315709c1d6dfb3
7
+ data.tar.gz: 96eb5ad3f7334dd0a14fa481fd33864f03fafc6739d2f6b3ae73b60a6c98d0a07c1a7614684cd7747e0216988052a567c96b6268a387d3085fd31e568a9d8417
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qiita_org (0.1.23)
4
+ qiita_org (0.1.24)
5
5
  colorize
6
6
  command_line (> 2.0.0)
7
7
  fileutils
@@ -13,6 +13,7 @@ require "qiita_org/upload"
13
13
  require "qiita_org/get_file_path"
14
14
  require "qiita_org/show_file_and_url"
15
15
  require "qiita_org/decide_option"
16
+ require "qiita_org/get_multiple_files"
16
17
  #require "qiita_org/qiita_org_thor"
17
18
 
18
19
  module QiitaOrg
@@ -38,16 +39,22 @@ module QiitaOrg
38
39
  checkos = CheckPcOs.new
39
40
  os = checkos.return_os()
40
41
 
41
- p ["in qiita_org.rb", argv]
42
- p file = argv[0] || "README.org"
43
- p mode = argv[1] || DecideOption.new(file).decide_option()
44
- qiita = QiitaPost.new(file, mode, os)
45
- begin
46
- qiita.select_option(mode)
47
- rescue RuntimeError => e
48
- puts $!
42
+ if argv.size > 2
43
+ GetMultipleFiles.new(argv, os, "post").run()
44
+ elsif argv[-1].match(/(.+).org/) && argv.size != 1
45
+ GetMultipleFiles.new(argv, os, "post").run()
49
46
  else
50
- qiita.run
47
+ p ["in qiita_org.rb", argv]
48
+ p file = argv[0] || "README.org"
49
+ p mode = argv[1] || DecideOption.new(file).decide_option()
50
+ qiita = QiitaPost.new(file, mode, os)
51
+ begin
52
+ qiita.select_option(mode)
53
+ rescue RuntimeError => e
54
+ puts $!
55
+ else
56
+ qiita.run
57
+ end
51
58
  end
52
59
  end
53
60
 
@@ -57,10 +64,16 @@ module QiitaOrg
57
64
  checkos = CheckPcOs.new
58
65
  os = checkos.return_os()
59
66
 
60
- p file = argv[0] || "README.org"
61
- p mode = argv[1] || DecideOption.new(file).decide_option()
67
+ if argv.size > 2
68
+ GetMultipleFiles.new(argv, os, "upload").run()
69
+ elsif argv[-1].match(/(.+).org/) && argv.size != 1
70
+ GetMultipleFiles.new(argv, os, "upload").run()
71
+ else
72
+ p file = argv[0] || "README.org"
73
+ p mode = argv[1] || DecideOption.new(file).decide_option()
62
74
 
63
- UpLoad.new(file, mode, os).upload()
75
+ qiita = UpLoad.new(file, mode, os).upload()
76
+ end
64
77
  =begin
65
78
  getpath = GetFilePath.new(file)
66
79
  paths = getpath.get_file_path()
@@ -24,29 +24,33 @@ class ErrorMessage
24
24
  exit
25
25
  end
26
26
 
27
- def qiita_post_error(response)
27
+ def qiita_post_error(response, file)
28
28
  message = response.message
29
29
  if message != "Created"
30
30
  if message != "OK"
31
31
  if message == "Unauthorized"
32
32
  puts "#{message}".red
33
33
  puts "Please check your access_token.".red
34
+ system "rm #{file}"
34
35
  exit
35
- elsif message == "Forbidden"
36
+ elsif message == "Forbidden"
36
37
  puts "#{message}".red
37
38
  puts "You are not authorized to access this page. please check qiita_id.".red
39
+ system "rm #{file}"
38
40
  exit
39
41
  elsif message == "Not Found"
40
- puts "#{message}".red
42
+ puts "#{message}".red
43
+ system "rm #{file}"
41
44
  exit
42
45
  else
43
46
  puts "#{message}".red
47
+ system "rm #{file}"
44
48
  exit
45
49
  end
46
50
  end
47
51
  end
48
52
  end
49
-
53
+
50
54
  def config_set_error(conf_dir)
51
55
  conf_path = File.join(conf_dir, ".qiita.conf")
52
56
  conf = JSON.load(File.read(conf_path))
@@ -77,7 +77,7 @@ class QiitaGet
77
77
  File.write(filename, item["body"])
78
78
  convert_md_to_org()
79
79
  write_header_on_org()
80
- puts_massage_and_delete_md()
80
+ puts_massage_and_delete_md(item)
81
81
  end
82
82
  end
83
83
  end
@@ -125,9 +125,9 @@ EOS
125
125
  end
126
126
 
127
127
  # see massage and delete id.md
128
- def puts_massage_and_delete_md()
128
+ def puts_massage_and_delete_md(item)
129
129
  puts "created #{@id}.org".green
130
- puts "URL: #{@items["url"]}"
130
+ puts "URL: #{item["url"]}"
131
131
  system "rm -f #{@id}.md"
132
132
  end
133
133
 
@@ -155,7 +155,7 @@ EOS
155
155
  File.write(filename, @items["body"])
156
156
  convert_md_to_org()
157
157
  write_header_on_org()
158
- puts_massage_and_delete_md()
158
+ puts_massage_and_delete_md(@items)
159
159
  end
160
160
 
161
161
  def run()
@@ -165,7 +165,7 @@ EOS
165
165
  end
166
166
 
167
167
  if @get_id == nil
168
- @qiita, @path = @selectpath.select_path(@mode)
168
+ @qiita, @path = @selectpath.select_path(@mode, @teams_url)
169
169
  @items = AccessQiita.new(@access_token, @qiita, @path).access_qiita()
170
170
  select_report()
171
171
  else
@@ -0,0 +1,38 @@
1
+ require "colorize"
2
+ #require "../qiita_org/qiita_org.rb"
3
+ require "qiita_org/post.rb"
4
+ require "qiita_org/upload.rb"
5
+ require "qiita_org/decide_option.rb"
6
+
7
+ class GetMultipleFiles
8
+ def initialize(files, os, type)
9
+ @files = files
10
+ @option = nil
11
+ @os = os
12
+ @type = type
13
+ unless @files[-1].match(/(.+).org/)
14
+ @option = @files[-1]
15
+ @files = @files[0..-2]
16
+ end
17
+ end
18
+
19
+ def run()
20
+ puts "post files: #{@files}".green
21
+ @files.each do |file|
22
+ mode = @option || DecideOption.new(file).decide_option()
23
+ puts "qiita #{@type} #{file} #{mode}".green
24
+ if @type == "post"
25
+ qiita = QiitaPost.new(file, mode, @os)
26
+ begin
27
+ qiita.select_option(mode)
28
+ rescue RuntimeError => e
29
+ puts $!
30
+ else
31
+ qiita.run
32
+ end
33
+ elsif @type == "upload"
34
+ UpLoad.new(file, mode, @os).upload()
35
+ end
36
+ end
37
+ end
38
+ end
@@ -15,7 +15,7 @@ class QiitaList
15
15
  ErrorMessage.new().teams_url_error(@teams_url)
16
16
  end
17
17
 
18
- @qiita, @path = SelectPath.new().select_path(@mode)
18
+ @qiita, @path = SelectPath.new().select_path(@mode, @teams_url)
19
19
  @items = AccessQiita.new(@access_token, @qiita, @path).access_qiita()
20
20
  view_list()
21
21
  end
@@ -110,7 +110,7 @@ class QiitaPost
110
110
  res = http_req.post(uri.path, params.to_json, headers)
111
111
  end
112
112
 
113
- ErrorMessage.new().qiita_post_error(res)
113
+ ErrorMessage.new().qiita_post_error(res, @src.gsub(".org", ".md"))
114
114
 
115
115
  return res
116
116
  end
@@ -2,10 +2,10 @@ class SelectPath
2
2
  def initialize()
3
3
  end
4
4
 
5
- def select_path(mode)
5
+ def select_path(mode, teams_url)
6
6
  case mode
7
7
  when "teams"
8
- qiita = @teams_url
8
+ qiita = teams_url
9
9
  path = "api/v2/items?page=1&per_page=100"
10
10
  else
11
11
  qiita = "https://qiita.com/"
@@ -1,3 +1,3 @@
1
1
  module QiitaOrg
2
- VERSION = "0.1.23"
2
+ VERSION = "0.1.24"
3
3
  end
@@ -1,3 +1,4 @@
1
+ #+qiita_private: d786bc76ea7a4ad09fb0
1
2
  # +qiita_private: 5f8c73e8007e52ef3f40
2
3
  # +qiita_private: 4decbf7a81ef2327643f
3
4
  #+OPTIONS: ^:{}
@@ -1,4 +1,3 @@
1
- #+qiita_private: ca3a6b6e1f5e8c0ba743
2
1
  #+OPTIONS: ^:{}
3
2
  #+STARTUP: indent nolineimages
4
3
  #+TITLE: test
@@ -18,6 +17,6 @@ fogefoge
18
17
  #+ATTR_LATEX: :width 8cm
19
18
  [[https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/ebf505d2-6960-6bb9-20f0-e16dab142f4a.png][file:../figs/fig1.png]]
20
19
 
21
- [[file:../figs/fig1.png]]
20
+ [[https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/ebf505d2-6960-6bb9-20f0-e16dab142f4a.png][file:../figs/fig1.png]]
22
21
 
23
22
 
@@ -1,4 +1,4 @@
1
- #+qiita_teams: bd41ced53b4b18701453
1
+ # +qiita_teams: bd41ced53b4b18701453
2
2
  #+OPTIONS: ^:{}
3
3
  #+STARTUP: indent nolineimages
4
4
  #+TITLE: test
@@ -1,4 +1,4 @@
1
- #+qiita_private: 92b50b88e7da7aa25a1b
1
+ # +qiita_private: 92b50b88e7da7aa25a1b
2
2
  #+OPTIONS: ^:{}
3
3
  #+STARTUP: indent nolineimages
4
4
  #+TITLE: title
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qiita_org
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.23
4
+ version: 0.1.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenta Yamamoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-11 00:00:00.000000000 Z
11
+ date: 2020-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -967,6 +967,7 @@ files:
967
967
  - lib/qiita_org/get.rb
968
968
  - lib/qiita_org/get_file_path.rb
969
969
  - lib/qiita_org/get_file_url.rb
970
+ - lib/qiita_org/get_multiple_files.rb
970
971
  - lib/qiita_org/get_template.rb
971
972
  - lib/qiita_org/hoge.txt
972
973
  - lib/qiita_org/list.rb
@@ -984,7 +985,6 @@ files:
984
985
  - tests/hoge.rb
985
986
  - tests/test.html
986
987
  - tests/test.org
987
- - tests/test2.md
988
988
  - tests/test2.org
989
989
  - tests/test3.org
990
990
  - tests/test4.org
@@ -1,6 +0,0 @@
1
- \![Mac OS X-10.13.3](<https://img.shields.io/badge/MacOSX-10.13.3-brightgreen>) \![ruby-2.7.0p0](<https://img.shields.io/badge/ruby-2.7.0p0-brightgreen>)
2
-
3
- fogefoge
4
-
5
- [![img](../figs/fig1.png)](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/ebf505d2-6960-6bb9-20f0-e16dab142f4a.png)
6
-