Class: Mu::Curl::Verify

Inherits:
Object
  • Object
show all
Defined in:
lib/mu/curl/verify.rb

Defined Under Namespace

Classes: Request, Response, Result

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_id) ⇒ Verify

Returns a new instance of Verify.



96
97
98
# File 'lib/mu/curl/verify.rb', line 96

def initialize job_id
    @job_id = job_id
end

Instance Attribute Details

#job_idObject (readonly)

Returns the value of attribute job_id.



94
95
96
# File 'lib/mu/curl/verify.rb', line 94

def job_id
  @job_id
end

Class Method Details

.execute(args) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/mu/curl/verify.rb', line 79

def self.execute args
    args.delete 'pattern'

    res = Command::API.client.curl args
    if res['error']
        if res['error'] == 'authorize'
            raise Error::Authorize.new(res)
        else
            raise Error.new(res)
        end
    end

    return self.new(res['job_id'])
end

Instance Method Details

#abortObject



132
133
134
# File 'lib/mu/curl/verify.rb', line 132

def abort
    Command::API.client.abort_job job_id rescue nil
end

#resultObject



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/mu/curl/verify.rb', line 100

def result
    while true
        sleep 2.0

        job = Command::API.client.job_status job_id
        if job['error']
            raise Error
        end

        result = job['result']
        next if job['status'] == 'queued'
        next if job['status'] == 'running' and not result

        if result['error']
            result['region'] = job['region']
            if result['dns']
                raise Error::DNS.new(result)
            elsif result['step'] == 0
                raise Error::Connect.new(result)
            elsif result['step'] == 2
                raise Error::Timeout.new(result)
            elsif result['assert'] == 0
                raise Error::Status.new(result)
            else
                raise Error
            end
        end
        
        return Result.new(job)
    end
end