Class: Luna::Binary::Delete

Inherits:
Object
  • Object
show all
Defined in:
lib/luna/binary/delete.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, version) ⇒ Delete

Returns a new instance of Delete.



14
15
16
17
18
# File 'lib/luna/binary/delete.rb', line 14

def initialize(name, version)
    @name = name
    @version = version
    validate!
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/luna/binary/delete.rb', line 11

def name
  @name
end

#versionObject (readonly)

Returns the value of attribute version.



12
13
14
# File 'lib/luna/binary/delete.rb', line 12

def version
  @version
end

Instance Method Details

#deleteObject



25
26
27
28
29
30
31
32
33
# File 'lib/luna/binary/delete.rb', line 25

def delete
    begin
        deleteRepo
    rescue => exception
        
    ensure
        deleteBinaryFramework
    end
end

#deleteBinaryFrameworkObject



43
44
45
46
47
# File 'lib/luna/binary/delete.rb', line 43

def deleteBinaryFramework 
    command = "curl -X 'DELETE' #{CBin.config.binary_upload_url}/#{name}/#{version}"
    p command 
    system command
end

#deleteRepoObject



35
36
37
38
39
40
41
# File 'lib/luna/binary/delete.rb', line 35

def deleteRepo
    command = "cd #{Luna::Binary::Common.instance.repoPath}; git stash;git checkout master;git pull origin master;"
    system command
    Luna::Binary::Common.instance.deleteDirectory("#{Luna::Binary::Common.instance.repoPath}/#{name}/#{version}")
    commandADD = "cd #{Luna::Binary::Common.instance.repoPath};git add .; git commit -m 'DEL::#{name}-#{version} by LBU'; git push -f origin master"
    system commandADD
end

#validate!Object



20
21
22
23
# File 'lib/luna/binary/delete.rb', line 20

def validate!
    raise "缺少参数" unless name
    raise "缺少参数" unless version
end