rsr_group 2.2.0 → 2.2.1

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: 467740abf8326fecad3f20cc809ef42cb313e0b3
4
- data.tar.gz: e26c64746fe87e2cb0d98067b6811a5813771c8e
3
+ metadata.gz: a8b2ec538c829b5cdd5337c4daff8498ff5a68f8
4
+ data.tar.gz: 7ca678d75d29821fc5c3d667a57b453d26107d54
5
5
  SHA512:
6
- metadata.gz: 948d5d2cead337fc4461473b044acc4b11e48fe877bdd09a96a7cd0ea4018dde67233180dbf8e11e3d0a52657118cd69bc6b3e36a9f4e73bd67e25e4f68be701
7
- data.tar.gz: bed5c06fbbbb07c500bfccab57b17c086ff23b19c9761e1671fdc0255ef7ed6cf723512905c44918f9af4540f6cc3358f840b4c6a18395f5a5c144e702f331a0
6
+ metadata.gz: 675917f7dd8813979a9f744cd87f27112c2f8f2073c4d5a0a909cb34c187d880ff4e52049d2ff9f9c20c8c862de6af6e7c349f2962637dfe216d64d2b29045e5
7
+ data.tar.gz: 246c0795dcca757b3171759cabf30092c4a78fe64a4aaad45fedbfd4e471cdd7c0a1ef6c67d4f5e1249e57b571312229da495aa63f087e18c44a89fd8afc5278
@@ -29,6 +29,16 @@ module RsrGroup
29
29
  @options = options
30
30
  end
31
31
 
32
+ def self.get_quantity_file(options = {})
33
+ requires!(options, :username, :password)
34
+ new(options).get_quantity_file
35
+ end
36
+
37
+ def self.quantity(chunk_size, options = {}, &block)
38
+ requires!(options, :username, :password)
39
+ new(options).quantity(chunk_size, &block)
40
+ end
41
+
32
42
  def self.all(chunk_size, options = {}, &block)
33
43
  requires!(options, :username, :password)
34
44
  new(options).all(chunk_size, &block)
@@ -58,9 +68,38 @@ module RsrGroup
58
68
  end
59
69
  end
60
70
 
61
- def self.quantity(chunk_size, options = {}, &block)
62
- requires!(options, :username, :password)
63
- new(options).quantity(chunk_size, &block)
71
+ def get_quantity_file
72
+ connect(@options) do |ftp|
73
+ quantity_tempfile = Tempfile.new
74
+ tempfile = Tempfile.new
75
+
76
+ # Is this a key dealer?
77
+ if ftp.nlst.include?(KEYDEALER_DIR)
78
+ ftp.chdir(KEYDEALER_DIR)
79
+ # Pull from the FTP and save as a temp file
80
+ ftp.getbinaryfile(QTY_FILENAME, quantity_tempfile.path)
81
+ else
82
+ ftp.chdir(INVENTORY_DIR)
83
+ # Pull from the FTP and save as a temp file
84
+ ftp.getbinaryfile(QTY_FILENAME, quantity_tempfile.path)
85
+ end
86
+
87
+ SmarterCSV.process(quantity_tempfile.open, {
88
+ chunk_size: 100,
89
+ force_utf8: true,
90
+ convert_values_to_numeric: false,
91
+ user_provided_headers: [:item_identifier, :quantity]
92
+ }) do |chunk|
93
+ chunk.each do |item|
94
+ tempfile.puts("#{item[:item_identifier]}, #{item[:quantity]}")
95
+ end
96
+ end
97
+
98
+ quantity_tempfile.unlink
99
+ ftp.close
100
+
101
+ tempfile.path
102
+ end
64
103
  end
65
104
 
66
105
  def quantity(chunk_size, &block)
@@ -1,3 +1,3 @@
1
1
  module RsrGroup
2
- VERSION = '2.2.0'.freeze
2
+ VERSION = '2.2.1'.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.2.0
4
+ version: 2.2.1
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-04-23 00:00:00.000000000 Z
11
+ date: 2018-05-10 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