rsr_group 2.4.0 → 3.0.1
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/catalog.rb +6 -6
- data/lib/rsr_group/inventory.rb +25 -18
- data/lib/rsr_group/version.rb +1 -1
- data/rsr_group.gemspec +1 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d660007bcdfce8880a51ab15665a8d83b55fe4f
|
4
|
+
data.tar.gz: 15faf1b6e152b3a6acb91102905b44c056de3162
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a7cc57d289350b4bf86604c841b0b3f014f39616cf49ec9a5e6abbb52d85d8ff774f3d18e3422cb279d56672d9070aba00681eeb6d80f1ee918b7540a949d48
|
7
|
+
data.tar.gz: 98b7e8ac62f25143ab3c7969b0da796882fe6b55ff473d32a363e764833778ed47fb156e6e99d28e359b534d6f577f17765064d53027ddaeeae93ff1e41cbeff
|
data/lib/rsr_group/catalog.rb
CHANGED
@@ -12,12 +12,12 @@ module RsrGroup
|
|
12
12
|
@options = options
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.all(
|
15
|
+
def self.all(options = {}, &block)
|
16
16
|
requires!(options, :username, :password)
|
17
|
-
new(options).all
|
17
|
+
new(options).all &block
|
18
18
|
end
|
19
19
|
|
20
|
-
def all(
|
20
|
+
def all(&block)
|
21
21
|
connect(@options) do |ftp|
|
22
22
|
begin
|
23
23
|
csv_tempfile = Tempfile.new
|
@@ -30,8 +30,8 @@ module RsrGroup
|
|
30
30
|
ftp.getbinaryfile(INVENTORY_FILENAME, csv_tempfile.path)
|
31
31
|
end
|
32
32
|
|
33
|
-
CSV.
|
34
|
-
|
33
|
+
CSV.foreach(csv_tempfile, { col_sep: ';', quote_char: "\x00" }).each do |row|
|
34
|
+
yield(process_row(row))
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -54,7 +54,7 @@ module RsrGroup
|
|
54
54
|
name: sanitize(row[2]),
|
55
55
|
model: sanitize(row[9]),
|
56
56
|
short_description: sanitize(row[2]),
|
57
|
-
category: row[3].nil? ?
|
57
|
+
category: row[3].nil? ? nil : RsrGroup::Department.new(row[3]).name,
|
58
58
|
brand: sanitize(row[10]),
|
59
59
|
map_price: sanitize(row[70]),
|
60
60
|
price: sanitize(row[6]),
|
data/lib/rsr_group/inventory.rb
CHANGED
@@ -9,7 +9,7 @@ module RsrGroup
|
|
9
9
|
KEYDEALER_FILENAME = 'rsrinventory-keydlr-new.txt'.freeze
|
10
10
|
|
11
11
|
DEFAULT_SMART_OPTS = {
|
12
|
-
chunk_size:
|
12
|
+
chunk_size: 500,
|
13
13
|
convert_values_to_numeric: false,
|
14
14
|
col_sep: ";",
|
15
15
|
quote_char: "|",
|
@@ -34,17 +34,17 @@ module RsrGroup
|
|
34
34
|
new(options).get_quantity_file
|
35
35
|
end
|
36
36
|
|
37
|
-
def self.quantity(
|
37
|
+
def self.quantity(options = {}, &block)
|
38
38
|
requires!(options, :username, :password)
|
39
|
-
new(options).quantity
|
39
|
+
new(options).quantity &block
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.all(
|
42
|
+
def self.all(options = {}, &block)
|
43
43
|
requires!(options, :username, :password)
|
44
|
-
new(options).all
|
44
|
+
new(options).all &block
|
45
45
|
end
|
46
46
|
|
47
|
-
def all(
|
47
|
+
def all(&block)
|
48
48
|
connect(@options) do |ftp|
|
49
49
|
tempfile = Tempfile.new
|
50
50
|
|
@@ -59,7 +59,7 @@ module RsrGroup
|
|
59
59
|
ftp.getbinaryfile(INVENTORY_FILENAME, tempfile.path)
|
60
60
|
end
|
61
61
|
|
62
|
-
SmarterCSV.process(tempfile, DEFAULT_SMART_OPTS
|
62
|
+
SmarterCSV.process(tempfile, DEFAULT_SMART_OPTS) do |chunk|
|
63
63
|
chunk.each do |item|
|
64
64
|
yield(item)
|
65
65
|
end
|
@@ -73,7 +73,7 @@ module RsrGroup
|
|
73
73
|
def get_quantity_file
|
74
74
|
connect(@options) do |ftp|
|
75
75
|
quantity_tempfile = Tempfile.new
|
76
|
-
tempfile = Tempfile.new
|
76
|
+
tempfile = Tempfile.new(['quantity-', '.csv'])
|
77
77
|
|
78
78
|
# Is this a key dealer?
|
79
79
|
if ftp.nlst.include?(KEYDEALER_DIR)
|
@@ -86,6 +86,8 @@ module RsrGroup
|
|
86
86
|
ftp.getbinaryfile(QTY_FILENAME, quantity_tempfile.path)
|
87
87
|
end
|
88
88
|
|
89
|
+
ftp.close
|
90
|
+
|
89
91
|
SmarterCSV.process(quantity_tempfile.open, {
|
90
92
|
chunk_size: 100,
|
91
93
|
force_utf8: true,
|
@@ -93,18 +95,16 @@ module RsrGroup
|
|
93
95
|
user_provided_headers: [:item_identifier, :quantity]
|
94
96
|
}) do |chunk|
|
95
97
|
chunk.each do |item|
|
96
|
-
tempfile.puts("#{item[:item_identifier]}
|
98
|
+
tempfile.puts("#{item[:item_identifier]},#{item[:quantity].to_i}")
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
100
102
|
quantity_tempfile.unlink
|
101
|
-
ftp.close
|
102
|
-
|
103
103
|
tempfile.path
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
def quantity(
|
107
|
+
def quantity(&block)
|
108
108
|
connect(@options) do |ftp|
|
109
109
|
tempfile = Tempfile.new
|
110
110
|
|
@@ -112,23 +112,30 @@ module RsrGroup
|
|
112
112
|
if ftp.nlst.include?(KEYDEALER_DIR)
|
113
113
|
ftp.chdir(KEYDEALER_DIR)
|
114
114
|
# Pull from the FTP and save as a temp file
|
115
|
-
ftp.getbinaryfile(
|
115
|
+
ftp.getbinaryfile(QTY_FILENAME, tempfile.path)
|
116
116
|
else
|
117
117
|
ftp.chdir(INVENTORY_DIR)
|
118
118
|
# Pull from the FTP and save as a temp file
|
119
|
-
ftp.getbinaryfile(
|
119
|
+
ftp.getbinaryfile(QTY_FILENAME, tempfile.path)
|
120
120
|
end
|
121
|
+
ftp.close
|
121
122
|
|
122
|
-
|
123
|
-
|
124
|
-
|
123
|
+
smart_opts = {
|
124
|
+
col_sep: ",",
|
125
|
+
headers_in_file: false,
|
126
|
+
user_provided_headers: [
|
127
|
+
:item_identifier,
|
128
|
+
:quantity
|
129
|
+
]
|
130
|
+
}
|
125
131
|
|
132
|
+
SmarterCSV.process(tempfile, smart_opts) do |chunk|
|
133
|
+
chunk.each do |item|
|
126
134
|
yield(item)
|
127
135
|
end
|
128
136
|
end
|
129
137
|
|
130
138
|
tempfile.unlink
|
131
|
-
ftp.close
|
132
139
|
end
|
133
140
|
end
|
134
141
|
|
data/lib/rsr_group/version.rb
CHANGED
data/rsr_group.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_runtime_dependency "smarter_csv", "~> 1.1.4"
|
28
28
|
|
29
29
|
spec.add_development_dependency "bundler", "~> 1.12"
|
30
|
+
spec.add_development_dependency "memory_profiler", "~> 0.9"
|
30
31
|
spec.add_development_dependency "rake", "~> 10.0"
|
31
32
|
spec.add_development_dependency "rspec", "~> 3.0"
|
32
33
|
spec.add_development_dependency "webmock", "~> 1.20"
|
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:
|
4
|
+
version: 3.0.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-07-
|
11
|
+
date: 2018-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: smarter_csv
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: memory_profiler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.9'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
148
|
version: '0'
|
135
149
|
requirements: []
|
136
150
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
151
|
+
rubygems_version: 2.6.12
|
138
152
|
signing_key:
|
139
153
|
specification_version: 4
|
140
154
|
summary: RSR Group Ruby library
|