feedjira 3.2.1 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +17 -0
- data/.github/workflows/ruby.yml +2 -2
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -7
- data/.rubocop_todo.yml +28 -4
- data/CHANGELOG.md +17 -0
- data/Gemfile +13 -3
- data/README.md +3 -4
- data/feedjira.gemspec +4 -14
- data/lib/feedjira/configuration.rb +1 -1
- data/lib/feedjira/core_ext/date.rb +3 -6
- data/lib/feedjira/core_ext/time.rb +3 -3
- data/lib/feedjira/feed_entry_utilities.rb +4 -5
- data/lib/feedjira/feed_utilities.rb +3 -7
- data/lib/feedjira/parser/json_feed.rb +5 -2
- data/lib/feedjira/rss_entry_utilities.rb +5 -1
- data/lib/feedjira/version.rb +1 -1
- data/lib/feedjira.rb +0 -4
- data/spec/feedjira/core_ext/time_spec.rb +57 -0
- data/spec/feedjira/feed_spec.rb +39 -11
- data/spec/feedjira/feed_utilities_entry_spec.rb +1 -1
- data/spec/feedjira/feed_utilities_spec.rb +7 -5
- data/spec/feedjira/parser/json_feed_spec.rb +13 -1
- data/spec/feedjira/parser/rss_entry_spec.rb +7 -1
- data/spec/feedjira/parser/rss_feed_burner_entry_spec.rb +1 -0
- data/spec/feedjira/parser/rss_spec.rb +1 -1
- data/spec/feedjira_spec.rb +11 -1
- data/spec/sample_feeds/RSSWithComments.xml +277 -0
- data/spec/sample_feeds/itunes_feedburner.xml +117 -0
- data/spec/sample_feeds/json_feed.json +2 -0
- data/spec/sample_feeds.rb +3 -1
- data/spec/spec_helper.rb +3 -0
- data/spec/support/coverage.rb +10 -0
- metadata +22 -190
- data/lib/feedjira/date_time_utilities/date_time_epoch_parser.rb +0 -14
- data/lib/feedjira/date_time_utilities/date_time_language_parser.rb +0 -24
- data/lib/feedjira/date_time_utilities/date_time_pattern_parser.rb +0 -30
- data/lib/feedjira/date_time_utilities.rb +0 -30
- data/spec/feedjira/feed_utilities_date_time_spec.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12ef7af9ab5efeab944facbebb844c347458d7cc422927f0971f74606a0a57a3
|
4
|
+
data.tar.gz: 1d3c99b6799f173aaeea41b8e91f1e28c68cebfe59af92da0c32320c90d8ff20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c8527d5cfdc791d27cc970223575cdd4a75831d1665f63b7f650b733f4c9f7dadbd071ea3403c97a107d8cfbb930abc631a9428acadd3316f22e46802b7f2a2
|
7
|
+
data.tar.gz: b2710b27a649c0544e7f4f71a05117e96bc63c4fff9c3be0a7273ea4a173063b963e59dae9ed1c59aace5ca6319cb56f7012e994c9cecd8b2158f8931299bfbe
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
3
|
+
# Please see the documentation for all configuration options:
|
4
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
5
|
+
|
6
|
+
version: 2
|
7
|
+
updates:
|
8
|
+
- package-ecosystem: "bundler" # See documentation for possible values
|
9
|
+
directory: "/" # Location of package manifests
|
10
|
+
schedule:
|
11
|
+
interval: "weekly"
|
12
|
+
assignees:
|
13
|
+
- "mockdeep"
|
14
|
+
groups:
|
15
|
+
all:
|
16
|
+
patterns:
|
17
|
+
- "*"
|
data/.github/workflows/ruby.yml
CHANGED
@@ -3,7 +3,7 @@ name: Ruby
|
|
3
3
|
on:
|
4
4
|
push:
|
5
5
|
branches:
|
6
|
-
-
|
6
|
+
- main
|
7
7
|
pull_request:
|
8
8
|
|
9
9
|
jobs:
|
@@ -12,7 +12,7 @@ jobs:
|
|
12
12
|
fail-fast: false
|
13
13
|
matrix:
|
14
14
|
os: [ubuntu]
|
15
|
-
ruby: [2.
|
15
|
+
ruby: [2.7, 3.0, 3.1, 3.2, 3.3]
|
16
16
|
handler: [nokogiri, ox, oga]
|
17
17
|
exclude:
|
18
18
|
- { ruby: jruby, handler: ox }
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -6,7 +6,7 @@ require:
|
|
6
6
|
- rubocop-performance
|
7
7
|
|
8
8
|
AllCops:
|
9
|
-
TargetRubyVersion: 2.
|
9
|
+
TargetRubyVersion: 2.7
|
10
10
|
NewCops: enable
|
11
11
|
|
12
12
|
# Offense count: 3
|
@@ -29,9 +29,6 @@ Layout/LineLength:
|
|
29
29
|
Exclude:
|
30
30
|
- 'spec/**/*.rb'
|
31
31
|
|
32
|
-
Style/AsciiComments:
|
33
|
-
Enabled: false
|
34
|
-
|
35
32
|
Style/IfUnlessModifier:
|
36
33
|
Enabled: false
|
37
34
|
|
@@ -59,8 +56,5 @@ RSpec/MultipleMemoizedHelpers:
|
|
59
56
|
RSpec/BeforeAfterAll:
|
60
57
|
Enabled: false
|
61
58
|
|
62
|
-
RSpec/VerifiedDoubles:
|
63
|
-
Enabled: false
|
64
|
-
|
65
59
|
RSpec/RepeatedExample:
|
66
60
|
Enabled: false
|
data/.rubocop_todo.yml
CHANGED
@@ -1,11 +1,35 @@
|
|
1
1
|
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
2
|
+
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400`
|
3
|
+
# on 2023-12-16 21:24:13 UTC using RuboCop version 1.59.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 16
|
10
|
+
# Configuration parameters: AllowedConstants.
|
10
11
|
Style/Documentation:
|
11
|
-
|
12
|
+
Exclude:
|
13
|
+
- 'spec/**/*'
|
14
|
+
- 'test/**/*'
|
15
|
+
- 'lib/feedjira/atom_entry_utilities.rb'
|
16
|
+
- 'lib/feedjira/core_ext/string.rb'
|
17
|
+
- 'lib/feedjira/core_ext/time.rb'
|
18
|
+
- 'lib/feedjira/feed.rb'
|
19
|
+
- 'lib/feedjira/feed_entry_utilities.rb'
|
20
|
+
- 'lib/feedjira/feed_utilities.rb'
|
21
|
+
- 'lib/feedjira/parser.rb'
|
22
|
+
- 'lib/feedjira/parser/atom_youtube_entry.rb'
|
23
|
+
- 'lib/feedjira/parser/globally_unique_identifier.rb'
|
24
|
+
- 'lib/feedjira/parser/google_docs_atom.rb'
|
25
|
+
- 'lib/feedjira/parser/google_docs_atom_entry.rb'
|
26
|
+
- 'lib/feedjira/parser/itunes_rss_owner.rb'
|
27
|
+
- 'lib/feedjira/parser/podlove_chapter.rb'
|
28
|
+
- 'lib/feedjira/preprocessor.rb'
|
29
|
+
- 'lib/feedjira/rss_entry_utilities.rb'
|
30
|
+
|
31
|
+
# Offense count: 1
|
32
|
+
# This cop supports safe autocorrection (--autocorrect).
|
33
|
+
Style/SuperWithArgsParentheses:
|
34
|
+
Exclude:
|
35
|
+
- 'lib/feedjira/feed_utilities.rb'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Feedjira Changelog
|
2
2
|
|
3
|
+
## 3.2.3
|
4
|
+
|
5
|
+
* Switch date parse error to debug (#492)
|
6
|
+
|
7
|
+
## 3.2.2
|
8
|
+
|
9
|
+
* Fix time handling again usec is not a timezone
|
10
|
+
|
11
|
+
* Update rubocop * drop official support for eol Ruby
|
12
|
+
|
13
|
+
|
14
|
+
## 3.2.1
|
15
|
+
|
16
|
+
* Fix time handling in ruby 3.1
|
17
|
+
|
18
|
+
* Atom feeds now have an icon field via https://github.com/feedjira/feedjira/pull/452 (@jswanner)
|
19
|
+
|
3
20
|
## 3.2.0
|
4
21
|
|
5
22
|
* Atom `feed_url` no longer falls back to `url` via https://github.com/feedjira/feedjira/pull/451 (@frederfred)
|
data/Gemfile
CHANGED
@@ -4,8 +4,18 @@ source "https://rubygems.org/"
|
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
+
gem "faraday", "~> 2.8.1"
|
8
|
+
gem "pry", "~> 0.14.2"
|
9
|
+
gem "rspec", "~> 3.13.0"
|
10
|
+
gem "rubocop", "~> 1.60.1"
|
11
|
+
gem "rubocop-performance", "~> 1.20.0"
|
12
|
+
gem "rubocop-rake", "~> 0.6.0"
|
13
|
+
gem "rubocop-rspec", "~> 2.26.1"
|
14
|
+
gem "simplecov", "~> 0.22.0"
|
15
|
+
gem "yard", "~> 0.9.34"
|
16
|
+
|
7
17
|
group :test do
|
8
|
-
gem "oga"
|
9
|
-
gem "ox", platforms: %i[mri rbx]
|
10
|
-
gem "rake"
|
18
|
+
gem "oga", "~> 3.4"
|
19
|
+
gem "ox", "~> 2.14.17", platforms: %i[mri rbx]
|
20
|
+
gem "rake", "~> 13.1.0"
|
11
21
|
end
|
data/README.md
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# Feedjira
|
2
2
|
|
3
|
-
[![Build Status][
|
3
|
+
[![Build Status][actions-badge]][actions] [![Code Climate][code-climate-badge]][code-climate]
|
4
4
|
|
5
|
-
[
|
6
|
-
[
|
5
|
+
[actions-badge]: https://github.com/feedjira/feedjira/actions/workflows/ruby.yml/badge.svg?branch=main
|
6
|
+
[actions]: https://github.com/feedjira/feedjira/actions?query=branch%3Amain
|
7
7
|
[code-climate-badge]: https://codeclimate.com/github/feedjira/feedjira/badges/gpa.svg
|
8
8
|
[code-climate]: https://codeclimate.com/github/feedjira/feedjira
|
9
9
|
[gitter-badge]: https://badges.gitter.im/feedjira/feedjira.svg
|
10
|
-
[gitter]: https://gitter.im/feedjira/feedjira?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
|
11
10
|
|
12
11
|
Feedjira is a Ruby library designed to parse feeds.
|
13
12
|
|
data/feedjira.gemspec
CHANGED
@@ -22,25 +22,15 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.metadata = {
|
23
23
|
"homepage_uri" => "https://github.com/feedjira/feedjira",
|
24
24
|
"source_code_uri" => "https://github.com/feedjira/feedjira",
|
25
|
-
"changelog_uri" => "https://github.com/feedjira/feedjira/blob/
|
25
|
+
"changelog_uri" => "https://github.com/feedjira/feedjira/blob/main/CHANGELOG.md",
|
26
26
|
"rubygems_mfa_required" => "true"
|
27
27
|
}
|
28
28
|
|
29
29
|
s.files = `git ls-files`.split("\n")
|
30
30
|
s.require_paths = ["lib"]
|
31
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
32
31
|
|
33
|
-
s.required_ruby_version = ">=2.
|
32
|
+
s.required_ruby_version = ">=2.7"
|
34
33
|
|
35
|
-
s.
|
36
|
-
s.
|
37
|
-
|
38
|
-
s.add_development_dependency "faraday"
|
39
|
-
s.add_development_dependency "pry"
|
40
|
-
s.add_development_dependency "rspec"
|
41
|
-
s.add_development_dependency "rubocop"
|
42
|
-
s.add_development_dependency "rubocop-performance"
|
43
|
-
s.add_development_dependency "rubocop-rake"
|
44
|
-
s.add_development_dependency "rubocop-rspec"
|
45
|
-
s.add_development_dependency "yard"
|
34
|
+
s.add_runtime_dependency "loofah", ">= 2.3.1", "< 3"
|
35
|
+
s.add_runtime_dependency "sax-machine", ">= 1.0", "< 2"
|
46
36
|
end
|
@@ -59,13 +59,13 @@ module Feedjira
|
|
59
59
|
# @private
|
60
60
|
def default_parsers
|
61
61
|
[
|
62
|
+
Feedjira::Parser::ITunesRSS,
|
62
63
|
Feedjira::Parser::RSSFeedBurner,
|
63
64
|
Feedjira::Parser::GoogleDocsAtom,
|
64
65
|
Feedjira::Parser::AtomYoutube,
|
65
66
|
Feedjira::Parser::AtomFeedBurner,
|
66
67
|
Feedjira::Parser::AtomGoogleAlerts,
|
67
68
|
Feedjira::Parser::Atom,
|
68
|
-
Feedjira::Parser::ITunesRSS,
|
69
69
|
Feedjira::Parser::RSS,
|
70
70
|
Feedjira::Parser::JSONFeed
|
71
71
|
]
|
@@ -9,14 +9,11 @@ class Date
|
|
9
9
|
feed_utils_to_time(new_offset, :gm)
|
10
10
|
end
|
11
11
|
|
12
|
-
def feed_utils_to_local_time
|
13
|
-
feed_utils_to_time(new_offset(DateTime.now.offset - offset), :local)
|
14
|
-
end
|
15
|
-
|
16
12
|
private
|
17
13
|
|
18
14
|
def feed_utils_to_time(dest, method)
|
19
|
-
|
20
|
-
|
15
|
+
# Convert a fraction of a day to a number of microseconds
|
16
|
+
usec = (dest.sec_fraction * (10**6)).to_i
|
17
|
+
Time.send(method, dest.year, dest.month, dest.day, dest.hour, dest.min, dest.sec, usec)
|
21
18
|
end
|
22
19
|
end
|
@@ -16,12 +16,12 @@ class Time
|
|
16
16
|
if datetime.is_a?(Time)
|
17
17
|
datetime.utc
|
18
18
|
elsif datetime.respond_to?(:to_datetime)
|
19
|
-
datetime.
|
20
|
-
|
19
|
+
datetime.to_time.utc
|
20
|
+
else
|
21
21
|
parse_string_safely datetime.to_s
|
22
22
|
end
|
23
23
|
rescue StandardError => e
|
24
|
-
Feedjira.logger.debug
|
24
|
+
Feedjira.logger.debug("Failed to parse time #{datetime}")
|
25
25
|
Feedjira.logger.debug(e)
|
26
26
|
nil
|
27
27
|
end
|
@@ -3,7 +3,6 @@
|
|
3
3
|
module Feedjira
|
4
4
|
module FeedEntryUtilities
|
5
5
|
include Enumerable
|
6
|
-
include DateTimeUtilities
|
7
6
|
|
8
7
|
def published
|
9
8
|
@published ||= @updated
|
@@ -12,8 +11,8 @@ module Feedjira
|
|
12
11
|
def parse_datetime(string)
|
13
12
|
DateTime.parse(string).feed_utils_to_gm_time
|
14
13
|
rescue StandardError => e
|
15
|
-
Feedjira.logger.
|
16
|
-
Feedjira.logger.
|
14
|
+
Feedjira.logger.debug("Failed to parse date #{string.inspect}")
|
15
|
+
Feedjira.logger.debug(e)
|
17
16
|
nil
|
18
17
|
end
|
19
18
|
|
@@ -64,11 +63,11 @@ module Feedjira
|
|
64
63
|
end
|
65
64
|
|
66
65
|
def [](field)
|
67
|
-
instance_variable_get("@#{field}")
|
66
|
+
instance_variable_get(:"@#{field}")
|
68
67
|
end
|
69
68
|
|
70
69
|
def []=(field, value)
|
71
|
-
instance_variable_set("@#{field}", value)
|
70
|
+
instance_variable_set(:"@#{field}", value)
|
72
71
|
end
|
73
72
|
end
|
74
73
|
end
|
@@ -41,11 +41,7 @@ module Feedjira
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def last_modified
|
44
|
-
@last_modified ||=
|
45
|
-
published = entries.reject { |e| e.published.nil? }
|
46
|
-
entry = published.max_by(&:published)
|
47
|
-
entry ? entry.published : nil
|
48
|
-
end
|
44
|
+
@last_modified ||= entries.reject { |e| e.published.nil? }.max_by(&:published)&.published
|
49
45
|
end
|
50
46
|
|
51
47
|
def updated?
|
@@ -78,7 +74,7 @@ module Feedjira
|
|
78
74
|
if old_value == new_value
|
79
75
|
false
|
80
76
|
else
|
81
|
-
send("#{name}=", new_value)
|
77
|
+
send(:"#{name}=", new_value)
|
82
78
|
true
|
83
79
|
end
|
84
80
|
end
|
@@ -95,7 +91,7 @@ module Feedjira
|
|
95
91
|
# entries just parsed and insert each one as a new entry until we get to
|
96
92
|
# one that has the same id as the the newest for the feed.
|
97
93
|
def find_new_entries_for(feed)
|
98
|
-
return feed.entries if entries.
|
94
|
+
return feed.entries if entries.empty?
|
99
95
|
|
100
96
|
latest_entry = entries.first
|
101
97
|
found_new_entries = []
|
@@ -15,8 +15,8 @@ module Feedjira
|
|
15
15
|
new(JSON.parse(json))
|
16
16
|
end
|
17
17
|
|
18
|
-
attr_reader :json, :version, :title, :url, :feed_url, :
|
19
|
-
:expired, :entries
|
18
|
+
attr_reader :json, :version, :title, :description, :url, :feed_url, :icon, :favicon,
|
19
|
+
:language, :expired, :entries
|
20
20
|
|
21
21
|
def initialize(json)
|
22
22
|
@json = json
|
@@ -24,7 +24,10 @@ module Feedjira
|
|
24
24
|
@title = json.fetch("title")
|
25
25
|
@url = json.fetch("home_page_url", nil)
|
26
26
|
@feed_url = json.fetch("feed_url", nil)
|
27
|
+
@icon = json.fetch("icon", nil)
|
28
|
+
@favicon = json.fetch("favicon", nil)
|
27
29
|
@description = json.fetch("description", nil)
|
30
|
+
@language = json.fetch("language", nil)
|
28
31
|
@expired = json.fetch("expired", nil)
|
29
32
|
@entries = parse_items(json["items"])
|
30
33
|
end
|
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
module Feedjira
|
4
4
|
module RSSEntryUtilities
|
5
|
-
|
5
|
+
# rubocop:todo Metrics/MethodLength
|
6
|
+
def self.included(mod) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
6
7
|
mod.class_exec do
|
7
8
|
element :title
|
8
9
|
|
@@ -34,9 +35,12 @@ module Feedjira
|
|
34
35
|
element :"media:content", as: :image, value: :url
|
35
36
|
element :enclosure, as: :image, value: :url
|
36
37
|
|
38
|
+
element :comments
|
39
|
+
|
37
40
|
elements :category, as: :categories
|
38
41
|
end
|
39
42
|
end
|
43
|
+
# rubocop:enable Metrics/MethodLength
|
40
44
|
|
41
45
|
def entry_id
|
42
46
|
@entry_id&.guid
|
data/lib/feedjira/version.rb
CHANGED
data/lib/feedjira.rb
CHANGED
@@ -8,10 +8,6 @@ require "json"
|
|
8
8
|
|
9
9
|
require "feedjira/core_ext"
|
10
10
|
require "feedjira/configuration"
|
11
|
-
require "feedjira/date_time_utilities/date_time_epoch_parser"
|
12
|
-
require "feedjira/date_time_utilities/date_time_language_parser"
|
13
|
-
require "feedjira/date_time_utilities/date_time_pattern_parser"
|
14
|
-
require "feedjira/date_time_utilities"
|
15
11
|
require "feedjira/feed_entry_utilities"
|
16
12
|
require "feedjira/feed_utilities"
|
17
13
|
require "feedjira/feed"
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
RSpec.describe Time do
|
6
|
+
describe "#parse_safely" do
|
7
|
+
it "returns the datetime in utc when given a Time" do
|
8
|
+
time = described_class.now
|
9
|
+
|
10
|
+
expect(described_class.parse_safely(time)).to eq(time.utc)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns the datetime in utc when given a Date" do
|
14
|
+
date = Date.today
|
15
|
+
|
16
|
+
expect(described_class.parse_safely(date)).to eq(date.to_time.utc)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns the datetime in utc when given a String" do
|
20
|
+
timestamp = "2016-01-01 00:00:00"
|
21
|
+
|
22
|
+
expect(described_class.parse_safely(timestamp)).to eq(described_class.parse(timestamp).utc)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns nil when given an empty String" do
|
26
|
+
timestamp = ""
|
27
|
+
|
28
|
+
expect(described_class.parse_safely(timestamp)).to be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns the the datetime in utc given a 14-digit time" do
|
32
|
+
time = described_class.now.utc
|
33
|
+
timestamp = time.strftime("%Y%m%d%H%M%S")
|
34
|
+
|
35
|
+
expect(described_class.parse_safely(timestamp)).to eq(time.floor)
|
36
|
+
end
|
37
|
+
|
38
|
+
context "when given an invalid time string" do
|
39
|
+
it "returns nil" do
|
40
|
+
timestamp = "2016-51-51 00:00:00"
|
41
|
+
|
42
|
+
expect(described_class.parse_safely(timestamp)).to be_nil
|
43
|
+
end
|
44
|
+
|
45
|
+
it "logs an error" do
|
46
|
+
timestamp = "2016-51-51 00:00:00"
|
47
|
+
|
48
|
+
expect(Feedjira.logger)
|
49
|
+
.to receive(:debug).with("Failed to parse time #{timestamp}")
|
50
|
+
expect(Feedjira.logger)
|
51
|
+
.to receive(:debug).with(an_instance_of(ArgumentError))
|
52
|
+
|
53
|
+
described_class.parse_safely(timestamp)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/spec/feedjira/feed_spec.rb
CHANGED
@@ -2,17 +2,8 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
class Hell < StandardError; end
|
6
|
-
|
7
|
-
class FailParser
|
8
|
-
def self.parse(_xml)
|
9
|
-
yield "this parser always fails."
|
10
|
-
# on_failure.call
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
5
|
describe Feedjira::Feed do
|
15
|
-
describe "
|
6
|
+
describe ".add_common_feed_element" do
|
16
7
|
before(:all) do
|
17
8
|
described_class.add_common_feed_element("generator")
|
18
9
|
end
|
@@ -30,7 +21,25 @@ describe Feedjira::Feed do
|
|
30
21
|
end
|
31
22
|
end
|
32
23
|
|
33
|
-
describe "
|
24
|
+
describe ".add_common_feed_elements" do
|
25
|
+
before do
|
26
|
+
described_class.add_common_feed_elements(:foos)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "parses the added element out of Atom feeds" do
|
30
|
+
expect(Feedjira.parse(sample_wfw_feed).foos).to eq []
|
31
|
+
end
|
32
|
+
|
33
|
+
it "parses the added element out of Atom Feedburner feeds" do
|
34
|
+
expect(Feedjira::Parser::Atom.new).to respond_to(:foos)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "parses the added element out of RSS feeds" do
|
38
|
+
expect(Feedjira::Parser::RSS.new).to respond_to(:foos)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe ".add_common_feed_entry_element" do
|
34
43
|
before(:all) do
|
35
44
|
tag = "wfw:commentRss"
|
36
45
|
described_class.add_common_feed_entry_element tag, as: :comment_rss
|
@@ -49,4 +58,23 @@ describe Feedjira::Feed do
|
|
49
58
|
expect(Feedjira::Parser::RSSEntry.new).to respond_to(:comment_rss)
|
50
59
|
end
|
51
60
|
end
|
61
|
+
|
62
|
+
describe ".add_common_feed_entry_elements" do
|
63
|
+
before do
|
64
|
+
described_class.add_common_feed_entry_elements(:things)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "parses the added element out of Atom feeds entries" do
|
68
|
+
entry = Feedjira.parse(sample_wfw_feed).entries.first
|
69
|
+
expect(entry.things).to eq []
|
70
|
+
end
|
71
|
+
|
72
|
+
it "parses the added element out of Atom Feedburner feeds entries" do
|
73
|
+
expect(Feedjira::Parser::AtomEntry.new).to respond_to(:things)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "parses the added element out of RSS feeds entries" do
|
77
|
+
expect(Feedjira::Parser::RSSEntry.new).to respond_to(:things)
|
78
|
+
end
|
79
|
+
end
|
52
80
|
end
|
@@ -19,7 +19,7 @@ describe Feedjira::FeedUtilities do
|
|
19
19
|
it "parses a ISO 8601 with milliseconds into Time" do
|
20
20
|
time = @klass.new.parse_datetime("2013-09-17T08:20:13.931-04:00")
|
21
21
|
expect(time.class).to eq Time
|
22
|
-
expect(time).to eq Time.
|
22
|
+
expect(time).to eq Time.strptime("Tue Sep 17 12:20:13.931 UTC 2013", "%a %b %d %H:%M:%S.%N %Z %Y")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -20,7 +20,7 @@ describe Feedjira::FeedUtilities do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
context "when the flag is set" do
|
23
|
-
it "calls the preprocessing method" do
|
23
|
+
it "calls the preprocessing method" do # rubocop:todo RSpec/NoExpectationExample
|
24
24
|
@klass.preprocess_xml = true
|
25
25
|
allow(@klass).to receive(:preprocess).and_return sample_rss_feed
|
26
26
|
@klass.parse sample_rss_feed
|
@@ -78,7 +78,7 @@ describe Feedjira::FeedUtilities do
|
|
78
78
|
it "returns new_entries? as true when entries are put into new_entries" do
|
79
79
|
feed = @klass.new
|
80
80
|
feed.new_entries << :foo
|
81
|
-
expect(feed.new_entries?).to
|
81
|
+
expect(feed.new_entries?).to be true
|
82
82
|
end
|
83
83
|
|
84
84
|
it "returns a last_modified value from the entry with the most recent published date if the last_modified date hasn't been set" do
|
@@ -116,6 +116,7 @@ describe Feedjira::FeedUtilities do
|
|
116
116
|
it "updates the title if changed" do
|
117
117
|
@updated_feed.title = "new title"
|
118
118
|
@feed.update_from_feed(@updated_feed)
|
119
|
+
|
119
120
|
expect(@feed.title).to eq @updated_feed.title
|
120
121
|
expect(@feed).to be_updated
|
121
122
|
end
|
@@ -252,11 +253,12 @@ describe Feedjira::FeedUtilities do
|
|
252
253
|
let(:url_one) { "http://example.com/post_one.html" }
|
253
254
|
let(:url_two) { "http://example.com/post_two.html" }
|
254
255
|
|
255
|
-
let(:entry_one) {
|
256
|
-
|
256
|
+
let(:entry_one) { object_double(Feedjira::Parser::AtomEntry.new, entry_id: id_one, url: url_one) }
|
257
|
+
|
258
|
+
let(:entry_two) { object_double(Feedjira::Parser::AtomEntry.new, entry_id: id_two, url: url_two) }
|
257
259
|
|
258
260
|
let(:feed_one) { Feedjira::Parser::Atom.new }
|
259
|
-
let(:feed_two) {
|
261
|
+
let(:feed_two) { object_double(Feedjira::Parser::Atom.new, entries: [entry_two]) }
|
260
262
|
|
261
263
|
before do
|
262
264
|
stub_const("Feedjira::FeedUtilities::UPDATABLE_ATTRIBUTES", [])
|
@@ -43,8 +43,20 @@ module Feedjira
|
|
43
43
|
expect(@feed.description).to eq "Brent Simmons’s weblog."
|
44
44
|
end
|
45
45
|
|
46
|
+
it "parses the favicon" do
|
47
|
+
expect(@feed.favicon).to eq "http://inessential.com/favicon.ico"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "parses the icon" do
|
51
|
+
expect(@feed.icon).to eq "http://inessential.com/icon.png"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "parses the language" do
|
55
|
+
expect(@feed.language).to eq "en-US"
|
56
|
+
end
|
57
|
+
|
46
58
|
it "parses expired and return default (nil)" do
|
47
|
-
expect(@feed.expired).to
|
59
|
+
expect(@feed.expired).to be_nil
|
48
60
|
end
|
49
61
|
|
50
62
|
it "parses entries" do
|
@@ -72,6 +72,7 @@ describe Feedjira::Parser::RSSEntry do
|
|
72
72
|
author
|
73
73
|
categories
|
74
74
|
comment_rss
|
75
|
+
comments
|
75
76
|
content
|
76
77
|
entry_id
|
77
78
|
published
|
@@ -99,7 +100,7 @@ describe Feedjira::Parser::RSSEntry do
|
|
99
100
|
|
100
101
|
it "ignores urls from guids with isPermaLink='false'" do
|
101
102
|
feed = Feedjira.parse(sample_rss_feed_permalinks)
|
102
|
-
expect(feed.entries[0].url).to
|
103
|
+
expect(feed.entries[0].url).to be_nil
|
103
104
|
end
|
104
105
|
|
105
106
|
it "gets urls from guids with isPermaLink='true'" do
|
@@ -116,4 +117,9 @@ describe Feedjira::Parser::RSSEntry do
|
|
116
117
|
feed = Feedjira.parse(sample_rss_feed_permalinks)
|
117
118
|
expect(feed.entries[3].url).to eq "http://example.com/4"
|
118
119
|
end
|
120
|
+
|
121
|
+
it "exposes comments URL" do
|
122
|
+
feed = Feedjira.parse(sample_rss_feed_with_comments)
|
123
|
+
expect(feed.entries[0].comments).to eq "https://news.ycombinator.com/item?id=30937433"
|
124
|
+
end
|
119
125
|
end
|