html2rss 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -4
- data/lib/html2rss/attribute_post_processors/substring.rb +1 -1
- data/lib/html2rss/item.rb +11 -6
- data/lib/html2rss/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96f99a816804e1d3a4234199193d08128433f75d0ddccb974682b5d3fd48882b
|
4
|
+
data.tar.gz: c280b360d4113c2a1807b05afa9cc63917b4cdab73da6076021b9f7f90ee1a38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2a55528d5a34d9dd030b61bae6c8b999ba3730dab12658a684bbcee06c1c7fe3c14bf15788c3a994070bc6305467138fbb3e62fd4b311160d5b4071b531c1c3
|
7
|
+
data.tar.gz: f02a4f4db982c97ab005feb0e4294ea87094766aad75b36d1f2ef00a8dab499d3e4425702c8f71bd743f45acd9067b2787072bf4aa7b5abdd479fed40cc17315
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -7,15 +7,15 @@ Request HTML from an URL and transform it to a Ruby RSS 2.0 object.
|
|
7
7
|
**Are you searching for a ready to use "website to RSS" solution?**
|
8
8
|
[Check out `html2rss-web`!](https://github.com/gildesmarais/html2rss-web)
|
9
9
|
|
10
|
-
Each website needs a feed config which contains the URL to scrape and
|
10
|
+
Each website needs a *feed config* which contains the URL to scrape and
|
11
11
|
CSS selectors to extract the required information (like title, URL, ...).
|
12
12
|
This gem provides [extractors](https://github.com/gildesmarais/html2rss/blob/master/lib/html2rss/item_extractor.rb) (e.g. extract the information from an HTML attribute)
|
13
|
-
and [post processors](https://github.com/gildesmarais/html2rss/tree/master/lib/html2rss/attribute_post_processors) to make information retrieval even easier.
|
13
|
+
and chainable [post processors](https://github.com/gildesmarais/html2rss/tree/master/lib/html2rss/attribute_post_processors) to make information retrieval even easier.
|
14
14
|
|
15
15
|
## Installation
|
16
16
|
|
17
|
-
Add this line to your application's Gemfile: `gem 'html2rss'`
|
18
|
-
|
17
|
+
Add this line to your application's Gemfile: `gem 'html2rss'`
|
18
|
+
Then execute: `bundle`
|
19
19
|
|
20
20
|
```ruby
|
21
21
|
rss = Html2rss.feed(
|
data/lib/html2rss/item.rb
CHANGED
@@ -26,10 +26,7 @@ module Html2rss
|
|
26
26
|
proc = ItemExtractor.const_get extractor.upcase.to_sym
|
27
27
|
value = proc.call(xml, attribute_config)
|
28
28
|
|
29
|
-
|
30
|
-
value = post_process(value, post_process_options) if post_process_options
|
31
|
-
|
32
|
-
value
|
29
|
+
post_process(value, attribute_config.fetch('post_process', false))
|
33
30
|
end
|
34
31
|
|
35
32
|
def available_attributes
|
@@ -59,10 +56,18 @@ module Html2rss
|
|
59
56
|
|
60
57
|
private
|
61
58
|
|
62
|
-
def post_process(value,
|
63
|
-
|
59
|
+
def post_process(value, post_process_options = [])
|
60
|
+
return value unless post_process_options
|
61
|
+
|
62
|
+
post_process_options = [post_process_options] unless post_process_options.is_a?(Array)
|
63
|
+
|
64
|
+
post_process_options.each do |options|
|
65
|
+
value = AttributePostProcessors.get_processor(options)
|
64
66
|
.new(value, options, self)
|
65
67
|
.get
|
68
|
+
end
|
69
|
+
|
70
|
+
value
|
66
71
|
end
|
67
72
|
end
|
68
73
|
end
|
data/lib/html2rss/version.rb
CHANGED