qiita_org 0.1.38 → 0.1.39
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/qiita_org/post.rb +54 -5
- data/lib/qiita_org/version.rb +1 -1
- data/tests/tags_test.org +16 -0
- data/tests/tags_test2.org +16 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e53c42941ae7a27b95dee8bd322f8a32a27f7180d30e760fd90f18727ec8dd8e
|
4
|
+
data.tar.gz: c712d00069cce5f41c713b7e5fadd4ca5acfb5050fcb89b4118268308d338b7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 166df0fdcb5f34c0eb065a5901bbdd113452f6f8179faaa34921b9299bf8261ac7cbad8be28ef08a3fb2fe2f0fe49e23031cc4bee43bfa273d1741f8fb8d8c70
|
7
|
+
data.tar.gz: bb6e700cf92e27f9b36c7168476b3a300711ff7d7eeee766775a282dae838ef86a6c4206651c6fcd922dd9d9758ebb5cb83716ed7ceafad9e432d341f67d1f2f
|
data/Gemfile.lock
CHANGED
data/lib/qiita_org/post.rb
CHANGED
@@ -22,16 +22,53 @@ class QiitaPost
|
|
22
22
|
@title = m ? m[2] : "テスト"
|
23
23
|
@tags = if m = conts.match(/\#\+(TAG|tag|Tag|tags|TAGS|Tags): (.+)/)
|
24
24
|
ErrorMessage.new().many_tags_error(m[2])
|
25
|
-
m[2]
|
26
|
-
|
27
|
-
|
25
|
+
check_tags(m[2])
|
26
|
+
#m[2].split(",").inject([]) do |l, c|
|
27
|
+
#l << { name: c.strip } #, versions: []}
|
28
|
+
#end
|
28
29
|
else
|
29
|
-
|
30
|
+
new_tags = get_tags()
|
31
|
+
#[{ name: "hoge" }] #, versions: [] }]
|
32
|
+
check_tags(new_tags)
|
30
33
|
end
|
31
34
|
p @tags
|
32
35
|
return @title, @tags
|
33
36
|
end
|
34
37
|
|
38
|
+
#chack tags "hoge" or "hoge2"
|
39
|
+
def check_tags(tags)
|
40
|
+
if tags.include?("hoge" || "hoge2")
|
41
|
+
new_tags = get_tags()
|
42
|
+
tags = []
|
43
|
+
new_tags.each do |tag|
|
44
|
+
tags << { name: tag.strip }
|
45
|
+
end
|
46
|
+
else
|
47
|
+
tags = tags.split(",").inject([]) do |l, c|
|
48
|
+
l << { name: c.strip } #, versions: []}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
return tags
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_tags()
|
56
|
+
tags = []
|
57
|
+
count = 0
|
58
|
+
puts "Please input tags, or 'e' for end."
|
59
|
+
while count < 5 do
|
60
|
+
p "tag#{count+1}:"
|
61
|
+
string = STDIN.gets.chomp
|
62
|
+
if string == 'e'
|
63
|
+
count = 5
|
64
|
+
else
|
65
|
+
tags << string
|
66
|
+
end
|
67
|
+
count += 1
|
68
|
+
end
|
69
|
+
return tags
|
70
|
+
end
|
71
|
+
|
35
72
|
# src.org -> src.md
|
36
73
|
def convert_org_to_md()
|
37
74
|
command = "emacs #{@src} --batch -l #{@ox_qmd_load_path} -f org-qmd-export-to-markdown --kill"
|
@@ -153,12 +190,24 @@ class QiitaPost
|
|
153
190
|
#end
|
154
191
|
end
|
155
192
|
|
156
|
-
# add qiita_id on src.org
|
193
|
+
# add qiita_id on src.org, and add tags
|
157
194
|
def add_qiita_id_on_org()
|
158
195
|
@qiita_id = @res_body["id"]
|
159
196
|
unless @patch
|
160
197
|
File.write(@src, "#+qiita_#{@option}: #{@qiita_id}\n" + @conts)
|
161
198
|
end
|
199
|
+
new_tags = []
|
200
|
+
@res_body["tags"].each do |tag|
|
201
|
+
new_tags << tag["name"]
|
202
|
+
end
|
203
|
+
new_lines = File.readlines(@src)
|
204
|
+
new_lines.each_with_index do |line, i|
|
205
|
+
if line.match(/\#\+(TAG|tag|Tag|tags|TAGS|Tags): (.+)/)
|
206
|
+
new_lines[i] = "#+TAG: #{new_tags.join(", ")}\n"
|
207
|
+
break
|
208
|
+
end
|
209
|
+
end
|
210
|
+
File.write(@src, new_lines.join)
|
162
211
|
end
|
163
212
|
|
164
213
|
def run()
|
data/lib/qiita_org/version.rb
CHANGED
data/tests/tags_test.org
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#+qiita_private: e58d6513b42c9e1f3eb6
|
2
|
+
#+OPTIONS: ^:{}
|
3
|
+
#+STARTUP: indent nolineimages
|
4
|
+
#+TITLE: title
|
5
|
+
#+AUTHOR: Kenta Yamamoto
|
6
|
+
#+EMAIL: (concat "doi35077@kwansei.ac.jp")
|
7
|
+
#+LANGUAGE: jp
|
8
|
+
# +OPTIONS: H:4 toc:t num:2
|
9
|
+
#+OPTIONS: toc:nil
|
10
|
+
#+TAG: Qiita, Ruby
|
11
|
+
#+TWITTER: off
|
12
|
+
# +SETUPFILE: ~/.emacs.d/org-mode/theme-readtheorg.setup
|
13
|
+
|
14
|
+
![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)
|
15
|
+
|
16
|
+
hogehoge
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#+qiita_private: e58d6513b42c9e1f3eb6
|
2
|
+
#+OPTIONS: ^:{}
|
3
|
+
#+STARTUP: indent nolineimages
|
4
|
+
#+TITLE: title
|
5
|
+
#+AUTHOR: Kenta Yamamoto
|
6
|
+
#+EMAIL: (concat "doi35077@kwansei.ac.jp")
|
7
|
+
#+LANGUAGE: jp
|
8
|
+
# +OPTIONS: H:4 toc:t num:2
|
9
|
+
#+OPTIONS: toc:nil
|
10
|
+
#+TAG: hoge2
|
11
|
+
#+TWITTER: off
|
12
|
+
# +SETUPFILE: ~/.emacs.d/org-mode/theme-readtheorg.setup
|
13
|
+
|
14
|
+
![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)
|
15
|
+
|
16
|
+
hogehoge
|
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.
|
4
|
+
version: 0.1.39
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenta Yamamoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -151,6 +151,8 @@ files:
|
|
151
151
|
- lib/qiita_org/version.rb
|
152
152
|
- qiita_org.gemspec
|
153
153
|
- tests/hoge.rb
|
154
|
+
- tests/tags_test.org
|
155
|
+
- tests/tags_test2.org
|
154
156
|
- tests/test.html
|
155
157
|
- tests/test.org
|
156
158
|
- tests/test2.org
|