pointmd_comments 0.1.0 → 0.1.5
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: a24b7ec9ac474cb157789d03ddb9c41270eb58d96578c6c6dca1ad6d68ed7f24
|
4
|
+
data.tar.gz: ea9984f5c43eca94286344ec7ebc83fcac9dba399e7ab13b06a9cc80f88e7083
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28e1ff1042ee11284ae1c2bd87dcc41fbb77b2bc033debb92df912499253977dc83ee17e132febfdfae6aeb71e9e2f664c37864c3e50e8e9243e32668fa20565
|
7
|
+
data.tar.gz: 03f40f717c3919eddfe850e5aa4381b1a90b9053a6f2ae847eec605cb3713ae93410083b38f2d9e28e6e8d85dfcf8ffbb4026c90fa6ce1fb9a2e27c336c7f170
|
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,11 +1,13 @@
|
|
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
|
@browser = ::Watir::Browser.new :chrome, headless: true
|
@@ -44,10 +46,21 @@ module PointmdComments
|
|
44
46
|
end
|
45
47
|
|
46
48
|
def write_to_csv
|
47
|
-
|
49
|
+
# File#expand_path is needed to process paths like '~/test.txt' => '/Users/me/test.txt'
|
50
|
+
file_path = File.expand_path(output)
|
51
|
+
|
52
|
+
CSV.open(file_path, 'w') do |csv|
|
48
53
|
all_comments.each { |c| csv << c }
|
49
54
|
end
|
50
55
|
end
|
56
|
+
|
57
|
+
def default_output_path
|
58
|
+
"pointmd_comments_#{current_time}.csv"
|
59
|
+
end
|
60
|
+
|
61
|
+
def current_time
|
62
|
+
Time.now.strftime('%Y%m%d_%H%M')
|
63
|
+
end
|
51
64
|
end
|
52
65
|
end
|
53
66
|
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.5
|
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
|
+
date: 2020-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|