Selaa lähdekoodia

Rename get and get_all methods to fetch and fetch_all

master
Adrian Short 12 vuotta sitten
vanhempi
commit
18403cbc29
2 muutettua tiedostoa jossa 6 lisäystä ja 2 poistoa
  1. +2
    -2
      app/controllers/feeds_controller.rb
  2. +4
    -0
      app/models/feed.rb

+ 2
- 2
app/controllers/feeds_controller.rb Näytä tiedosto

@@ -87,12 +87,12 @@ class FeedsController < ApplicationController
def fetch
@feed = Feed.find(params[:id])
@feed.get
@feed.fetch
redirect_to :back, notice: 'Feed fetched OK'
end
def fetch_all
Feed.get_all
Feed.fetch_all
redirect_to :back, notice: 'All feeds fetched OK'
end
end

+ 4
- 0
app/models/feed.rb Näytä tiedosto

@@ -5,15 +5,19 @@ class Feed < ActiveRecord::Base
validates_format_of :feed_url, :with => URI::regexp(%w(http https)), :message => "must be a valid URL"
after_create :get
after_create :fetch
# Fetch and parse feed contents from web

def self.get_all
Feed.all.each { |f| f.get }
def self.fetch_all
Feed.all.each { |f| f.fetch }
end

def get
puts "Fetching feed: #{@url}"
def fetch
Feedzirra::Feed.add_common_feed_entry_element('georss:point', :as => :point)
Feedzirra::Feed.add_common_feed_entry_element('geo:lat', :as => :geo_lat)
Feedzirra::Feed.add_common_feed_entry_element('geo:long', :as => :geo_long)


Ladataan…
Peruuta
Tallenna