bibsync 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +10 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +88 -0
- data/Rakefile +16 -0
- data/bibsync.gemspec +4 -2
- data/lib/bibsync/actions/{check_versions.rb → check_arxiv_versions.rb} +6 -6
- data/lib/bibsync/actions/determine_arxiv_doi.rb +70 -0
- data/lib/bibsync/actions/fetch_from_arxiv.rb +11 -9
- data/lib/bibsync/actions/find_my_citations.rb +4 -4
- data/lib/bibsync/actions/jabref_format.rb +2 -2
- data/lib/bibsync/actions/synchronize_files.rb +5 -6
- data/lib/bibsync/actions/synchronize_metadata.rb +14 -57
- data/lib/bibsync/actions/validate.rb +16 -6
- data/lib/bibsync/actions.rb +1 -7
- data/lib/bibsync/bibliography.rb +60 -23
- data/lib/bibsync/command.rb +13 -8
- data/lib/bibsync/log.rb +22 -20
- data/lib/bibsync/transformer.rb +1 -1
- data/lib/bibsync/utils.rb +7 -9
- data/lib/bibsync/version.rb +1 -1
- data/test/actions/test_check_arxiv_versions.rb +4 -0
- data/test/actions/test_determine_arxiv_doi.rb +61 -0
- data/test/actions/test_fetch_from_arxiv.rb +4 -0
- data/test/actions/test_find_my_citations.rb +4 -0
- data/test/actions/test_jabref_format.rb +4 -0
- data/test/actions/test_synchronize_files.rb +4 -0
- data/test/actions/test_synchronize_metadata.rb +34 -0
- data/test/actions/test_validate.rb +4 -0
- data/test/fixture/FileWithEmbeddedArXiv.pdf +0 -0
- data/test/fixture/FileWithEmbeddedArXiv.tex +7 -0
- data/test/fixture/FileWithEmbeddedDOI.pdf +0 -0
- data/test/fixture/FileWithEmbeddedDOI.tex +7 -0
- data/test/fixture/entry.bib +8 -0
- data/test/fixture/test.bib +34 -0
- data/test/helper.rb +21 -0
- data/test/test_bibliography.rb +222 -0
- data/test/test_utils.rb +54 -0
- metadata +63 -16
@@ -0,0 +1,222 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe BibSync::Bibliography do
|
4
|
+
let(:newbib) do
|
5
|
+
BibSync::Bibliography.new
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:bib) do
|
9
|
+
BibSync::Bibliography.new(File.join(fixturedir, 'test.bib'))
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#initialize' do
|
13
|
+
it 'creates unnamed bibliography' do
|
14
|
+
BibSync::Bibliography.new.file.must_be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'creates named bibliography' do
|
18
|
+
BibSync::Bibliography.new('test.bib').file.must_equal 'test.bib'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'reads bibliography' do
|
22
|
+
BibSync::Bibliography.new(File.join(fixturedir, 'test.bib')).empty?.must_equal false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#dirty?' do
|
27
|
+
it 'must be false for new bibliography' do
|
28
|
+
newbib.dirty?.must_equal false
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'must be true after adding an entry' do
|
32
|
+
bib << BibSync::Bibliography::Entry.new(key: 'test')
|
33
|
+
bib.dirty?.must_equal true
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'must be true after deleting an entry' do
|
37
|
+
bib.delete(bib['TestBook'])
|
38
|
+
bib.dirty?.must_equal true
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'must be true after calling dirty!' do
|
42
|
+
bib.dirty!
|
43
|
+
bib.dirty?.must_equal true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#empty?' do
|
48
|
+
it 'must be true for new bibliography' do
|
49
|
+
newbib.empty?.must_equal true
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'must be false for non-empty bibliography' do
|
53
|
+
bib.empty?.must_equal false
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'must be false after adding an entry' do
|
57
|
+
newbib << BibSync::Bibliography::Entry.new(key: 'test')
|
58
|
+
newbib.empty?.must_equal false
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#size' do
|
63
|
+
it 'must be 0 for new bibliography' do
|
64
|
+
newbib.size.must_equal 0
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'must increment after adding an entry' do
|
68
|
+
size = bib.size
|
69
|
+
bib << BibSync::Bibliography::Entry.new(key: 'test')
|
70
|
+
bib.size.must_equal size + 1
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#[]' do
|
75
|
+
it 'must return nil for non-existing entry' do
|
76
|
+
newbib['nonexisting'].must_be_nil
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'must return entry' do
|
80
|
+
bib['TestBook'].must_be_instance_of BibSync::Bibliography::Entry
|
81
|
+
bib['TestBook'].key.must_equal 'TestBook'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#delete' do
|
86
|
+
it 'must delete entry' do
|
87
|
+
bib.delete(bib['TestBook'])
|
88
|
+
bib['TestBook'].must_equal nil
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#clear' do
|
93
|
+
it 'must clear bibliography' do
|
94
|
+
bib.clear
|
95
|
+
bib.size.must_equal 0
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#relative_path' do
|
100
|
+
it 'must return relative path' do
|
101
|
+
bib.relative_path(__FILE__).must_equal '../test_bibliography.rb'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe '#each' do
|
106
|
+
it 'must iterate over entries' do
|
107
|
+
found = false
|
108
|
+
bib.each do |entry|
|
109
|
+
entry.must_be_instance_of BibSync::Bibliography::Entry
|
110
|
+
found = true
|
111
|
+
end
|
112
|
+
found.must_equal true
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe '#save' do
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '#<<' do
|
120
|
+
it 'must support adding an entry' do
|
121
|
+
entry = BibSync::Bibliography::Entry.new(key: 'test')
|
122
|
+
bib << entry
|
123
|
+
bib['test'].must_be_same_as entry
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe '#load' do
|
128
|
+
end
|
129
|
+
|
130
|
+
describe '#load!' do
|
131
|
+
end
|
132
|
+
|
133
|
+
describe '#parse' do
|
134
|
+
end
|
135
|
+
|
136
|
+
describe '#to_s' do
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe BibSync::Bibliography::Entry do
|
141
|
+
describe '#self.parse' do
|
142
|
+
it 'should parse entry' do
|
143
|
+
entry = BibSync::Bibliography::Entry.parse(File.read(File.join(fixturedir, 'entry.bib')))
|
144
|
+
entry.type.must_equal 'BOOK'
|
145
|
+
entry.key.must_equal 'TestBook'
|
146
|
+
entry[:title].must_equal 'BookTitle'
|
147
|
+
entry[:publisher].must_equal 'BookPublisher'
|
148
|
+
entry[:year].must_equal '2000'
|
149
|
+
entry[:month].must_equal 'jan'
|
150
|
+
entry[:month].must_be_instance_of BibSync::Bibliography::RawValue
|
151
|
+
entry[:author].must_equal 'BookAuthor'
|
152
|
+
entry[:volume].must_equal 'BookVolume'
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe '#initialize' do
|
157
|
+
it 'should not set type and key' do
|
158
|
+
entry = BibSync::Bibliography::Entry.new
|
159
|
+
entry.type.must_be_nil
|
160
|
+
entry.key.must_be_nil
|
161
|
+
entry[:author].must_be_nil
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should initialize fields' do
|
165
|
+
entry = BibSync::Bibliography::Entry.new(type: 'ARTICLE', key: 'key', author: 'Daniel')
|
166
|
+
entry.type.must_equal 'ARTICLE'
|
167
|
+
entry.key.must_equal 'key'
|
168
|
+
entry[:author].must_equal 'Daniel'
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe '#file=' do
|
173
|
+
end
|
174
|
+
|
175
|
+
describe '#file' do
|
176
|
+
end
|
177
|
+
|
178
|
+
describe '#[]' do
|
179
|
+
end
|
180
|
+
|
181
|
+
describe '#[]=' do
|
182
|
+
end
|
183
|
+
|
184
|
+
describe '#delete' do
|
185
|
+
end
|
186
|
+
|
187
|
+
describe '#each' do
|
188
|
+
end
|
189
|
+
|
190
|
+
describe '#comment?' do
|
191
|
+
it 'should return true for a comment entry' do
|
192
|
+
BibSync::Bibliography::Entry.new(type: 'coMMent').comment?.must_equal true
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'should return false for a non-comment entry' do
|
196
|
+
BibSync::Bibliography::Entry.new.comment?.must_equal false
|
197
|
+
BibSync::Bibliography::Entry.new(type: 'article').comment?.must_equal false
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe '#dirty!' do
|
202
|
+
end
|
203
|
+
|
204
|
+
describe '#to_s' do
|
205
|
+
end
|
206
|
+
|
207
|
+
describe '#parse' do
|
208
|
+
it 'should parse entry' do
|
209
|
+
entry = BibSync::Bibliography::Entry.new
|
210
|
+
entry.parse(File.read(File.join(fixturedir, 'entry.bib')))
|
211
|
+
entry.type.must_equal 'BOOK'
|
212
|
+
entry.key.must_equal 'TestBook'
|
213
|
+
entry[:title].must_equal 'BookTitle'
|
214
|
+
entry[:publisher].must_equal 'BookPublisher'
|
215
|
+
entry[:year].must_equal '2000'
|
216
|
+
entry[:month].must_equal 'jan'
|
217
|
+
entry[:month].must_be_instance_of BibSync::Bibliography::RawValue
|
218
|
+
entry[:author].must_equal 'BookAuthor'
|
219
|
+
entry[:volume].must_equal 'BookVolume'
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
data/test/test_utils.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe BibSync::Utils do
|
4
|
+
include BibSync::Utils
|
5
|
+
|
6
|
+
describe '#name_without_ext' do
|
7
|
+
it 'returns name without extension' do
|
8
|
+
name_without_ext('name.ext').must_equal 'name'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#fetch' do
|
13
|
+
it 'fetches page' do
|
14
|
+
fetch('http://google.com/').include?('<title>Google</title>').must_equal true
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'fetches page with header' do
|
18
|
+
fetch('http://dx.doi.org/10.1098/rspa.1984.0023', 'Accept' => 'text/bibliography; style=bibtex').include?('Berry').must_equal true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#arxiv_download' do
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#fetch_xml' do
|
26
|
+
it 'fetches xml' do
|
27
|
+
fetch_xml('http://export.arxiv.org/oai2?verb=GetRecord&identifier=oai:arXiv.org:1208.2881&metadataPrefix=arXiv').must_be_instance_of Nokogiri::XML::Document
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#fetch_html' do
|
32
|
+
it 'fetches html' do
|
33
|
+
fetch_html('http://google.com').must_be_instance_of Nokogiri::HTML::Document
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#arxiv_id' do
|
38
|
+
it 'removes version from arxiv id' do
|
39
|
+
arxiv_id('1234.5678v1', version: false, prefix: false).must_equal '1234.5678'
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'keeps version from arxiv id' do
|
43
|
+
arxiv_id('1234.5678v1', version: true, prefix: false).must_equal '1234.5678v1'
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'removes prefix from arxiv id' do
|
47
|
+
arxiv_id('prefix/1234v1', version: false, prefix: false).must_equal '1234'
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'keeps prefix from arxiv id' do
|
51
|
+
arxiv_id('prefix/1234v1', version: false, prefix: true).must_equal 'prefix/1234'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
CHANGED
@@ -1,33 +1,58 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bibsync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Daniel Mendler
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-07 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: nokogiri
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
|
-
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: BibSync is a tool to synchronize scientific papers and BibTeX bibliography
|
31
56
|
files
|
32
57
|
email:
|
33
58
|
- mail@daniel-mendler.de
|
@@ -37,11 +62,17 @@ extensions: []
|
|
37
62
|
extra_rdoc_files: []
|
38
63
|
files:
|
39
64
|
- .gitignore
|
65
|
+
- .travis.yml
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
40
70
|
- bibsync.gemspec
|
41
71
|
- bin/bibsync
|
42
72
|
- lib/bibsync.rb
|
43
73
|
- lib/bibsync/actions.rb
|
44
|
-
- lib/bibsync/actions/
|
74
|
+
- lib/bibsync/actions/check_arxiv_versions.rb
|
75
|
+
- lib/bibsync/actions/determine_arxiv_doi.rb
|
45
76
|
- lib/bibsync/actions/fetch_from_arxiv.rb
|
46
77
|
- lib/bibsync/actions/find_my_citations.rb
|
47
78
|
- lib/bibsync/actions/jabref_format.rb
|
@@ -54,29 +85,45 @@ files:
|
|
54
85
|
- lib/bibsync/transformer.rb
|
55
86
|
- lib/bibsync/utils.rb
|
56
87
|
- lib/bibsync/version.rb
|
88
|
+
- test/actions/test_check_arxiv_versions.rb
|
89
|
+
- test/actions/test_determine_arxiv_doi.rb
|
90
|
+
- test/actions/test_fetch_from_arxiv.rb
|
91
|
+
- test/actions/test_find_my_citations.rb
|
92
|
+
- test/actions/test_jabref_format.rb
|
93
|
+
- test/actions/test_synchronize_files.rb
|
94
|
+
- test/actions/test_synchronize_metadata.rb
|
95
|
+
- test/actions/test_validate.rb
|
96
|
+
- test/fixture/FileWithEmbeddedArXiv.pdf
|
97
|
+
- test/fixture/FileWithEmbeddedArXiv.tex
|
98
|
+
- test/fixture/FileWithEmbeddedDOI.pdf
|
99
|
+
- test/fixture/FileWithEmbeddedDOI.tex
|
100
|
+
- test/fixture/entry.bib
|
101
|
+
- test/fixture/test.bib
|
102
|
+
- test/helper.rb
|
103
|
+
- test/test_bibliography.rb
|
104
|
+
- test/test_utils.rb
|
57
105
|
homepage: https://github.com/minad/bibsync
|
58
106
|
licenses: []
|
107
|
+
metadata: {}
|
59
108
|
post_install_message:
|
60
109
|
rdoc_options: []
|
61
110
|
require_paths:
|
62
111
|
- lib
|
63
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
-
none: false
|
65
113
|
requirements:
|
66
|
-
- -
|
114
|
+
- - '>='
|
67
115
|
- !ruby/object:Gem::Version
|
68
116
|
version: '0'
|
69
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
118
|
requirements:
|
72
|
-
- -
|
119
|
+
- - '>='
|
73
120
|
- !ruby/object:Gem::Version
|
74
121
|
version: '0'
|
75
122
|
requirements: []
|
76
123
|
rubyforge_project: bibsync
|
77
|
-
rubygems_version:
|
124
|
+
rubygems_version: 2.0.0
|
78
125
|
signing_key:
|
79
|
-
specification_version:
|
80
|
-
summary: BibSync is a tool to synchronize scientific papers and
|
126
|
+
specification_version: 4
|
127
|
+
summary: BibSync is a tool to synchronize scientific papers and BibTeX bibliography
|
81
128
|
files
|
82
129
|
test_files: []
|