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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cfb9a3890a3f90598c222cca47320362a63fd8026b3dbc6132b200ec8936a325
4
- data.tar.gz: c65a9dc970da43abfa4496721bc5cf909515956c4b6d5c1f72a6d4adb6fe0502
3
+ metadata.gz: 96f99a816804e1d3a4234199193d08128433f75d0ddccb974682b5d3fd48882b
4
+ data.tar.gz: c280b360d4113c2a1807b05afa9cc63917b4cdab73da6076021b9f7f90ee1a38
5
5
  SHA512:
6
- metadata.gz: a5e61889e5523c0717583b28c38d8eee344024dca0153cbb1c6e80cd45fe8645845ecd31017bc4ca56d92de09a2ac24cd560ae8989100fd3317636f9aaf6b07d
7
- data.tar.gz: 21452d3b4316ea51be4c6e7cccd9e90a532aa182d8010090321a6ba8371cdb146f10fca4eeb6908f705bd63d889e1d4db408765322bcbd2fc5ee7f48c9300e1e
6
+ metadata.gz: e2a55528d5a34d9dd030b61bae6c8b999ba3730dab12658a684bbcee06c1c7fe3c14bf15788c3a994070bc6305467138fbb3e62fd4b311160d5b4071b531c1c3
7
+ data.tar.gz: f02a4f4db982c97ab005feb0e4294ea87094766aad75b36d1f2ef00a8dab499d3e4425702c8f71bd743f45acd9067b2787072bf4aa7b5abdd479fed40cc17315
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- html2rss (0.3.2)
4
+ html2rss (0.3.3)
5
5
  faraday (~> 0.15)
6
6
  faraday_middleware (~> 0.13)
7
7
  hashie (~> 3.6)
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
- And then execute: `bundle`
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(
@@ -7,7 +7,7 @@ module Html2rss
7
7
  end
8
8
 
9
9
  def get
10
- ending = @options['end'].to_i.positive? ? @options['end'].to_i : @value.length
10
+ ending = @options.fetch('end', false) ? @options['end'].to_i : @value.length
11
11
  @value[@options['start'].to_i..ending]
12
12
  end
13
13
  end
@@ -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
- post_process_options = attribute_config.fetch('post_process', false)
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, options)
63
- Html2rss::AttributePostProcessors.get_processor(options)
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
@@ -1,3 +1,3 @@
1
1
  module Html2rss
2
- VERSION = '0.3.2'.freeze
2
+ VERSION = '0.3.3'.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.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gil Desmarais