pointmd_comments 0.1.1 → 0.1.6

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: 562f9314352d713e79b1000a52b8fb5118cf7c8380fbff54a42437a40fe5b1bb
4
- data.tar.gz: 80784c08130b3edcefd58d6c7e298eeacac14eb66c8ca59e56e3a751ae0a758b
3
+ metadata.gz: 33e78e92e82cde074461ee904263960acf61b7f4b346ed6e6195f966fc852456
4
+ data.tar.gz: ee1271f3f136cbaf9ad88988a7de7c973fec3bcfc115823808b0e234afd016ca
5
5
  SHA512:
6
- metadata.gz: 71ca6190c6db162d1aceaa231fffb7b00f9684dbfa7534adeb265c051bf910aa3b9de0d74cbe887f46e5d8ec03500511f657f4a80a971c8a6c6e8eeecb550884
7
- data.tar.gz: 869d4bbfa6491937846230d29c578dffa27be82df82669ae8d6693f32a18cd741eb966194bf9be78277f5680e5087846ad82098ca5f5d1f86eea22f5a8a92fac
6
+ metadata.gz: be7a9b05cdeaf6c5ec7613f628fc259ca1312c80d29258764d244e99dfb561a8c2479ae3c2620f091001764693bd875537bcc435ea2d1363be000e19f1de3c10
7
+ data.tar.gz: bb718e968268bda91b7d2227465860846f133a94d926bb24ea9eb73b5e9e2e04fb73882684ad19724d1acb218123070192987156f2e2c568859c2d46a522829b
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,15 +13,15 @@ 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
22
- # DOESN'T WORK!!
19
+ def self.collect(options = {})
20
+ Aggregators::Main.new(options).call
21
+ end
22
+
23
+ def self.collect_from_shell
23
24
  args = ARGV.dup
24
- puts args
25
25
  options = OptParser.new.parse
26
26
  Aggregators::Main.new(options).call
27
27
  rescue StandardError => e
@@ -1,14 +1,21 @@
1
1
  module PointmdComments
2
2
  module Aggregators
3
3
  class Main
4
- attr_reader :posts_aggregator, :browser, :comments_aggregator, :all_comments, :posts, :source, :path
4
+ attr_reader :posts_aggregator, :browser, :comments_aggregator, :all_comments, :posts, :source, :output, :path
5
5
 
6
6
  def initialize(options)
7
- @path = options[:path]
8
- @source = options[:source]
7
+ # Currently 'path' is not supported
8
+ @path = nil
9
+ @output = options[:output] || default_output_path
10
+ @source = options[:source] || Aggregators::Posts::DEFAULT_SOURCE
9
11
  @posts_aggregator = Aggregators::Posts.new(source: source, path: path)
10
12
  @comments_aggregator = Aggregators::Comments.new
11
- @browser = ::Watir::Browser.new :chrome, headless: true
13
+
14
+ client = Selenium::WebDriver::Remote::Http::Default.new
15
+ # NOTE: #timeout= is deprecated, use #read_timeout= and #open_timeout= instead
16
+ client.timeout = 600 # instead of the default 60 (seconds)
17
+
18
+ @browser = ::Watir::Browser.new :chrome, http_client: client, headless: true
12
19
  @all_comments = []
13
20
  end
14
21
 
@@ -44,10 +51,22 @@ module PointmdComments
44
51
  end
45
52
 
46
53
  def write_to_csv
47
- CSV.open('output.csv', 'w') do |csv|
54
+ # File#expand_path is needed to process paths like '~/test.txt' => '/Users/me/test.txt'
55
+ file_path = File.expand_path(output)
56
+ puts "File Path is #{file_path}"
57
+
58
+ CSV.open(file_path, 'w') do |csv|
48
59
  all_comments.each { |c| csv << c }
49
60
  end
50
61
  end
62
+
63
+ def default_output_path
64
+ "pointmd_comments_#{current_time}.csv"
65
+ end
66
+
67
+ def current_time
68
+ Time.now.strftime('%Y%m%d_%H%M')
69
+ end
51
70
  end
52
71
  end
53
72
  end
@@ -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
@@ -26,11 +26,11 @@ module PointmdComments
26
26
  options[:source] = s.to_sym
27
27
  end
28
28
  opts.on(
29
- '-p PATH',
30
- '--path=PATH',
31
- 'A file path to pull links from.'
32
- ) do |s|
33
- options[:source] = s.to_sym
29
+ '-o OUTPUT_PATH',
30
+ '--output=OUTPUT_PATH',
31
+ 'A custom file path for the CSV.'
32
+ ) do |p|
33
+ options[:output] = p
34
34
  end
35
35
  opts.on('-V', '--version', 'Version') do
36
36
  puts PointmdComments::VERSION
@@ -1,3 +1,3 @@
1
1
  module PointmdComments
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.6'.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.1
4
+ version: 0.1.6
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-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry