feedjira 3.2.2 → 3.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/spec/sample_feeds.rb CHANGED
@@ -10,6 +10,7 @@ module SampleFeeds
10
10
  sample_atom_feed_line_breaks: "AtomFeedWithSpacesAroundEquals.xml",
11
11
  sample_atom_entry_content: "AmazonWebServicesBlogFirstEntryContent.xml",
12
12
  sample_itunes_feed: "itunes.xml",
13
+ sample_itunes_feedburner_feed: "itunes_feedburner.xml",
13
14
  sample_itunes_feed_with_single_quotes: "ITunesWithSingleQuotedAttributes.xml",
14
15
  sample_itunes_feed_with_spaces: "ITunesWithSpacesInAttributes.xml",
15
16
  sample_podlove_feed: "CRE.xml",
@@ -31,6 +32,7 @@ module SampleFeeds
31
32
  sample_youtube_atom_feed: "youtube_atom.xml",
32
33
  sample_atom_xhtml_with_escpaed_html_in_pre_tag_feed: "AtomEscapedHTMLInPreTag.xml",
33
34
  sample_json_feed: "json_feed.json",
35
+ sample_json_feed_with_escaped_uris: "json_feed_with_escaped_uris.json",
34
36
  sample_rss_feed_huffpost_ca: "HuffPostCanada.xml",
35
37
  sample_invalid_date_format_feed: "InvalidDateFormat.xml",
36
38
  sample_rss_feed_permalinks: "Permalinks.xml",
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # coverage setup must come before loading lib/ code
4
+ require "support/coverage"
5
+
3
6
  require File.expand_path("#{File.dirname(__FILE__)}/../lib/feedjira")
4
7
  require "sample_feeds"
5
8
 
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "simplecov"
4
+
5
+ SimpleCov.start do
6
+ enable_coverage :branch
7
+ add_filter "_spec.rb"
8
+ end
9
+
10
+ SimpleCov.minimum_coverage(line: 98, branch: 75)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedjira
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Hess
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2022-10-19 00:00:00.000000000 Z
17
+ date: 2025-01-09 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: loofah
@@ -23,6 +23,9 @@ dependencies:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
25
  version: 2.3.1
26
+ - - "<"
27
+ - !ruby/object:Gem::Version
28
+ version: '3'
26
29
  type: :runtime
27
30
  prerelease: false
28
31
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,6 +33,9 @@ dependencies:
30
33
  - - ">="
31
34
  - !ruby/object:Gem::Version
32
35
  version: 2.3.1
36
+ - - "<"
37
+ - !ruby/object:Gem::Version
38
+ version: '3'
33
39
  - !ruby/object:Gem::Dependency
34
40
  name: sax-machine
35
41
  requirement: !ruby/object:Gem::Requirement
@@ -37,6 +43,9 @@ dependencies:
37
43
  - - ">="
38
44
  - !ruby/object:Gem::Version
39
45
  version: '1.0'
46
+ - - "<"
47
+ - !ruby/object:Gem::Version
48
+ version: '2'
40
49
  type: :runtime
41
50
  prerelease: false
42
51
  version_requirements: !ruby/object:Gem::Requirement
@@ -44,118 +53,9 @@ dependencies:
44
53
  - - ">="
45
54
  - !ruby/object:Gem::Version
46
55
  version: '1.0'
47
- - !ruby/object:Gem::Dependency
48
- name: faraday
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '0'
61
- - !ruby/object:Gem::Dependency
62
- name: pry
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '0'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
- - !ruby/object:Gem::Dependency
76
- name: rspec
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '0'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: '0'
89
- - !ruby/object:Gem::Dependency
90
- name: rubocop
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: '0'
103
- - !ruby/object:Gem::Dependency
104
- name: rubocop-performance
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: '0'
117
- - !ruby/object:Gem::Dependency
118
- name: rubocop-rake
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- version: '0'
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- version: '0'
131
- - !ruby/object:Gem::Dependency
132
- name: rubocop-rspec
133
- requirement: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- version: '0'
138
- type: :development
139
- prerelease: false
140
- version_requirements: !ruby/object:Gem::Requirement
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: '0'
145
- - !ruby/object:Gem::Dependency
146
- name: yard
147
- requirement: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - ">="
150
- - !ruby/object:Gem::Version
151
- version: '0'
152
- type: :development
153
- prerelease: false
154
- version_requirements: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - ">="
56
+ - - "<"
157
57
  - !ruby/object:Gem::Version
158
- version: '0'
58
+ version: '2'
159
59
  description:
160
60
  email:
161
61
  executables: []
@@ -164,6 +64,7 @@ extra_rdoc_files: []
164
64
  files:
165
65
  - ".github/ISSUE_TEMPLATE/feed-parsing.md"
166
66
  - ".github/ISSUE_TEMPLATE/general-issue.md"
67
+ - ".github/dependabot.yml"
167
68
  - ".github/workflows/ruby.yml"
168
69
  - ".gitignore"
169
70
  - ".rspec"
@@ -183,10 +84,6 @@ files:
183
84
  - lib/feedjira/core_ext/date.rb
184
85
  - lib/feedjira/core_ext/string.rb
185
86
  - lib/feedjira/core_ext/time.rb
186
- - lib/feedjira/date_time_utilities.rb
187
- - lib/feedjira/date_time_utilities/date_time_epoch_parser.rb
188
- - lib/feedjira/date_time_utilities/date_time_language_parser.rb
189
- - lib/feedjira/date_time_utilities/date_time_pattern_parser.rb
190
87
  - lib/feedjira/feed.rb
191
88
  - lib/feedjira/feed_entry_utilities.rb
192
89
  - lib/feedjira/feed_utilities.rb
@@ -218,8 +115,8 @@ files:
218
115
  - lib/feedjira/rss_entry_utilities.rb
219
116
  - lib/feedjira/version.rb
220
117
  - spec/feedjira/configuration_spec.rb
118
+ - spec/feedjira/core_ext/time_spec.rb
221
119
  - spec/feedjira/feed_spec.rb
222
- - spec/feedjira/feed_utilities_date_time_spec.rb
223
120
  - spec/feedjira/feed_utilities_entry_spec.rb
224
121
  - spec/feedjira/feed_utilities_spec.rb
225
122
  - spec/feedjira/parser/atom_entry_spec.rb
@@ -282,17 +179,20 @@ files:
282
179
  - spec/sample_feeds/atom_with_link_tag_for_url_unmarked.xml
283
180
  - spec/sample_feeds/google_alerts_atom.xml
284
181
  - spec/sample_feeds/itunes.xml
182
+ - spec/sample_feeds/itunes_feedburner.xml
285
183
  - spec/sample_feeds/json_feed.json
184
+ - spec/sample_feeds/json_feed_with_escaped_uris.json
286
185
  - spec/sample_feeds/pet_atom.xml
287
186
  - spec/sample_feeds/youtube_atom.xml
288
187
  - spec/spec_helper.rb
188
+ - spec/support/coverage.rb
289
189
  homepage: https://github.com/feedjira/feedjira
290
190
  licenses:
291
191
  - MIT
292
192
  metadata:
293
193
  homepage_uri: https://github.com/feedjira/feedjira
294
194
  source_code_uri: https://github.com/feedjira/feedjira
295
- changelog_uri: https://github.com/feedjira/feedjira/blob/master/CHANGELOG.md
195
+ changelog_uri: https://github.com/feedjira/feedjira/blob/main/CHANGELOG.md
296
196
  rubygems_mfa_required: 'true'
297
197
  post_install_message:
298
198
  rdoc_options: []
@@ -309,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
309
209
  - !ruby/object:Gem::Version
310
210
  version: '0'
311
211
  requirements: []
312
- rubygems_version: 3.4.0.dev
212
+ rubygems_version: 3.4.10
313
213
  signing_key:
314
214
  specification_version: 4
315
215
  summary: A feed parsing library
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Feedjira
4
- module DateTimeUtilities
5
- class DateTimeEpochParser
6
- def self.parse(string)
7
- epoch_time = string.to_i
8
- return Time.at(epoch_time).to_datetime if epoch_time.to_s == string
9
-
10
- raise "#{string} is not a valid epoch time"
11
- end
12
- end
13
- end
14
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Feedjira
4
- module DateTimeUtilities
5
- class DateTimeLanguageParser
6
- MONTHS_ENGLISH =
7
- %w[Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec].freeze
8
- MONTHS_SPANISH =
9
- %w[Ene Feb Mar Abr May Jun Jul Ago Sep Oct Nov Dic].freeze
10
-
11
- def self.parse(string)
12
- DateTime.parse(translate(string))
13
- end
14
-
15
- def self.translate(string)
16
- MONTHS_SPANISH.each_with_index do |m, i|
17
- rgx = Regexp.new("\s#{m}\s", Regexp::IGNORECASE)
18
- return string.gsub(rgx, MONTHS_ENGLISH[i]) if string&.match?(rgx)
19
- end
20
- raise "No translation found for #{string}"
21
- end
22
- end
23
- end
24
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Feedjira
4
- module DateTimeUtilities
5
- class DateTimePatternParser
6
- # Japanese Symbols are required for strange Date Strings like
7
- # '水, 31 8 2016 07:37:00 PDT'
8
- JAPANESE_SYMBOLS = %w[日 月 火 水 木 金 土].freeze
9
- PATTERNS = ["%m/%d/%Y %T %p", "%d %m %Y %T %Z"].freeze
10
-
11
- def self.parse(string)
12
- PATTERNS.each do |p|
13
- datetime = DateTime.strptime(prepare(string), p)
14
- return datetime
15
- rescue StandardError => e
16
- Feedjira.logger.debug("Failed to parse date #{string}")
17
- Feedjira.logger.debug(e)
18
- nil
19
- end
20
- raise "No pattern matched #{string}"
21
- end
22
-
23
- def self.prepare(string)
24
- rgx = Regexp.new("^(#{JAPANESE_SYMBOLS.join('|')}),\s")
25
- string.gsub(rgx, "")
26
- end
27
- private_class_method :prepare
28
- end
29
- end
30
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Feedjira
4
- module DateTimeUtilities
5
- # This is our date parsing heuristic.
6
- # Date Parsers are attempted in order.
7
- DATE_PARSERS = [
8
- DateTimePatternParser,
9
- DateTimeLanguageParser,
10
- DateTimeEpochParser,
11
- DateTime
12
- ].freeze
13
-
14
- # Parse the given string starting with the most common parser (default ruby)
15
- # and going over all other available parsers
16
- def parse_datetime(string)
17
- res = DATE_PARSERS.detect do |parser|
18
- return parser.parse(string).feed_utils_to_gm_time
19
- rescue StandardError => e
20
- Feedjira.logger.debug { "Failed to parse date #{string}" }
21
- Feedjira.logger.debug(e)
22
- nil
23
- end
24
-
25
- Feedjira.logger.warn { "Failed to parse date #{string}" } if res.nil?
26
-
27
- res
28
- end
29
- end
30
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- describe Feedjira::FeedUtilities do
6
- before do
7
- @klass = Class.new do
8
- include Feedjira::DateTimeUtilities
9
- end
10
- end
11
-
12
- describe "handling dates" do
13
- it "parses an ISO 8601 formatted datetime into Time" do
14
- time = @klass.new.parse_datetime("2008-02-20T8:05:00-010:00")
15
- expect(time.class).to eq Time
16
- expect(time).to eq Time.parse_safely("Wed Feb 20 18:05:00 UTC 2008")
17
- end
18
-
19
- it "parses a ISO 8601 with milliseconds into Time" do
20
- time = @klass.new.parse_datetime("2013-09-17T08:20:13.931-04:00")
21
- expect(time.class).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
- end
24
-
25
- it "parses a US Format into Time" do
26
- time = @klass.new.parse_datetime("8/23/2016 12:29:58 PM")
27
- expect(time.class).to eq Time
28
- expect(time).to eq Time.parse_safely("Wed Aug 23 12:29:58 UTC 2016")
29
- end
30
-
31
- it "parses a Spanish Format into Time" do
32
- time = @klass.new.parse_datetime("Wed, 31 Ago 2016 11:08:22 GMT")
33
- expect(time.class).to eq Time
34
- expect(time).to eq Time.parse_safely("Wed Aug 31 11:08:22 UTC 2016")
35
- end
36
-
37
- it "parses Format with japanese symbols into Time" do
38
- time = @klass.new.parse_datetime("水, 31 8 2016 07:37:00 PDT")
39
- expect(time.class).to eq Time
40
- expect(time).to eq Time.parse_safely("Wed Aug 31 14:37:00 UTC 2016")
41
- end
42
-
43
- it "parses epoch into Time" do
44
- time = @klass.new.parse_datetime("1472654220")
45
- expect(time.class).to eq Time
46
- expect(time).to eq Time.parse_safely("Wed Aug 31 14:37:00 UTC 2016")
47
- end
48
- end
49
- end