relaton-jis 1.16.0 → 1.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +16 -5
- data/lib/relaton_jis/bibliography.rb +10 -8
- data/lib/relaton_jis/config.rb +10 -0
- data/lib/relaton_jis/util.rb +9 -0
- data/lib/relaton_jis/version.rb +1 -1
- data/lib/relaton_jis.rb +6 -4
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f553d8895e1407f6efa8f149be93c2923b89a6a8e8c1a104098b9b8c3a56055
|
4
|
+
data.tar.gz: ec304140ac64f7173e592661d0f183d1b1285d09164fc4b472d53154758f045b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df6a1896c95ab8245adc1647b530c7fa821bf1f7c9da679805005f28acf396b8c6acc33ed63ad80fe1dfc85635fce7bf287da13d7a9c7ad32fc7cbd52f0bd7c2
|
7
|
+
data.tar.gz: 78dfe40b2cdcb55c4ae4215a4bd3ad95f6181cd16284956963d00501c4527d5945b7f806e6206a637d93e6ae029ca3e5df893713020328407e95547b8a9499f4
|
data/README.adoc
CHANGED
@@ -22,13 +22,24 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
22
22
|
|
23
23
|
== Usage
|
24
24
|
|
25
|
-
===
|
25
|
+
=== Configuration
|
26
|
+
|
27
|
+
Configuration is optional. The available option is `logger` which is a `Logger` instance. By default, the logger is `Logger.new($stderr)` with `Logger::WARN` level. To change the logger level, use `RelatonJis.configure` block.
|
26
28
|
|
27
29
|
[source,ruby]
|
28
30
|
----
|
29
31
|
require 'relaton_jis'
|
30
32
|
=> true
|
31
33
|
|
34
|
+
RelatonJis.configure do |config|
|
35
|
+
config.logger.level = Logger::DEBUG
|
36
|
+
end
|
37
|
+
----
|
38
|
+
|
39
|
+
=== Search for standards using keywords
|
40
|
+
|
41
|
+
[source,ruby]
|
42
|
+
----
|
32
43
|
hit_collection = RelatonJis::Bibliography.search("JIS X 0208")
|
33
44
|
=> <RelatonJis::HitCollection:0x00000000018858 @ref=JIS X 0208 @fetched=false>
|
34
45
|
|
@@ -54,14 +65,14 @@ item.docidentifier
|
|
54
65
|
[source,ruby]
|
55
66
|
----
|
56
67
|
item = RelatonJis::Bibliography.get "JIS X 0208:1997"
|
57
|
-
[relaton-jis] (
|
58
|
-
[relaton-jis] (
|
68
|
+
[relaton-jis] (JIS X 0208:1997) Fetching from webdesk.jsa.or.jp ...
|
69
|
+
[relaton-jis] (JIS X 0208:1997) Found: `JIS X 0208:1997`
|
59
70
|
=> #<RelatonJis::BibliographicItem:0x00007fe4478ecc08
|
60
71
|
...
|
61
72
|
|
62
73
|
item = RelatonJis::Bibliography.get "JIS X 0208", "1997"
|
63
|
-
[relaton-jis] (
|
64
|
-
[relaton-jis] (
|
74
|
+
[relaton-jis] (JIS X 0208) Fetching from webdesk.jsa.or.jp ...
|
75
|
+
[relaton-jis] (JIS X 0208) Found: `JIS X 0208:1997`
|
65
76
|
=> #<RelatonJis::BibliographicItem:0x00007fe436b49d90
|
66
77
|
...
|
67
78
|
|
@@ -14,13 +14,15 @@ module RelatonJis
|
|
14
14
|
#
|
15
15
|
def search(code, year = nil)
|
16
16
|
agent = Mechanize.new
|
17
|
-
resp = agent.post "#{SOURCE}0010/searchByKeyword", search_type: "JIS",
|
17
|
+
resp = agent.post "#{SOURCE}0010/searchByKeyword", search_type: "JIS",
|
18
|
+
keyword: code
|
18
19
|
disp = JSON.parse resp.body
|
19
20
|
# raise RelatonBib::RequestError, "No results found for #{code}" if disp["disp_screen"].nil?
|
20
21
|
return if disp["disp_screen"].nil?
|
21
22
|
|
22
23
|
result = agent.get "#{SOURCE}#{disp['disp_screen']}/index"
|
23
|
-
HitCollection.new code, year,
|
24
|
+
HitCollection.new code, year,
|
25
|
+
result: result.xpath("//div[@class='blockGenaral']")
|
24
26
|
end
|
25
27
|
|
26
28
|
#
|
@@ -36,7 +38,7 @@ module RelatonJis
|
|
36
38
|
def get(ref, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
37
39
|
code = ref.sub(/\s\((all parts|規格群)\)/, "")
|
38
40
|
opts[:all_parts] ||= !$1.nil?
|
39
|
-
warn "
|
41
|
+
Util.warn "(#{ref}) Fetching from webdesk.jsa.or.jp ..."
|
40
42
|
hits = search(code, year)
|
41
43
|
unless hits
|
42
44
|
hint [], ref, year
|
@@ -44,7 +46,7 @@ module RelatonJis
|
|
44
46
|
end
|
45
47
|
result = opts[:all_parts] ? hits.find_all_parts : hits.find
|
46
48
|
if result.is_a? RelatonJis::BibliographicItem
|
47
|
-
warn "
|
49
|
+
Util.warn "(#{ref}) Found: `#{result.docidentifier[0].id}`"
|
48
50
|
return result
|
49
51
|
end
|
50
52
|
hint result, ref, year
|
@@ -58,12 +60,12 @@ module RelatonJis
|
|
58
60
|
# @param [String, nil] year year to search
|
59
61
|
#
|
60
62
|
def hint(result, ref, year)
|
61
|
-
warn "
|
62
|
-
"exactly as shown on the webdesk.jsa.or.jp website."
|
63
|
+
Util.warn "(#{ref}) Not found."
|
63
64
|
if result.any?
|
64
|
-
warn "
|
65
|
-
|
65
|
+
Util.warn "(#{ref}) TIP: No match for edition year `#{year}`, " \
|
66
|
+
"but matches exist for `#{result.uniq.join('`, `')}`."
|
66
67
|
end
|
68
|
+
nil
|
67
69
|
end
|
68
70
|
end
|
69
71
|
end
|
data/lib/relaton_jis/version.rb
CHANGED
data/lib/relaton_jis.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
require "mechanize"
|
4
4
|
require "relaton_iso_bib"
|
5
5
|
require_relative "relaton_jis/version"
|
6
|
+
require_relative "relaton_jis/config"
|
7
|
+
require_relative "relaton_jis/util"
|
6
8
|
require_relative "relaton_jis/bibliographic_item"
|
7
9
|
require_relative "relaton_jis/xml_parser"
|
8
10
|
require_relative "relaton_jis/hash_converter"
|
@@ -17,9 +19,9 @@ module RelatonJis
|
|
17
19
|
# Returns hash of XML reammar
|
18
20
|
# @return [String]
|
19
21
|
def self.grammar_hash
|
20
|
-
gem_path = File.expand_path "..", __dir__
|
21
|
-
grammars_path = File.join gem_path, "grammars", "*"
|
22
|
-
grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
23
|
-
Digest::MD5.hexdigest grammars
|
22
|
+
# gem_path = File.expand_path "..", __dir__
|
23
|
+
# grammars_path = File.join gem_path, "grammars", "*"
|
24
|
+
# grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
25
|
+
Digest::MD5.hexdigest RelatonJis::VERSION + RelatonIsoBib::VERSION + RelatonBib::VERSION # grammars
|
24
26
|
end
|
25
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-jis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.16.
|
4
|
+
version: 1.16.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|
@@ -60,11 +60,13 @@ files:
|
|
60
60
|
- lib/relaton_jis.rb
|
61
61
|
- lib/relaton_jis/bibliographic_item.rb
|
62
62
|
- lib/relaton_jis/bibliography.rb
|
63
|
+
- lib/relaton_jis/config.rb
|
63
64
|
- lib/relaton_jis/hash_converter.rb
|
64
65
|
- lib/relaton_jis/hit.rb
|
65
66
|
- lib/relaton_jis/hit_collection.rb
|
66
67
|
- lib/relaton_jis/processor.rb
|
67
68
|
- lib/relaton_jis/scraper.rb
|
69
|
+
- lib/relaton_jis/util.rb
|
68
70
|
- lib/relaton_jis/version.rb
|
69
71
|
- lib/relaton_jis/xml_parser.rb
|
70
72
|
- relaton_jis.gemspec
|