Module: Gitcloudcli

Defined in:
lib/gitcloudcli.rb,
lib/gitcloudcli/version.rb,
lib/gitcloudcli/command/space.rb,
lib/gitcloudcli/command/config.rb,
lib/gitcloudcli/command/git/git.rb,
lib/gitcloudcli/command/git/gitee.rb,
lib/gitcloudcli/command/git/github.rb,
lib/gitcloudcli/command/git/gitlab.rb

Defined Under Namespace

Classes: Cli, CloudSpace, Git, Gitee, Github

Constant Summary collapse

VERSION =
"1.0.5"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configCover(configs) ⇒ Object



26
27
28
# File 'lib/gitcloudcli/command/config.rb', line 26

def configCover(configs)
  YAML.dump(configs, Gitcloudcli.configFile("w"))
end

.configFile(model = "r") ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/gitcloudcli/command/config.rb', line 5

def configFile(model="r")
  yaml_dir = Dir.home + "/.gitcloud"
  yaml_name = "gitcloud.yaml"
  yaml_path = yaml_dir + "/#{yaml_name}"
  if !Dir.exist?(yaml_dir)
    Dir.mkdir(yaml_dir)
  end
  if !File.exist? yaml_path
    File.open(yaml_path, 'w').close
  end
  file = File.open(yaml_path, model)
end

.configHashObject



18
19
20
21
22
23
24
# File 'lib/gitcloudcli/command/config.rb', line 18

def configHash
  configs = YAML.load(Gitcloudcli.configFile("r"))
  if !configs
    configs = {}
  end
  return configs
end

.gitadapter(space = nil) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/gitcloudcli/command/config.rb', line 34

def gitadapter(space=nil)
  remote = nil
  token = nil
  configHash.each do |key, value|
    if space
      if key==space
        remote = value["remote"]
        token = value["token"]
        break
      end
    else
      puts "space为空,默认使用#{key}"
      remote = value["remote"]
      token = value["token"]
      break
    end
  end

  if remote
    if remote.to_s.include? "github.com"
      yield Gitcloudcli::Github.new(remote, token)
    else
      puts "#{remote} 不支持"
    end
  else
    puts "#{space} 不不存在"
  end
end

Instance Method Details

#configModelsObject



30
31
32
# File 'lib/gitcloudcli/command/config.rb', line 30

def configModels
  configs = Gitcloudcli.configHash
end