qiita_org 0.1.3 → 0.1.8

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: d23130946a125381e9ded0d662dbaf551e8842076070e02dd8abd8063cb923a1
4
- data.tar.gz: 05b6e8fc0799d7060fd7cf86afa59bf0168882104763ac044f7ebfd3716914b3
3
+ metadata.gz: 2e8c82431a22c64669538797e28a4063ec88e0716014fec98371f3fa03833fa5
4
+ data.tar.gz: 060c5ba8fb541193fec02aa66570300d2b3801e5c3ead68339267d514c1ae36f
5
5
  SHA512:
6
- metadata.gz: 1b08b02e2873c25ed0df0c41983d8812b5726532c359308bfe8e0e142b8285eca8e0415809bc13e8b2de6fe7efa841762eb6d65df76296846a069e93f28dd9a7
7
- data.tar.gz: 38e0f983e929f0815a17c391af8923b92675ba36c8b1324f4cc619fa4cf8f55e366b56979a0277a1ca0c48217303a8e91cb8eaaa1bb364653f721aa3e43bd0a1
6
+ metadata.gz: fe04ad5ab1e88a6b722b71e705b0e96fd2378bf19a70f3cdc98e6158ca3c52e707586bd2889c483d249fb658660315445f1d0b0d80402a07f1c597f20a71376d
7
+ data.tar.gz: e83f076ae7624915c4569f1bc81455882b854d694f0898aab5810825d4653d28356c259657515942c0bc86ea1508f327610fcd228539187ab592f9397d195ba3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qiita_org (0.1.2)
4
+ qiita_org (0.1.4)
5
5
  colorize
6
6
  command_line (> 2.0.0)
7
7
  fileutils
@@ -40,9 +40,10 @@ module QiitaOrg
40
40
  desc "config", "set config"
41
41
 
42
42
  def config(*argv)
43
- option = argv[0] || nil
44
- input = [argv[1], argv[2], argv[3]]
45
- config = QiitaConfig.new(option, input)
43
+ status = argv[0] || "local"
44
+ option = argv[1] || nil
45
+ input = [argv[2], argv[3], argv[4]]
46
+ config = QiitaConfig.new(status, option, input)
46
47
  config.run
47
48
  end
48
49
 
@@ -3,10 +3,20 @@ require "fileutils"
3
3
  require "json"
4
4
 
5
5
  class QiitaConfig
6
- def initialize(option, input)
6
+ def initialize(status, option, input)
7
7
  @option = option
8
8
  @input = input
9
- @setup = "#{ENV["HOME"]}/.qiita.conf"
9
+ if status == "local"
10
+ search = SearchConfPath.new(Dir.pwd, Dir.home)
11
+ conf_dir = search.search_conf_path()
12
+ if conf_dir == Dir.home || @option == "set"
13
+ @setup = File.join(Dir.pwd, ".qiita.conf")
14
+ else
15
+ @setup = File.join(conf_dir, ".qiita.conf")
16
+ end
17
+ else
18
+ @setup = File.join(Dir.home, ".qiita.conf")
19
+ end
10
20
  end
11
21
 
12
22
  # check qiita.conf or copy qiita.conf
@@ -14,7 +24,7 @@ class QiitaConfig
14
24
  lib = File.expand_path("../../../lib", __FILE__)
15
25
  cp_file = File.join(lib, "qiita_org", ".qiita.conf")
16
26
 
17
- if File.exists?("#{ENV["HOME"]}/.qiita.conf")
27
+ if File.exists?(@setup) # "# {ENV["HOME"]}/.qiita.conf")
18
28
  puts @setup.green
19
29
  print_config("now", "black")
20
30
  else
@@ -46,7 +56,7 @@ class QiitaConfig
46
56
  end
47
57
 
48
58
  def run()
49
- if @option == nil
59
+ if @option == nil || @option == "set"
50
60
  check_or_copy_config()
51
61
  else
52
62
  set_config()
@@ -3,16 +3,19 @@ require "json"
3
3
  require "open-uri"
4
4
  require "io/console"
5
5
  require "colorize"
6
+ require "qiita_org/search_conf_path.rb"
6
7
 
7
8
  class QiitaGet
8
9
  def initialize(mode, id)
9
10
  @mode = mode
10
11
  @get_id = id
12
+ search = SearchConfPath.new(Dir.pwd, Dir.home)
13
+ @conf_dir = search.search_conf_path()
11
14
  end
12
15
 
13
16
  # set config
14
17
  def set_config()
15
- conf_path = File.join(ENV["HOME"], ".qiita.conf")
18
+ conf_path = File.join(@conf_dir, ".qiita.conf")
16
19
  conf = JSON.load(File.read(conf_path))
17
20
  @access_token = conf["access_token"]
18
21
  @teams_url = conf["teams_url"]
@@ -1,9 +1,12 @@
1
1
  require "fileutils"
2
2
  require "colorize"
3
+ require "qiita_org/search_conf_path"
3
4
 
4
5
  class QiitaGetTemplate
5
6
  def initialize()
6
7
  cp_template()
8
+ search = SearchConfPath.new(Dir.pwd, Dir.home)
9
+ @conf_dir = search.search_conf_path()
7
10
  set_name_and_email()
8
11
  # check_write_header()
9
12
  check_write_contents()
@@ -83,7 +86,7 @@ class QiitaGetTemplate
83
86
  end
84
87
 
85
88
  def set_name_and_email()
86
- conf_path = File.join(ENV["HOME"], ".qiita.conf")
89
+ conf_path = File.join(@conf_dir, ".qiita.conf")
87
90
  conf = JSON.load(File.read(conf_path))
88
91
  name = conf["name"]
89
92
  email = conf["email"]
@@ -2,10 +2,13 @@ require "net/https"
2
2
  require "json"
3
3
  require "open-uri"
4
4
  require "colorize"
5
+ require "qiita_org/search_conf_path.rb"
5
6
 
6
7
  class QiitaList
7
8
  def initialize(mode)
8
9
  @mode = mode
10
+ search = SearchConfPath.new(Dir.pwd, Dir.home)
11
+ @conf_dir = search.search_conf_path()
9
12
  set_config()
10
13
  select_path()
11
14
  access_qiita()
@@ -13,7 +16,7 @@ class QiitaList
13
16
  end
14
17
 
15
18
  def set_config()
16
- conf_path = File.join(ENV["HOME"], ".qiita.conf")
19
+ conf_path = File.join(@conf_dir, ".qiita.conf")
17
20
  conf = JSON.load(File.read(conf_path))
18
21
  @access_token = conf["access_token"]
19
22
  @teams_url = conf["teams_url"]
@@ -4,11 +4,15 @@ require "net/https"
4
4
  require "json"
5
5
  require "command_line/global"
6
6
  require "colorize"
7
+ require "qiita_org/search_conf_path.rb"
7
8
 
8
9
  class QiitaPost
9
10
  def initialize(file, option)
10
11
  @src = file
11
12
  @option = (option == "qiita" || option == "open")? "public" : option
13
+ search = SearchConfPath.new(Dir.pwd, Dir.home)
14
+ @conf_dir = search.search_conf_path()
15
+ p @conf_dir
12
16
  end
13
17
 
14
18
  public
@@ -18,7 +22,7 @@ class QiitaPost
18
22
  m = []
19
23
  @tags = if m = @conts.match(/\#\+(TAG|tag|Tag|tags|TAGS|Tags): (.+)/)
20
24
  if m[2].count(",") >= 5
21
- p "The maximum number of tags is five. Please edit tags"
25
+ puts "The maximum number of tag is five. Please delete some tags.".red
22
26
  exit
23
27
  end
24
28
  m[2].split(",").inject([]) do |l, c|
@@ -31,7 +35,7 @@ class QiitaPost
31
35
  end
32
36
 
33
37
  def set_config()
34
- conf_path = File.join(ENV["HOME"], ".qiita.conf")
38
+ conf_path = File.join(@conf_dir, ".qiita.conf")
35
39
  @conf = JSON.load(File.read(conf_path))
36
40
  @access_token = @conf["access_token"]
37
41
  @teams_url = @conf["teams_url"]
@@ -65,8 +69,9 @@ class QiitaPost
65
69
  end
66
70
 
67
71
  def select_option(option)
68
- qiita = (option == "teams")? "https://nishitani.qiita.com/" :
69
- "https://qiita.com/"
72
+ qiita = (option == "teams")? @teams_url : "https://qiita.com/"
73
+ #qiita = (option == "teams")? "https://nishitani.qiita.com/" :
74
+ # "https://qiita.com/"
70
75
  case option
71
76
  when "teams", "qiita", "public", "open"
72
77
  private = false
@@ -0,0 +1,18 @@
1
+ class SearchConfPath
2
+ def initialize(dir, home)
3
+ @dir = dir
4
+ @home = home
5
+ search_conf_path()
6
+ end
7
+
8
+ def search_conf_path()
9
+ while @dir != @home
10
+ if File.exists?(File.join(@dir, ".qiita.conf"))
11
+ return @dir
12
+ else
13
+ @dir = @dir.match(/(.+)\//)[1]
14
+ end
15
+ end
16
+ return @dir
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module QiitaOrg
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.8"
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.3
4
+ version: 0.1.8
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-09-16 00:00:00.000000000 Z
11
+ date: 2020-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -960,6 +960,7 @@ files:
960
960
  - lib/qiita_org/hoge.txt
961
961
  - lib/qiita_org/list.rb
962
962
  - lib/qiita_org/post.rb
963
+ - lib/qiita_org/search_conf_path.rb
963
964
  - lib/qiita_org/template.org
964
965
  - lib/qiita_org/version.rb
965
966
  - qiita_org.gemspec