Class: Mugen::Job

Inherits:
Client show all
Defined in:
lib/mugen/job.rb

Class Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Client

before_get, before_post, before_put, check_for_errors

Class Attribute Details

.as_groupObject

Returns the value of attribute as_group.



6
7
8
# File 'lib/mugen/job.rb', line 6

def as_group
  @as_group
end

.auto_approveObject

Returns the value of attribute auto_approve.



6
7
8
# File 'lib/mugen/job.rb', line 6

def auto_approve
  @auto_approve
end

.body_srcObject

Returns the value of attribute body_src.



6
7
8
# File 'lib/mugen/job.rb', line 6

def body_src
  @body_src
end

.body_tgtObject

Returns the value of attribute body_tgt.



6
7
8
# File 'lib/mugen/job.rb', line 6

def body_tgt
  @body_tgt
end

.callback_urlObject

Returns the value of attribute callback_url.



6
7
8
# File 'lib/mugen/job.rb', line 6

def callback_url
  @callback_url
end

.capcha_urlObject

Returns the value of attribute capcha_url.



6
7
8
# File 'lib/mugen/job.rb', line 6

def capcha_url
  @capcha_url
end

.commentObject

Returns the value of attribute comment.



6
7
8
# File 'lib/mugen/job.rb', line 6

def comment
  @comment
end

.creditsObject

Returns the value of attribute credits.



6
7
8
# File 'lib/mugen/job.rb', line 6

def credits
  @credits
end

.ctimeObject

Returns the value of attribute ctime.



6
7
8
# File 'lib/mugen/job.rb', line 6

def ctime
  @ctime
end

.custom_dataObject

Returns the value of attribute custom_data.



6
7
8
# File 'lib/mugen/job.rb', line 6

def custom_data
  @custom_data
end

.etaObject

Returns the value of attribute eta.



6
7
8
# File 'lib/mugen/job.rb', line 6

def eta
  @eta
end

.job_idObject

Returns the value of attribute job_id.



6
7
8
# File 'lib/mugen/job.rb', line 6

def job_id
  @job_id
end

.lc_srcObject

Returns the value of attribute lc_src.



6
7
8
# File 'lib/mugen/job.rb', line 6

def lc_src
  @lc_src
end

.lc_tgtObject

Returns the value of attribute lc_tgt.



6
7
8
# File 'lib/mugen/job.rb', line 6

def lc_tgt
  @lc_tgt
end

.mtObject

Returns the value of attribute mt.



6
7
8
# File 'lib/mugen/job.rb', line 6

def mt
  @mt
end

.slugObject

Returns the value of attribute slug.



6
7
8
# File 'lib/mugen/job.rb', line 6

def slug
  @slug
end

.statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/mugen/job.rb', line 6

def status
  @status
end

.tierObject

Returns the value of attribute tier.



6
7
8
# File 'lib/mugen/job.rb', line 6

def tier
  @tier
end

.unit_countObject

Returns the value of attribute unit_count.



6
7
8
# File 'lib/mugen/job.rb', line 6

def unit_count
  @unit_count
end

Class Method Details

.approve(job_id, options = {}) ⇒ Object



63
64
65
# File 'lib/mugen/job.rb', line 63

def approve(job_id, options = {})
  update(job_id, 'approve', options)
end

.comments(id, options = {}) ⇒ Object

translate/job/id/comments (GET)

Retrieves the comment thread for a job



128
129
130
131
132
# File 'lib/mugen/job.rb', line 128

def comments(id, options = {})
  res = self.get "/translate/job/#{id}/comments", :query => options
  check_for_errors(res)
  res['response']['thread']
end

.create(options = {}) ⇒ Object

translate/job (POST)

Post a new job for translation



29
30
31
32
33
34
35
36
37
# File 'lib/mugen/job.rb', line 29

def create(options = {})
  if options.nil? || options.empty?
    raise Exception, '"options" missing required parameters'
  end
  job = { 'job' => options }
  res = self.post "/translate/job", :body => job
  check_for_errors(res)
  res['response']
end

.create_comment(job_id, comment) ⇒ Object

translate/job/id/comment (POST)

Submits a new comment to the job’s comment thread.



114
115
116
117
118
119
120
121
# File 'lib/mugen/job.rb', line 114

def create_comment(job_id, comment)
  if comment.nil? || comment.empty?
    raise Exception, '"options" missing required parameters'
  end
  res = self.post "/translate/job/#{job_id}/comment", :body => comment
  check_for_errors(res)
  res['response']
end

.delete(id, options = {}) ⇒ Object

translate/job/id (DELETE)

Cancels the job. You can only cancel a job if it has not been started already by a translator.



77
78
79
80
81
82
# File 'lib/mugen/job.rb', line 77

def delete(id, options = {})
  options.merge!('_method' => 'delete')
  res = self.delete "/translate/job/#{id}", :query => options
  check_for_errors(res)
  res['response']
end

.feedback(id, options = {}) ⇒ Object

translate/job/id/feedback (GET)

Retrieves the feedback



139
140
141
142
143
# File 'lib/mugen/job.rb', line 139

def feedback(id, options = {})
  res = self.get "/translate/job/#{id}/feedback", :query => options
  check_for_errors(res)
  res['response']['feedback']
end

.find(id, options = {}) ⇒ Object

translate/job/id (GET)

Retrieves a specific job



18
19
20
21
22
# File 'lib/mugen/job.rb', line 18

def find(id, options={})
  res = self.get "/translate/job/#{id}", :query => options
  check_for_errors(res)
  res['response']['job']
end

.preview(id, options = {}) ⇒ Object

translate/job/id/preview (GET)

Renders a JPEG preview of the translated text N.B. - if the request is valid, a raw JPEG stream is returned.



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/mugen/job.rb', line 90

def preview(id, options = {})
  name = "#{Time.now.gmtime.to_i}.jpg"
  res = self.get "/translate/job/#{id}/preview", :query => options
  check_for_errors(res)
  fn = if defined?(Rails)
    Rails.root.join('public', 'images', 'mygengo', name)
  else
    Tempfile.new(name)
  end
  if !File.exists?(fn)
    tempfile = File.new(fn, "w+")
    tempfile << res
    tempfile.close
    "mygengo/#{name}"
  else
    nil
  end
end

.purchase(job_id, options = {}) ⇒ Object



55
56
57
# File 'lib/mugen/job.rb', line 55

def purchase(job_id, options = {})
  update(job_id, 'purchase', options)
end

.reject(job_id, options = {}) ⇒ Object



67
68
69
# File 'lib/mugen/job.rb', line 67

def reject(job_id, options = {})
  update(job_id, 'reject', options)
end

.revise(job_id, options = {}) ⇒ Object



59
60
61
# File 'lib/mugen/job.rb', line 59

def revise(job_id, options = {})
  update(job_id, 'revise', options)
end

.revision(job_id, id, options = {}) ⇒ Object

translate/job/job_id/revision/id (GET)

Gets specific revision for a job.



161
162
163
164
165
# File 'lib/mugen/job.rb', line 161

def revision(job_id, id, options = {})
  res = self.get "/translate/job/#{job_id}/revision/#{id}", :query => options
  check_for_errors(res)
  res['response']['revision']
end

.revisions(id, options = {}) ⇒ Object

translate/job/id/revisions (GET)

Gets list of revision resources for a job.



150
151
152
153
154
# File 'lib/mugen/job.rb', line 150

def revisions(id, options = {})
  res = self.get "/translate/job/#{id}/revisions", :query => options
  check_for_errors(res)
  res['response']['revisions']
end

.update(job_id, action, options = {}) ⇒ Object

translate/job/id (PUT)

Updates a job to translate.



44
45
46
47
48
49
50
51
52
53
# File 'lib/mugen/job.rb', line 44

def update(job_id, action, options = {})
  # if options.nil? || options.empty?
  #   raise Exception, '"options" missing required parameters'
  # end
  options.merge! :action => action
  job = options
  res = self.put "/translate/job/#{job_id}", :body => job
  check_for_errors(res)
  res['response']
end