Class: Saber::Tracker2::Gazelle

Inherits:
Base
  • Object
show all
Defined in:
lib/saber/tracker2/gazelle.rb

Direct Known Subclasses

BB, STP

Constant Summary

Constants inherited from Base

Base::BASE_URL, Base::TYPES

Instance Attribute Summary

Attributes inherited from Base

#agent, #name, #options

Instance Method Summary collapse

Methods inherited from Base

inherited, #initialize, #upload

Constructor Details

This class inherits a constructor from Saber::Tracker2::Base

Instance Method Details

#add_format(info) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/saber/tracker2/gazelle.rb', line 4

def add_format(info)
  unless info[:groupid]
    Saber.ui.error "You must provide a groupid -- #{info[:groupid].inspect}" 
    return false 
  end

  agent.goto "#{self.class::BASE_URL}/upload.php?groupid=#{info[:groupid]}"
   %r~/upload\.php~

  form = agent.form(action: "")
  fill_add_form(form, info)
  form.submit() unless options["dry-run"]

  if agent.url =~ %r~/upload\.php~
    err = agent.element(xpath: "//*[@id='content']/div[2]/p[2]")
    msg = err.exists? ? ReverseMarkdown.parse(err.html).strip : "" 
    Saber.ui.error "ERROR: #{msg}\n"
    return false 
  else
    return true
  end
end

#new_upload(info) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/saber/tracker2/gazelle.rb', line 27

def new_upload(info)
  agent.goto "#{self.class::BASE_URL}/upload.php"
   %r~/upload\.php~

  form = agent.form(action: "")
  fill_form(form, info)
  form.submit() unless options["dry-run"]

  if agent.url =~ %r~/upload\.php~
    err = agent.element(xpath: "//*[@id='content']/div[2]/p[2]")
    msg = err.exists? ? ReverseMarkdown.parse(err.html).strip : "" 
    Saber.ui.error "ERROR: #{msg}\n"
    return false 
  else
    return true
  end
end