relaton-bib 0.7.0 → 0.8.0

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: 89eba8a2b96388c5ec85c3065c8a1df4f9e58f548f41cc4a31aeec5ee086e365
4
- data.tar.gz: 2388ef34214483df6c1862481ac590f5478cf21e0d766104da290ad7ec1c7e63
3
+ metadata.gz: 2d8b311616840c90e25325574979fe74ec6253ef5d23c0873545255ff3dce033
4
+ data.tar.gz: b144ea5a04e375c1a97ccc06891e0660b790048394a65e272f54ffda8d8c2edb
5
5
  SHA512:
6
- metadata.gz: 71c430b477177ecadd215af4c7e3e1255eda41fa48be5ef87c2b79a1ac88e93361d66cade1ed9a5a86c741db21454f2a6eff8f6383f7dc47f5877f1b1e123816
7
- data.tar.gz: 7bf28cfb67462740134c7cfdd86445bb3d3ada541af4c9c6789f833e834558c634df786acfd5d86a826d3b9654b87c094bfc5d47dbb09b97b868b5c489ada40d
6
+ metadata.gz: 81c5c5906f25a7f2289f9393efce6233ba11c7d8a0ffa0dfa1b7b863d69413756a6df679e5e0222fc744b3450bb6610499cbabe89da8b75dbaa00c1d9502080b
7
+ data.tar.gz: 31a66938522b61ca282a674106023d65c6250d0636f477b1dbed979427092a2f5aa3f6f8863331190b101a0eb56aa8e96dafed023c17a37f3c0459b148b2e413
@@ -1,20 +1,29 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
3
  name: macos
4
4
 
5
- on: [push]
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ pull_request:
9
+ branches: [ '**' ]
6
10
 
7
11
  jobs:
8
12
  test-macos:
9
13
  name: Test on Ruby ${{ matrix.ruby }} macOS
10
14
  runs-on: macos-latest
11
15
  strategy:
16
+ fail-fast: false
12
17
  matrix:
13
18
  ruby: [ '2.6', '2.5', '2.4' ]
14
19
  steps:
15
- - uses: actions/checkout@v1
16
- with:
17
- submodules: recursive
20
+ - uses: actions/checkout@master
21
+ - name: Checkout submodules
22
+ shell: bash
23
+ run: |
24
+ auth_header="$(git config --local --get http.https://github.com/.extraheader)"
25
+ git submodule sync --recursive
26
+ git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
18
27
  - name: Use Ruby
19
28
  uses: actions/setup-ruby@v1
20
29
  with:
@@ -22,7 +31,7 @@ jobs:
22
31
  architecture: 'x64'
23
32
  - name: Update gems
24
33
  run: |
25
- sudo gem install bundler -v "~> 2" --force
34
+ sudo gem install bundler --force
26
35
  bundle install --jobs 4 --retry 3
27
36
  - name: Run specs
28
37
  run: |
@@ -1,20 +1,29 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
3
  name: ubuntu
4
4
 
5
- on: [push]
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ pull_request:
9
+ branches: [ '**' ]
6
10
 
7
11
  jobs:
8
12
  test-linux:
9
13
  name: Test on Ruby ${{ matrix.ruby }} Ubuntu
10
14
  runs-on: ubuntu-latest
11
15
  strategy:
16
+ fail-fast: false
12
17
  matrix:
13
18
  ruby: [ '2.6', '2.5', '2.4' ]
14
19
  steps:
15
- - uses: actions/checkout@v1
16
- with:
17
- submodules: recursive
20
+ - uses: actions/checkout@master
21
+ - name: Checkout submodules
22
+ shell: bash
23
+ run: |
24
+ auth_header="$(git config --local --get http.https://github.com/.extraheader)"
25
+ git submodule sync --recursive
26
+ git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
18
27
  - name: Use Ruby
19
28
  uses: actions/setup-ruby@v1
20
29
  with:
@@ -22,7 +31,7 @@ jobs:
22
31
  architecture: 'x64'
23
32
  - name: Update gems
24
33
  run: |
25
- gem install bundler -v "~> 2"
34
+ gem install bundler
26
35
  bundle install --jobs 4 --retry 3
27
36
  - name: Run specs
28
37
  run: |
@@ -1,20 +1,29 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
3
  name: windows
4
4
 
5
- on: [push]
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ pull_request:
9
+ branches: [ '**' ]
6
10
 
7
11
  jobs:
8
12
  test-windows:
9
13
  name: Test on Ruby ${{ matrix.ruby }} Windows
10
14
  runs-on: windows-latest
11
15
  strategy:
16
+ fail-fast: false
12
17
  matrix:
13
18
  ruby: [ '2.6', '2.5', '2.4' ]
14
19
  steps:
15
- - uses: actions/checkout@v1
16
- with:
17
- submodules: recursive
20
+ - uses: actions/checkout@master
21
+ - name: Checkout submodules
22
+ shell: bash
23
+ run: |
24
+ auth_header="$(git config --local --get http.https://github.com/.extraheader)"
25
+ git submodule sync --recursive
26
+ git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
18
27
  - name: Use Ruby
19
28
  uses: actions/setup-ruby@v1
20
29
  with:
@@ -23,7 +32,7 @@ jobs:
23
32
  - name: Update gems
24
33
  shell: pwsh
25
34
  run: |
26
- gem install bundler -v "~> 2"
35
+ gem install bundler
27
36
  bundle config --local path vendor/bundle
28
37
  bundle update
29
38
  bundle install --jobs 4 --retry 3
@@ -1,4 +1,5 @@
1
1
  require "relaton_bib/version"
2
+ require "relaton_bib/deep_dup"
2
3
  require "relaton_bib/bibliographic_item"
3
4
  require "relaton_bib/hit_collection"
4
5
  require "relaton_bib/hit"
@@ -0,0 +1,30 @@
1
+ class Object
2
+ def duplicable?
3
+ true
4
+ end
5
+
6
+ def deep_dup
7
+ duplicable? ? dup : self
8
+ end
9
+ end
10
+
11
+ class Array
12
+ def deep_dup
13
+ map(&:deep_dup)
14
+ end
15
+ end
16
+
17
+ # class Hash
18
+ # def deep_dup
19
+ # hash = dup
20
+ # each_pair do |key, value|
21
+ # if key.frozen? && ::String === key
22
+ # hash[key] = value.deep_dup
23
+ # else
24
+ # hash.delete(key)
25
+ # hash[key.deep_dup] = value.deep_dup
26
+ # end
27
+ # end
28
+ # hash
29
+ # end
30
+ # end
@@ -1,5 +1,8 @@
1
1
  module RelatonBib
2
2
  class Hit
3
+ # @return [RelatonBib::HitCollection]
4
+ attr_reader :hit_collection
5
+
3
6
  # @return [Array<Hash>]
4
7
  attr_reader :hit
5
8
 
@@ -24,9 +27,20 @@ module RelatonBib
24
27
  "@title=\"#{@hit[:code]}\">"
25
28
  end
26
29
 
27
- # @return [String]
28
- def to_xml(**opts)
29
- fetch.to_xml **opts
30
+ def fetch
31
+ raise "Not implemented"
32
+ end
33
+
34
+ # @param builder [Nokogiri::XML::Builder]
35
+ def to_xml(builder = nil, **opts)
36
+ if builder
37
+ fetch.to_xml builder, **opts
38
+ else
39
+ builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
40
+ fetch.to_xml xml, **opts
41
+ end
42
+ builder.doc.root.to_xml
43
+ end
30
44
  end
31
45
  end
32
46
  end
@@ -1,5 +1,11 @@
1
+ require "forwardable"
2
+
1
3
  module RelatonBib
2
- class HitCollection < Array
4
+ class HitCollection
5
+ extend Forwardable
6
+
7
+ def_delegators :@array, :<<, :[], :first, :empty?, :any?, :size, :each, :each_slice
8
+
3
9
  # @return [TrueClass, FalseClass]
4
10
  attr_reader :fetched
5
11
 
@@ -9,6 +15,14 @@ module RelatonBib
9
15
  # @return [String]
10
16
  attr_reader :year
11
17
 
18
+ # @param text [String] reference to search
19
+ def initialize(text, year = nil)
20
+ @array = []
21
+ @text = text
22
+ @year = year
23
+ @fetched = false
24
+ end
25
+
12
26
  # @return [RelatonIso::HitCollection]
13
27
  def fetch
14
28
  workers = WorkersPool.new 4
@@ -22,13 +36,38 @@ module RelatonBib
22
36
  self
23
37
  end
24
38
 
39
+ def to_xml(**opts)
40
+ builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
41
+ xml.documents do
42
+ @array.each do |hit|
43
+ hit.fetch
44
+ hit.to_xml xml, **opts
45
+ end
46
+ end
47
+ end
48
+ builder.to_xml
49
+ end
50
+
51
+ def select(&block)
52
+ me = self.deep_dup
53
+ array_dup = self.instance_variable_get(:@array).deep_dup
54
+ me.instance_variable_set(:@array, array_dup)
55
+ array_dup.select!(&block)
56
+ me
57
+ end
58
+
59
+ def reduce!(sum, &block)
60
+ @array = @array.reduce sum, &block
61
+ self
62
+ end
63
+
25
64
  def to_s
26
65
  inspect
27
66
  end
28
67
 
29
68
  # @return [String]
30
69
  def inspect
31
- "<#{self.class}:#{format('%#.14x', object_id << 1)} @fetched=#{@fetched}>"
70
+ "<#{self.class}:#{format('%#.14x', object_id << 1)} @ref=#{@text} @fetched=#{@fetched}>"
32
71
  end
33
72
  end
34
73
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonBib
2
- VERSION = "0.7.0".freeze
2
+ VERSION = "0.8.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-bib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-16 00:00:00.000000000 Z
11
+ date: 2020-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase
@@ -211,6 +211,7 @@ files:
211
211
  - lib/relaton_bib/contribution_info.rb
212
212
  - lib/relaton_bib/contributor.rb
213
213
  - lib/relaton_bib/copyright_association.rb
214
+ - lib/relaton_bib/deep_dup.rb
214
215
  - lib/relaton_bib/document_identifier.rb
215
216
  - lib/relaton_bib/document_relation.rb
216
217
  - lib/relaton_bib/document_relation_collection.rb