marc4j4r 0.1.0

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/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 BillDueber
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,41 @@
1
+ # marc4j4r -- work with marc4j in JRuby
2
+
3
+ marc4j4r is some simple syntactic sugar on top of the java libary [marc4j](http://marc4j.tigris.org/). It allows iteration
4
+ via #each and implements many of the same convenience functions as [ruby-marc](http://marc.rubyforge.org/).
5
+
6
+ Most of the good stuff is in RecordImpl and DataFieldImpl. They, along with the *Reader classes, now implement #each
7
+ for their subparts as well as #[] where it makes sense. See the examples in [the documentation]() for more information.
8
+
9
+ There's also a convenience module method, MARC4J4R.reader, to get a reader, as shown below.
10
+
11
+ Full documentation can be generated via the 'rake yard' command and is online at http://rdoc.info/projects/billdueber/marc4j4r
12
+
13
+ ## Example
14
+
15
+ require 'rubygems'
16
+ require 'marc4j4r'
17
+
18
+ reader = MARC4J4R.reader('test.mrc')
19
+ #reader = MARC4J4R.reader('test.mrc', :strictmarc) # be explicit
20
+ #preader = MARC4J4R.reader('test.mrc', :permissivemarc)
21
+ #xmlreader = MARC4J4R.reader('test.xml', :marcxml)
22
+ #
23
+ # Can also use an IO object
24
+ # reader = MARC4J4R.reader(File.new('test.mrc'))
25
+
26
+
27
+ reader.each do |r|
28
+ lccn = r['010']['a'] if r['010']
29
+ isSBns = r.find_by_tag(['020', '022']).map {|f| f['a']}
30
+ first035 = r['035']
31
+ fullTitle = r['245'].sub_values(['a', 'b', 'd', 'f', 'h']).join(' ')
32
+ r['300'].each do |subfield|
33
+ puts subfield.code + ' ' + subfield.value
34
+ end
35
+ end
36
+
37
+
38
+
39
+ == Copyright
40
+
41
+ Copyright (c) 2010 BillDueber. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "marc4j4r"
8
+ gem.summary = %Q{Use marc4j java library in JRuby in a more ruby-ish way}
9
+ gem.description = %Q{Syntactic sugar and some extra methods to deal with classes in the marc4j java package}
10
+ gem.email = "bill@dueber.com"
11
+ gem.homepage = "http://github.com/billdueber/marc4j4r"
12
+ gem.authors = ["BillDueber"]
13
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
+ gem.add_development_dependency "yard", ">= 0"
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ require 'rake/testtask'
23
+ Rake::TestTask.new(:test) do |test|
24
+ test.libs << 'lib' << 'test'
25
+ test.pattern = 'test/**/test_*.rb'
26
+ test.verbose = true
27
+ end
28
+
29
+ begin
30
+ require 'rcov/rcovtask'
31
+ Rcov::RcovTask.new do |test|
32
+ test.libs << 'test'
33
+ test.pattern = 'test/**/test_*.rb'
34
+ test.verbose = true
35
+ end
36
+ rescue LoadError
37
+ task :rcov do
38
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
39
+ end
40
+ end
41
+
42
+ task :test => :check_dependencies
43
+
44
+ task :default => :test
45
+
46
+ begin
47
+ require 'yard'
48
+ YARD::Rake::YardocTask.new
49
+ rescue LoadError
50
+ task :yardoc do
51
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
52
+ end
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,255 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta name="Content-Type" content="text/html; charset=UTF-8" />
6
+ <title>Class: ControlFieldImpl</title>
7
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
8
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
9
+
10
+ <script type="text/javascript" charset="utf-8">
11
+ relpath = '';
12
+ if (relpath != '') relpath += '/';
13
+ </script>
14
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
15
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
16
+
17
+ </head>
18
+ <body>
19
+ <script type="text/javascript" charset="utf-8">
20
+ if (window.top.frames.main) document.body.className = 'frames';
21
+ </script>
22
+
23
+ <div id="header">
24
+ <div id="menu">
25
+
26
+ <a href="_index.html">Index (C)</a> &raquo;
27
+
28
+
29
+ <span class="title">ControlFieldImpl</span>
30
+
31
+
32
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
33
+ </div>
34
+
35
+ <div id="search">
36
+ <a id="class_list_link" href="#">Class List</a>
37
+ <a id="method_list_link" href="#">Method List</a>
38
+ <a id ="file_list_link" href="#">File List</a>
39
+ </div>
40
+
41
+ <div class="clear"></div>
42
+ </div>
43
+
44
+ <iframe id="search_frame"></iframe>
45
+
46
+ <div id="content"><h1>Class: ControlFieldImpl
47
+
48
+
49
+ </h1>
50
+
51
+ <dl class="box">
52
+
53
+ <dt class="r1">Inherits:</dt>
54
+ <dd class="r1">
55
+ <span class="inheritName">Object</span>
56
+
57
+ <ul class="fullTree">
58
+ <li>Object</li>
59
+
60
+ <li class="next">ControlFieldImpl</li>
61
+
62
+ </ul>
63
+ <a href="#" class="inheritanceTree">show all</a>
64
+
65
+ </dd>
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+ <dt class="r2 last">Defined in:</dt>
75
+ <dd class="r2 last">lib/marc4j4r.rb</dd>
76
+
77
+ </dl>
78
+ <div class="clear"></div>
79
+
80
+
81
+
82
+
83
+ <h2>Instance Method Summary</h2>
84
+
85
+ <ul class="summary">
86
+
87
+ <li class="public ">
88
+ <span class="summary_signature">
89
+
90
+ <a href="#to_s-instance_method" title="#to_s (instance method)">- (Object) <strong>to_s</strong> </a>
91
+
92
+
93
+
94
+ </span>
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+ <span class="summary_desc">
103
+ Pretty-print.
104
+
105
+ </span>
106
+
107
+ </li>
108
+
109
+
110
+ <li class="public ">
111
+ <span class="summary_signature">
112
+
113
+ <a href="#value-instance_method" title="#value (instance method)">- (Object) <strong>value</strong> </a>
114
+
115
+
116
+
117
+ </span>
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+ <span class="summary_desc"></span>
126
+
127
+ </li>
128
+
129
+
130
+ </ul>
131
+
132
+
133
+ <div id="instance_method_details" class="method_details_list">
134
+ <h2>Instance Method Details</h2>
135
+
136
+
137
+ <div class="method_details first">
138
+ <p class="signature first" id="to_s-instance_method">
139
+
140
+ - (<tt>Object</tt>) <strong>to_s</strong>
141
+
142
+
143
+
144
+ </p><div class="docstring">
145
+ <div class="discussion">
146
+ <p>
147
+ Pretty-print
148
+ </p>
149
+
150
+
151
+ </div>
152
+ </div>
153
+ <div class="tags">
154
+ <h3>Parameters:</h3>
155
+ <ul class="param">
156
+
157
+ <li>
158
+
159
+ <span class='type'>(<tt>String</tt>)</span>
160
+
161
+
162
+ <span class='name'>joiner</span>
163
+
164
+
165
+
166
+ &mdash;
167
+
168
+ What string to use to join the subfields
169
+
170
+
171
+
172
+ </li>
173
+
174
+ <li>
175
+
176
+ <span class='type'>(<tt>String</tt>)</span>
177
+
178
+
179
+ <span class='name'>The</span>
180
+
181
+
182
+
183
+ &mdash;
184
+
185
+ pretty string
186
+
187
+
188
+
189
+ </li>
190
+
191
+ </ul>
192
+
193
+ </div><table class="source_code">
194
+ <tr>
195
+ <td>
196
+ <pre class="lines">
197
+
198
+
199
+ 244
200
+ 245
201
+ 246</pre>
202
+ </td>
203
+ <td>
204
+ <pre class="code"><span class="info file"># File 'lib/marc4j4r.rb', line 244</span>
205
+
206
+ <span class='def def kw'>def</span> <span class='to_s identifier id'>to_s</span>
207
+ <span class='return return kw'>return</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='tag identifier id'>tag</span> <span class='plus op'>+</span> <span class='string val'>&quot; &quot;</span> <span class='plus op'>+</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='value identifier id'>value</span>
208
+ <span class='end end kw'>end</span>
209
+ </pre>
210
+ </td>
211
+ </tr>
212
+ </table>
213
+ </div>
214
+
215
+ <div class="method_details ">
216
+ <p class="signature " id="value-instance_method">
217
+
218
+ - (<tt>Object</tt>) <strong>value</strong>
219
+
220
+
221
+
222
+ </p><table class="source_code">
223
+ <tr>
224
+ <td>
225
+ <pre class="lines">
226
+
227
+
228
+ 237
229
+ 238
230
+ 239</pre>
231
+ </td>
232
+ <td>
233
+ <pre class="code"><span class="info file"># File 'lib/marc4j4r.rb', line 237</span>
234
+
235
+ <span class='def def kw'>def</span> <span class='value identifier id'>value</span>
236
+ <span class='return return kw'>return</span> <span class='self self kw'>self</span><span class='dot token'>.</span><span class='data identifier id'>data</span>
237
+ <span class='end end kw'>end</span>
238
+ </pre>
239
+ </td>
240
+ </tr>
241
+ </table>
242
+ </div>
243
+
244
+ </div>
245
+
246
+ </div>
247
+
248
+ <div id="footer">
249
+ Generated on Sun Feb 14 22:11:52 2010 by
250
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
251
+ 0.5.3 (ruby-1.8.7).
252
+ </div>
253
+
254
+ </body>
255
+ </html>