qiita_org 0.1.24 → 0.1.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.yardopts +4 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +40 -1
- data/lib/qiita_org.rb +7 -12
- data/lib/qiita_org/.qiita.conf +1 -0
- data/lib/qiita_org/all.rb +31 -0
- data/lib/qiita_org/config.json +1 -0
- data/lib/qiita_org/get.rb +1 -1
- data/lib/qiita_org/get_file_url.rb +1 -1
- data/lib/qiita_org/list.rb +1 -1
- data/lib/qiita_org/post.rb +12 -2
- data/lib/qiita_org/set_config.rb +2 -1
- data/lib/qiita_org/show_file_and_url.rb +3 -2
- data/lib/qiita_org/template.org +1 -0
- data/lib/qiita_org/upload.rb +75 -3
- data/lib/qiita_org/version.rb +1 -1
- data/tests/template.org +13 -0
- data/tests/test.org +1 -1
- data/tests/test2.org +1 -0
- data/tests/test3.org +1 -0
- data/tests/test4.org +1 -0
- data/tests/twitter_test.org +14 -0
- metadata +1604 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c58fb11dfd57ea6232e6e98e928d8d27f794f6f6ad87ecdf1fdcffb2ce1a6dbf
|
4
|
+
data.tar.gz: 1b882620532dfbc2f74e3ce758f9ff4b73bac938454c534918a927a1f66ec08a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 778ca2f40420b1436bdc851602b5a7ba97ec6f22e7e8ea5992779e18d793e7ac9070615e02e0dd67411a09ce7768d9be0992738808918e497ee472bc9de1fdfb
|
7
|
+
data.tar.gz: e847a505b58de91a61004d8a00bae41689c1197ba4d6b317717eb84a81f1a3afe899bab7e92954ffaca92414612794df68c74de721662c52be673112e58a8759
|
data/.gitignore
CHANGED
data/.yardopts
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
qiita_org (0.1.
|
4
|
+
qiita_org (0.1.28)
|
5
5
|
colorize
|
6
6
|
command_line (> 2.0.0)
|
7
7
|
fileutils
|
@@ -10,11 +10,42 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
+
coderay (1.1.3)
|
13
14
|
colorize (0.8.1)
|
14
15
|
command_line (2.0.1)
|
15
16
|
diff-lcs (1.4.4)
|
17
|
+
ffi (1.13.1)
|
16
18
|
fileutils (1.4.1)
|
19
|
+
formatador (0.2.5)
|
20
|
+
guard (2.16.2)
|
21
|
+
formatador (>= 0.2.4)
|
22
|
+
listen (>= 2.7, < 4.0)
|
23
|
+
lumberjack (>= 1.0.12, < 2.0)
|
24
|
+
nenv (~> 0.1)
|
25
|
+
notiffany (~> 0.0)
|
26
|
+
pry (>= 0.9.12)
|
27
|
+
shellany (~> 0.0)
|
28
|
+
thor (>= 0.18.1)
|
29
|
+
guard-yard (2.2.1)
|
30
|
+
guard (>= 1.1.0)
|
31
|
+
yard (>= 0.7.0)
|
32
|
+
listen (3.3.1)
|
33
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
34
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
35
|
+
lumberjack (1.2.8)
|
36
|
+
method_source (1.0.0)
|
37
|
+
nenv (0.3.0)
|
38
|
+
notiffany (0.1.3)
|
39
|
+
nenv (~> 0.1)
|
40
|
+
shellany (~> 0.0)
|
41
|
+
pry (0.13.1)
|
42
|
+
coderay (~> 1.1)
|
43
|
+
method_source (~> 1.0)
|
17
44
|
rake (12.3.3)
|
45
|
+
rb-fsevent (0.10.4)
|
46
|
+
rb-inotify (0.10.1)
|
47
|
+
ffi (~> 1.0)
|
48
|
+
redcarpet (3.5.0)
|
18
49
|
rspec (3.9.0)
|
19
50
|
rspec-core (~> 3.9.0)
|
20
51
|
rspec-expectations (~> 3.9.0)
|
@@ -28,16 +59,24 @@ GEM
|
|
28
59
|
diff-lcs (>= 1.2.0, < 2.0)
|
29
60
|
rspec-support (~> 3.9.0)
|
30
61
|
rspec-support (3.9.3)
|
62
|
+
shellany (0.0.1)
|
31
63
|
thor (1.0.1)
|
64
|
+
yard (0.9.25)
|
65
|
+
yard-activesupport-concern (0.0.1)
|
66
|
+
yard (>= 0.8)
|
32
67
|
|
33
68
|
PLATFORMS
|
34
69
|
ruby
|
35
70
|
|
36
71
|
DEPENDENCIES
|
37
72
|
bundler (> 1.16)
|
73
|
+
guard-yard
|
38
74
|
qiita_org!
|
39
75
|
rake (~> 12.0)
|
76
|
+
redcarpet
|
40
77
|
rspec (~> 3.0)
|
78
|
+
yard
|
79
|
+
yard-activesupport-concern
|
41
80
|
|
42
81
|
BUNDLED WITH
|
43
82
|
2.1.4
|
data/lib/qiita_org.rb
CHANGED
@@ -7,6 +7,7 @@ require "qiita_org/post"
|
|
7
7
|
require "qiita_org/config"
|
8
8
|
require "qiita_org/get"
|
9
9
|
require "qiita_org/list"
|
10
|
+
require "qiita_org/all"
|
10
11
|
require "qiita_org/get_template"
|
11
12
|
require "qiita_org/check_pc_os"
|
12
13
|
require "qiita_org/upload"
|
@@ -72,7 +73,7 @@ module QiitaOrg
|
|
72
73
|
p file = argv[0] || "README.org"
|
73
74
|
p mode = argv[1] || DecideOption.new(file).decide_option()
|
74
75
|
|
75
|
-
qiita =
|
76
|
+
qiita = QiitaUpLoad.new(file, mode, os).upload()
|
76
77
|
end
|
77
78
|
=begin
|
78
79
|
getpath = GetFilePath.new(file)
|
@@ -121,18 +122,12 @@ module QiitaOrg
|
|
121
122
|
end
|
122
123
|
|
123
124
|
desc "all", "post all org files in the directory"
|
124
|
-
|
125
|
+
method_options hoge: :string
|
125
126
|
def all(*argv)
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
system ("qiita post #{org} teams") if File.read(org).match(/#\+(.+)_teams/)
|
131
|
-
system ("qiita post #{org} private") if File.read(org).match(/#\+(.+)_private/)
|
132
|
-
else
|
133
|
-
system ("qiita post #{org}")
|
134
|
-
end
|
135
|
-
end
|
127
|
+
mode = argv[0] || false
|
128
|
+
# p [argv[0], argv[1]]
|
129
|
+
puts options[:hoge]
|
130
|
+
QiitaAll.new(mode).run()
|
136
131
|
end
|
137
132
|
|
138
133
|
desc "list [qiita/teams]", "view qiita report list"
|
data/lib/qiita_org/.qiita.conf
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "colorize"
|
2
|
+
|
3
|
+
class QiitaAll
|
4
|
+
def initialize(mode)
|
5
|
+
@mode = mode
|
6
|
+
@files = Dir.glob("*.org")
|
7
|
+
p @files
|
8
|
+
end
|
9
|
+
|
10
|
+
def run()
|
11
|
+
@files.each do |file|
|
12
|
+
if file == "template.org"
|
13
|
+
next
|
14
|
+
end
|
15
|
+
|
16
|
+
unless @mode
|
17
|
+
puts file.blue
|
18
|
+
if File.read(file).match(/#\+qiita_(.+)/)
|
19
|
+
system ("qiita post #{file} open") if File.read(file).match(/#\+(.+)_public/)
|
20
|
+
system ("qiita post #{file} teams") if File.read(file).match(/#\+(.+)_teams/)
|
21
|
+
system ("qiita post #{file} private") if File.read(file).match(/#\+(.+)_private/)
|
22
|
+
else
|
23
|
+
system ("qiita post #{file}")
|
24
|
+
end
|
25
|
+
else
|
26
|
+
puts "qiita post #{file} #{@mode}".blue
|
27
|
+
system "qiita post #{file} #{@mode}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/qiita_org/config.json
CHANGED
data/lib/qiita_org/get.rb
CHANGED
@@ -159,7 +159,7 @@ EOS
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def run()
|
162
|
-
@access_token, @teams_url, @ox_qmd_load_path = SetConfig.new().set_config()
|
162
|
+
@access_token, @teams_url, @display, @ox_qmd_load_path = SetConfig.new().set_config()
|
163
163
|
if @mode == "teams"
|
164
164
|
ErrorMessage.new().teams_url_error(@teams_url)
|
165
165
|
end
|
@@ -12,7 +12,7 @@ class GetFileUrl
|
|
12
12
|
@id = id
|
13
13
|
@file = file
|
14
14
|
@mode = (mode == "qiita" || mode == "open")? "public" : mode
|
15
|
-
@access_token, @teams_url, @ox_qmd_load_path = SetConfig.new().set_config()
|
15
|
+
@access_token, @teams_url, @display, @ox_qmd_load_path = SetConfig.new().set_config()
|
16
16
|
if @mode == "teams"
|
17
17
|
ErrorMessage.new().teams_url_error(@teams_url)
|
18
18
|
end
|
data/lib/qiita_org/list.rb
CHANGED
@@ -10,7 +10,7 @@ require "qiita_org/access_qiita.rb"
|
|
10
10
|
class QiitaList
|
11
11
|
def initialize(mode)
|
12
12
|
@mode = mode
|
13
|
-
@access_token, @teams_url, @ox_qmd_load_path = SetConfig.new().set_config()
|
13
|
+
@access_token, @teams_url, @display, @ox_qmd_load_path = SetConfig.new().set_config()
|
14
14
|
if @mode == "teams"
|
15
15
|
ErrorMessage.new().teams_url_error(@teams_url)
|
16
16
|
end
|
data/lib/qiita_org/post.rb
CHANGED
@@ -64,6 +64,11 @@ class QiitaPost
|
|
64
64
|
return qiita_id, patch
|
65
65
|
end
|
66
66
|
|
67
|
+
# check twitter post
|
68
|
+
def select_twitter(conts, option)
|
69
|
+
option == "public" && conts.match?(/^\#\+twitter:\s*on$/i)
|
70
|
+
end
|
71
|
+
|
67
72
|
def select_option(option)
|
68
73
|
qiita = (option == "teams")? @teams_url : "https://qiita.com/"
|
69
74
|
#qiita = (option == "teams")? "https://nishitani.qiita.com/" :
|
@@ -86,6 +91,7 @@ class QiitaPost
|
|
86
91
|
"private": @private,
|
87
92
|
"title": @title,
|
88
93
|
"tags": @tags,
|
94
|
+
"tweet": @twitter,
|
89
95
|
}
|
90
96
|
|
91
97
|
if @patch
|
@@ -127,6 +133,9 @@ class QiitaPost
|
|
127
133
|
end
|
128
134
|
print "%20s %s\n" % [key, cont]
|
129
135
|
end
|
136
|
+
#if @display == "suppress"
|
137
|
+
# puts @res_body["url"].green
|
138
|
+
#end
|
130
139
|
end
|
131
140
|
|
132
141
|
# add qiita_id on src.org
|
@@ -154,7 +163,7 @@ class QiitaPost
|
|
154
163
|
def run()
|
155
164
|
@conts = File.read(@src)
|
156
165
|
@title, @tags = get_title_tags(@conts)
|
157
|
-
@access_token, @teams_url, @ox_qmd_load_path = SetConfig.new().set_config()
|
166
|
+
@access_token, @teams_url, @display, @ox_qmd_load_path = SetConfig.new().set_config()
|
158
167
|
|
159
168
|
if @option == "teams"
|
160
169
|
ErrorMessage.new().teams_url_error(@teams_url)
|
@@ -164,12 +173,13 @@ class QiitaPost
|
|
164
173
|
add_source_path_in_md()
|
165
174
|
@lines = MdConverter.new().convert_for_image(@lines)
|
166
175
|
@qiita_id, @patch = select_patch_or_post(@conts, @option)
|
176
|
+
@twitter = select_twitter(@conts, @option)
|
167
177
|
@qiita, @private = select_option(@option)
|
168
178
|
@res = qiita_post()
|
169
179
|
get_and_print_qiita_return()
|
170
180
|
|
171
181
|
#open_qiita()
|
172
|
-
FileOpen.new(@os).file_open(@res_body["url"])
|
182
|
+
FileOpen.new(@os).file_open(@res_body["url"]) if @display != "suppress"
|
173
183
|
|
174
184
|
add_qiita_id_on_org()
|
175
185
|
|
data/lib/qiita_org/set_config.rb
CHANGED
@@ -18,12 +18,13 @@ class SetConfig
|
|
18
18
|
conf = JSON.load(File.read(conf_path))
|
19
19
|
access_token = conf["access_token"]
|
20
20
|
teams_url = conf["teams_url"]
|
21
|
+
display = conf["display"]
|
21
22
|
ox_qmd_load_path = File.join(@lib, "qiita_org", "ox-qmd", "ox-qmd")
|
22
23
|
|
23
24
|
ErrorMessage.new().access_token_error(access_token) #== false
|
24
25
|
# puts "Please setting ACCESS_TOKEN".red
|
25
26
|
# exit
|
26
27
|
|
27
|
-
return access_token, teams_url, ox_qmd_load_path
|
28
|
+
return access_token, teams_url, display, ox_qmd_load_path
|
28
29
|
end
|
29
30
|
end
|
@@ -3,6 +3,7 @@ require "qiita_org/get_file_url.rb"
|
|
3
3
|
require "qiita_org/set_config.rb"
|
4
4
|
require "qiita_org/access_qiita.rb"
|
5
5
|
require "qiita_org/file_open.rb"
|
6
|
+
require "qiita_org/error_message.rb"
|
6
7
|
|
7
8
|
class ShowFile
|
8
9
|
def initialize(paths, src, mode, os)
|
@@ -50,9 +51,9 @@ class ShowFile
|
|
50
51
|
conts = File.read(@src)
|
51
52
|
id = conts.match(/\#\+qiita_#{@mode}: (.+)/)[1]
|
52
53
|
|
53
|
-
@access_token, @teams_url, @ox_qmd_load_path = SetConfig.new().set_config()
|
54
|
+
@access_token, @teams_url, @display, @ox_qmd_load_path = SetConfig.new().set_config()
|
54
55
|
if @mode == "teams"
|
55
|
-
|
56
|
+
ErrorMessage.new().teams_url_error(@teams_url)
|
56
57
|
end
|
57
58
|
|
58
59
|
qiita = (@mode == "teams") ? @teams_url : "https://qiita.com/"
|
data/lib/qiita_org/template.org
CHANGED
data/lib/qiita_org/upload.rb
CHANGED
@@ -2,20 +2,25 @@ require "colorize"
|
|
2
2
|
require "io/console"
|
3
3
|
require "qiita_org/get_file_path.rb"
|
4
4
|
require "qiita_org/show_file_and_url.rb"
|
5
|
+
require "qiita_org/file_open.rb"
|
6
|
+
require "qiita_org/set_config.rb"
|
7
|
+
require "qiita_org/access_qiita.rb"
|
5
8
|
|
6
|
-
class
|
9
|
+
class QiitaUpLoad
|
7
10
|
def initialize(src, option, os)
|
8
11
|
@src = src
|
9
12
|
@option = (option == "qiita" || option == "open")? "public" : option
|
10
13
|
@os = os
|
14
|
+
@fileopen = FileOpen.new(@os)
|
11
15
|
end
|
12
16
|
|
13
17
|
def upload()
|
14
18
|
paths = GetFilePath.new(@src).get_file_path()
|
19
|
+
#paths = get_file_path(@src)
|
15
20
|
unless paths.empty?
|
16
21
|
showfile = ShowFile.new(paths, @src, @option, @os)
|
17
|
-
showfile.open_file_dir()
|
18
|
-
showfile.open_qiita()
|
22
|
+
showfile.open_file_dir() #open_file_dir(paths)
|
23
|
+
showfile.open_qiita() #open_qiita()
|
19
24
|
|
20
25
|
puts "Overwrite file URL's on #{@src}? (y/n)".green
|
21
26
|
ans = STDIN.getch
|
@@ -23,6 +28,73 @@ class UpLoad
|
|
23
28
|
if ans == "y"
|
24
29
|
showfile.input_url_to_org()
|
25
30
|
end
|
31
|
+
else
|
32
|
+
puts "file path is empty.".red
|
26
33
|
end
|
27
34
|
end
|
35
|
+
|
36
|
+
def get_file_path(src)
|
37
|
+
lines = File.readlines(src)
|
38
|
+
files = []
|
39
|
+
lines.each do |line|
|
40
|
+
if path = line.match(/\[\[(.+)\]\[file:(.+)\]\]/) || line.match(/\[\[file:(.+)\]\]/)
|
41
|
+
if path[2] == nil
|
42
|
+
files << path[1]
|
43
|
+
else
|
44
|
+
files << path[2]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
return files
|
50
|
+
end
|
51
|
+
|
52
|
+
def open_file_dir(paths)
|
53
|
+
previous_paths = []
|
54
|
+
previous_paths << File.join(paths[0].split("/")[0..-2])
|
55
|
+
@fileopen.file_open(File.join(paths[0].split("/")[0..-2]))
|
56
|
+
|
57
|
+
paths.each do |path|
|
58
|
+
dir_path = File.join(path.split("/")[0..-2])
|
59
|
+
unless previous_paths.include?(dir_path)
|
60
|
+
previous_paths << dir_path
|
61
|
+
@fileopen.file_open(dir_path)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def open_qiita()
|
67
|
+
conts = File.read(@src)
|
68
|
+
id = conts.match(/\#\+qiita_#{option}: (.+)/)[1]
|
69
|
+
|
70
|
+
@access_token, @teams_url, @display, @ox_qmd_load_path = SetConfig.new().set_config()
|
71
|
+
if @option == "teams"
|
72
|
+
ErrorMassage.new().teams_url_error(@teams_url)
|
73
|
+
end
|
74
|
+
|
75
|
+
qiita = (@option == "teams") ? @teams_url : "https://qiita.com/"
|
76
|
+
path = "api/v2/items/#{id}"
|
77
|
+
|
78
|
+
items = AccessQiita.new(@access_token, qiita, path).access_qiita()
|
79
|
+
|
80
|
+
@fileopen.file_open(items["url"])
|
81
|
+
end
|
82
|
+
|
83
|
+
def input_url_to_org(paths)
|
84
|
+
lines = File.readlines(@src)
|
85
|
+
conts = File.read(@src)
|
86
|
+
id = conts.match(/\#\+qiita_#{@option}: (.+)/)[1]
|
87
|
+
|
88
|
+
paths.each do |path|
|
89
|
+
file_name = File.basename(path).strip
|
90
|
+
url = get_file_url(id, file_name)
|
91
|
+
lines.each_with_index do |line, i|
|
92
|
+
if line.match(/\[\[file:#{path}\]\]/)
|
93
|
+
lines[i] = "[[#{url}][file:#{path}]]\n"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
File.write(@src, lines.join)
|
99
|
+
end
|
28
100
|
end
|
data/lib/qiita_org/version.rb
CHANGED
data/tests/template.org
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#+OPTIONS: ^:{}
|
2
|
+
#+STARTUP: indent nolineimages
|
3
|
+
#+TITLE: title
|
4
|
+
#+AUTHOR: Kenta Yamamoto
|
5
|
+
#+EMAIL: (concat "doi35077@kwansei.ac.jp")
|
6
|
+
#+LANGUAGE: jp
|
7
|
+
# +OPTIONS: H:4 toc:t num:2
|
8
|
+
#+OPTIONS: toc:nil
|
9
|
+
#+TAG: tag1, tag2
|
10
|
+
#+TWITTER: off
|
11
|
+
# +SETUPFILE: ~/.emacs.d/org-mode/theme-readtheorg.setup
|
12
|
+
|
13
|
+
![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)
|