rsr_group 2.1.2 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c84f6fdaa956cb1b991eb2c13058093bea3a9bdb
4
- data.tar.gz: 19f7233418ca4f619a49f1e068a5595a1d017c4c
3
+ metadata.gz: f14f17dee115f2e0be70d42e6e144b911004c337
4
+ data.tar.gz: 0474a3572e4d03b185c00d45875c689882d94a7c
5
5
  SHA512:
6
- metadata.gz: 1a5d05a35d699fb6c7c8dc7a87598e3a5e20361e17217a143ff91b7e524e1bdcab20b5845c0cfdf388ad7acf5e1e92535193e06044332890c102f4a3a3fb0063
7
- data.tar.gz: ed6b276730fc6f8e55b068df1ea6534d7be28e4fbe8b69e6aa8643653657dba5ae45ab39f2c6b6318484b4203795186beb8b0a4b0cfd0ded9541e97ceb3f766d
6
+ metadata.gz: 865b098d1a54ba20729635d452fdf8f31c46d6aab5202cc55648abced9639ec82a8c5d4398580a0dfe5de63d4b20866853a6ce6f7876f11244877641647870a8
7
+ data.tar.gz: 4d84719a8701be4c2d7287d884c4bffe1b01835e43dfd1c895b2583a1051064586d06536c4145c1db1854aeced9e2c51b236e7a828726b17b964b11c29e9c1f2
@@ -58,5 +58,38 @@ module RsrGroup
58
58
  end
59
59
  end
60
60
 
61
+ def self.quantity(chunk_size, options = {}, &block)
62
+ requires!(options, :username, :password)
63
+ new(options).quantity(chunk_size, &block)
64
+ end
65
+
66
+ def quantity(chunk_size, &block)
67
+ connect(@options) do |ftp|
68
+ tempfile = Tempfile.new
69
+
70
+ # Is this a key dealer?
71
+ if ftp.nlst.include?(KEYDEALER_DIR)
72
+ ftp.chdir(KEYDEALER_DIR)
73
+ # Pull from the FTP and save as a temp file
74
+ ftp.getbinaryfile(KEYDEALER_FILENAME, tempfile.path)
75
+ else
76
+ ftp.chdir(INVENTORY_DIR)
77
+ # Pull from the FTP and save as a temp file
78
+ ftp.getbinaryfile(INVENTORY_FILENAME, tempfile.path)
79
+ end
80
+
81
+ SmarterCSV.process(tempfile, DEFAULT_SMART_OPTS.merge(chunk_size: chunk_size)) do |chunk|
82
+ chunk.each do |item|
83
+ item = Hash[*item.select {|k,v| [:item_identifier, :quantity].include?(k)}.flatten]
84
+ end
85
+
86
+ yield(chunk)
87
+ end
88
+
89
+ tempfile.unlink
90
+ ftp.close
91
+ end
92
+ end
93
+
61
94
  end
62
95
  end
@@ -1,3 +1,3 @@
1
1
  module RsrGroup
2
- VERSION = '2.1.2'.freeze
2
+ VERSION = '2.1.3'.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.1.2
4
+ version: 2.1.3
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-01-18 00:00:00.000000000 Z
11
+ date: 2018-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smarter_csv
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  requirements: []
137
137
  rubyforge_project:
138
- rubygems_version: 2.6.12
138
+ rubygems_version: 2.5.1
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: RSR Group Ruby library