qiita_org 0.1.4 → 0.1.5

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: 6e1d39ee46dabf4d2acd53bd27ad8f825a1717981cd63231c2431e531f5cf8ee
4
- data.tar.gz: 5e6e874f3f83341978fba00585728811dfebf001e4cccc159ea24c958aa9aeb0
3
+ metadata.gz: 72dc27665b3c0c77fe171a3440a39e610d0cf2bb5649259ec0d0e3d13b51d0d2
4
+ data.tar.gz: 29cdbf92e0e8b1001085796a60ff7537fec377ef49577252c9783e12c0982888
5
5
  SHA512:
6
- metadata.gz: b9c49a2e0405a8627caee3b7893d3abab9c957698e3b686ee6a590ab56432d70c4365a99e1c9f68a9b2e08554e2600c427af8413562d0aed7d3b328037d13869
7
- data.tar.gz: 39239a9bd1ada1fd34b42d8a27f6176d82ea7e986d8e3c2f7a434780ed9dc3d0e4c37a9d8019e49fe43263bd1f89b6650e797e0e7aee645960c887319e29413d
6
+ metadata.gz: 270d6285dac1e3d4e03feccaa075ef87ff259d07ac7ad862860b57307d132bd3b09311db5f215d96d32add017a013e3dbb6b7faa14c342e01f20a2ad489f55c4
7
+ data.tar.gz: 676b4534810880410bc134aa96bf174e72e447a412a7b4211d27e77481e52e88bf6b377d88dae22191ee11f1693afa693cb09525a58559e136efbf08db4594bf
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qiita_org (0.1.3)
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
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
@@ -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
@@ -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.4"
2
+ VERSION = "0.1.5"
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.4
4
+ version: 0.1.5
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-09-30 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