relaton-index 0.1.0 → 0.1.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: e593c33ab08170851f728d43821031387b3ad70ce441501429909132306880ab
4
- data.tar.gz: a5445a29d744fa3ff9214274be7be64a0694f1262ee8f99820a4abef61c0398b
3
+ metadata.gz: ba264ee91f3458c72c08556365a2cf318a42ba7d28f54b33f94ebcaa5819a5cb
4
+ data.tar.gz: 1036ca48d53463eb1b13349f4865a8022a06651fc233851d316c70fb496040ac
5
5
  SHA512:
6
- metadata.gz: a0a292add233827c1298bcddad35aaab24a611a4ac4bdc9cb8a323aee92b2673740f551d68fb1591a11bda20fa01ccc55ea444233b4bc5d2719493ba9ab5dd92
7
- data.tar.gz: 0e06a6dd6372fc7cca12bf05b5f83007f48ee992af18c2191b8fc0f6ea854df9401867aa9aac848bd93e228ac5de8f66ca52ee19b42cfb0f7b1c55078678804c
6
+ metadata.gz: d13c60883ccbf875b28cf17968ccdb766f957f4a27f578b8af80369b97847f9c4cdd4cb87314f9b3795c2107e02317b808f9808d80e31b6ddb2da77cb2b01085
7
+ data.tar.gz: 9363b56f7968471b7853a8ca25169c0425ad911f4c99e657b2ff5776314baac3ba8b9ad507d98cacbb07c21c11cad0a29c29f096ca5b7cc6dcd8b0408f1c01f8
data/Gemfile CHANGED
@@ -9,8 +9,8 @@ gem "rake", "~> 13.0"
9
9
 
10
10
  gem "rspec", "~> 3.0"
11
11
 
12
- gem "rubocop", "~> 1.46"
13
- gem "rubocop-performance", "~> 1.15"
14
- gem "rubocop-rails", "~> 2.17"
12
+ gem "rubocop", "~> 1.48"
13
+ gem "rubocop-performance", "~> 1.16"
14
+ gem "rubocop-rails", "~> 2.18"
15
15
 
16
16
  gem "simplecov", "~> 0.22"
data/README.adoc CHANGED
@@ -57,8 +57,15 @@ index = Relaton::Index.find_or_create :IHO, url: "https://raw.githubusercontent.
57
57
 
58
58
 
59
59
  # Search for a document by reference
60
- index.search "B-4 2.19.0"
61
- # => ["data/b-4_2_19_0.xml"]
60
+ index.search "B-4"
61
+ # => [{ id: "B-4 2.19.0", file: "data/b-4_2_19_0.xml" }]
62
+
63
+ # Search for a document by reference using a block
64
+ index.search do |row|
65
+ # do something with the index row
66
+ row[:id] == "B-4"
67
+ end
68
+ # => [{ id: "B-4 2.19.0", file: "data/b-4_2_19_0.xml" }]
62
69
 
63
70
  # Remove the index from the pool.
64
71
  Relaton::Index.close :IHO
@@ -66,7 +66,7 @@ module Relaton
66
66
  resp = URI(@url).open
67
67
  zip = Zip::InputStream.new resp
68
68
  entry = zip.get_next_entry
69
- index = YAML.safe_load(entry.get_input_stream.read, [Symbol])
69
+ index = YAML.safe_load(entry.get_input_stream.read, permitted_classes: [Symbol])
70
70
  save index
71
71
  index
72
72
  end
@@ -37,6 +37,8 @@ module Relaton
37
37
  # @return [void]
38
38
  #
39
39
  def write(file, data)
40
+ dir = File.dirname file
41
+ FileUtils.mkdir_p dir
40
42
  File.write file, data, encoding: "UTF-8"
41
43
  end
42
44
 
@@ -39,7 +39,7 @@ module Relaton
39
39
  #
40
40
  # @return [Array<Hash>] search results
41
41
  #
42
- def search(id)
42
+ def search(id = nil)
43
43
  @index.select do |i|
44
44
  block_given? ? yield(i) : i[:id].include?(id)
45
45
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Relaton
4
4
  module Index
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-index
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.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-03-07 00:00:00.000000000 Z
11
+ date: 2023-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip