Class: Mugen::Job
Class Attribute Summary collapse
-
.as_group ⇒ Object
Returns the value of attribute as_group.
-
.auto_approve ⇒ Object
Returns the value of attribute auto_approve.
-
.body_src ⇒ Object
Returns the value of attribute body_src.
-
.body_tgt ⇒ Object
Returns the value of attribute body_tgt.
-
.callback_url ⇒ Object
Returns the value of attribute callback_url.
-
.capcha_url ⇒ Object
Returns the value of attribute capcha_url.
-
.comment ⇒ Object
Returns the value of attribute comment.
-
.credits ⇒ Object
Returns the value of attribute credits.
-
.ctime ⇒ Object
Returns the value of attribute ctime.
-
.custom_data ⇒ Object
Returns the value of attribute custom_data.
-
.eta ⇒ Object
Returns the value of attribute eta.
-
.job_id ⇒ Object
Returns the value of attribute job_id.
-
.lc_src ⇒ Object
Returns the value of attribute lc_src.
-
.lc_tgt ⇒ Object
Returns the value of attribute lc_tgt.
-
.mt ⇒ Object
Returns the value of attribute mt.
-
.slug ⇒ Object
Returns the value of attribute slug.
-
.status ⇒ Object
Returns the value of attribute status.
-
.tier ⇒ Object
Returns the value of attribute tier.
-
.unit_count ⇒ Object
Returns the value of attribute unit_count.
Class Method Summary collapse
- .approve(job_id, options = {}) ⇒ Object
-
.comments(id, options = {}) ⇒ Object
translate/job/id/comments (GET).
-
.create(options = {}) ⇒ Object
translate/job (POST).
-
.create_comment(job_id, comment) ⇒ Object
translate/job/id/comment (POST).
-
.delete(id, options = {}) ⇒ Object
translate/job/id (DELETE).
-
.feedback(id, options = {}) ⇒ Object
translate/job/id/feedback (GET).
-
.find(id, options = {}) ⇒ Object
translate/job/id (GET).
-
.preview(id, options = {}) ⇒ Object
translate/job/id/preview (GET).
- .purchase(job_id, options = {}) ⇒ Object
- .reject(job_id, options = {}) ⇒ Object
- .revise(job_id, options = {}) ⇒ Object
-
.revision(job_id, id, options = {}) ⇒ Object
translate/job/Job.job_id/revision/id (GET).
-
.revisions(id, options = {}) ⇒ Object
translate/job/id/revisions (GET).
-
.update(job_id, action, options = {}) ⇒ Object
translate/job/id (PUT).
Methods inherited from Client
before_get, before_post, before_put, check_for_errors
Class Attribute Details
.as_group ⇒ Object
Returns the value of attribute as_group.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def as_group @as_group end |
.auto_approve ⇒ Object
Returns the value of attribute auto_approve.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def auto_approve @auto_approve end |
.body_src ⇒ Object
Returns the value of attribute body_src.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def body_src @body_src end |
.body_tgt ⇒ Object
Returns the value of attribute body_tgt.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def body_tgt @body_tgt end |
.callback_url ⇒ Object
Returns the value of attribute callback_url.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def callback_url @callback_url end |
.capcha_url ⇒ Object
Returns the value of attribute capcha_url.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def capcha_url @capcha_url end |
.comment ⇒ Object
Returns the value of attribute comment.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def comment @comment end |
.credits ⇒ Object
Returns the value of attribute credits.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def credits @credits end |
.ctime ⇒ Object
Returns the value of attribute ctime.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def ctime @ctime end |
.custom_data ⇒ Object
Returns the value of attribute custom_data.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def custom_data @custom_data end |
.eta ⇒ Object
Returns the value of attribute eta.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def eta @eta end |
.job_id ⇒ Object
Returns the value of attribute job_id.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def job_id @job_id end |
.lc_src ⇒ Object
Returns the value of attribute lc_src.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def lc_src @lc_src end |
.lc_tgt ⇒ Object
Returns the value of attribute lc_tgt.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def lc_tgt @lc_tgt end |
.mt ⇒ Object
Returns the value of attribute mt.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def mt @mt end |
.slug ⇒ Object
Returns the value of attribute slug.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def slug @slug end |
.status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def status @status end |
.tier ⇒ Object
Returns the value of attribute tier.
6 7 8 |
# File 'lib/mugen/job.rb', line 6 def tier @tier end |
.unit_count ⇒ Object
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, = {}) update(job_id, 'approve', ) 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, = {}) res = self.get "/translate/job/#{id}/comments", :query => 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( = {}) if .nil? || .empty? raise Exception, '"options" missing required parameters' end job = { 'job' => } 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, = {}) .merge!('_method' => 'delete') res = self.delete "/translate/job/#{id}", :query => 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, = {}) res = self.get "/translate/job/#{id}/feedback", :query => 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, ={}) res = self.get "/translate/job/#{id}", :query => 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, = {}) name = "#{Time.now.gmtime.to_i}.jpg" res = self.get "/translate/job/#{id}/preview", :query => 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, = {}) update(job_id, 'purchase', ) end |
.reject(job_id, options = {}) ⇒ Object
67 68 69 |
# File 'lib/mugen/job.rb', line 67 def reject(job_id, = {}) update(job_id, 'reject', ) end |
.revise(job_id, options = {}) ⇒ Object
59 60 61 |
# File 'lib/mugen/job.rb', line 59 def revise(job_id, = {}) update(job_id, 'revise', ) 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, = {}) res = self.get "/translate/job/#{job_id}/revision/#{id}", :query => 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, = {}) res = self.get "/translate/job/#{id}/revisions", :query => 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, = {}) # if options.nil? || options.empty? # raise Exception, '"options" missing required parameters' # end .merge! :action => action job = res = self.put "/translate/job/#{job_id}", :body => job check_for_errors(res) res['response'] end |