pointmd_comments 0.1.4 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 198cd3c27d299997ca927ded8927ca90390751e51f7c21015b27b871915bfc0e
4
- data.tar.gz: 27bb94862cbc8d391c9274fa2e921a10e62adb0d72892a4fb1a0070ec1190e17
3
+ metadata.gz: 2a8d49153c05c07e558908b1c19086c4262bc11d756bcff25e6b6bde5a910296
4
+ data.tar.gz: 2177d0c16b2081673973716b3b7234c81ac1ce381d8e1c06176b4749aca68ccf
5
5
  SHA512:
6
- metadata.gz: 2cab6853272b96d288ff0ec49b8b3924a884285fde307ecd56549f7d217dda576aa3f5813a85f908ed75c581db4cf2f3ed8d3b1b6d41702554ec81f9af633c1f
7
- data.tar.gz: 56235e2eb248b0a2987b296686af0448be815ab0fc805db12cd8e4559ae73f6f8d799ec106494dd7957e324596790b405965391f56c728a981e903a472f02c0b
6
+ metadata.gz: 893a9e4361e7dad02e3de991cc7a8590137f55ce766d620a3a8fbd59a5388f0a01d7266dc341d70b03603ecb5665db7530952991387179e20cc3b7ce888b7927
7
+ data.tar.gz: 827406d9bf3c0a374645af5a8405f1a603e6fc72826c9abff692d2b1532adcad1c6c60bacace4e78adc4f698725717291f5ba3df61188839babc0030803853d0
@@ -1,6 +1,8 @@
1
1
  module PointmdComments
2
2
  module Aggregators
3
3
  class Main
4
+ CHROME_ARGS = %w[disable-dev-shm-usage disable-software-rasterizer no-sandbox].freeze
5
+
4
6
  attr_reader :posts_aggregator, :browser, :comments_aggregator, :all_comments, :posts, :source, :output, :path
5
7
 
6
8
  def initialize(options)
@@ -10,7 +12,12 @@ module PointmdComments
10
12
  @source = options[:source] || Aggregators::Posts::DEFAULT_SOURCE
11
13
  @posts_aggregator = Aggregators::Posts.new(source: source, path: path)
12
14
  @comments_aggregator = Aggregators::Comments.new
13
- @browser = ::Watir::Browser.new :chrome, headless: true
15
+
16
+ client = Selenium::WebDriver::Remote::Http::Default.new
17
+ # NOTE: #timeout= is deprecated, use #read_timeout= and #open_timeout= instead
18
+ client.timeout = 600 # instead of the default 60 (seconds)
19
+
20
+ @browser = ::Watir::Browser.new :chrome, http_client: client, headless: true, args: CHROME_ARGS
14
21
  @all_comments = []
15
22
  end
16
23
 
@@ -46,7 +53,9 @@ module PointmdComments
46
53
  end
47
54
 
48
55
  def write_to_csv
49
- file_path = output
56
+ # File#expand_path is needed to process paths like '~/test.txt' => '/Users/me/test.txt'
57
+ file_path = File.expand_path(output)
58
+ puts "File Path is #{file_path}"
50
59
 
51
60
  CSV.open(file_path, 'w') do |csv|
52
61
  all_comments.each { |c| csv << c }
@@ -11,7 +11,6 @@ module PointmdComments
11
11
  def initialize(source:, path:)
12
12
  @source = source
13
13
  @path = path
14
- @urls = []
15
14
  end
16
15
 
17
16
  def call
@@ -41,22 +40,14 @@ module PointmdComments
41
40
  end
42
41
 
43
42
  def fetch_news_posts
44
- posts_block = @page.css('.post-blocks-wrap')
45
- main_post_heading = posts_block.children.css('.post-big-block').children.css('h2')
46
-
47
- main_post = main_post_heading.children.css('a').first['href']
48
- other_posts = posts_block.children.css('.post-small-blocks-wrap')
49
-
50
- populate_urls(main_post, other_posts)
51
- end
52
-
53
- def populate_urls(main_post, other_posts)
54
- @urls << main_post
55
-
56
- @urls += other_posts.children.map do |child|
57
- child.css('article').css('h2').children[1]['href']
58
- rescue StandardError
59
- next
43
+ # NOTE: .post-blocks-wrap does not exist anymore
44
+ # Find <article> tags instead
45
+ articles = @page.css('article')
46
+
47
+ @urls = articles.map do |article|
48
+ article.css('a').last.attribute('href').to_s
49
+ rescue StandardError => e
50
+ puts e
60
51
  end.compact
61
52
  end
62
53
 
@@ -1,3 +1,3 @@
1
1
  module PointmdComments
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '0.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pointmd_comments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolai Stoianov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-14 00:00:00.000000000 Z
11
+ date: 2021-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubygems_version: 3.1.2
123
+ rubygems_version: 3.2.3
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Point.md comments aggregator