Class: SauceWhisk::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/sauce_whisk/jobs.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameters = {}) ⇒ Job

Returns a new instance of Job.



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/sauce_whisk/jobs.rb', line 112

def initialize(parameters={})
  passed = parameters.delete "status"
  cd = parameters.delete "custom-data"
  visibility = parameters.delete "public"

  self.passed = passed
  self.custom_data = cd
  self.visibility = visibility

  parameters.each do |k,v|
    self.instance_variable_set("@#{k}".to_sym, v)
  end

  @updated_fields = []
end

Instance Attribute Details

#browserObject (readonly)

Returns the value of attribute browser.



106
107
108
# File 'lib/sauce_whisk/jobs.rb', line 106

def browser
  @browser
end

#browser_versionObject (readonly)

Returns the value of attribute browser_version.



106
107
108
# File 'lib/sauce_whisk/jobs.rb', line 106

def browser_version
  @browser_version
end

#creation_timeObject (readonly)

Returns the value of attribute creation_time.



107
108
109
# File 'lib/sauce_whisk/jobs.rb', line 107

def creation_time
  @creation_time
end

#end_timeObject (readonly)

Returns the value of attribute end_time.



107
108
109
# File 'lib/sauce_whisk/jobs.rb', line 107

def end_time
  @end_time
end

#errorObject (readonly)

Returns the value of attribute error.



107
108
109
# File 'lib/sauce_whisk/jobs.rb', line 107

def error
  @error
end

#idObject (readonly)

Returns the value of attribute id.



106
107
108
# File 'lib/sauce_whisk/jobs.rb', line 106

def id
  @id
end

#log_urlObject (readonly)

Returns the value of attribute log_url.



106
107
108
# File 'lib/sauce_whisk/jobs.rb', line 106

def log_url
  @log_url
end

#osObject (readonly)

Returns the value of attribute os.



106
107
108
# File 'lib/sauce_whisk/jobs.rb', line 106

def os
  @os
end

#ownerObject (readonly)

Returns the value of attribute owner.



106
107
108
# File 'lib/sauce_whisk/jobs.rb', line 106

def owner
  @owner
end

#screenshot_urlsObject (readonly)

Returns the value of attribute screenshot_urls.



108
109
110
# File 'lib/sauce_whisk/jobs.rb', line 108

def screenshot_urls
  @screenshot_urls
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



107
108
109
# File 'lib/sauce_whisk/jobs.rb', line 107

def start_time
  @start_time
end

#updated_fieldsObject



144
145
146
# File 'lib/sauce_whisk/jobs.rb', line 144

def updated_fields
  @updated_fields ||= []
end

#video_urlObject (readonly)

Returns the value of attribute video_url.



107
108
109
# File 'lib/sauce_whisk/jobs.rb', line 107

def video_url
  @video_url
end

Class Method Details

.tracked_attr_accessor(*methods) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/sauce_whisk/jobs.rb', line 94

def self.tracked_attr_accessor(*methods)
  methods.each do |method|
    attr_reader method
    self.send(:define_method, "#{method}=") do |arg|
      if method != arg
        updated_fields << method
        instance_variable_set("@#{method}", arg)
      end
    end
  end
end

Instance Method Details

#deleteObject



136
137
138
# File 'lib/sauce_whisk/jobs.rb', line 136

def delete
  Jobs.delete_job id
end

#has_all_asset_names?Boolean

Returns:

  • (Boolean)


140
141
142
# File 'lib/sauce_whisk/jobs.rb', line 140

def has_all_asset_names?
  !screenshot_urls.nil?
end

#saveObject



128
129
130
# File 'lib/sauce_whisk/jobs.rb', line 128

def save
  Jobs.save(self)
end

#screenshotsObject



148
149
150
151
152
153
154
155
156
# File 'lib/sauce_whisk/jobs.rb', line 148

def screenshots
  unless @screenshots || screenshot_urls.nil?
   @screenshots = screenshot_urls.map do |screenshot|
      Assets.fetch id, screenshot
    end
  end

  @screenshots
end

#stopObject



132
133
134
# File 'lib/sauce_whisk/jobs.rb', line 132

def stop
  Jobs.stop id
end

#videoObject



158
159
160
161
162
163
164
# File 'lib/sauce_whisk/jobs.rb', line 158

def video
  unless @video
    @video = Assets.fetch id, "video.flv", :video
  end

  @video
end