Class: PPL::Command::Publish

Inherits:
PPL::Command show all
Defined in:
lib/pod-pipeline/command/publish.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PPL::Command

#argv_extension, ensure_not_root_or_allowed!, git_version, options_extension, run, verify_minimum_git_version!, verify_xcode_license_approved!

Constructor Details

#initialize(argv) ⇒ Publish

Returns a new instance of Publish.



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/pod-pipeline/command/publish.rb', line 36

def initialize(argv)
    @path                   = argv.arguments!
    @repo                   = argv.option('repo', '').split(',').first
    
    @projectPath = @path.count.zero? ? Pathname.pwd.to_s : @path.first
    @is_master = false
    unless @repo
        @repo = 'master'
        @is_master = true
    end

    super
end

Class Method Details

.optionsObject



22
23
24
25
26
# File 'lib/pod-pipeline/command/publish.rb', line 22

def self.options
    [
        ['--repo=master', 'Pod库所属的repo。(默认使用官方repo:master)'],
    ].concat(super).concat(options_extension)
end

.options_extension_hashObject



28
29
30
31
32
33
34
# File 'lib/pod-pipeline/command/publish.rb', line 28

def self.options_extension_hash
    Hash[
        'update' => PPL::Command::Update.options,
        'trunk-push' => Pod::Command::Trunk::Push.options,
        'repo-push' => Pod::Command::Repo::Push.options
    ]
end

Instance Method Details

#runObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/pod-pipeline/command/publish.rb', line 50

def run
    PPL::Command::Update.run([@projectPath] + argv_extension['update'])

    PPL::Scanner.new(@projectPath, ['all']).run
    
    podspec_file = PPL::Scanner.linter.file
    
    if @is_master
        puts "[发布 #{podspec_file}]"
        push_argv = [podspec_file] + argv_extension['trunk-push']
        Pod::Command::Trunk::Push.run(push_argv)
    else
        puts "[发布 #{@repo} #{podspec_file}]"
        push_argv = [@repo, podspec_file] + argv_extension['repo-push']
        Pod::Command::Repo::Push.run(push_argv)
    end
end