pointmd_comments 0.1.1 → 0.1.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33e78e92e82cde074461ee904263960acf61b7f4b346ed6e6195f966fc852456
|
4
|
+
data.tar.gz: ee1271f3f136cbaf9ad88988a7de7c973fec3bcfc115823808b0e234afd016ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be7a9b05cdeaf6c5ec7613f628fc259ca1312c80d29258764d244e99dfb561a8c2479ae3c2620f091001764693bd875537bcc435ea2d1363be000e19f1de3c10
|
7
|
+
data.tar.gz: bb718e968268bda91b7d2227465860846f133a94d926bb24ea9eb73b5e9e2e04fb73882684ad19724d1acb218123070192987156f2e2c568859c2d46a522829b
|
data/bin/pointmd_comments
CHANGED
data/lib/pointmd_comments.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
8
|
-
@
|
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
|
-
|
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
|
-
|
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
|
@@ -26,11 +26,11 @@ module PointmdComments
|
|
26
26
|
options[:source] = s.to_sym
|
27
27
|
end
|
28
28
|
opts.on(
|
29
|
-
'-
|
30
|
-
'--
|
31
|
-
'A file path
|
32
|
-
) do |
|
33
|
-
options[:
|
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
|
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
|
+
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:
|
11
|
+
date: 2021-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|