Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rss::Crons .get_feed_from and .update_from_feed added, using feedzirra.
- Loading branch information
Showing
3 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
activesupport (3.1.4) | ||
multi_json (~> 1.0) | ||
builder (3.0.0) | ||
curb (0.7.18) | ||
diff-lcs (1.1.3) | ||
feedzirra (0.1.3) | ||
activesupport (~> 3.1.1) | ||
builder (>= 2.1.2) | ||
curb (~> 0.7.15) | ||
i18n (>= 0.5.0) | ||
loofah (~> 1.2.0) | ||
nokogiri (>= 1.4.4) | ||
rake (>= 0.8.7) | ||
rdoc (~> 3.8) | ||
sax-machine (~> 0.1.0) | ||
git (1.2.5) | ||
i18n (0.6.0) | ||
jeweler (1.8.3) | ||
bundler (~> 1.0) | ||
git (>= 1.2.5) | ||
rake | ||
rdoc | ||
json (1.6.6) | ||
loofah (1.2.0) | ||
nokogiri (>= 1.4.4) | ||
multi_json (1.2.0) | ||
nokogiri (1.5.2) | ||
rake (0.9.2.2) | ||
rdoc (3.12) | ||
json (~> 1.4) | ||
rspec (2.8.0) | ||
rspec-core (~> 2.8.0) | ||
rspec-expectations (~> 2.8.0) | ||
rspec-mocks (~> 2.8.0) | ||
rspec-core (2.8.0) | ||
rspec-expectations (2.8.0) | ||
diff-lcs (~> 1.1.2) | ||
rspec-mocks (2.8.0) | ||
sax-machine (0.1.0) | ||
nokogiri (> 0.0.0) | ||
simplecov (0.6.1) | ||
multi_json (~> 1.0) | ||
simplecov-html (~> 0.5.3) | ||
simplecov-html (0.5.3) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
bundler (~> 1.0.0) | ||
feedzirra | ||
jeweler (~> 1.8.3) | ||
rdoc (~> 3.12) | ||
rspec (~> 2.8.0) | ||
simplecov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require "feedzirra" | ||
|
||
module Rss | ||
module Crons | ||
def self.get_feed_from(feed_url) | ||
@feed = Feedzirra::Feed.fetch_and_parse(feed_url) | ||
end | ||
|
||
def self.update_from_feed | ||
@feed.new_entries.tap do |feed_new_entries| | ||
record = self.new | ||
feed_new_entries.each do |entry| | ||
entry.to_hash.each do |key, value| | ||
self[key.to_sym] = value.sanitize | ||
end | ||
record.save | ||
end | ||
end | ||
end | ||
end | ||
end |