Class: RSS_Check

Inherits:
Object
  • Object
show all
Defined in:
lib/rss_check.rb

Defined Under Namespace

Classes: LIRS_File, RSS_File

Instance Method Summary collapse

Constructor Details

#initialize(paths, cache_file = nil, init_now = false) ⇒ RSS_Check

Returns a new instance of RSS_Check.



131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/rss_check.rb', line 131

def initialize paths, cache_file=nil, init_now=false
  @paths = paths
  @db = YAML::Store.new(cache_file) if cache_file
  @rss_files = paths.map{|uri|
    load_file(uri) ||
      if /LIRS:(.+)/ =~ uri
        LIRS_File.new($1, init_now)
      else
        RSS_File.new(uri, init_now)
      end
  }
end

Instance Method Details

#checkObject



144
145
146
147
148
# File 'lib/rss_check.rb', line 144

def check
  @rss_files.map{|rf|
    rf.check
  }.flatten
end

#clearObject



172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/rss_check.rb', line 172

def clear
  debug = $DEBUG
  $DEBUG = false
  if @db
    @db.transaction{
      @db.keys.each{|k|
        @db.delete k
      }
    }
  end
ensure
  $DEBUG = debug
end

#load_file(file) ⇒ Object



162
163
164
165
166
167
168
169
170
# File 'lib/rss_check.rb', line 162

def load_file file
  debug = $DEBUG
  $DEBUG = false
  @db.transaction{
    @db[file]
  } if @db
ensure
  $DEBUG = debug
end

#saveObject



150
151
152
153
154
155
156
157
158
159
160
# File 'lib/rss_check.rb', line 150

def save
  debug = $DEBUG
  $DEBUG = false
  @db.transaction{
    @paths.each_with_index{|path, i|
      @db[path] = @rss_files[i]
    }
  } if @db
ensure
  $DEBUG = debug
end