Class: Datagraph::Process

Inherits:
Resource show all
Defined in:
lib/datagraph/process.rb

Overview

Represents a Datagraph.org process.

Constant Summary

SPEC =

/uuid

%r(^([^/]+)$)

Constants inherited from Resource

HEADERS

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Resource

#<=>, #eql?, #exists?, #get, #head, #inspect, #inspect!, new, #to_rdf, #to_uri

Constructor Details

- (Process) initialize(uuid)

A new instance of Process

Parameters:

  • (String, #to_s) uuid


12
13
14
15
# File 'lib/datagraph/process.rb', line 12

def initialize(uuid)
  @uuid = uuid.to_s
  super(Datagraph::URL.join(@uuid)) # FIXME
end

Instance Attribute Details

- (String) uuid (readonly)

Returns:

  • (String)


8
9
10
# File 'lib/datagraph/process.rb', line 8

def uuid
  @uuid
end

Instance Method Details

- abort!

This method returns an undefined value.

Aborts this process.



88
89
90
91
# File 'lib/datagraph/process.rb', line 88

def abort!
  Datagraph::Client.rpc.call('datagraph.process.abort', uuid)
  self
end

- (Boolean) aborted?

Returns true if this process was aborted for any reason.

Returns:

  • (Boolean)


37
38
39
# File 'lib/datagraph/process.rb', line 37

def aborted?
  status.eql?(:aborted)
end

- (Boolean) completed? Also known as: finished?

Returns true if this process has already completed.

Returns:

  • (Boolean)


45
46
47
# File 'lib/datagraph/process.rb', line 45

def completed?
  status.eql?(:completed)
end

- (Time) completed_at

Returns the time when this process finished executing, or nil if it hasn't completed yet.

Returns:

  • (Time)


80
81
82
# File 'lib/datagraph/process.rb', line 80

def completed_at
  # TODO
end

- (Boolean) done?

Returns true if this process has completed or was aborted, and false if it's currently pending or running.

Returns:

  • (Boolean)


55
56
57
# File 'lib/datagraph/process.rb', line 55

def done?
  [:completed, :aborted].include?(status)
end

- (Boolean) pending?

Returns true if this process is currently pending to run.

Returns:

  • (Boolean)


21
22
23
# File 'lib/datagraph/process.rb', line 21

def pending?
  status.eql?(:pending)
end

- (Boolean) running?

Returns true if this process is currently running.

Returns:

  • (Boolean)


29
30
31
# File 'lib/datagraph/process.rb', line 29

def running?
  status.eql?(:running)
end

- (Symbol) status

Returns the current status of this process.

Returns:

  • (Symbol)


63
64
65
# File 'lib/datagraph/process.rb', line 63

def status
  Datagraph::Client.rpc.call('datagraph.process.status', uuid).to_sym
end

- (Time) submitted_at

Returns the time when this process was submitted for execution.

Returns:

  • (Time)


71
72
73
# File 'lib/datagraph/process.rb', line 71

def 
  # TODO
end

- (Object) to_s

Returns a string representation of the process ID.



112
113
114
# File 'lib/datagraph/process.rb', line 112

def to_s
  uuid
end

- wait!(options = {}, &block)

This method returns an undefined value.

Waits until this process is done, meanwhile calling the given block at regular intervals.

Parameters:

  • (Hash{Symbol => Object} options) Hash{Symbol

    => Object} options

  • (Hash) options (defaults to: {})

    a customizable set of options

Options Hash (options):

  • (Float) :sleep — default: 0.5

    how many seconds to sleep before re-polling the process status



101
102
103
104
105
106
107
108
# File 'lib/datagraph/process.rb', line 101

def wait!(options = {}, &block)
  delay = options[:sleep] || 0.5
  until done?
    yield if block_given?
    sleep delay unless delay.zero?
  end
  self
end