pointmd_comments 0.1.2 → 0.1.7

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: d1240669a7cadfb4f4b32107b6a88265099a1ec232d68826c2371b8281e9f16f
4
- data.tar.gz: fb50998e48a4c61ae0d904c26ba9c56a4d297dd21a9b7529178a80d8078565aa
3
+ metadata.gz: 14bdb214817ffa3446133a02ce63339577eefeb5d92b07ec706916d287401698
4
+ data.tar.gz: d56a2648b21a6a6b4c091fe050e6d16f20c20a2c0f4de9dc6a44f64c665ac328
5
5
  SHA512:
6
- metadata.gz: 65803978c6330f2d99f17c7eeb77594676ac34a37bc44df9566c37928c98f1e1eb9c0aa1af752da41560e52e3a35dd2d9ce32d2ee2604f74d4407229d4735399
7
- data.tar.gz: 94dee964589f7260d3e320db9943b33311c98b360680a47d7c1b9e7838af2046e36176abb8be44a96df827f6197d280c7173a4ce1a64c6e7cfab182d3f7bb9b3
6
+ metadata.gz: 6d1fa692ce179995acf29b6b3f4ea91021279919485c76a5a10c9219995dff0d5bbb015e31f87c2331b2c76dbeaada7b181e83c825273c29842e61b83c40d70a
7
+ data.tar.gz: f90df92a739a23ed10c72d257973f60a7bffcc67ce28d1a60dbfbe8be0bff0a2753741576e0059c2db9decb0a2427a50ec1bd887e9fcaafa324bb32d53a0949d
data/bin/pointmd_comments CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'pointmd_comments'
3
3
 
4
- PointmdComments.collect
4
+ PointmdComments.collect_from_shell
@@ -13,12 +13,14 @@ require 'pointmd_comments/aggregators/comments'
13
13
  require 'pointmd_comments/errors/not_implemented'
14
14
  require 'pointmd_comments/errors/unknown_source'
15
15
 
16
- require 'pry'
17
-
18
16
  module PointmdComments
19
17
  class Error < StandardError; end
20
18
 
21
- def self.collect
19
+ def self.collect(options = {})
20
+ Aggregators::Main.new(options).call
21
+ end
22
+
23
+ def self.collect_from_shell
22
24
  args = ARGV.dup
23
25
  options = OptParser.new.parse
24
26
  Aggregators::Main.new(options).call
@@ -1,16 +1,23 @@
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)
7
9
  # Currently 'path' is not supported
8
10
  @path = nil
9
- @output = options[:output]
10
- @source = options[:source]
11
+ @output = options[:output] || default_output_path
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 || default_output_path
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 }
@@ -3,6 +3,7 @@ module PointmdComments
3
3
  class Posts
4
4
  # NOTE: This array may be populated with other website sections in the future.
5
5
  ALLOWED_SOURCES = %i[news today].freeze
6
+ DEFAULT_SOURCE = :news
6
7
  MAIN_PAGE = 'https://point.md/ru/'.freeze
7
8
 
8
9
  attr_reader :source, :urls
@@ -1,3 +1,3 @@
1
1
  module PointmdComments
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.1.7'.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.2
4
+ version: 0.1.7
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-11 00:00:00.000000000 Z
11
+ date: 2021-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry