Class: ODDB::RssPlugin

Inherits:
Plugin show all
Defined in:
src/plugin/rss.rb

Constant Summary

Constants inherited from Plugin

ARCHIVE_PATH, RECIPIENTS

Instance Method Summary (collapse)

Methods inherited from Plugin

#initialize, #l10n_sessions, #log_info, #recipients, #report, #resolve_link, #update_rss_feeds

Methods included from HttpFile

#http_body, #http_file

Constructor Details

This class inherits a constructor from ODDB::Plugin

Instance Method Details

- (Object) sort_packages(packages)



40
41
42
43
44
45
# File 'src/plugin/rss.rb', line 40

def sort_packages(packages)
  packages.sort_by { |pac|
    time = pac.price_public.valid_from
    [-time.year, -time.month, -time.day, pac]
  }
end

- (Object) update_price_feeds(month = @@today)



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
# File 'src/plugin/rss.rb', line 11

def update_price_feeds(month=@@today)
  @month = month
  cuts = []
  rises = []
  news = []
  cutoff = (month << 1) + 1 
  first = Time.local(cutoff.year, cutoff.month, cutoff.day)
  last = Time.local(month.year, month.month, month.day)
  range = first..last
  @app.each_package { |package|
    if((current = package.price_public) \
      && (range.include?(current.valid_from)))
      previous = package.price_public(1)
      target = if previous.nil?
                 news if current.authority == :sl
               elsif [:sl, :lppv, :bag].include?(package.data_origin(:price_public))
                 if previous > current
                   cuts
                 elsif current > previous
                   rises
                 end
               end
      target.push(package) if(target)
    end
  }
  update_rss_feeds('sl_introduction.rss', sort_packages(news), View::Rss::SlIntroduction)
  update_rss_feeds('price_cut.rss', sort_packages(cuts), View::Rss::PriceCut)
  update_rss_feeds('price_rise.rss', sort_packages(rises), View::Rss::PriceRise)
end