Class: DSL
- Inherits:
-
Object
- Object
- DSL
- Defined in:
- lib/dsl.rb
Instance Attribute Summary collapse
-
#titles ⇒ Object
Returns the value of attribute titles.
Instance Method Summary collapse
- #add_feed(feed) ⇒ Object
- #add_title(title) ⇒ Object
- #after(&block) ⇒ Object
- #download(link, options = {}) ⇒ Object
- #download_complete(torrents) ⇒ Object
- #feeds ⇒ Object
- #filter(&block) ⇒ Object
-
#initialize(options) ⇒ DSL
constructor
A new instance of DSL.
- #log ⇒ Object
- #options ⇒ Object
- #parse_metadata(item) ⇒ Object
- #perform_filter(items) ⇒ Object
Constructor Details
#initialize(options) ⇒ DSL
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dsl.rb', line 6 def initialize() = @items, @torrents, @feeds, @titles = [], [], [], [] contents = '' [:filter_paths].each do |path| begin File.open(path, 'r') do |fh| [:logger].info "Adding #{path} to recipe list" if [:verbose] contents += fh.read end rescue => e [:logger].info "Couldn't add #{path} to recipe list: #{e}" if [:verbose] end end eval " def run_dsl(obj = nil, type = nil)\n @items = []\n @torrents = []\n\n case(type)\n when :filter\n @items = obj\n when :torrent\n @torrents = obj\n end\n \n \#{contents}\n end\n END\n\n # Prime the DSL\n @primed = false\n run_dsl\n @primed = true\nend\n" |
Instance Attribute Details
#titles ⇒ Object
Returns the value of attribute titles.
4 5 6 |
# File 'lib/dsl.rb', line 4 def titles @titles end |
Instance Method Details
#add_feed(feed) ⇒ Object
52 53 54 |
# File 'lib/dsl.rb', line 52 def add_feed(feed) @feeds << feed unless @primed end |
#add_title(title) ⇒ Object
60 61 62 |
# File 'lib/dsl.rb', line 60 def add_title(title) @titles << title unless @primed end |
#after(&block) ⇒ Object
84 85 86 |
# File 'lib/dsl.rb', line 84 def after &block @torrents.each { |torrent| yield(torrent) } end |
#download(link, options = {}) ⇒ Object
76 77 78 |
# File 'lib/dsl.rb', line 76 def download(link, = {}) Torrent.download(link, , self.) end |
#download_complete(torrents) ⇒ Object
48 49 50 |
# File 'lib/dsl.rb', line 48 def download_complete(torrents) run_dsl(torrents, :torrent) end |
#feeds ⇒ Object
56 57 58 |
# File 'lib/dsl.rb', line 56 def feeds @feeds end |
#filter(&block) ⇒ Object
80 81 82 |
# File 'lib/dsl.rb', line 80 def filter &block @items.each { |item| yield(item) } end |
#log ⇒ Object
68 69 70 |
# File 'lib/dsl.rb', line 68 def log [:logger] end |
#options ⇒ Object
72 73 74 |
# File 'lib/dsl.rb', line 72 def end |
#parse_metadata(item) ⇒ Object
64 65 66 |
# File 'lib/dsl.rb', line 64 def (item) Lexicon.parse(item) end |
#perform_filter(items) ⇒ Object
44 45 46 |
# File 'lib/dsl.rb', line 44 def perform_filter(items) run_dsl(items, :filter) end |