rsr_group 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rsr_group.rb +0 -1
- data/lib/rsr_group/catalog.rb +1 -14
- data/lib/rsr_group/inventory.rb +5 -3
- data/lib/rsr_group/version.rb +1 -1
- metadata +3 -4
- data/lib/rsr_group/chunker.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4e4f34827e9ede124f8e486883383b27e56db84
|
4
|
+
data.tar.gz: 1b4d50d861555d20ac59957d897d83a39e2011d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16a6c131821a8f87184a5d3d0e6bbc04865e8ebb382cfdd6b37d8a614024d908d1c2eacbecaeb2a7ee4981eaba167fe3e770f3e31c5863cb69f8084c2bbf1bde
|
7
|
+
data.tar.gz: d43927890db8f102bd1ab35ff67db8e75c847d6cfa32cad3f524b81a12e569cedbf94158b70f34b9932d399bf214bfc04a72151e57f3dfcc4c3356a5b8cb61a7
|
data/lib/rsr_group.rb
CHANGED
data/lib/rsr_group/catalog.rb
CHANGED
@@ -20,7 +20,6 @@ module RsrGroup
|
|
20
20
|
def all(chunk_size, &block)
|
21
21
|
connect(@options) do |ftp|
|
22
22
|
begin
|
23
|
-
chunker = RsrGroup::Chunker.new(chunk_size)
|
24
23
|
csv_tempfile = Tempfile.new
|
25
24
|
|
26
25
|
if ftp.nlst.include?(KEYDEALER_DIR)
|
@@ -31,20 +30,8 @@ module RsrGroup
|
|
31
30
|
ftp.getbinaryfile(INVENTORY_FILENAME, csv_tempfile.path)
|
32
31
|
end
|
33
32
|
|
34
|
-
chunker.total_count = File.readlines(csv_tempfile).size
|
35
|
-
|
36
33
|
CSV.readlines(csv_tempfile, col_sep: ';', quote_char: "\x00").to_enum.with_index(1).each do |row, current_line|
|
37
|
-
|
38
|
-
yield(chunker.chunk)
|
39
|
-
|
40
|
-
chunker.reset
|
41
|
-
elsif chunker.is_complete?
|
42
|
-
yield(chunker.chunk)
|
43
|
-
|
44
|
-
break
|
45
|
-
else
|
46
|
-
chunker.add(process_row(row))
|
47
|
-
end
|
34
|
+
process_row(row)
|
48
35
|
end
|
49
36
|
end
|
50
37
|
|
data/lib/rsr_group/inventory.rb
CHANGED
@@ -60,7 +60,9 @@ module RsrGroup
|
|
60
60
|
end
|
61
61
|
|
62
62
|
SmarterCSV.process(tempfile, DEFAULT_SMART_OPTS.merge(chunk_size: chunk_size)) do |chunk|
|
63
|
-
|
63
|
+
chunk.each do |item|
|
64
|
+
yield(item)
|
65
|
+
end
|
64
66
|
end
|
65
67
|
|
66
68
|
tempfile.unlink
|
@@ -120,9 +122,9 @@ module RsrGroup
|
|
120
122
|
SmarterCSV.process(tempfile, DEFAULT_SMART_OPTS.merge(chunk_size: chunk_size)) do |chunk|
|
121
123
|
chunk.each do |item|
|
122
124
|
item = Hash[*item.select {|k,v| [:item_identifier, :quantity].include?(k)}.flatten]
|
123
|
-
end
|
124
125
|
|
125
|
-
|
126
|
+
yield(item)
|
127
|
+
end
|
126
128
|
end
|
127
129
|
|
128
130
|
tempfile.unlink
|
data/lib/rsr_group/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsr_group
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dale Campbell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: smarter_csv
|
@@ -102,7 +102,6 @@ files:
|
|
102
102
|
- lib/rsr_group.rb
|
103
103
|
- lib/rsr_group/base.rb
|
104
104
|
- lib/rsr_group/catalog.rb
|
105
|
-
- lib/rsr_group/chunker.rb
|
106
105
|
- lib/rsr_group/constants.rb
|
107
106
|
- lib/rsr_group/data_row.rb
|
108
107
|
- lib/rsr_group/department.rb
|
@@ -135,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
134
|
version: '0'
|
136
135
|
requirements: []
|
137
136
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.5.1
|
139
138
|
signing_key:
|
140
139
|
specification_version: 4
|
141
140
|
summary: RSR Group Ruby library
|
data/lib/rsr_group/chunker.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module RsrGroup
|
2
|
-
class Chunker
|
3
|
-
|
4
|
-
attr_accessor :chunk, :total_count, :current_count, :size
|
5
|
-
|
6
|
-
def initialize(size, total_count = nil)
|
7
|
-
@size = size
|
8
|
-
@chunk = Array.new
|
9
|
-
@current_count = 0
|
10
|
-
@total_count = total_count
|
11
|
-
end
|
12
|
-
|
13
|
-
def add(row)
|
14
|
-
reset if is_full?
|
15
|
-
|
16
|
-
@chunk.push(row)
|
17
|
-
|
18
|
-
@current_count += 1
|
19
|
-
end
|
20
|
-
|
21
|
-
def reset
|
22
|
-
@chunk.clear
|
23
|
-
end
|
24
|
-
|
25
|
-
def is_full?
|
26
|
-
@chunk.count == @size
|
27
|
-
end
|
28
|
-
|
29
|
-
def is_complete?
|
30
|
-
@total_count == @current_count
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|