qiita_org 0.1.27 → 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 +2 -0
- data/Gemfile.lock +1 -1
- data/lib/qiita_org.rb +2 -2
- data/lib/qiita_org/all.rb +1 -1
- 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 +1 -12
- data/lib/qiita_org/upload.rb +75 -3
- data/lib/qiita_org/version.rb +1 -1
- metadata +2 -2
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/Gemfile.lock
CHANGED
data/lib/qiita_org.rb
CHANGED
@@ -73,7 +73,7 @@ module QiitaOrg
|
|
73
73
|
p file = argv[0] || "README.org"
|
74
74
|
p mode = argv[1] || DecideOption.new(file).decide_option()
|
75
75
|
|
76
|
-
qiita =
|
76
|
+
qiita = QiitaUpLoad.new(file, mode, os).upload()
|
77
77
|
end
|
78
78
|
=begin
|
79
79
|
getpath = GetFilePath.new(file)
|
@@ -125,7 +125,7 @@ module QiitaOrg
|
|
125
125
|
|
126
126
|
def all(*argv)
|
127
127
|
mode = argv[0] || false
|
128
|
-
|
128
|
+
QiitaAll.new(mode).run()
|
129
129
|
end
|
130
130
|
|
131
131
|
desc "list [qiita/teams]", "view qiita report list"
|
data/lib/qiita_org/all.rb
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
@@ -66,18 +66,7 @@ class QiitaPost
|
|
66
66
|
|
67
67
|
# check twitter post
|
68
68
|
def select_twitter(conts, option)
|
69
|
-
|
70
|
-
twitter = false
|
71
|
-
if option == "public"
|
72
|
-
m = conts.match(/\#\+(twitter|Twitter|TWITTER): (.+)/)
|
73
|
-
if m[2] == 'on' || m[2] == 'On' || m[2] == 'ON'
|
74
|
-
twitter = true
|
75
|
-
else
|
76
|
-
twitter = false
|
77
|
-
end
|
78
|
-
end
|
79
|
-
twitter
|
80
|
-
return twitter
|
69
|
+
option == "public" && conts.match?(/^\#\+twitter:\s*on$/i)
|
81
70
|
end
|
82
71
|
|
83
72
|
def select_option(option)
|
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
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.28
|
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
|
+
date: 2020-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|