bibtex-ruby 4.0.3 → 4.0.4
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/History.txt +4 -0
- data/README.md +7 -5
- data/features/bibtex.feature +5 -5
- data/features/query.feature +2 -0
- data/lib/bibtex/elements.rb +7 -5
- data/lib/bibtex/entry.rb +1 -1
- data/lib/bibtex/version.rb +1 -1
- data/test/bibtex/test_entry.rb +42 -7
- metadata +11 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8dfc396ec0cd2efd0f5f64425c8e9ffd767da58c
|
|
4
|
+
data.tar.gz: 857697705ed8d3cf337beba83c088808cb88bb61
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 111bf7910b6e38a5aeb40ad2d128fe06d5ee992e1ea64fb1503c445b63256b714fe6ef6fd9a43ac9ad4e4bb28d7677ad82d711c6ee723efff2457a9cae569b62
|
|
7
|
+
data.tar.gz: 538da62b61ae3e58fda93839ad712c95ef949552be07157a66e712f58e8faa1d58538e977019ec202df69aace8beda7d5689bd966fe888665c59c0fd41894263
|
data/History.txt
CHANGED
data/README.md
CHANGED
|
@@ -150,11 +150,11 @@ Instead of parsing strings you can also create BibTeX elements directly in
|
|
|
150
150
|
Ruby:
|
|
151
151
|
|
|
152
152
|
> bib = BibTeX::Bibliography.new
|
|
153
|
-
|
|
153
|
+
|
|
154
154
|
Using a Hash:
|
|
155
155
|
|
|
156
156
|
> bib << BibTeX::Entry.new({
|
|
157
|
-
:
|
|
157
|
+
:bibtex_type => :book,
|
|
158
158
|
:key => :rails,
|
|
159
159
|
:address => 'Raleigh, North Carolina',
|
|
160
160
|
:author => 'Ruby, Sam and Thomas, Dave, and Hansson, David Heinemeier',
|
|
@@ -236,7 +236,7 @@ query functionality with the exception of yielding to a block. For instance:
|
|
|
236
236
|
|
|
237
237
|
# note that the above includes entries inheriting the book title
|
|
238
238
|
# from a cross-referenced entry!
|
|
239
|
-
|
|
239
|
+
|
|
240
240
|
bib['@book[keywords=ruby]']
|
|
241
241
|
=> Returns all books whose keywords attribute equals 'ruby' or []
|
|
242
242
|
bib['@book[keywords!=ruby]']
|
|
@@ -248,6 +248,8 @@ query functionality with the exception of yielding to a block. For instance:
|
|
|
248
248
|
=> Returns all books whose keywords attribute matches /^ruby/
|
|
249
249
|
bib.q('@book[keywords ~= ruby]')
|
|
250
250
|
=> Returns all books whose keywords attribute matches /ruby/
|
|
251
|
+
bib['@book[keywords!~ruby]']
|
|
252
|
+
=> Returns all books whose keywords attribute does not match /ruby/ or don't have keywords attribute
|
|
251
253
|
|
|
252
254
|
bib.q('@article[year<=2007]')
|
|
253
255
|
=> Returns all articles published in 2007 or earlier
|
|
@@ -522,7 +524,7 @@ because these tokens will be concatenated using BibTeX's '#' operator).
|
|
|
522
524
|
Year = {2009}
|
|
523
525
|
}
|
|
524
526
|
END
|
|
525
|
-
=> [{:
|
|
527
|
+
=> [{:bibtex_key=>:pickaxe, :bibtex_type=>:book,
|
|
526
528
|
:address=>"{Raleigh, North Carolina}",
|
|
527
529
|
:author=>"{Thomas, Dave, and Fowler, Chad, and Hunt, Andy}",
|
|
528
530
|
:publisher=>"{The Pragmatic Bookshelf}",
|
|
@@ -535,7 +537,7 @@ quotes; therefore you can simply add the :quotes option with an empty string:
|
|
|
535
537
|
>> BibTeX.parse(<<-END).to_a(:quotes => '')
|
|
536
538
|
...
|
|
537
539
|
END
|
|
538
|
-
=> [{:
|
|
540
|
+
=> [{:bibtex_key=>:pickaxe, :bibtex_type=>:book,
|
|
539
541
|
:address=>"Raleigh, North Carolina",
|
|
540
542
|
:author=>"Thomas, Dave, and Fowler, Chad, and Hunt, Andy",
|
|
541
543
|
:publisher=>"The Pragmatic Bookshelf",
|
data/features/bibtex.feature
CHANGED
|
@@ -5,11 +5,11 @@ Feature: Parse BibTeX files
|
|
|
5
5
|
Scenario: A BibTeX file with lots of objects and comments
|
|
6
6
|
When I parse the following file:
|
|
7
7
|
"""
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
##
|
|
9
|
+
## This BibTeX file contains all the examples of valid BibTeX objects
|
|
10
|
+
## in Xavier Decoret's `A summary of BibTeX' at
|
|
11
|
+
## http://artis.imag.fr/~Xavier.Decoret/resources/xdkbibtex/bibtex_summary.html
|
|
12
|
+
##
|
|
13
13
|
|
|
14
14
|
@Article{py03,
|
|
15
15
|
author = {Xavier D\'ecoret},
|
data/features/query.feature
CHANGED
|
@@ -59,6 +59,8 @@ Feature: Searching in BibTeX bibliographies
|
|
|
59
59
|
Then there should be exactly 3 matches
|
|
60
60
|
When I search for "@*[year=2007]"
|
|
61
61
|
Then there should be exactly 1 match
|
|
62
|
+
When I search for "@*[keywords!~lex]"
|
|
63
|
+
Then there should be exactly 2 matches
|
|
62
64
|
|
|
63
65
|
@query
|
|
64
66
|
Scenario: Find entries using compound queries
|
data/lib/bibtex/elements.rb
CHANGED
|
@@ -55,11 +55,11 @@ module BibTeX
|
|
|
55
55
|
def values_at(*arguments)
|
|
56
56
|
[]
|
|
57
57
|
end
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
def digest(*arguments)
|
|
60
60
|
[type, content].join('|')
|
|
61
61
|
end
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
# Invokes BibTeX string replacement on this element.
|
|
64
64
|
def replace(*arguments); self; end
|
|
65
65
|
|
|
@@ -187,11 +187,11 @@ module BibTeX
|
|
|
187
187
|
def inspect
|
|
188
188
|
"#<#{self.class} #{content.gsub(/\n/, ' ')}>"
|
|
189
189
|
end
|
|
190
|
-
|
|
190
|
+
|
|
191
191
|
private
|
|
192
|
-
|
|
192
|
+
|
|
193
193
|
def meets_condition?(condition)
|
|
194
|
-
property, operator, value = condition.split(/\s*([!~\/\^<>]
|
|
194
|
+
property, operator, value = condition.split(/\s*([!~\/\^<>]?=|!~)\s*/)
|
|
195
195
|
|
|
196
196
|
if property.nil?
|
|
197
197
|
true
|
|
@@ -208,6 +208,8 @@ module BibTeX
|
|
|
208
208
|
!actual.nil? && actual.to_s.match("^#{value}")
|
|
209
209
|
when '~='
|
|
210
210
|
!actual.nil? && actual.to_s.match(value)
|
|
211
|
+
when '!~'
|
|
212
|
+
actual.nil? || !actual.to_s.match(value)
|
|
211
213
|
when '<='
|
|
212
214
|
!actual.nil? && actual.to_i <= value.to_i
|
|
213
215
|
when '>='
|
data/lib/bibtex/entry.rb
CHANGED
|
@@ -382,7 +382,7 @@ module BibTeX
|
|
|
382
382
|
# Returns false if the entry is one of the standard entry types and does not have
|
|
383
383
|
# definitions of all the required fields for that type.
|
|
384
384
|
def valid?
|
|
385
|
-
REQUIRED_FIELDS[
|
|
385
|
+
REQUIRED_FIELDS[type].all? do |f|
|
|
386
386
|
f.is_a?(Array) ? !(f & fields.keys).empty? : !fields[f].nil?
|
|
387
387
|
end
|
|
388
388
|
end
|
data/lib/bibtex/version.rb
CHANGED
data/test/bibtex/test_entry.rb
CHANGED
|
@@ -594,20 +594,20 @@ module BibTeX
|
|
|
594
594
|
|
|
595
595
|
describe '#meet?' do
|
|
596
596
|
before { @e = Entry.new }
|
|
597
|
-
|
|
597
|
+
|
|
598
598
|
it 'returns true for an empty condition list' do
|
|
599
599
|
assert @e.meet? []
|
|
600
600
|
assert @e.meet? ['']
|
|
601
601
|
end
|
|
602
|
-
|
|
602
|
+
|
|
603
603
|
it 'it returns true when all conditions hold' do
|
|
604
604
|
refute @e.meet? ['author = Edgar']
|
|
605
|
-
|
|
605
|
+
|
|
606
606
|
@e.author = 'Poe, Edgar A.'
|
|
607
607
|
|
|
608
608
|
refute @e.meet? ['author = Edgar']
|
|
609
609
|
refute @e.meet? ['author = Poe, Edgar']
|
|
610
|
-
|
|
610
|
+
|
|
611
611
|
assert @e.meet? ['author = Poe, Edgar A.']
|
|
612
612
|
|
|
613
613
|
assert @e.meet? ['author ^= Poe']
|
|
@@ -617,11 +617,46 @@ module BibTeX
|
|
|
617
617
|
|
|
618
618
|
assert @e.meet? ['author ~= .']
|
|
619
619
|
assert @e.meet? ['author ~= [a-z]*']
|
|
620
|
-
|
|
621
|
-
assert @e.meet? ['author ^= P\w+']
|
|
622
620
|
|
|
621
|
+
assert @e.meet? ['author ^= P\w+']
|
|
622
|
+
end
|
|
623
|
+
end
|
|
624
|
+
|
|
625
|
+
describe '#valid?' do
|
|
626
|
+
before {
|
|
627
|
+
@misc = Entry.new
|
|
628
|
+
@book = Entry.new({ :bibtex_type => :book })
|
|
629
|
+
@article = Entry.new({ :bibtex_type => :article })
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
it 'is true by default' do
|
|
633
|
+
assert @misc.valid?
|
|
634
|
+
end
|
|
635
|
+
|
|
636
|
+
it 'is not true by default for types with mandatory fields' do
|
|
637
|
+
refute @book.valid?
|
|
638
|
+
refute @article.valid?
|
|
639
|
+
end
|
|
640
|
+
|
|
641
|
+
it 'is true only if all mandatory fields are present' do
|
|
642
|
+
@book.update({
|
|
643
|
+
:author => 'Henry James',
|
|
644
|
+
:title => 'What Maisie Knew',
|
|
645
|
+
:year => 1897,
|
|
646
|
+
:publisher => 'Heineman'
|
|
647
|
+
})
|
|
648
|
+
|
|
649
|
+
assert @book.valid?
|
|
650
|
+
|
|
651
|
+
@book.delete :publisher
|
|
652
|
+
refute @book.valid?
|
|
653
|
+
|
|
654
|
+
@book.publisher = 'Heineman'
|
|
655
|
+
assert @book.valid?
|
|
656
|
+
|
|
657
|
+
@book.delete :year
|
|
658
|
+
refute @book.valid?
|
|
623
659
|
end
|
|
624
|
-
|
|
625
660
|
end
|
|
626
661
|
end
|
|
627
662
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bibtex-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0.
|
|
4
|
+
version: 4.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sylvester Keil
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-10-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: latex-decode
|
|
@@ -145,23 +145,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
145
145
|
version: '0'
|
|
146
146
|
requirements: []
|
|
147
147
|
rubyforge_project:
|
|
148
|
-
rubygems_version: 2.
|
|
148
|
+
rubygems_version: 2.1.8
|
|
149
149
|
signing_key:
|
|
150
150
|
specification_version: 4
|
|
151
151
|
summary: A BibTeX parser, converter and API for Ruby.
|
|
152
152
|
test_files:
|
|
153
|
-
- test/bibtex/
|
|
154
|
-
- test/bibtex/test_bibliography.rb
|
|
155
|
-
- test/bibtex/test_elements.rb
|
|
156
|
-
- test/bibtex/test_entry.rb
|
|
157
|
-
- test/bibtex/test_filters.rb
|
|
153
|
+
- test/bibtex/test_value.rb
|
|
158
154
|
- test/bibtex/test_lexer.rb
|
|
159
|
-
- test/bibtex/test_name_parser.rb
|
|
160
155
|
- test/bibtex/test_names.rb
|
|
161
156
|
- test/bibtex/test_parser.rb
|
|
162
|
-
- test/bibtex/
|
|
157
|
+
- test/bibtex/test_bibliography.rb
|
|
158
|
+
- test/bibtex/test_filters.rb
|
|
163
159
|
- test/bibtex/test_utilities.rb
|
|
164
|
-
- test/bibtex/
|
|
160
|
+
- test/bibtex/test_string.rb
|
|
161
|
+
- test/bibtex/test_entry.rb
|
|
162
|
+
- test/bibtex/test_name_parser.rb
|
|
163
|
+
- test/bibtex/test_elements.rb
|
|
164
|
+
- test/bibtex/entry/test_rdf_converter.rb
|
|
165
165
|
- test/test_bibtex.rb
|
|
166
166
|
- test/test_export.rb
|
|
167
167
|
has_rdoc: yard
|