rsr_group 1.4.0 → 1.5.0

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: 60077c8e965e51a98ec7c77d7cfaf1c5869745a3
4
- data.tar.gz: b7b1ba2099f3c0d6266ca5f1e308f428b624009a
3
+ metadata.gz: 0f597af23859de3b4fb4b5104fc70cd3a3777efe
4
+ data.tar.gz: 7eab603991778fb0c7ded372a205422042d225ca
5
5
  SHA512:
6
- metadata.gz: f38996136bb58a2b5538a632636da40269514c6d7968ee1dd43942d0e5f38bd4618603f4016f4117ccc10c59f192ae7c5f18b9f0796c32dd76cd4a913de210fe
7
- data.tar.gz: f0735f15fb151e9f37330bc1f8f7a9c875849fb4628849ff565fa475cda6d9ba02b65a8adf20e8d9ad42c5da356560310b6b69f38b63c3df717236e14ce79f53
6
+ metadata.gz: 7e6a749b1301037434f8dfd97b2a5fd5ca4899c89606c977d2443ad278bd218090c3df315fb1003094e27e6d5bd09de2d64c326741af54718a819d8fad930443
7
+ data.tar.gz: 45d546ac46e6a09b79b02280fd0a89f69a492b874f2b30093e34c952d951bad69e6b39093b9b45ce11f77d3552b76056dae687271eecddf1644ff24481d006c0
@@ -14,6 +14,8 @@ module RsrGroup
14
14
  @line_type = LINE_TYPES[points[1]]
15
15
 
16
16
  case @line_type
17
+ when :file_header
18
+ get_errors(points[-1]) if has_errors && points[-1] != "00000"
17
19
  when :order_header
18
20
  get_errors(points[-1]) if has_errors && points[-1] != "00000"
19
21
  @ship_to_name = points[2]
@@ -1,10 +1,11 @@
1
1
  module RsrGroup
2
2
  class Inventory < Base
3
3
 
4
- KEYDEALER_DIR = 'keydealer'
5
- INVENTORY_DIR = 'ftpdownloads'
6
- INVENTORY_FILENAME = 'rsrinventory-new.txt'
7
- KEYDEALER_FILENAME = 'rsrinventory-keydlr-new.txt'
4
+ KEYDEALER_DIR = 'keydealer'.freeze
5
+ INVENTORY_DIR = 'ftpdownloads'.freeze
6
+ INVENTORY_FILENAME = 'rsrinventory-new.txt'.freeze
7
+ KEYDEALER_FILENAME = 'rsrinventory-keydlr-new.txt'.freeze
8
+ QTY_FILENAME = 'IM-QTY-CSV.csv'.freeze
8
9
 
9
10
  def initialize(options = {})
10
11
  requires!(options, :username, :password)
@@ -16,6 +17,11 @@ module RsrGroup
16
17
  new(options).all
17
18
  end
18
19
 
20
+ def self.quantities(options = {})
21
+ requires!(options, :username, :password)
22
+ new(options).quantities
23
+ end
24
+
19
25
  def all
20
26
  items = []
21
27
 
@@ -115,6 +121,29 @@ module RsrGroup
115
121
  items
116
122
  end
117
123
 
124
+ def quantities
125
+ rows = []
126
+
127
+ connect(@options) do |ftp|
128
+ if ftp.nlst.include?(KEYDEALER_DIR)
129
+ ftp.chdir(KEYDEALER_DIR)
130
+ else
131
+ ftp.chdir(INVENTORY_DIR)
132
+ end
133
+
134
+ csv = ftp.gettextfile(QTY_FILENAME, nil)
135
+
136
+ CSV.parse(csv) do |row|
137
+ rows << {
138
+ stock_number: row[0],
139
+ quantity: row[1].to_i,
140
+ }
141
+ end
142
+ end
143
+
144
+ rows
145
+ end
146
+
118
147
  private
119
148
 
120
149
  def sanitize(data)
@@ -2,6 +2,7 @@ module RsrGroup
2
2
  class ResponseFile < Base
3
3
 
4
4
  attr_reader :filename
5
+ attr_reader :timestamp
5
6
 
6
7
  def initialize(options = {})
7
8
  requires!(options, :username, :password, :filename)
@@ -29,7 +30,8 @@ module RsrGroup
29
30
  return @content if @content
30
31
  connect(@credentials) do |ftp|
31
32
  ftp.chdir(RsrGroup.config.response_dir)
32
- @content = ftp.gettextfile(@filename, nil)
33
+ @timestamp = ftp.mtime(@filename)
34
+ @content = ftp.gettextfile(@filename, nil)
33
35
  end
34
36
  end
35
37
  alias get_content content
@@ -54,7 +56,7 @@ module RsrGroup
54
56
  private
55
57
 
56
58
  def parse_eerr
57
- errors = @content.lines[1..-2].map do |line|
59
+ errors = @content.lines[0..-2].map do |line|
58
60
  DataRow.new(line, has_errors: true).to_h
59
61
  end.compact
60
62
 
@@ -1,3 +1,3 @@
1
1
  module RsrGroup
2
- VERSION = '1.4.0'
2
+ VERSION = '1.5.0'
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: 1.4.0
4
+ version: 1.5.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: 2017-02-27 00:00:00.000000000 Z
11
+ date: 2017-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler