Class: Saber::Tracker::Base
- Inherits:
-
Object
- Object
- Saber::Tracker::Base
- Defined in:
- lib/saber/tracker/base.rb
Constant Summary collapse
- @@POPULATE_TYPES =
implement
[]
- @@BASE_URL =
implement
""- @@LOGIN_CHECK_PATH =
""
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#site_name ⇒ Object
readonly
Returns the value of attribute site_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #login ⇒ Object
-
#populate(type, *args) ⇒ Hash
Return data by auto-fill functions provied by site.
- #upload(*torrent_files) ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
24 25 26 27 28 29 |
# File 'lib/saber/tracker/base.rb', line 24 def initialize @site_name = self.class.name.demodulize.underscore @agent = Mechanize.new @agent.get(@@BASE_URL) end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
21 22 23 |
# File 'lib/saber/tracker/base.rb', line 21 def agent @agent end |
#site_name ⇒ Object (readonly)
Returns the value of attribute site_name.
22 23 24 |
# File 'lib/saber/tracker/base.rb', line 22 def site_name @site_name end |
Class Method Details
.can_populate?(type) ⇒ Boolean
13 14 15 |
# File 'lib/saber/tracker/base.rb', line 13 def self.can_populate?(type) @@POPULATE_TYPES.include?(type.to_s) end |
.inherited(child) ⇒ Object
6 7 8 |
# File 'lib/saber/tracker/base.rb', line 6 def self.inherited(child) Tracker.trackers[child.name.demodulize.underscore] = child end |
Instance Method Details
#login ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/saber/tracker/base.rb', line 31 def login if return end login_with_username end |
#populate(type, *args) ⇒ Hash
Return data by auto-fill functions provied by site.
60 61 62 63 64 65 66 67 68 |
# File 'lib/saber/tracker/base.rb', line 60 def populate(type, *args) meth = "populate_#{type}" if respond_to?(meth) then send meth, *args else raise ArgumentError, "Not support this type -- #{type}" end end |
#upload(*torrent_files) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/saber/tracker/base.rb', line 39 def upload(*torrent_files) files = torrent_files.map{|v| Pa.delete_ext(v, ".torrent")} files.each {|file| info = Optimism.require!("./#{file}.yml") if do_upload(file, info) Saber.ui.say "Upload Complete: #{file}" else Saber.ui.error "Upload Failed: #{file}" end } end |