qiita_org 0.1.9 → 0.1.14

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: 9e7a075ad1c16002e53fff794d556f9ce5bb2c6e7d5e37768a37a8deb59f28e9
4
- data.tar.gz: aad3df025127c3e87d3ccb71a262f28083904d63b12e7371cea4c80cf68ecdf1
3
+ metadata.gz: 02b35bf78555392cac08a4abe942e9d9bdaa25949e1df55a0461f385eaec21bb
4
+ data.tar.gz: afcdc3a3742b2c0e96ea083e282e95d10f0ebb0fd20f436b65dc53fb03819f77
5
5
  SHA512:
6
- metadata.gz: c4e4645899b5b8ef3cf84b4203b911d3cdc3da1cf3f58d67cc1ca8d64b06f95ada184fe7491102c69fd9d75da91346db01f734ad384fcbac492a9169d81238cf
7
- data.tar.gz: 72dcab368ce64937c26ed77e89d25face880d71cff3ac9ff5e2797dcdb78023d4d5e6be1a747813426a3851ad6f2a9b9edd7d3bffa9bd4156e8962763b039a48
6
+ metadata.gz: 6487eb7e630bdcdd8c6e5ec06a141d19da9134563a10019389a19e3cdf96a3813d69719745826c440bb4e052e5c9782b4d11912ebd852749cb69dc451db10e1e
7
+ data.tar.gz: c39fa5ef1c4ddc9ef166ca1fdb7d0925ad41f2ba70f16aa788037dd2a4f00552f3371549ee37418274aee08964770592c5bbed70ca28704902e71d154823cbfe
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qiita_org (0.1.8)
4
+ qiita_org (0.1.13)
5
5
  colorize
6
6
  command_line (> 2.0.0)
7
7
  fileutils
@@ -6,6 +6,7 @@ require "qiita_org/config"
6
6
  require "qiita_org/get"
7
7
  require "qiita_org/list"
8
8
  require "qiita_org/get_template"
9
+ require "qiita_org/check_pc_os"
9
10
  #require "qiita_org/qiita_org_thor"
10
11
 
11
12
  module QiitaOrg
@@ -14,6 +15,12 @@ module QiitaOrg
14
15
  # super(*argv)
15
16
  # end
16
17
  #
18
+ def initialize(*argv)
19
+ super(*argv)
20
+ checkos = CheckPcOs.new
21
+ @os = checkos.return_os()
22
+ end
23
+
17
24
  desc "say_hello", "say_hello"
18
25
 
19
26
  def say_hello(*name)
@@ -27,7 +34,7 @@ module QiitaOrg
27
34
  p ["in qiita_org.rb", argv]
28
35
  p file = argv[0] || "README.org"
29
36
  p mode = argv[1] || "private"
30
- qiita = QiitaPost.new(file, mode)
37
+ qiita = QiitaPost.new(file, mode, @os)
31
38
  begin
32
39
  qiita.select_option(mode)
33
40
  rescue RuntimeError => e
@@ -59,7 +66,7 @@ module QiitaOrg
59
66
  desc "template", "make template.org"
60
67
 
61
68
  def template(*argv)
62
- template = QiitaGetTemplate.new()
69
+ template = QiitaGetTemplate.new(@os)
63
70
  end
64
71
 
65
72
  desc "all", "post all org file in the directory"
@@ -0,0 +1,19 @@
1
+ class CheckPcOs
2
+ def initialize()
3
+ @macos = system "sw_vers"
4
+ @winos = system "wmic.exe os get caption"
5
+ end
6
+
7
+ def return_os()
8
+ if @macos
9
+ return os = "mac"
10
+ elsif @winos
11
+ return os = "windows"
12
+ else
13
+ return nil
14
+ end
15
+ end
16
+ end
17
+
18
+ #p os = CheckPcOs.new.return_os()
19
+
@@ -9,7 +9,7 @@ class QiitaConfig
9
9
  if status == "local"
10
10
  search = SearchConfPath.new(Dir.pwd, Dir.home)
11
11
  conf_dir = search.search_conf_path()
12
- if conf_dir == Dir.home || @option == "set"
12
+ if @option == "set"
13
13
  @setup = File.join(Dir.pwd, ".qiita.conf")
14
14
  else
15
15
  @setup = File.join(conf_dir, ".qiita.conf")
@@ -1,9 +1,11 @@
1
1
  require "fileutils"
2
2
  require "colorize"
3
+ require "kconv"
3
4
  require "qiita_org/search_conf_path"
4
5
 
5
6
  class QiitaGetTemplate
6
- def initialize()
7
+ def initialize(os)
8
+ @os = os
7
9
  cp_template()
8
10
  search = SearchConfPath.new(Dir.pwd, Dir.home)
9
11
  @conf_dir = search.search_conf_path()
@@ -23,6 +25,32 @@ class QiitaGetTemplate
23
25
  File.write("template.org", conts) # + "# {m[1]}: # {m[2]}\n")
24
26
  end
25
27
 
28
+ def get_windowsos_version()
29
+ system 'wmic.exe os get caption > hoge1.txt'
30
+ system 'wmic.exe os get osarchitecture > hoge2.txt'
31
+ version1 = Kconv.tosjis(File.read("hoge1.txt"))
32
+ version2 = Kconv.tosjis(File.read("hoge2.txt"))
33
+ m1, m2 = [], []
34
+ m1 = version1.match(/Caption\nMicrosoft (.+) (.+)/)
35
+ m2 = version2.match(/OSArchitecture\n(.+)-bit/)
36
+ system 'rm hoge1.txt'
37
+ system 'rm hoge2.txt'
38
+ conts = File.read("template.org")
39
+ conts << "![#{m1[1]}-#{m1[2]}](https://img.shields.io/badge/#{m1[1].gsub(" ", "")}#{m1[2]}-#{m2[1]}bit-brightgreen) "
40
+ File.write("template.org", conts) # + "# {m[1]}: # {m[2]}\n")
41
+ end
42
+
43
+ def get_ubuntu_version()
44
+ system 'cat /etc/issue > hoge.txt'
45
+ version = File.read("hoge.txt")
46
+ m = []
47
+ m = version.match(/(.+) (.+) LTS /)
48
+ system 'rm hoge.txt'
49
+ conts = File.read("template.org")
50
+ conts << "![#{m[1]}-#{m[2]}](https://img.shields.io/badge/#{m[1]}-#{m[2]}-brightgreen) "
51
+ File.write("template.org", conts)
52
+ end
53
+
26
54
  def get_ruby_version()
27
55
  system 'ruby --version > hoge.txt'
28
56
  version = File.read("hoge.txt")
@@ -48,12 +76,32 @@ class QiitaGetTemplate
48
76
  end
49
77
 
50
78
  def check_write_contents()
51
- ["MacOS", "ruby"].each do |src|
52
- print "Write #{src} version?(y/n) "
53
- ans = STDIN.gets.chomp
54
- next if ans == "n"
55
- if ans == "y"
56
- send("get_#{src.downcase}_version")
79
+ if @os == "mac"
80
+ ["MacOS", "ruby"].each do |src|
81
+ print "Write #{src} version?(y/n) "
82
+ ans = STDIN.gets.chomp
83
+ next if ans == "n"
84
+ if ans == "y"
85
+ send("get_#{src.downcase}_version")
86
+ end
87
+ end
88
+ elsif @os == "windows"
89
+ ["Ubuntu", "ruby"].each do |src|
90
+ print "Write #{src} version?(y/n) "
91
+ ans = STDIN.gets.chomp
92
+ next if ans == "n"
93
+ if ans == "y"
94
+ send("get_#{src.downcase}_version")
95
+ end
96
+ end
97
+ else
98
+ ["ruby"].each do |src|
99
+ print "Write #{src} version?(y/n) "
100
+ ans = STDIN.gets.chomp
101
+ next if ans == "n"
102
+ if ans == "y"
103
+ send("get_#{src.downcase}_version")
104
+ end
57
105
  end
58
106
  end
59
107
  end
@@ -7,9 +7,10 @@ require "colorize"
7
7
  require "qiita_org/search_conf_path.rb"
8
8
 
9
9
  class QiitaPost
10
- def initialize(file, option)
10
+ def initialize(file, option, os)
11
11
  @src = file
12
12
  @option = (option == "qiita" || option == "open")? "public" : option
13
+ @os = os
13
14
  search = SearchConfPath.new(Dir.pwd, Dir.home)
14
15
  @conf_dir = search.search_conf_path()
15
16
  p @conf_dir
@@ -137,6 +138,17 @@ class QiitaPost
137
138
  end
138
139
  end
139
140
 
141
+ # open qiita
142
+ def open_qiita()
143
+ if @os == "mac"
144
+ system "open #{@res_body["url"]}"
145
+ elsif @os == "windows"
146
+ system "explorer.exe #{@res_body["url"]}"
147
+ else
148
+ system "open #{@res_body["url"]}"
149
+ end
150
+ end
151
+
140
152
  def run()
141
153
  get_title_tags()
142
154
  set_config()
@@ -147,8 +159,7 @@ class QiitaPost
147
159
  qiita_post()
148
160
  get_and_print_qiita_return()
149
161
 
150
- # open qiitta
151
- system "open #{@res_body["url"]}"
162
+ open_qiita()
152
163
 
153
164
  add_qiita_id_on_org()
154
165
  end
@@ -1,3 +1,3 @@
1
1
  module QiitaOrg
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.14"
3
3
  end
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.9
4
+ version: 0.1.14
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-10-13 00:00:00.000000000 Z
11
+ date: 2020-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -953,6 +953,7 @@ files:
953
953
  - hoge.rb
954
954
  - lib/qiita_org.rb
955
955
  - lib/qiita_org/.qiita.conf
956
+ - lib/qiita_org/check_pc_os.rb
956
957
  - lib/qiita_org/config.json
957
958
  - lib/qiita_org/config.rb
958
959
  - lib/qiita_org/get.rb