Class: PPL::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/pod-pipeline/util/scanner.rb

Constant Summary collapse

@@linter =
nil
@@name =
nil
@@version =
nil
@@depend =
nil
@@git =
nil
@@remote =
nil
@@branch =
nil
@@workspace =
nil

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(projectPath, channels) ⇒ Scanner

Returns a new instance of Scanner.



19
20
21
22
# File 'lib/pod-pipeline/util/scanner.rb', line 19

def initialize(projectPath, channels)
    @projectPath = projectPath
    @channels = channels
end

Class Method Details

.branchObject



88
89
90
# File 'lib/pod-pipeline/util/scanner.rb', line 88

def self.branch
    @@branch
end

.dependObject



76
77
78
# File 'lib/pod-pipeline/util/scanner.rb', line 76

def self.depend
    @@depend
end

.gitObject



80
81
82
# File 'lib/pod-pipeline/util/scanner.rb', line 80

def self.git
    @@git
end

.linterObject

—————————————-#



64
65
66
# File 'lib/pod-pipeline/util/scanner.rb', line 64

def self.linter
    @@linter
end

.nameObject



68
69
70
# File 'lib/pod-pipeline/util/scanner.rb', line 68

def self.name
    @@name
end

.remoteObject



84
85
86
# File 'lib/pod-pipeline/util/scanner.rb', line 84

def self.remote
    @@remote
end

.versionObject



72
73
74
# File 'lib/pod-pipeline/util/scanner.rb', line 72

def self.version
    @@version
end

.workspaceObject



92
93
94
# File 'lib/pod-pipeline/util/scanner.rb', line 92

def self.workspace
    @@workspace
end

Instance Method Details

#runObject



24
25
26
27
28
29
30
31
32
33
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
# File 'lib/pod-pipeline/util/scanner.rb', line 24

def run
    @channels = ["all"] if @channels.count.zero?
    
    @channels.each do |channel|
        case channel
        when "all"
            puts "\n[扫描 #{@projectPath.split("/").last} 内容]"
            @@linter = scan_pod @projectPath
            @@name = @@linter.spec.name
            @@version = @@linter.spec.version
            @@depend = @@linter.spec.dependencies
            @@git = scan_git @projectPath
            @@remote = @@git.remote
            @@branch = @@git.branches.current.first
            @@workspace = scan_workspace @projectPath
        when "name"
            @@linter = scan_pod @projectPath
            @@name = @@linter.spec.name
        when "version"
            @@linter = scan_pod @projectPath
            @@version = @@linter.spec.version
        when "depend"
            @@linter = scan_pod @projectPath
            @@depend = @@linter.spec.dependencies.map{ |depend| depend.name }.join(',')
        when "remote"
            @@git = scan_git @projectPath
            @@remote = @@git.remote
        when "branch"
            @@git = scan_git @projectPath
            @@branch = @@git.branches.current.first
        when "workspace"
            @@workspace = scan_workspace @projectPath
        else
            raise "暂不支持#{channel}内容扫描"
        end
    end
end