relaton-iso 0.6.0 → 0.6.1

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
  SHA1:
3
- metadata.gz: cc801b7e86beb613871c89c758a03461e3731c5b
4
- data.tar.gz: 11de8f75ad6b7db84bc8c6d8015f2817a02001be
3
+ metadata.gz: 36087254e7d4a03e2b10043bf3982b8302c4b03e
4
+ data.tar.gz: 410db681abb2e79f7cc6f20adc94ea760fb68c5f
5
5
  SHA512:
6
- metadata.gz: 2fde58ae095f74a36131efb6bebbc3dde7dfcda12d23d3b5204d13cfac7d5f024b093fb8d718c8ceac3c055076a4fbc71dd4ec3be1fb0ff46c2da0752aad9d68
7
- data.tar.gz: dc57fb39f91e4eeec4f2988ced6a0c0d0108d440db528db592c8242bc21a635afc27f617db7a65e4d572bd14b2c14341c9d84a2437603a40c43d5d2eca528502
6
+ metadata.gz: 4de83577a94249d2a11217f279fcd83d1ea982d5a4e3f37ff50f5a1ab2050d8fcffe402ff18f27ae37c06de35af7e612fd07d678bb46623c5258b5646d8f3227
7
+ data.tar.gz: 8d01def2dddc97a28e4bf7f37f5ea1ebc8210adb55d505a555028762269801a8aed7114040ad89a76cd9e0283c221e6daad739efb7b464638093a0566d249abc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- relaton-iso (0.6.0)
4
+ relaton-iso (0.6.1)
5
5
  relaton-iec (~> 0.4.0)
6
6
  relaton-iso-bib (~> 0.3.0)
7
7
 
@@ -36,13 +36,13 @@ GEM
36
36
  pry (~> 0.10)
37
37
  public_suffix (3.1.1)
38
38
  rake (10.5.0)
39
- relaton-bib (0.3.0)
39
+ relaton-bib (0.3.1)
40
40
  addressable
41
41
  nokogiri (~> 1.10)
42
42
  relaton-iec (0.4.0)
43
43
  addressable
44
44
  relaton-iso-bib (~> 0.3.0)
45
- relaton-iso-bib (0.3.0)
45
+ relaton-iso-bib (0.3.1)
46
46
  isoics (~> 0.1.6)
47
47
  relaton-bib (~> 0.3.0)
48
48
  ruby_deep_clone (~> 0.8.0)
@@ -48,5 +48,15 @@ module RelatonIso
48
48
  builder.doc.root.to_xml
49
49
  end
50
50
  end
51
+
52
+ def sort_weight
53
+ case hit["publicationStatus"]
54
+ when "Published" then 0
55
+ when "Under development" then 1
56
+ when "Withdrawn" then 2
57
+ else
58
+ 3
59
+ end
60
+ end
51
61
  end
52
62
  end
@@ -35,6 +35,13 @@ module RelatonIso
35
35
 
36
36
  json = JSON.parse resp.body
37
37
  concat(json["standards"].map { |h| Hit.new h, self })
38
+ sort! do |a, b|
39
+ if a.sort_weight == b.sort_weight
40
+ (parse_date(b.hit) - parse_date(a.hit)).to_i
41
+ else
42
+ a.sort_weight - b.sort_weight
43
+ end
44
+ end
38
45
  end
39
46
 
40
47
  # @return [RelatonIso::HitCollection]
@@ -69,5 +76,19 @@ module RelatonIso
69
76
  end
70
77
  builder.to_xml
71
78
  end
79
+
80
+ private
81
+
82
+ def parse_date(hit)
83
+ if hit["publicationDate"]
84
+ Date.strptime(hit["publicationDate"], "%Y-%m")
85
+ elsif %r{:(?<year>\d{4})} =~ hit["docRef"]
86
+ Date.strptime(year, "%Y")
87
+ elsif hit["newProjectDate"]
88
+ Date.parse hit["newProjectDate"]
89
+ else
90
+ Date.new 0
91
+ end
92
+ end
72
93
  end
73
94
  end
@@ -142,7 +142,8 @@ module RelatonIso
142
142
  def isobib_results_filter(result, year)
143
143
  missed_years = []
144
144
  result.each do |s|
145
- return { ret: s.fetch } if !year
145
+ next if !year && s.hit["publicationStatus"] == "Withdrawn"
146
+ return { ret: s.fetch } unless year
146
147
 
147
148
  %r{:(?<iyear>\d{4})} =~ s.hit["docRef"]
148
149
  return { ret: s.fetch } if iyear == year
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonIso
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.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: 2019-07-25 00:00:00.000000000 Z
11
+ date: 2019-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler