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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f09fece5c75d3d9d1304a2d8fbc7d4c60eb2b0c
4
- data.tar.gz: 9f0d50ae67fd3b89d4c3bd20293ab05a4d63e111
3
+ metadata.gz: e4e4f34827e9ede124f8e486883383b27e56db84
4
+ data.tar.gz: 1b4d50d861555d20ac59957d897d83a39e2011d8
5
5
  SHA512:
6
- metadata.gz: 477a47be32795c951af6483f39a2c814ea35b8bfcf3736fdb7bd1338f1e96819aa4eb87c0739b30d60f24f1ebe6e288f8e95a19bb4de241b5c0d4d39a358fb09
7
- data.tar.gz: 661cce484e55dd430d658952a8275408fa347ac25455e370c6e80f24e10815d8c7297cb0e77a08e2785d87961d65d7877df9876f10095614dd55aebc4ecf393d
6
+ metadata.gz: 16a6c131821a8f87184a5d3d0e6bbc04865e8ebb382cfdd6b37d8a614024d908d1c2eacbecaeb2a7ee4981eaba167fe3e770f3e31c5863cb69f8084c2bbf1bde
7
+ data.tar.gz: d43927890db8f102bd1ab35ff67db8e75c847d6cfa32cad3f524b81a12e569cedbf94158b70f34b9932d399bf214bfc04a72151e57f3dfcc4c3356a5b8cb61a7
@@ -8,7 +8,6 @@ require 'smarter_csv'
8
8
 
9
9
  require 'rsr_group/base'
10
10
  require 'rsr_group/constants'
11
- require 'rsr_group/chunker'
12
11
  require 'rsr_group/data_row'
13
12
  require 'rsr_group/department'
14
13
  require 'rsr_group/catalog'
@@ -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
- if chunker.is_full?
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
 
@@ -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
- yield(chunk)
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
- yield(chunk)
126
+ yield(item)
127
+ end
126
128
  end
127
129
 
128
130
  tempfile.unlink
@@ -1,3 +1,3 @@
1
1
  module RsrGroup
2
- VERSION = '2.3.0'.freeze
2
+ VERSION = '2.4.0'.freeze
3
3
  end
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.3.0
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-05-11 00:00:00.000000000 Z
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.6.12
137
+ rubygems_version: 2.5.1
139
138
  signing_key:
140
139
  specification_version: 4
141
140
  summary: RSR Group Ruby library
@@ -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