bibtex-ruby 1.1.1 → 1.1.2

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.
data.tar.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 1.1.2 / 2011-01-27
2
+
3
+ * Added dynamic ghost methods to BibTeX::Entry for more convenient access
4
+ to BibTeX values.
5
+
1
6
  === 1.1.1 / 2011-01-25
2
7
 
3
8
  * Improved JSON and XML export.
data/README.md CHANGED
@@ -1,12 +1,11 @@
1
1
  BibTeX-Ruby
2
2
  ===========
3
3
 
4
- The BibTeX-Ruby package contains a parser for BibTeX
5
- bibliography files and a class structure to manage BibTeX objects in
6
- Ruby. It is designed to support all BibTeX objects (including @comment,
7
- string-replacements via @string, as well as string concatenation using '#')
8
- and handles all content outside of BibTeX objects as 'meta comments' which may
9
- be included in post-processing.
4
+ The BibTeX-Ruby package contains a parser for BibTeX bibliography files and a
5
+ class structure to manage BibTeX objects in Ruby. It is designed to support all
6
+ BibTeX objects (including @comment, string-replacements via @string, as well
7
+ as string concatenation using '#') and handles all content outside of BibTeX
8
+ objects as 'meta comments' which may or may not be included in post-processing.
10
9
 
11
10
 
12
11
  Quickstart
@@ -29,6 +28,10 @@ Quickstart
29
28
  }
30
29
  > bib[:pickaxe][:author]
31
30
  => ["Thomas, Dave, and Fowler, Chad, and Hunt, Andy"]
31
+ > bib[:pickaxe].author
32
+ => ["Thomas, Dave, and Fowler, Chad, and Hunt, Andy"]
33
+ > bib[:pickaxe].author = ['Thomas, D., Fowler, C., and Hunt, A.']
34
+ => ["Thomas, D., and Fowler, C., and Hunt, A."]
32
35
 
33
36
 
34
37
  Installation
@@ -54,8 +57,8 @@ Requirements
54
57
  ------------
55
58
 
56
59
  * The parser generator [racc](http://i.loveruby.net/en/projects/racc/) is required to generate parser.
57
- * The minitest gem is required to run the tests in older Ruby versions (prior to 1.9).
58
- * The json gem is required on older ruby versions for JSON export.
60
+ * The *minitest* gem is required to run the tests in older Ruby versions (prior to 1.9).
61
+ * The *json* gem is required on older ruby versions for JSON export (prior to 1.9).
59
62
 
60
63
 
61
64
  Usage
@@ -111,11 +114,11 @@ The Parser
111
114
  ----------
112
115
 
113
116
  The BibTeX-Ruby parser is generated using the wonderful
114
- [racc](http://i.loveruby.net/en/projects/racc/) parser generator.
117
+ [racc](http://i.loveruby.net/en/projects/racc/) parser generator. You can take
118
+ look at the grammar definition in the file `lib/bibtex/bibtex.y`.
115
119
 
116
120
 
117
- The BibTeX Format
118
- _________________
121
+ ### The BibTeX Format
119
122
 
120
123
  At first glance, the BibTeX file format seems very clear and simple;
121
124
  however, there are a number of peculiarities which warrant some
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ spec = Gem::Specification.new do |s|
17
17
  s.version = BibTeX::Version::STRING
18
18
  s.summary = "A BibTeX parser written in Ruby"
19
19
  s.description = "A (fairly complete) BibTeX parser written in Ruby. Supports regular BibTeX entries, @comments, string replacement via @string, and simple export formats (e.g. YAML)."
20
- s.homepage = 'http://github.com/inukshuk/bibtex-ruby'
20
+ s.homepage = 'http://inukshuk.github.com/bibtex-ruby'
21
21
  s.authors = ["Sylvester Keil"]
22
22
  s.email = 'http://sylvester.keil.or.at'
23
23
  s.cert_chain = ["/Users/sylvester/.gem/keys/gem-public_cert.pem"]
data/lib/bibtex/entry.rb CHANGED
@@ -62,6 +62,16 @@ module BibTeX
62
62
  @type = type
63
63
  end
64
64
 
65
+ def method_missing(name, *args)
66
+ return @fields[name]if @fields.has_key?(name)
67
+ return self.send(:add, name.to_s.chop.to_sym, args[0]) if name.match(/=$/)
68
+ super
69
+ end
70
+
71
+ def respond_to?(method)
72
+ @fields.has_key?(method.to_sym) || method.match(/=$/) || super
73
+ end
74
+
65
75
  # Returns the value of the field with the given name.
66
76
  def [](name)
67
77
  @fields[name.to_sym]
@@ -18,6 +18,6 @@
18
18
 
19
19
  module BibTeX
20
20
  module Version
21
- STRING = '1.1.1'
21
+ STRING = '1.1.2'
22
22
  end
23
23
  end
data/test/test_entry.rb CHANGED
@@ -32,4 +32,17 @@ class TestEntry < MiniTest::Unit::TestCase
32
32
  assert_equal(['Selected \\emph{Poetry} and `Tales\''], bib.data[0].fields[:title])
33
33
  assert_equal(['Tales and Sketches'], bib.data[1].fields[:title])
34
34
  end
35
+
36
+ def test_ghost_methods
37
+ bib = BibTeX::Bibliography.open('test/bib/07_entry.bib', :debug => true)
38
+ refute_nil(bib)
39
+ assert_equal(BibTeX::Bibliography, bib.class)
40
+ assert_equal(['Poe, Edgar A.'], bib.data[0].author)
41
+
42
+ expected = ['Poe, Edgar Allen']
43
+ bib.data[0].author = expected
44
+
45
+ assert_equal(expected, bib.data[0].author)
46
+ end
47
+
35
48
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 1
9
- version: 1.1.1
8
+ - 2
9
+ version: 1.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sylvester Keil
@@ -35,7 +35,7 @@ cert_chain:
35
35
  J/FeJ8pSGMcNlQbhGpGIX+ARJK5ArG0Aq4214ttgefkdQJvw5r9hG3J4AgM=
36
36
  -----END CERTIFICATE-----
37
37
 
38
- date: 2011-01-25 00:00:00 +01:00
38
+ date: 2011-01-27 00:00:00 +01:00
39
39
  default_executable:
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
@@ -129,7 +129,7 @@ files:
129
129
  - test/test_preamble.rb
130
130
  - test/test_string.rb
131
131
  has_rdoc: true
132
- homepage: http://github.com/inukshuk/bibtex-ruby
132
+ homepage: http://inukshuk.github.com/bibtex-ruby
133
133
  licenses: []
134
134
 
135
135
  post_install_message:
metadata.gz.sig CHANGED
Binary file