pointmd_comments 0.1.1 → 0.1.2
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: d1240669a7cadfb4f4b32107b6a88265099a1ec232d68826c2371b8281e9f16f
|
4
|
+
data.tar.gz: fb50998e48a4c61ae0d904c26ba9c56a4d297dd21a9b7529178a80d8078565aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65803978c6330f2d99f17c7eeb77594676ac34a37bc44df9566c37928c98f1e1eb9c0aa1af752da41560e52e3a35dd2d9ce32d2ee2604f74d4407229d4735399
|
7
|
+
data.tar.gz: 94dee964589f7260d3e320db9943b33311c98b360680a47d7c1b9e7838af2046e36176abb8be44a96df827f6197d280c7173a4ce1a64c6e7cfab182d3f7bb9b3
|
data/lib/pointmd_comments.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
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
|
-
|
7
|
+
# Currently 'path' is not supported
|
8
|
+
@path = nil
|
9
|
+
@output = options[:output]
|
8
10
|
@source = options[:source]
|
9
11
|
@posts_aggregator = Aggregators::Posts.new(source: source, path: path)
|
10
12
|
@comments_aggregator = Aggregators::Comments.new
|
@@ -44,10 +46,20 @@ module PointmdComments
|
|
44
46
|
end
|
45
47
|
|
46
48
|
def write_to_csv
|
47
|
-
|
49
|
+
file_path = output || default_output_path
|
50
|
+
|
51
|
+
CSV.open(file_path, 'w') do |csv|
|
48
52
|
all_comments.each { |c| csv << c }
|
49
53
|
end
|
50
54
|
end
|
55
|
+
|
56
|
+
def default_output_path
|
57
|
+
"pointmd_comments_#{current_time}.csv"
|
58
|
+
end
|
59
|
+
|
60
|
+
def current_time
|
61
|
+
Time.now.strftime('%Y%m%d_%H%M')
|
62
|
+
end
|
51
63
|
end
|
52
64
|
end
|
53
65
|
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
|