library_standard_numbers 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.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +8 -0
- data/Cargo.lock +354 -0
- data/Cargo.toml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +47 -0
- data/Rakefile +22 -0
- data/ext/library_standard_numbers/Cargo.toml +14 -0
- data/ext/library_standard_numbers/extconf.rb +6 -0
- data/ext/library_standard_numbers/src/lib.rs +63 -0
- data/lib/library_standard_numbers/version.rb +5 -0
- data/lib/library_standard_numbers.rb +9 -0
- data/sig/library_standard_numbers.rbs +4 -0
- metadata +71 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3e82269f3b6695275e7c3184a3e23bee5793aff8bf5468a93b468bfededec718
|
4
|
+
data.tar.gz: 561c959facc3e2346621867eaa990e7482e661983627205c828a2f4608e9cc21
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5e581aac00b1ef39d34892bb7627ba3749c4b7e27bbbf8d5ca5d982e1ee7df43d9f221e52964dd298023befbdf0e1f7ca1b97813d692edc444e8a6dfcc907e7f
|
7
|
+
data.tar.gz: 432aa950284b16069023b432bf95e145788c50b70ea2e0c839429f37c742dcf79fca10b42830b7e9c3f17282750dce88af75d5298e0bd6d417ab6a943f6ef792
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/Cargo.lock
ADDED
@@ -0,0 +1,354 @@
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
2
|
+
# It is not intended for manual editing.
|
3
|
+
version = 4
|
4
|
+
|
5
|
+
[[package]]
|
6
|
+
name = "aho-corasick"
|
7
|
+
version = "1.1.3"
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
9
|
+
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
10
|
+
dependencies = [
|
11
|
+
"memchr",
|
12
|
+
]
|
13
|
+
|
14
|
+
[[package]]
|
15
|
+
name = "bindgen"
|
16
|
+
version = "0.69.5"
|
17
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
18
|
+
checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088"
|
19
|
+
dependencies = [
|
20
|
+
"bitflags",
|
21
|
+
"cexpr",
|
22
|
+
"clang-sys",
|
23
|
+
"itertools",
|
24
|
+
"lazy_static",
|
25
|
+
"lazycell",
|
26
|
+
"proc-macro2",
|
27
|
+
"quote",
|
28
|
+
"regex",
|
29
|
+
"rustc-hash",
|
30
|
+
"shlex",
|
31
|
+
"syn",
|
32
|
+
]
|
33
|
+
|
34
|
+
[[package]]
|
35
|
+
name = "bitflags"
|
36
|
+
version = "2.9.0"
|
37
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
38
|
+
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
|
39
|
+
|
40
|
+
[[package]]
|
41
|
+
name = "cexpr"
|
42
|
+
version = "0.6.0"
|
43
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
44
|
+
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
45
|
+
dependencies = [
|
46
|
+
"nom",
|
47
|
+
]
|
48
|
+
|
49
|
+
[[package]]
|
50
|
+
name = "cfg-if"
|
51
|
+
version = "1.0.0"
|
52
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
53
|
+
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
54
|
+
|
55
|
+
[[package]]
|
56
|
+
name = "clang-sys"
|
57
|
+
version = "1.8.1"
|
58
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
59
|
+
checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
|
60
|
+
dependencies = [
|
61
|
+
"glob",
|
62
|
+
"libc",
|
63
|
+
"libloading",
|
64
|
+
]
|
65
|
+
|
66
|
+
[[package]]
|
67
|
+
name = "either"
|
68
|
+
version = "1.15.0"
|
69
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
70
|
+
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
71
|
+
|
72
|
+
[[package]]
|
73
|
+
name = "glob"
|
74
|
+
version = "0.3.2"
|
75
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
76
|
+
checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2"
|
77
|
+
|
78
|
+
[[package]]
|
79
|
+
name = "itertools"
|
80
|
+
version = "0.12.1"
|
81
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
82
|
+
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
|
83
|
+
dependencies = [
|
84
|
+
"either",
|
85
|
+
]
|
86
|
+
|
87
|
+
[[package]]
|
88
|
+
name = "lazy_static"
|
89
|
+
version = "1.5.0"
|
90
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
91
|
+
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
92
|
+
|
93
|
+
[[package]]
|
94
|
+
name = "lazycell"
|
95
|
+
version = "1.3.0"
|
96
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
97
|
+
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
98
|
+
|
99
|
+
[[package]]
|
100
|
+
name = "libc"
|
101
|
+
version = "0.2.172"
|
102
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
103
|
+
checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
|
104
|
+
|
105
|
+
[[package]]
|
106
|
+
name = "libloading"
|
107
|
+
version = "0.8.6"
|
108
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
109
|
+
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
|
110
|
+
dependencies = [
|
111
|
+
"cfg-if",
|
112
|
+
"windows-targets",
|
113
|
+
]
|
114
|
+
|
115
|
+
[[package]]
|
116
|
+
name = "library_standard_numbers"
|
117
|
+
version = "0.1.0"
|
118
|
+
dependencies = [
|
119
|
+
"library_stdnums",
|
120
|
+
"magnus",
|
121
|
+
]
|
122
|
+
|
123
|
+
[[package]]
|
124
|
+
name = "library_stdnums"
|
125
|
+
version = "0.1.0"
|
126
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
127
|
+
checksum = "ff45009282f541df36b35638ca06f8ecc0c7154fe380ad79e279660e7c1d758c"
|
128
|
+
|
129
|
+
[[package]]
|
130
|
+
name = "magnus"
|
131
|
+
version = "0.6.4"
|
132
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
133
|
+
checksum = "b1597ef40aa8c36be098249e82c9a20cf7199278ac1c1a1a995eeead6a184479"
|
134
|
+
dependencies = [
|
135
|
+
"magnus-macros",
|
136
|
+
"rb-sys",
|
137
|
+
"rb-sys-env",
|
138
|
+
"seq-macro",
|
139
|
+
]
|
140
|
+
|
141
|
+
[[package]]
|
142
|
+
name = "magnus-macros"
|
143
|
+
version = "0.6.0"
|
144
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
145
|
+
checksum = "5968c820e2960565f647819f5928a42d6e874551cab9d88d75e3e0660d7f71e3"
|
146
|
+
dependencies = [
|
147
|
+
"proc-macro2",
|
148
|
+
"quote",
|
149
|
+
"syn",
|
150
|
+
]
|
151
|
+
|
152
|
+
[[package]]
|
153
|
+
name = "memchr"
|
154
|
+
version = "2.7.4"
|
155
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
156
|
+
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
157
|
+
|
158
|
+
[[package]]
|
159
|
+
name = "minimal-lexical"
|
160
|
+
version = "0.2.1"
|
161
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
162
|
+
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
163
|
+
|
164
|
+
[[package]]
|
165
|
+
name = "nom"
|
166
|
+
version = "7.1.3"
|
167
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
168
|
+
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
169
|
+
dependencies = [
|
170
|
+
"memchr",
|
171
|
+
"minimal-lexical",
|
172
|
+
]
|
173
|
+
|
174
|
+
[[package]]
|
175
|
+
name = "proc-macro2"
|
176
|
+
version = "1.0.95"
|
177
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
178
|
+
checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
|
179
|
+
dependencies = [
|
180
|
+
"unicode-ident",
|
181
|
+
]
|
182
|
+
|
183
|
+
[[package]]
|
184
|
+
name = "quote"
|
185
|
+
version = "1.0.40"
|
186
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
187
|
+
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
188
|
+
dependencies = [
|
189
|
+
"proc-macro2",
|
190
|
+
]
|
191
|
+
|
192
|
+
[[package]]
|
193
|
+
name = "rb-sys"
|
194
|
+
version = "0.9.111"
|
195
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
196
|
+
checksum = "becea799ce051c16fb140be80f5e7cf781070f99ca099332383c2b17861249af"
|
197
|
+
dependencies = [
|
198
|
+
"rb-sys-build",
|
199
|
+
]
|
200
|
+
|
201
|
+
[[package]]
|
202
|
+
name = "rb-sys-build"
|
203
|
+
version = "0.9.111"
|
204
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
205
|
+
checksum = "64691175abc704862f60a9ca8ef06174080cc50615f2bf1d4759f46db18b4d29"
|
206
|
+
dependencies = [
|
207
|
+
"bindgen",
|
208
|
+
"lazy_static",
|
209
|
+
"proc-macro2",
|
210
|
+
"quote",
|
211
|
+
"regex",
|
212
|
+
"shell-words",
|
213
|
+
"syn",
|
214
|
+
]
|
215
|
+
|
216
|
+
[[package]]
|
217
|
+
name = "rb-sys-env"
|
218
|
+
version = "0.1.2"
|
219
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
220
|
+
checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb"
|
221
|
+
|
222
|
+
[[package]]
|
223
|
+
name = "regex"
|
224
|
+
version = "1.11.1"
|
225
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
226
|
+
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
227
|
+
dependencies = [
|
228
|
+
"aho-corasick",
|
229
|
+
"memchr",
|
230
|
+
"regex-automata",
|
231
|
+
"regex-syntax",
|
232
|
+
]
|
233
|
+
|
234
|
+
[[package]]
|
235
|
+
name = "regex-automata"
|
236
|
+
version = "0.4.9"
|
237
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
238
|
+
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
239
|
+
dependencies = [
|
240
|
+
"aho-corasick",
|
241
|
+
"memchr",
|
242
|
+
"regex-syntax",
|
243
|
+
]
|
244
|
+
|
245
|
+
[[package]]
|
246
|
+
name = "regex-syntax"
|
247
|
+
version = "0.8.5"
|
248
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
249
|
+
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
250
|
+
|
251
|
+
[[package]]
|
252
|
+
name = "rustc-hash"
|
253
|
+
version = "1.1.0"
|
254
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
255
|
+
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
256
|
+
|
257
|
+
[[package]]
|
258
|
+
name = "seq-macro"
|
259
|
+
version = "0.3.6"
|
260
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
261
|
+
checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc"
|
262
|
+
|
263
|
+
[[package]]
|
264
|
+
name = "shell-words"
|
265
|
+
version = "1.1.0"
|
266
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
267
|
+
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
|
268
|
+
|
269
|
+
[[package]]
|
270
|
+
name = "shlex"
|
271
|
+
version = "1.3.0"
|
272
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
273
|
+
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
274
|
+
|
275
|
+
[[package]]
|
276
|
+
name = "syn"
|
277
|
+
version = "2.0.101"
|
278
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
279
|
+
checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf"
|
280
|
+
dependencies = [
|
281
|
+
"proc-macro2",
|
282
|
+
"quote",
|
283
|
+
"unicode-ident",
|
284
|
+
]
|
285
|
+
|
286
|
+
[[package]]
|
287
|
+
name = "unicode-ident"
|
288
|
+
version = "1.0.18"
|
289
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
290
|
+
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
291
|
+
|
292
|
+
[[package]]
|
293
|
+
name = "windows-targets"
|
294
|
+
version = "0.52.6"
|
295
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
296
|
+
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
297
|
+
dependencies = [
|
298
|
+
"windows_aarch64_gnullvm",
|
299
|
+
"windows_aarch64_msvc",
|
300
|
+
"windows_i686_gnu",
|
301
|
+
"windows_i686_gnullvm",
|
302
|
+
"windows_i686_msvc",
|
303
|
+
"windows_x86_64_gnu",
|
304
|
+
"windows_x86_64_gnullvm",
|
305
|
+
"windows_x86_64_msvc",
|
306
|
+
]
|
307
|
+
|
308
|
+
[[package]]
|
309
|
+
name = "windows_aarch64_gnullvm"
|
310
|
+
version = "0.52.6"
|
311
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
312
|
+
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
313
|
+
|
314
|
+
[[package]]
|
315
|
+
name = "windows_aarch64_msvc"
|
316
|
+
version = "0.52.6"
|
317
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
318
|
+
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
319
|
+
|
320
|
+
[[package]]
|
321
|
+
name = "windows_i686_gnu"
|
322
|
+
version = "0.52.6"
|
323
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
324
|
+
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
325
|
+
|
326
|
+
[[package]]
|
327
|
+
name = "windows_i686_gnullvm"
|
328
|
+
version = "0.52.6"
|
329
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
330
|
+
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
331
|
+
|
332
|
+
[[package]]
|
333
|
+
name = "windows_i686_msvc"
|
334
|
+
version = "0.52.6"
|
335
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
336
|
+
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
337
|
+
|
338
|
+
[[package]]
|
339
|
+
name = "windows_x86_64_gnu"
|
340
|
+
version = "0.52.6"
|
341
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
342
|
+
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
343
|
+
|
344
|
+
[[package]]
|
345
|
+
name = "windows_x86_64_gnullvm"
|
346
|
+
version = "0.52.6"
|
347
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
348
|
+
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
349
|
+
|
350
|
+
[[package]]
|
351
|
+
name = "windows_x86_64_msvc"
|
352
|
+
version = "0.52.6"
|
353
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
354
|
+
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
data/Cargo.toml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# This Cargo.toml is here to let externals tools (IDEs, etc.) know that this is
|
2
|
+
# a Rust project. Your extensions dependencies should be added to the Cargo.toml
|
3
|
+
# in the ext/ directory.
|
4
|
+
|
5
|
+
[workspace]
|
6
|
+
members = ["./ext/library_standard_numbers"]
|
7
|
+
resolver = "2"
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2025 Princeton University Library
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# LibraryStandardNumbers
|
2
|
+
|
3
|
+
LibraryStandardNumbers is a ruby wrapper of the rust crate [library_stdnums](https://github.com/pulibrary/library_stdnums).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
bundle add library_standard_numbers
|
11
|
+
```
|
12
|
+
|
13
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
gem install library_standard_numbers
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```
|
22
|
+
LibraryStandardNumbers::ISBN.normalize '0-306-40615-2'
|
23
|
+
LibraryStandardNumbers::ISBN.valid? '0-306-40615-2'
|
24
|
+
|
25
|
+
LibraryStandardNumbers::ISSN.normalize '0378-5955'
|
26
|
+
LibraryStandardNumbers::ISSN.valid? '0378-5955'
|
27
|
+
|
28
|
+
LibraryStandardNumbers::LCCN.normalize 'n78-890351'
|
29
|
+
LibraryStandardNumbers::LCCN.valid? 'n78-890351'
|
30
|
+
```
|
31
|
+
|
32
|
+
## Development
|
33
|
+
|
34
|
+
1. git clone https://github.com/pulibrary/library_standard_numbers
|
35
|
+
2. run `bin/setup` to install dependencies.
|
36
|
+
3. run `bundle exec rake` to run the tests.
|
37
|
+
4. (optional) run `bundle exec rake compile && bin/console` for an interactive prompt that will allow you to experiment.
|
38
|
+
|
39
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/pulibrary/library_standard_numbers.
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
require "rubocop/rake_task"
|
9
|
+
|
10
|
+
RuboCop::RakeTask.new
|
11
|
+
|
12
|
+
require "rb_sys/extensiontask"
|
13
|
+
|
14
|
+
task build: :compile
|
15
|
+
|
16
|
+
GEMSPEC = Gem::Specification.load("library_standard_numbers.gemspec")
|
17
|
+
|
18
|
+
RbSys::ExtensionTask.new("library_standard_numbers", GEMSPEC) do |ext|
|
19
|
+
ext.lib_dir = "lib/library_standard_numbers"
|
20
|
+
end
|
21
|
+
|
22
|
+
task default: %i[compile spec rubocop]
|
@@ -0,0 +1,14 @@
|
|
1
|
+
[package]
|
2
|
+
name = "library_standard_numbers"
|
3
|
+
version = "0.1.0"
|
4
|
+
edition = "2021"
|
5
|
+
authors = ["Max Kadel <mkadel@princeton.edu>"]
|
6
|
+
license = "MIT"
|
7
|
+
publish = false
|
8
|
+
|
9
|
+
[lib]
|
10
|
+
crate-type = ["cdylib"]
|
11
|
+
|
12
|
+
[dependencies]
|
13
|
+
library_stdnums = "0.1.0"
|
14
|
+
magnus = { version = "0.6.2" }
|
@@ -0,0 +1,63 @@
|
|
1
|
+
use magnus::{function, prelude::*, Error, RModule, Ruby};
|
2
|
+
use library_stdnums::lccn::LCCN;
|
3
|
+
use library_stdnums::isbn::ISBN;
|
4
|
+
use library_stdnums::issn::ISSN;
|
5
|
+
use library_stdnums::traits::{Normalize, Valid};
|
6
|
+
|
7
|
+
fn lccn_validate(identifier: String) -> bool {
|
8
|
+
LCCN::new(identifier).valid()
|
9
|
+
}
|
10
|
+
|
11
|
+
fn lccn_normalize(identifier: String) -> Option<String> {
|
12
|
+
LCCN::new(identifier).normalize()
|
13
|
+
}
|
14
|
+
|
15
|
+
fn isbn_validate(identifier: String) -> bool {
|
16
|
+
ISBN::new(identifier).valid()
|
17
|
+
}
|
18
|
+
|
19
|
+
fn isbn_normalize(identifier: String) -> Option<String> {
|
20
|
+
ISBN::new(identifier).normalize()
|
21
|
+
}
|
22
|
+
|
23
|
+
fn issn_validate(identifier: String) -> bool {
|
24
|
+
ISSN::new(identifier).valid()
|
25
|
+
}
|
26
|
+
|
27
|
+
fn issn_normalize(identifier: String) -> Option<String> {
|
28
|
+
ISSN::new(identifier).normalize()
|
29
|
+
}
|
30
|
+
|
31
|
+
#[magnus::init]
|
32
|
+
fn init(ruby: &Ruby) -> Result<(), Error> {
|
33
|
+
let module = ruby.define_module("LibraryStandardNumbers")?;
|
34
|
+
create_lccn_module(&module)?;
|
35
|
+
create_isbn_module(&module)?;
|
36
|
+
create_issn_module(&module)?;
|
37
|
+
|
38
|
+
Ok(())
|
39
|
+
}
|
40
|
+
|
41
|
+
fn create_lccn_module(module: &RModule) -> Result<(), Error> {
|
42
|
+
let lccn_module = module.define_module("LCCN")?;
|
43
|
+
lccn_module.define_singleton_method("valid?", function!(lccn_validate, 1))?;
|
44
|
+
lccn_module.define_singleton_method("normalize", function!(lccn_normalize, 1))?;
|
45
|
+
|
46
|
+
Ok(())
|
47
|
+
}
|
48
|
+
|
49
|
+
fn create_isbn_module(module: &RModule) -> Result<(), Error> {
|
50
|
+
let isbn_module = module.define_module("ISBN")?;
|
51
|
+
isbn_module.define_singleton_method("valid?", function!(isbn_validate, 1))?;
|
52
|
+
isbn_module.define_singleton_method("normalize", function!(isbn_normalize, 1))?;
|
53
|
+
|
54
|
+
Ok(())
|
55
|
+
}
|
56
|
+
|
57
|
+
fn create_issn_module(module: &RModule) -> Result<(), Error> {
|
58
|
+
let isbn_module = module.define_module("ISSN")?;
|
59
|
+
isbn_module.define_singleton_method("valid?", function!(issn_validate, 1))?;
|
60
|
+
isbn_module.define_singleton_method("normalize", function!(issn_normalize, 1))?;
|
61
|
+
|
62
|
+
Ok(())
|
63
|
+
}
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: library_standard_numbers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Max Kadel
|
8
|
+
- Jane Sandberg
|
9
|
+
- Christina Chortaria
|
10
|
+
- Ryan Laddusaw
|
11
|
+
- Mark Zelesky
|
12
|
+
bindir: exe
|
13
|
+
cert_chain: []
|
14
|
+
date: 2025-04-30 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rb_sys
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.9.91
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.9.91
|
30
|
+
executables: []
|
31
|
+
extensions:
|
32
|
+
- ext/library_standard_numbers/extconf.rb
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".rspec"
|
36
|
+
- ".rubocop.yml"
|
37
|
+
- Cargo.lock
|
38
|
+
- Cargo.toml
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- ext/library_standard_numbers/Cargo.toml
|
43
|
+
- ext/library_standard_numbers/extconf.rb
|
44
|
+
- ext/library_standard_numbers/src/lib.rs
|
45
|
+
- lib/library_standard_numbers.rb
|
46
|
+
- lib/library_standard_numbers/version.rb
|
47
|
+
- sig/library_standard_numbers.rbs
|
48
|
+
homepage: https://github.com/pulibrary/library_standard_numbers
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
metadata:
|
52
|
+
homepage_uri: https://github.com/pulibrary/library_standard_numbers
|
53
|
+
source_code_uri: https://github.com/pulibrary/library_standard_numbers
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.1.0
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 3.3.11
|
67
|
+
requirements: []
|
68
|
+
rubygems_version: 3.6.3
|
69
|
+
specification_version: 4
|
70
|
+
summary: A library for processing standard bibliographic numbers
|
71
|
+
test_files: []
|