title_grabber 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/title_grabber/version.rb +1 -1
- data/lib/title_grabber.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 783d760ffd64b911ce9b869e81e9eecb471728e6eb1f147cfb0352cda18ccff9
|
4
|
+
data.tar.gz: 9894f60bd6eff8e73ca2a2b45a87483e69d39f4beeccbcaf7ae050b9f8e38b12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 071b788b02f27cf5bad8f54d34d4cf0f8483e71d9445eb920e9eb9e22896b2c548489ce0bb6663757c0db55ca6e0f3340aa95de67fc33bb1c92f87177d45a62e
|
7
|
+
data.tar.gz: d046603d9903f163b9fd6230b9dead31ba3bd8c64d57246892843903df1cdceaa312bea43f35029e0b0a9c624eb358a87267d4cb60fc902164d41ac20bcafc74
|
data/lib/title_grabber.rb
CHANGED
@@ -23,11 +23,10 @@ module TitleGrabber
|
|
23
23
|
include TextHelper
|
24
24
|
|
25
25
|
def call(lines, options)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
arr_of_h = CSV.read(tmp_path, headers: true)
|
26
|
+
out_path = options[:output]
|
27
|
+
|
28
|
+
processed_urls = if out_path.exist?
|
29
|
+
arr_of_h = CSV.read(out_path, headers: true)
|
31
30
|
arr_of_h.each_with_object({}) { |r, h|
|
32
31
|
page_tit = r[PAGE_TIT_HEAD]
|
33
32
|
art_tit = r[ART_TIT_HEAD]
|
@@ -45,7 +44,8 @@ module TitleGrabber
|
|
45
44
|
|
46
45
|
queue = Queue.new
|
47
46
|
|
48
|
-
|
47
|
+
tmp_path = out_path.sub_ext(".tmp#{out_path.extname}")
|
48
|
+
CSV.open(tmp_path, "w", force_quotes: true) do |csv|
|
49
49
|
csv << HEADERS
|
50
50
|
|
51
51
|
lines.each do |line|
|
@@ -89,7 +89,7 @@ module TitleGrabber
|
|
89
89
|
}.each(&:join)
|
90
90
|
end
|
91
91
|
|
92
|
-
tmp_path
|
92
|
+
FileUtils.mv(tmp_path, out_path)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|