qiita_org 0.1.23 → 0.1.28
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 +4 -4
- data/.gitignore +4 -0
- data/.yardopts +4 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +40 -1
- data/lib/qiita_org.rb +28 -22
- 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/error_message.rb +8 -4
- data/lib/qiita_org/get.rb +6 -6
- data/lib/qiita_org/get_file_url.rb +1 -1
- data/lib/qiita_org/get_multiple_files.rb +38 -0
- data/lib/qiita_org/list.rb +2 -2
- data/lib/qiita_org/post.rb +13 -3
- data/lib/qiita_org/select_path.rb +2 -2
- data/lib/qiita_org/set_config.rb +2 -1
- data/lib/qiita_org/show_file_and_url.rb +1 -1
- 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 -0
- data/tests/test2.org +2 -2
- data/tests/test3.org +2 -1
- data/tests/test4.org +2 -1
- data/tests/twitter_test.org +14 -0
- metadata +1605 -3
- data/tests/test2.md +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74ddc5ddc92c8e9414041e6bc9b84b7d96eccf5cc7adba92101440bf70472d65
|
4
|
+
data.tar.gz: fb223cc7d3dbbe232067a5f38dcca6d1f953064972f60307ba206b2fdccf8962
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4dff3873fccd45d6ee707679bb0204076b402183d59b1f4c9d40bb05fe1a27d1d50b04299ff00bf5ce9461aea560426e508ba7ba291aa80cdb548a5d2c0b494
|
7
|
+
data.tar.gz: 72896ad25f227b1cbc0992518a3173b0e2d64ee684be3d2f06db83278ba871abee3331fcd30923a88d4aa6114be93484e6f9dbe096bd5c4e9abfb69db6c1e05e
|
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.27)
|
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,12 +7,14 @@ 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"
|
13
14
|
require "qiita_org/get_file_path"
|
14
15
|
require "qiita_org/show_file_and_url"
|
15
16
|
require "qiita_org/decide_option"
|
17
|
+
require "qiita_org/get_multiple_files"
|
16
18
|
#require "qiita_org/qiita_org_thor"
|
17
19
|
|
18
20
|
module QiitaOrg
|
@@ -38,16 +40,22 @@ module QiitaOrg
|
|
38
40
|
checkos = CheckPcOs.new
|
39
41
|
os = checkos.return_os()
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
begin
|
46
|
-
qiita.select_option(mode)
|
47
|
-
rescue RuntimeError => e
|
48
|
-
puts $!
|
43
|
+
if argv.size > 2
|
44
|
+
GetMultipleFiles.new(argv, os, "post").run()
|
45
|
+
elsif argv[-1].match(/(.+).org/) && argv.size != 1
|
46
|
+
GetMultipleFiles.new(argv, os, "post").run()
|
49
47
|
else
|
50
|
-
|
48
|
+
p ["in qiita_org.rb", argv]
|
49
|
+
p file = argv[0] || "README.org"
|
50
|
+
p mode = argv[1] || DecideOption.new(file).decide_option()
|
51
|
+
qiita = QiitaPost.new(file, mode, os)
|
52
|
+
begin
|
53
|
+
qiita.select_option(mode)
|
54
|
+
rescue RuntimeError => e
|
55
|
+
puts $!
|
56
|
+
else
|
57
|
+
qiita.run
|
58
|
+
end
|
51
59
|
end
|
52
60
|
end
|
53
61
|
|
@@ -57,10 +65,16 @@ module QiitaOrg
|
|
57
65
|
checkos = CheckPcOs.new
|
58
66
|
os = checkos.return_os()
|
59
67
|
|
60
|
-
|
61
|
-
|
68
|
+
if argv.size > 2
|
69
|
+
GetMultipleFiles.new(argv, os, "upload").run()
|
70
|
+
elsif argv[-1].match(/(.+).org/) && argv.size != 1
|
71
|
+
GetMultipleFiles.new(argv, os, "upload").run()
|
72
|
+
else
|
73
|
+
p file = argv[0] || "README.org"
|
74
|
+
p mode = argv[1] || DecideOption.new(file).decide_option()
|
62
75
|
|
63
|
-
|
76
|
+
qiita = QiitaUpLoad.new(file, mode, os).upload()
|
77
|
+
end
|
64
78
|
=begin
|
65
79
|
getpath = GetFilePath.new(file)
|
66
80
|
paths = getpath.get_file_path()
|
@@ -110,16 +124,8 @@ module QiitaOrg
|
|
110
124
|
desc "all", "post all org files in the directory"
|
111
125
|
|
112
126
|
def all(*argv)
|
113
|
-
|
114
|
-
|
115
|
-
if File.read(org).match(/#\+qiita_(.+)/)
|
116
|
-
system ("qiita post #{org} open") if File.read(org).match(/#\+(.+)_public/)
|
117
|
-
system ("qiita post #{org} teams") if File.read(org).match(/#\+(.+)_teams/)
|
118
|
-
system ("qiita post #{org} private") if File.read(org).match(/#\+(.+)_private/)
|
119
|
-
else
|
120
|
-
system ("qiita post #{org}")
|
121
|
-
end
|
122
|
-
end
|
127
|
+
mode = argv[0] || false
|
128
|
+
QiitaAll.new(mode).run()
|
123
129
|
end
|
124
130
|
|
125
131
|
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
@@ -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
|
-
|
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
|
-
|
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))
|
data/lib/qiita_org/get.rb
CHANGED
@@ -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: #{
|
130
|
+
puts "URL: #{item["url"]}"
|
131
131
|
system "rm -f #{@id}.md"
|
132
132
|
end
|
133
133
|
|
@@ -155,17 +155,17 @@ 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()
|
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
|
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
|
@@ -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
|
@@ -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
|
data/lib/qiita_org/list.rb
CHANGED
@@ -10,12 +10,12 @@ 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
|
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
|
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
|
@@ -110,7 +116,7 @@ class QiitaPost
|
|
110
116
|
res = http_req.post(uri.path, params.to_json, headers)
|
111
117
|
end
|
112
118
|
|
113
|
-
ErrorMessage.new().qiita_post_error(res)
|
119
|
+
ErrorMessage.new().qiita_post_error(res, @src.gsub(".org", ".md"))
|
114
120
|
|
115
121
|
return res
|
116
122
|
end
|
@@ -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
|
|