scholar-rename 0.1.4 → 0.1.5
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 +4 -4
- data/lib/renamer.rb +3 -3
- data/lib/selector.rb +9 -2
- data/lib/version.rb +1 -1
- data/readme.md +0 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae169fc39df1a61f63cef58fd566cb867404637f
|
4
|
+
data.tar.gz: 5b680769c7d4a719d2428bd932484d46a8ac7394
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6e21191894bd9aea0bd4e0913e89ed2508fd958ff44742a786b2d6ef7ed3be620642e56afcee7ed73ca40b1edee87449dfe21d363b35a515661cc27ec1919b6
|
7
|
+
data.tar.gz: d23e00467a6864f45cb191fd8f1403f8e874997e6d09567da0137748dd21383cf49de114e739a23ccf379f85c035ac4a6b5d3f920fb1f7cfb355528429a9c035
|
data/lib/renamer.rb
CHANGED
@@ -12,7 +12,7 @@ class Renamer
|
|
12
12
|
puts "please install pdftotext to use scholar-rename"
|
13
13
|
puts "osx: brew install xpdf"
|
14
14
|
else
|
15
|
-
rename
|
15
|
+
rename a1
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -21,7 +21,7 @@ class Renamer
|
|
21
21
|
$?.success?
|
22
22
|
end
|
23
23
|
|
24
|
-
def rename
|
24
|
+
def rename(opts)
|
25
25
|
raw = `pdftotext -q '#{@file}' -` # may contain non-ascii characters
|
26
26
|
content = raw.encode('UTF-8', :invalid => :replace, :undef => :replace)
|
27
27
|
|
@@ -31,7 +31,7 @@ class Renamer
|
|
31
31
|
#system("pdftotext -q '#{@file}' '#{temp}'")
|
32
32
|
|
33
33
|
# Choose pdf qualities
|
34
|
-
s = Selector.new(content)
|
34
|
+
s = Selector.new(content, opts)
|
35
35
|
s.select_all # choose props
|
36
36
|
printf "Ok? [Yn]: "
|
37
37
|
|
data/lib/selector.rb
CHANGED
@@ -14,11 +14,14 @@ class Selector
|
|
14
14
|
# take the first 10 lines of the pdftotext output and assign it to the
|
15
15
|
# context class instance variable, use later when choosing selector
|
16
16
|
# https://stackoverflow.com/questions/9503554/
|
17
|
-
def initialize(c)
|
17
|
+
def initialize(c, opts)
|
18
18
|
@content = c.split("\n")[0..14]
|
19
19
|
.reject {|x| x.length < 2 }
|
20
20
|
.map {|x| x[0..100] } # trim
|
21
21
|
@fulltxt = c.split("\n")
|
22
|
+
if opts = "if"
|
23
|
+
@format = True # autoselect format type
|
24
|
+
end
|
22
25
|
end
|
23
26
|
|
24
27
|
def select_all
|
@@ -35,8 +38,12 @@ class Selector
|
|
35
38
|
|
36
39
|
year = gen_year # just read it
|
37
40
|
|
41
|
+
if @format
|
42
|
+
@title = gen_forms(year, title, author).first
|
43
|
+
else
|
38
44
|
puts "Select desired title:".bow
|
39
45
|
@title = choose(gen_forms year, title, author)
|
46
|
+
end
|
40
47
|
end
|
41
48
|
|
42
49
|
private
|
@@ -78,8 +85,8 @@ class Selector
|
|
78
85
|
ad = a.downcase
|
79
86
|
au = a.upcase
|
80
87
|
return [
|
81
|
-
"#{y} #{a} #{t}.pdf",
|
82
88
|
"#{y} - #{a} - #{t}.pdf",
|
89
|
+
"#{y} #{a} #{t}.pdf",
|
83
90
|
"#{a}_#{y}_#{t}.pdf".gsub(" ", "_"),
|
84
91
|
"#{au}_#{y}_#{t}.pdf".gsub(" ", "_"),
|
85
92
|
"#{ad}_#{y}_#{t}.pdf".gsub(" ", "_"),
|
data/lib/version.rb
CHANGED
data/readme.md
CHANGED
@@ -19,7 +19,3 @@ academic people may find it useful for renaming pdfs that come in arbitrarily
|
|
19
19
|
named file formats. services like mendeley kind of make this not super
|
20
20
|
relevant. it helps when searching for a specific pdf and when labeling pdfs.
|
21
21
|
|
22
|
-
## todo
|
23
|
-
|
24
|
-
- only show index lines once
|
25
|
-
- actually clean up tempfile
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scholar-rename
|
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
|
- Jeremy Warner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colored
|