relaton-index 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e593c33ab08170851f728d43821031387b3ad70ce441501429909132306880ab
4
- data.tar.gz: a5445a29d744fa3ff9214274be7be64a0694f1262ee8f99820a4abef61c0398b
3
+ metadata.gz: c687782518f5a65ec1d2817f0465ad259512fd036c245405c51d33791c9283a8
4
+ data.tar.gz: 0ad89006b9935eabfa69493c230337be7b0b4f698c9e2cc8fb2caef3e11b5862
5
5
  SHA512:
6
- metadata.gz: a0a292add233827c1298bcddad35aaab24a611a4ac4bdc9cb8a323aee92b2673740f551d68fb1591a11bda20fa01ccc55ea444233b4bc5d2719493ba9ab5dd92
7
- data.tar.gz: 0e06a6dd6372fc7cca12bf05b5f83007f48ee992af18c2191b8fc0f6ea854df9401867aa9aac848bd93e228ac5de8f66ca52ee19b42cfb0f7b1c55078678804c
6
+ metadata.gz: 18479264d80c4139e0a819a3a49c8c06b7d0f864e8b01098eaa9535a593c2cb3f7117c025ac6fd978b54350aa390685d16b380e05ac5778ce4d4d2e0effe63a4
7
+ data.tar.gz: 84cdc050c23d872de768672274189ad453708ecd961f8cdbac15e51e59aec64d4a6c9f9f7760b507ea602b7dc2dba04874a01a83d2be911d69361a33e300013b
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
@@ -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.1"
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.1
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