elibri_xml_versions 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ require "elibri_xml_versions/version"
4
4
  require 'elibri_api_client'
5
5
  require 'elibri_onix_dict'
6
6
  require 'digest/sha2'
7
-
7
+ require 'elibri_xml_versions/array.rb'
8
8
 
9
9
 
10
10
 
@@ -105,10 +105,13 @@ module Elibri
105
105
  b_m = b.map { |x| calculate_hash(x) }
106
106
  end
107
107
  # if a.map(&:id) != b.map(&:id)
108
+
109
+ ### tu jest błąd gdzieś
110
+ ### orly?
108
111
  if a_m != b_m
109
112
  if a.all? { |x| x.respond_to?(:eid) } && b.all? { |x| x.respond_to?(:eid) }
110
- deleted_ids = a.map(&:eid) - b.map(&:eid)
111
- added_ids = b.map(&:eid) - a.map(&:eid)
113
+ deleted_ids = a.map(&:eid).subtract_once(b.map(&:eid))
114
+ added_ids = b.map(&:eid).subtract_once(a.map(&:eid))
112
115
  deleted_ids.each do |eid|
113
116
  if a.find { |x| x.eid == eid } && !a.find { |x| x.eid == eid }.blank?
114
117
  deleted << a.find { |x| x.eid == eid }
@@ -0,0 +1,8 @@
1
+ class Array
2
+ def subtract_once(b)
3
+ h = b.inject({}) {|memo, v|
4
+ memo[v] ||= 0; memo[v] += 1; memo
5
+ }
6
+ reject { |e| h.include?(e) && (h[e] -= 1) >= 0 }
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module ElibriXmlVersions
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elibri_xml_versions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ hash: 13
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 11
10
+ version: 0.1.11
5
11
  platform: ruby
6
12
  authors:
7
13
  - Piotr Szmielew
@@ -9,51 +15,78 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2014-02-04 00:00:00 Z
18
+ date: 2014-02-08 00:00:00 Z
13
19
  dependencies:
14
20
  - !ruby/object:Gem::Dependency
15
21
  name: rspec
16
22
  prerelease: false
17
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
18
25
  requirements:
19
- - &id002
20
- - ">="
26
+ - - ">="
21
27
  - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
22
31
  version: "0"
23
32
  type: :development
24
33
  version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: rake
27
36
  prerelease: false
28
- requirement: &id003 !ruby/object:Gem::Requirement
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
29
39
  requirements:
30
- - *id002
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
31
46
  type: :development
32
- version_requirements: *id003
47
+ version_requirements: *id002
33
48
  - !ruby/object:Gem::Dependency
34
49
  name: elibri_onix_mocks
35
50
  prerelease: false
36
- requirement: &id004 !ruby/object:Gem::Requirement
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
37
53
  requirements:
38
- - *id002
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
39
60
  type: :development
40
- version_requirements: *id004
61
+ version_requirements: *id003
41
62
  - !ruby/object:Gem::Dependency
42
63
  name: elibri_api_client
43
64
  prerelease: false
44
- requirement: &id005 !ruby/object:Gem::Requirement
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
45
67
  requirements:
46
- - *id002
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
47
74
  type: :runtime
48
- version_requirements: *id005
75
+ version_requirements: *id004
49
76
  - !ruby/object:Gem::Dependency
50
77
  name: elibri_onix_dict
51
78
  prerelease: false
52
- requirement: &id006 !ruby/object:Gem::Requirement
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ none: false
53
81
  requirements:
54
- - *id002
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
87
+ version: "0"
55
88
  type: :runtime
56
- version_requirements: *id006
89
+ version_requirements: *id005
57
90
  description: |-
58
91
  Gem created for comparing eLibri xml objects. More info coming soon. Currently working and tested only on REE.
59
92
  Basic usage: Elibri::XmlVersions.new(product_ver1, product_ver2).diff
@@ -74,33 +107,43 @@ files:
74
107
  - Rakefile
75
108
  - elibri_xml_versions.gemspec
76
109
  - lib/elibri_xml_versions.rb
110
+ - lib/elibri_xml_versions/array.rb
77
111
  - lib/elibri_xml_versions/version.rb
78
112
  - spec/elibri_xml_versions_spec.rb
79
113
  - spec/spec_helper.rb
80
114
  homepage: ""
81
115
  licenses: []
82
116
 
83
- metadata: {}
84
-
85
117
  post_install_message:
86
118
  rdoc_options: []
87
119
 
88
120
  require_paths:
89
121
  - lib
90
122
  required_ruby_version: !ruby/object:Gem::Requirement
123
+ none: false
91
124
  requirements:
92
- - *id002
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ hash: 3
128
+ segments:
129
+ - 0
130
+ version: "0"
93
131
  required_rubygems_version: !ruby/object:Gem::Requirement
132
+ none: false
94
133
  requirements:
95
- - *id002
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ hash: 3
137
+ segments:
138
+ - 0
139
+ version: "0"
96
140
  requirements: []
97
141
 
98
142
  rubyforge_project: elibri_xml_versions
99
- rubygems_version: 2.1.11
143
+ rubygems_version: 1.8.21
100
144
  signing_key:
101
- specification_version: 4
145
+ specification_version: 3
102
146
  summary: Gem created for comparing eLibri xml objects.
103
147
  test_files:
104
148
  - spec/elibri_xml_versions_spec.rb
105
149
  - spec/spec_helper.rb
106
- has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: c1e97b43696955470db2450ac53e6c4523a9a57e
4
- data.tar.gz: cfb13ebf27f7439df9446ae3783f20d488fba235
5
- SHA512:
6
- metadata.gz: f4e681f48030ac3a4013daeb0b1b8dd2026e86e3fe6f00bd511b0551f839078458bf7532c90e0af7338782f6601298d5eb6109127a0d53f45e826d5d9aa7e19e
7
- data.tar.gz: 27533f2db556b69dec1ee6487a215903cf1ca1f85038d5e18d7a62bfae12f30ea713a38e080166768d6b316e2f74c5aead79de2abd3cc6468bd1887e92924d2b