html2rss 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/CHANGELOG.md +10 -1
  4. data/Gemfile.lock +3 -1
  5. data/README.md +35 -2
  6. data/html2rss.gemspec +1 -0
  7. data/lib/html2rss/attribute_post_processors/sanitize_html.rb +1 -3
  8. data/lib/html2rss/config.rb +4 -0
  9. data/lib/html2rss/item.rb +7 -4
  10. data/lib/html2rss/utils.rb +8 -0
  11. data/lib/html2rss/version.rb +1 -1
  12. metadata +15 -35
  13. data/docs/Html2rss.html +0 -353
  14. data/docs/Html2rss/AttributePostProcessors.html +0 -203
  15. data/docs/Html2rss/AttributePostProcessors/HtmlToMarkdown.html +0 -325
  16. data/docs/Html2rss/AttributePostProcessors/ParseTime.html +0 -326
  17. data/docs/Html2rss/AttributePostProcessors/ParseUri.html +0 -314
  18. data/docs/Html2rss/AttributePostProcessors/SanitizeHtml.html +0 -367
  19. data/docs/Html2rss/AttributePostProcessors/Substring.html +0 -321
  20. data/docs/Html2rss/AttributePostProcessors/Template.html +0 -336
  21. data/docs/Html2rss/Config.html +0 -847
  22. data/docs/Html2rss/FeedBuilder.html +0 -295
  23. data/docs/Html2rss/Item.html +0 -660
  24. data/docs/Html2rss/ItemExtractors.html +0 -297
  25. data/docs/Html2rss/ItemExtractors/Attribute.html +0 -317
  26. data/docs/Html2rss/ItemExtractors/CurrentTime.html +0 -297
  27. data/docs/Html2rss/ItemExtractors/Href.html +0 -319
  28. data/docs/Html2rss/ItemExtractors/Html.html +0 -314
  29. data/docs/Html2rss/ItemExtractors/Static.html +0 -301
  30. data/docs/Html2rss/ItemExtractors/Text.html +0 -312
  31. data/docs/Html2rss/Utils.html +0 -200
  32. data/docs/Html2rss/Utils/IndifferentAccessHash.html +0 -142
  33. data/docs/_index.html +0 -307
  34. data/docs/class_list.html +0 -51
  35. data/docs/css/common.css +0 -1
  36. data/docs/css/full_list.css +0 -58
  37. data/docs/css/style.css +0 -496
  38. data/docs/file.README.html +0 -135
  39. data/docs/file_list.html +0 -56
  40. data/docs/frames.html +0 -17
  41. data/docs/index.html +0 -135
  42. data/docs/js/app.js +0 -303
  43. data/docs/js/full_list.js +0 -216
  44. data/docs/js/jquery.js +0 -4
  45. data/docs/method_list.html +0 -467
  46. data/docs/top-level-namespace.html +0 -110
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1dd1359a4c5131040c10f884cbe5ddf2645b6e8cd08432b48be3bba3259dabf1
4
- data.tar.gz: cacf06dc936557983db59d2cab8fa5d98f6deccac9d321021a9d2794bf4fee5b
3
+ metadata.gz: 803f570ac19ab526a065ab4514725b15e692f9fc3ead0516f337841afce35f20
4
+ data.tar.gz: 887228a092ec286b5796b98ba92b32cb1391eab9abceee1d05dae042a8b607ac
5
5
  SHA512:
6
- metadata.gz: a82068417d47cb9f15848526667d30bb5f26bbf7e36f1b2ad66381f2830d2aa753c0b7e14bda2ed65a7539535920167a85383b4ce37299d5fe10d52771397087
7
- data.tar.gz: a6a53e264a5830b11d1dc8b498807cb9147a3bbc36156c0abc926f12e58d72c6668ebd7def89baf86b6e92ed56163a8553859d705e563884ae43ead7e639c07f
6
+ metadata.gz: 6526864907dd58f6a9add414e9db804a47c23c0d74907d8b055eeba020754c42d20bb97e5bd344925dbf87129fe4c73e97c6b79adb5eed687ad4f243d6bf7e74
7
+ data.tar.gz: 392c4e2f690c7f7e5a3ed511780bc44bd36dde70e237cb524f5f6cb7515d044bd7cc052456763c09e789999063cf513b8bff4c0c99bfdc857a3769f6bd9fc2ad
@@ -18,6 +18,9 @@ Metrics/ModuleLength:
18
18
  Exclude:
19
19
  - "**/*_spec.rb"
20
20
 
21
+ Metrics/MethodLength:
22
+ Max: 15
23
+
21
24
  Documentation:
22
25
  Enabled: false
23
26
 
@@ -1,4 +1,13 @@
1
- # [](https://github.com/gildesmarais/html2rss/compare/v0.4.1...v) (2019-09-18)
1
+ # [](https://github.com/gildesmarais/html2rss/compare/v0.5.0...v) (2019-09-18)
2
+
3
+
4
+
5
+ # [0.5.0](https://github.com/gildesmarais/html2rss/compare/v0.4.1...v0.5.0) (2019-09-18)
6
+
7
+
8
+ ### Features
9
+
10
+ * support JSON ([#37](https://github.com/gildesmarais/html2rss/issues/37)) ([d258f73](https://github.com/gildesmarais/html2rss/commit/d258f73))
2
11
 
3
12
 
4
13
 
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- html2rss (0.4.1)
4
+ html2rss (0.5.0)
5
5
  activesupport (~> 5.0)
6
+ builder
6
7
  faraday (~> 0.15)
7
8
  faraday_middleware (~> 0.13)
8
9
  hashie (~> 3.6)
@@ -19,6 +20,7 @@ GEM
19
20
  minitest (~> 5.1)
20
21
  tzinfo (~> 1.1)
21
22
  ast (2.4.0)
23
+ builder (3.2.3)
22
24
  byebug (11.0.1)
23
25
  concurrent-ruby (1.1.5)
24
26
  crass (1.0.4)
data/README.md CHANGED
@@ -1,13 +1,15 @@
1
1
  ![html2rss logo](https://github.com/gildesmarais/html2rss/raw/master/support/logo.png)
2
2
 
3
- # html2rss [![Build Status](https://travis-ci.org/gildesmarais/html2rss.svg?branch=master)](https://travis-ci.org/gildesmarais/html2rss) [![Gem Version](https://badge.fury.io/rb/html2rss.svg)](https://badge.fury.io/rb/html2rss)
3
+ [![Build Status](https://travis-ci.org/gildesmarais/html2rss.svg?branch=master)](https://travis-ci.org/gildesmarais/html2rss)
4
+ [![Gem Version](https://badge.fury.io/rb/html2rss.svg)](http://rubygems.org/gems/html2rss/)
5
+ [API docs on RubyDoc.info](https://www.rubydoc.info/gems/html2rss)
4
6
 
5
7
  Request HTML from an URL and transform it to a Ruby RSS 2.0 object.
6
8
 
7
9
  **Are you searching for a ready to use "website to RSS" solution?**
8
10
  [Check out `html2rss-web`!](https://github.com/gildesmarais/html2rss-web)
9
11
 
10
- Each website needs a *feed config* which contains the URL to scrape and
12
+ Each website needs a _feed config_ which contains the URL to scrape and
11
13
  CSS selectors to extract the required information (like title, URL, ...).
12
14
  This gem provides [extractors](https://github.com/gildesmarais/html2rss/blob/master/lib/html2rss/item_extractors) (e.g. extract the information from an HTML attribute)
13
15
  and chainable [post processors](https://github.com/gildesmarais/html2rss/tree/master/lib/html2rss/attribute_post_processors) to make information retrieval even easier.
@@ -40,6 +42,37 @@ an `RSS:Rss` object.
40
42
 
41
43
  **Too complicated?** See [`html2rss-configs`](https://github.com/gildesmarais/html2rss-configs) for ready-made feed configs!
42
44
 
45
+ ## Scraping JSON
46
+
47
+ Since 0.5.0 it is possible to scrape and process JSON.
48
+
49
+ Adding `json: true` to the channel config will convert the JSON response to XML.
50
+
51
+ Example:
52
+
53
+ ```json
54
+ {
55
+ "data": [{ "title": "Headline", "url": "https://example.com" }]
56
+ }
57
+ ```
58
+
59
+ will be converted to:
60
+
61
+ ```xml
62
+ <html>
63
+ <data>
64
+ <datum>
65
+ <title>Headline</title>
66
+ <url>https://example.com</url>
67
+ </datum>
68
+ </data>
69
+ </html>
70
+ ```
71
+
72
+ Your items selector would be `data > datum`, the item's link selector would be `url`.
73
+
74
+ Under the hood it uses ActiveSupport's [`Hash.to_xml`](https://apidock.com/rails/Hash/to_xml) core extension for the JSON to XML conversion.
75
+
43
76
  ## Development
44
77
 
45
78
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ['lib']
29
29
 
30
30
  spec.add_dependency 'activesupport', '~> 5.0'
31
+ spec.add_dependency 'builder'
31
32
  spec.add_dependency 'faraday', '~> 0.15'
32
33
  spec.add_dependency 'faraday_middleware', '~> 0.13'
33
34
  spec.add_dependency 'hashie', '~> 3.6'
@@ -43,9 +43,7 @@ module Html2rss
43
43
  def get
44
44
  Sanitize.fragment(@value, Sanitize::Config.merge(
45
45
  Sanitize::Config::RELAXED,
46
- attributes: {
47
- all: %w[dir lang alt title translate]
48
- },
46
+ attributes: { all: %w[dir lang alt title translate] },
49
47
  add_attributes: {
50
48
  'a' => {
51
49
  'rel' => 'nofollow noopener noreferrer',
@@ -35,6 +35,10 @@ module Html2rss
35
35
  channel_config.fetch 'time_zone', 'UTC'
36
36
  end
37
37
 
38
+ def json?
39
+ channel_config.fetch 'json', false
40
+ end
41
+
38
42
  def headers
39
43
  global_config.fetch('headers', {})
40
44
  end
@@ -49,19 +49,22 @@ module Html2rss
49
49
  ##
50
50
  # @return [Array]
51
51
  def self.from_url(url, config)
52
- page = Nokogiri::HTML(get_body_from_url(url, config.headers))
53
- page.css(config.selector('items')).map do |xml_item|
52
+ body = get_body_from_url(url, config)
53
+
54
+ Nokogiri::HTML(body).css(config.selector('items')).map do |xml_item|
54
55
  new xml_item, config
55
56
  end
56
57
  end
57
58
 
58
59
  private
59
60
 
60
- def self.get_body_from_url(url, headers)
61
- Faraday.new(url: url, headers: headers) do |faraday|
61
+ def self.get_body_from_url(url, config)
62
+ body = Faraday.new(url: url, headers: config.headers) do |faraday|
62
63
  faraday.use FaradayMiddleware::FollowRedirects
63
64
  faraday.adapter Faraday.default_adapter
64
65
  end.get.body
66
+
67
+ config.json? ? Html2rss::Utils.hash_to_xml(JSON.parse(body)) : body
65
68
  end
66
69
  private_class_method :get_body_from_url
67
70
 
@@ -1,4 +1,8 @@
1
+ require 'active_support/core_ext/hash'
2
+ require 'builder'
1
3
  require 'hashie'
4
+ require 'json'
5
+ require 'nokogiri'
2
6
 
3
7
  module Html2rss
4
8
  module Utils
@@ -20,5 +24,9 @@ module Html2rss
20
24
  uri.fragment = url.fragment if url.fragment
21
25
  end
22
26
  end
27
+
28
+ def self.hash_to_xml(hash)
29
+ hash.to_xml(root: :html, skip_instruct: true, skip_types: true)
30
+ end
23
31
  end
24
32
  end
@@ -1,3 +1,3 @@
1
1
  module Html2rss
2
- VERSION = '0.4.1'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html2rss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gil Desmarais
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: builder
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: faraday
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -260,40 +274,6 @@ files:
260
274
  - README.md
261
275
  - bin/console
262
276
  - bin/setup
263
- - docs/Html2rss.html
264
- - docs/Html2rss/AttributePostProcessors.html
265
- - docs/Html2rss/AttributePostProcessors/HtmlToMarkdown.html
266
- - docs/Html2rss/AttributePostProcessors/ParseTime.html
267
- - docs/Html2rss/AttributePostProcessors/ParseUri.html
268
- - docs/Html2rss/AttributePostProcessors/SanitizeHtml.html
269
- - docs/Html2rss/AttributePostProcessors/Substring.html
270
- - docs/Html2rss/AttributePostProcessors/Template.html
271
- - docs/Html2rss/Config.html
272
- - docs/Html2rss/FeedBuilder.html
273
- - docs/Html2rss/Item.html
274
- - docs/Html2rss/ItemExtractors.html
275
- - docs/Html2rss/ItemExtractors/Attribute.html
276
- - docs/Html2rss/ItemExtractors/CurrentTime.html
277
- - docs/Html2rss/ItemExtractors/Href.html
278
- - docs/Html2rss/ItemExtractors/Html.html
279
- - docs/Html2rss/ItemExtractors/Static.html
280
- - docs/Html2rss/ItemExtractors/Text.html
281
- - docs/Html2rss/Utils.html
282
- - docs/Html2rss/Utils/IndifferentAccessHash.html
283
- - docs/_index.html
284
- - docs/class_list.html
285
- - docs/css/common.css
286
- - docs/css/full_list.css
287
- - docs/css/style.css
288
- - docs/file.README.html
289
- - docs/file_list.html
290
- - docs/frames.html
291
- - docs/index.html
292
- - docs/js/app.js
293
- - docs/js/full_list.js
294
- - docs/js/jquery.js
295
- - docs/method_list.html
296
- - docs/top-level-namespace.html
297
277
  - html2rss.gemspec
298
278
  - lib/html2rss.rb
299
279
  - lib/html2rss/attribute_post_processors.rb
@@ -1,353 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>
7
- Module: Html2rss
8
-
9
- &mdash; Documentation by YARD 0.9.20
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
-
15
- <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
-
17
- <script type="text/javascript" charset="utf-8">
18
- pathId = "Html2rss";
19
- relpath = '';
20
- </script>
21
-
22
-
23
- <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
-
25
- <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
-
27
-
28
- </head>
29
- <body>
30
- <div class="nav_wrap">
31
- <iframe id="nav" src="class_list.html?1"></iframe>
32
- <div id="resizer"></div>
33
- </div>
34
-
35
- <div id="main" tabindex="-1">
36
- <div id="header">
37
- <div id="menu">
38
-
39
- <a href="_index.html">Index (H)</a> &raquo;
40
-
41
-
42
- <span class="title">Html2rss</span>
43
-
44
- </div>
45
-
46
- <div id="search">
47
-
48
- <a class="full_list_link" id="class_list_link"
49
- href="class_list.html">
50
-
51
- <svg width="24" height="24">
52
- <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
- <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
- <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
- </svg>
56
- </a>
57
-
58
- </div>
59
- <div class="clear"></div>
60
- </div>
61
-
62
- <div id="content"><h1>Module: Html2rss
63
-
64
-
65
-
66
- </h1>
67
- <div class="box_info">
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
- <dl>
80
- <dt>Defined in:</dt>
81
- <dd>lib/html2rss.rb<span class="defines">,<br />
82
- lib/html2rss/item.rb,<br /> lib/html2rss/utils.rb,<br /> lib/html2rss/config.rb,<br /> lib/html2rss/version.rb,<br /> lib/html2rss/feed_builder.rb,<br /> lib/html2rss/item_extractors.rb,<br /> lib/html2rss/item_extractors/href.rb,<br /> lib/html2rss/item_extractors/html.rb,<br /> lib/html2rss/item_extractors/text.rb,<br /> lib/html2rss/item_extractors/static.rb,<br /> lib/html2rss/attribute_post_processors.rb,<br /> lib/html2rss/item_extractors/attribute.rb,<br /> lib/html2rss/item_extractors/current_time.rb,<br /> lib/html2rss/attribute_post_processors/template.rb,<br /> lib/html2rss/attribute_post_processors/parse_uri.rb,<br /> lib/html2rss/attribute_post_processors/substring.rb,<br /> lib/html2rss/attribute_post_processors/parse_time.rb,<br /> lib/html2rss/attribute_post_processors/sanitize_html.rb,<br /> lib/html2rss/attribute_post_processors/html_to_markdown.rb</span>
83
- </dd>
84
- </dl>
85
-
86
- </div>
87
-
88
- <h2>Defined Under Namespace</h2>
89
- <p class="children">
90
-
91
-
92
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="Html2rss/AttributePostProcessors.html" title="Html2rss::AttributePostProcessors (module)">AttributePostProcessors</a></span>, <span class='object_link'><a href="Html2rss/ItemExtractors.html" title="Html2rss::ItemExtractors (module)">ItemExtractors</a></span>, <span class='object_link'><a href="Html2rss/Utils.html" title="Html2rss::Utils (module)">Utils</a></span>
93
-
94
-
95
-
96
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="Html2rss/Config.html" title="Html2rss::Config (class)">Config</a></span>, <span class='object_link'><a href="Html2rss/FeedBuilder.html" title="Html2rss::FeedBuilder (class)">FeedBuilder</a></span>, <span class='object_link'><a href="Html2rss/Item.html" title="Html2rss::Item (class)">Item</a></span>
97
-
98
-
99
- </p>
100
-
101
-
102
- <h2>
103
- Constant Summary
104
- <small><a href="#" class="constants_summary_toggle">collapse</a></small>
105
- </h2>
106
-
107
- <dl class="constants">
108
-
109
- <dt id="VERSION-constant" class="">VERSION =
110
-
111
- </dt>
112
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>0.4.1</span><span class='tstring_end'>&#39;</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
113
-
114
- </dl>
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
- <h2>
125
- Class Method Summary
126
- <small><a href="#" class="summary_toggle">collapse</a></small>
127
- </h2>
128
-
129
- <ul class="summary">
130
-
131
- <li class="public ">
132
- <span class="summary_signature">
133
-
134
- <a href="#feed-class_method" title="feed (class method)">.<strong>feed</strong>(config) &#x21d2; RSS:Rss </a>
135
-
136
-
137
-
138
- </span>
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
- <span class="summary_desc"><div class='inline'>
149
- <p>Returns a RSS object which is generated from the provided config.</p>
150
- </div></span>
151
-
152
- </li>
153
-
154
-
155
- <li class="public ">
156
- <span class="summary_signature">
157
-
158
- <a href="#feed_from_yaml_config-class_method" title="feed_from_yaml_config (class method)">.<strong>feed_from_yaml_config</strong>(file, name) &#x21d2; RSS:Rss </a>
159
-
160
-
161
-
162
- </span>
163
-
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
-
172
- <span class="summary_desc"><div class='inline'>
173
- <p>Returns a RSS object which is generated from the provided file.</p>
174
- </div></span>
175
-
176
- </li>
177
-
178
-
179
- </ul>
180
-
181
-
182
-
183
-
184
- <div id="class_method_details" class="method_details_list">
185
- <h2>Class Method Details</h2>
186
-
187
-
188
- <div class="method_details first">
189
- <h3 class="signature first" id="feed-class_method">
190
-
191
- .<strong>feed</strong>(config) &#x21d2; <tt>RSS:Rss</tt>
192
-
193
-
194
-
195
-
196
-
197
- </h3><div class="docstring">
198
- <div class="discussion">
199
-
200
- <p>Returns a RSS object which is generated from the provided config.</p>
201
-
202
- <p>`config`: can be a Hash or an instance of Html2rss::Config.</p>
203
-
204
- <p>Example:</p>
205
-
206
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_feed'>feed</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="Html2rss (module)">Html2rss</a></span></span><span class='period'>.</span><span class='id identifier rubyid_feed'>feed</span><span class='lparen'>(</span>
207
- <span class='label'>channel:</span> <span class='lbrace'>{</span> <span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>StackOverflow: Hot Network Questions</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>url:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>https://stackoverflow.com</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span><span class='comma'>,</span>
208
- <span class='label'>selectors:</span> <span class='lbrace'>{</span>
209
- <span class='label'>items:</span> <span class='lbrace'>{</span> <span class='label'>selector:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>#hot-network-questions &gt; ul &gt; li</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span><span class='comma'>,</span>
210
- <span class='label'>title:</span> <span class='lbrace'>{</span> <span class='label'>selector:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>a</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span><span class='comma'>,</span>
211
- <span class='label'>link:</span> <span class='lbrace'>{</span> <span class='label'>selector:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>a</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>extractor:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>href</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span>
212
- <span class='rbrace'>}</span>
213
- <span class='rparen'>)</span>
214
- <span class='comment'># =&gt; #&lt;RSS::Rss:0x00007fb2f48d14a0 ...&gt;
215
- </span></code></pre>
216
-
217
-
218
- </div>
219
- </div>
220
- <div class="tags">
221
-
222
- <p class="tag_title">Returns:</p>
223
- <ul class="return">
224
-
225
- <li>
226
-
227
-
228
- <span class='type'>(<tt>RSS:Rss</tt>)</span>
229
-
230
-
231
-
232
- </li>
233
-
234
- </ul>
235
-
236
- </div><table class="source_code">
237
- <tr>
238
- <td>
239
- <pre class="lines">
240
-
241
-
242
- 48
243
- 49
244
- 50
245
- 51
246
- 52
247
- 53</pre>
248
- </td>
249
- <td>
250
- <pre class="code"><span class="info file"># File 'lib/html2rss.rb', line 48</span>
251
-
252
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_feed'>feed</span><span class='lparen'>(</span><span class='id identifier rubyid_config'>config</span><span class='rparen'>)</span>
253
- <span class='id identifier rubyid_config'>config</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Html2rss/Config.html" title="Html2rss::Config (class)">Config</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Html2rss/Config.html#initialize-instance_method" title="Html2rss::Config#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_config'>config</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="Html2rss/Config.html" title="Html2rss::Config (class)">Config</a></span></span><span class='rparen'>)</span>
254
-
255
- <span class='id identifier rubyid_feed'>feed</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Html2rss/FeedBuilder.html" title="Html2rss::FeedBuilder (class)">FeedBuilder</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Html2rss/FeedBuilder.html#initialize-instance_method" title="Html2rss::FeedBuilder#initialize (method)">new</a></span></span> <span class='id identifier rubyid_config'>config</span>
256
- <span class='id identifier rubyid_feed'>feed</span><span class='period'>.</span><span class='id identifier rubyid_rss'>rss</span>
257
- <span class='kw'>end</span></pre>
258
- </td>
259
- </tr>
260
- </table>
261
- </div>
262
-
263
- <div class="method_details ">
264
- <h3 class="signature " id="feed_from_yaml_config-class_method">
265
-
266
- .<strong>feed_from_yaml_config</strong>(file, name) &#x21d2; <tt>RSS:Rss</tt>
267
-
268
-
269
-
270
-
271
-
272
- </h3><div class="docstring">
273
- <div class="discussion">
274
-
275
- <p>Returns a RSS object which is generated from the provided file.</p>
276
-
277
- <p>`file_path`: a File object of a YAML file `name`: the of the feed</p>
278
-
279
- <p>Example:</p>
280
-
281
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_feed'>feed</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="Html2rss (module)">Html2rss</a></span></span><span class='period'>.</span><span class='id identifier rubyid_feed_from_yaml_config'>feed_from_yaml_config</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>spec</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>config.test.yml</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>nuxt-releases</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
282
- <span class='comment'># =&gt; #&lt;RSS::Rss:0x00007fb2f6331228
283
- </span></code></pre>
284
-
285
-
286
- </div>
287
- </div>
288
- <div class="tags">
289
-
290
- <p class="tag_title">Returns:</p>
291
- <ul class="return">
292
-
293
- <li>
294
-
295
-
296
- <span class='type'>(<tt>RSS:Rss</tt>)</span>
297
-
298
-
299
-
300
- </li>
301
-
302
- </ul>
303
-
304
- </div><table class="source_code">
305
- <tr>
306
- <td>
307
- <pre class="lines">
308
-
309
-
310
- 19
311
- 20
312
- 21
313
- 22
314
- 23
315
- 24
316
- 25
317
- 26
318
- 27
319
- 28
320
- 29</pre>
321
- </td>
322
- <td>
323
- <pre class="code"><span class="info file"># File 'lib/html2rss.rb', line 19</span>
324
-
325
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_feed_from_yaml_config'>feed_from_yaml_config</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
326
- <span class='comment'># rubocop:disable Security/YAMLLoad
327
- </span> <span class='id identifier rubyid_yaml'>yaml</span> <span class='op'>=</span> <span class='const'>YAML</span><span class='period'>.</span><span class='id identifier rubyid_load'>load</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span><span class='rparen'>)</span><span class='rparen'>)</span>
328
- <span class='comment'># rubocop:enable Security/YAMLLoad
329
- </span>
330
- <span class='id identifier rubyid_feed_config'>feed_config</span> <span class='op'>=</span> <span class='id identifier rubyid_yaml'>yaml</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>feeds</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span>
331
- <span class='id identifier rubyid_global_config'>global_config</span> <span class='op'>=</span> <span class='id identifier rubyid_yaml'>yaml</span><span class='period'>.</span><span class='id identifier rubyid_reject'>reject</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='op'>|</span> <span class='id identifier rubyid_key'>key</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>feeds</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span>
332
-
333
- <span class='id identifier rubyid_config'>config</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Html2rss/Config.html" title="Html2rss::Config (class)">Config</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Html2rss/Config.html#initialize-instance_method" title="Html2rss::Config#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_feed_config'>feed_config</span><span class='comma'>,</span> <span class='id identifier rubyid_global_config'>global_config</span><span class='rparen'>)</span>
334
- <span class='id identifier rubyid_feed'>feed</span><span class='lparen'>(</span><span class='id identifier rubyid_config'>config</span><span class='rparen'>)</span>
335
- <span class='kw'>end</span></pre>
336
- </td>
337
- </tr>
338
- </table>
339
- </div>
340
-
341
- </div>
342
-
343
- </div>
344
-
345
- <div id="footer">
346
- Generated on Wed Sep 18 12:52:16 2019 by
347
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
348
- 0.9.20 (ruby-2.6.3).
349
- </div>
350
-
351
- </div>
352
- </body>
353
- </html>