Class: QCloudHive::ManifestProject

Inherits:
Object
  • Object
show all
Defined in:
lib/qcloudhive/manifest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(remote, name, path) ⇒ ManifestProject

Returns a new instance of ManifestProject.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/qcloudhive/manifest.rb', line 11

def initialize(remote, name ,path)
  @remote = remote
  @name = name
  @path = path
  @moduleName = name.split("/").last
  #private values
  @serverProject = nil
  @podspec = nil
  @git = nil
  @podStorageSpec = nil
  @localPath
end

Instance Attribute Details

#moduleNameObject

Returns the value of attribute moduleName.



10
11
12
# File 'lib/qcloudhive/manifest.rb', line 10

def moduleName
  @moduleName
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/qcloudhive/manifest.rb', line 9

def name
  @name
end

#pathObject

Returns the value of attribute path.



8
9
10
# File 'lib/qcloudhive/manifest.rb', line 8

def path
  @path
end

#remoteObject

Returns the value of attribute remote.



7
8
9
# File 'lib/qcloudhive/manifest.rb', line 7

def remote
  @remote
end

Instance Method Details

#exsitLocal?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/qcloudhive/manifest.rb', line 71

def exsitLocal?
  return self.gitRepo.nil? == false
end

#exsitPodRepo?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/qcloudhive/manifest.rb', line 74

def exsitPodRepo?
  return self.podStorageSpec.nil? == false
end

#exsitServer?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/qcloudhive/manifest.rb', line 77

def exsitServer?
  return self.serverProject.nil? == false
end

#gitRepoObject



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/qcloudhive/manifest.rb', line 59

def gitRepo
  if @git.nil?
    root = Pathname(Config.projectRootDirectory)
    gitPath = root.join(self.path)
    begin
      @git = Git.open(gitPath)
    rescue => err
      puts "创建Git工程失败 #{gitPath} #{err}"
    end
  end
  @git
end

#localPathObject



23
24
25
26
27
28
29
# File 'lib/qcloudhive/manifest.rb', line 23

def localPath
  if @localPath == nil
    root = Pathname(Config.projectRootDirectory)
    @localPath = root.join(self.path).to_path
  end
  @localPath
end

#needReleasePod?Boolean

Returns:

  • (Boolean)


81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/qcloudhive/manifest.rb', line 81

def needReleasePod?
  if exsitLocal?
    return false
  end
  version = self.podspec.version.first
  tag = gitRepo.tags.select { |e|  e.name == version.to_s }.first
  if tag.nil?
    return true
  end
  master = gitRepo.branches["master"]
  if tag.sha != master.gcommit.sha
    return true
  end
  return false
end

#podspecObject



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/qcloudhive/manifest.rb', line 44

def podspec
  if @podspec.nil?
    HivePod.podspecs.each { |pspec|
      if pspec.name == self.moduleName
         @podspec = pspec.podspec
      end
    }
    if @podspec.nil?
      @podspec = self.podStorageSpec
    end
  end
  @podspec
end

#podStorageSpecObject



36
37
38
39
40
41
42
43
# File 'lib/qcloudhive/manifest.rb', line 36

def podStorageSpec
  if @podStorageSpec.nil?
    L.info("search module #{moduleName}")
    @podStorageSpec = HivePod.search(moduleName)

  end
  @podStorageSpec
end

#serverProjectObject



30
31
32
33
34
35
# File 'lib/qcloudhive/manifest.rb', line 30

def serverProject
  if @serverProject.nil?
    @serverProject = CodeOA.existProjectByName?(moduleName)
  end
  @serverProject
end