relaton-jis 1.16.1 → 1.16.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2ee66af10fcc5b78823a228bc7ac31263f8cd52f9e8fbbfdfb47ac500eb9c4a
4
- data.tar.gz: 68ddb0faf39ad33cd96edd29f072e41787b7c9fa262c5647768f12a481f5e2a7
3
+ metadata.gz: 0f553d8895e1407f6efa8f149be93c2923b89a6a8e8c1a104098b9b8c3a56055
4
+ data.tar.gz: ec304140ac64f7173e592661d0f183d1b1285d09164fc4b472d53154758f045b
5
5
  SHA512:
6
- metadata.gz: b8c365ed292ca2405923fc74b5f9f3682bf7c95aef6cf2caa4a54e7d479203b617a530a19bf17c5ff9efb9365781f5c4b603ae7d1ec51fd467ff235eb4eed230
7
- data.tar.gz: 74d12f5337f22272db21fb76264a18b8d2be376d96f116ae6235f712388e4eb074d8c6a7806a24860be3ac560ff4d983899a043cf02d3b2183a03a0b2c39ce3f
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
- === Search for standards using keywords
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] ("JIS X 0208:1997") fetching...
58
- [relaton-jis] ("JIS X 0208:1997") found JIS X 0208:1997
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] ("JIS X 0208") fetching...
64
- [relaton-jis] ("JIS X 0208") found JIS X 0208:1997
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", keyword: code
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, result: result.xpath("//div[@class='blockGenaral']")
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
- Util.warn "(#{ref}) fetching..."
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
- Util.warn "(#{ref}) found `#{result.docidentifier[0].id}`"
49
+ Util.warn "(#{ref}) Found: `#{result.docidentifier[0].id}`"
48
50
  return result
49
51
  end
50
52
  hint result, ref, year
@@ -58,8 +60,7 @@ module RelatonJis
58
60
  # @param [String, nil] year year to search
59
61
  #
60
62
  def hint(result, ref, year)
61
- Util.warn "(#{ref}) not found. The identifier must be " \
62
- "exactly as shown on the webdesk.jsa.or.jp website."
63
+ Util.warn "(#{ref}) Not found."
63
64
  if result.any?
64
65
  Util.warn "(#{ref}) TIP: No match for edition year `#{year}`, " \
65
66
  "but matches exist for `#{result.uniq.join('`, `')}`."
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonJis
4
- VERSION = "1.16.1"
4
+ VERSION = "1.16.2"
5
5
  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.1
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-09-21 00:00:00.000000000 Z
11
+ date: 2023-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize