bill_hicks 2.2.0 → 3.0.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 +4 -4
- data/bill_hicks.gemspec +1 -0
- data/lib/bill_hicks/base.rb +12 -6
- data/lib/bill_hicks/brand_converter.rb +1 -0
- data/lib/bill_hicks/catalog.rb +14 -27
- data/lib/bill_hicks/inventory.rb +14 -13
- data/lib/bill_hicks/version.rb +1 -1
- 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: 200b1a8ece7bd7d86e47c15449d5d28cd9b576f2
|
4
|
+
data.tar.gz: 14f161f5c9b43a98481af55bb7fe2512de58b96d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43614bde0369cbe747eeac017e4466ff49c73b51dc3447408b832845eb0ba6501622ce5037bb0a63541c24002547924b5089caccdc7d86f6ea4625ab0094e3c5
|
7
|
+
data.tar.gz: 0f81c641898416ba0f01d0e00420c9ec18f921e1b85d14b917766bf9e563710598bddce3a45d2e7a4671813b18f1a3253276a5b9f3f65d0b85be1a0bb034f0c2
|
data/bill_hicks.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_runtime_dependency "smarter_csv", "~> 1.1.4"
|
25
25
|
|
26
|
+
spec.add_development_dependency "activesupport", "~> 5"
|
26
27
|
spec.add_development_dependency "bundler", "~> 1.12"
|
27
28
|
spec.add_development_dependency "rake", "~> 11.3"
|
28
29
|
spec.add_development_dependency "rspec", "~> 3.5"
|
data/lib/bill_hicks/base.rb
CHANGED
@@ -5,9 +5,13 @@ module BillHicks
|
|
5
5
|
requires!(options, :username, :password)
|
6
6
|
|
7
7
|
Net::FTP.open(BillHicks.config.ftp_host, options[:username], options[:password]) do |ftp|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
begin
|
9
|
+
ftp.debug_mode = BillHicks.config.debug_mode
|
10
|
+
ftp.passive = true
|
11
|
+
yield ftp
|
12
|
+
ensure
|
13
|
+
ftp.close
|
14
|
+
end
|
11
15
|
end
|
12
16
|
rescue Net::FTPPermError
|
13
17
|
raise BillHicks::NotAuthenticated
|
@@ -36,7 +40,11 @@ module BillHicks
|
|
36
40
|
# Instance methods become class methods through inheritance
|
37
41
|
def connect(options)
|
38
42
|
self.class.connect(options) do |ftp|
|
39
|
-
|
43
|
+
begin
|
44
|
+
yield ftp
|
45
|
+
ensure
|
46
|
+
ftp.close
|
47
|
+
end
|
40
48
|
end
|
41
49
|
end
|
42
50
|
|
@@ -48,8 +56,6 @@ module BillHicks
|
|
48
56
|
ftp.chdir(BillHicks.config.top_level_dir)
|
49
57
|
ftp.getbinaryfile(filename, tempfile.path)
|
50
58
|
|
51
|
-
tempfile.close
|
52
|
-
|
53
59
|
tempfile
|
54
60
|
ensure
|
55
61
|
ftp.close
|
@@ -134,6 +134,7 @@ module BillHicks
|
|
134
134
|
{ prefix: 'FED', company: 'Federal' },
|
135
135
|
{ prefix: 'IND', company: 'Federal' },
|
136
136
|
{ prefix: 'FIO', company: 'Fiocchi' },
|
137
|
+
{ prefix: 'FO', company: 'Freedom Ordnance' },
|
137
138
|
{ prefix: 'WILL', company: 'Williams Gun Sight Company' },
|
138
139
|
{ prefix: 'FC', company: 'Flippin Critters' },
|
139
140
|
{ prefix: 'FLITZ', company: 'Flitz' },
|
data/lib/bill_hicks/catalog.rb
CHANGED
@@ -14,7 +14,8 @@ module BillHicks
|
|
14
14
|
# }
|
15
15
|
class Catalog < Base
|
16
16
|
|
17
|
-
|
17
|
+
CHUNK_SIZE = 500
|
18
|
+
CATALOG_FILENAME = 'billhickscatalog.csv'.freeze
|
18
19
|
PERMITTED_FEATURES = [
|
19
20
|
'weight',
|
20
21
|
'caliber',
|
@@ -46,12 +47,12 @@ module BillHicks
|
|
46
47
|
@options = options
|
47
48
|
end
|
48
49
|
|
49
|
-
def self.all(
|
50
|
+
def self.all(options = {}, &block)
|
50
51
|
requires!(options, :username, :password)
|
51
|
-
new(options).all
|
52
|
+
new(options).all &block
|
52
53
|
end
|
53
54
|
|
54
|
-
def all(
|
55
|
+
def all(&block)
|
55
56
|
connect(@options) do |ftp|
|
56
57
|
tempfile = Tempfile.new
|
57
58
|
|
@@ -59,7 +60,7 @@ module BillHicks
|
|
59
60
|
ftp.getbinaryfile(CATALOG_FILENAME, tempfile.path)
|
60
61
|
|
61
62
|
SmarterCSV.process(tempfile, {
|
62
|
-
chunk_size:
|
63
|
+
chunk_size: CHUNK_SIZE,
|
63
64
|
force_utf8: true,
|
64
65
|
convert_values_to_numeric: false,
|
65
66
|
key_mapping: {
|
@@ -75,35 +76,21 @@ module BillHicks
|
|
75
76
|
item.except!(:category_code)
|
76
77
|
|
77
78
|
item[:item_identifier] = item[:name]
|
78
|
-
item[:brand]
|
79
|
-
item[:mfg_number]
|
79
|
+
item[:brand] = BillHicks::BrandConverter.convert(item[:name])
|
80
|
+
item[:mfg_number] = item[:name].split.last
|
80
81
|
|
81
82
|
if item[:long_description].present?
|
82
|
-
features =
|
83
|
+
features = parse_features(item[:long_description])
|
83
84
|
|
84
|
-
if features[:action].present?
|
85
|
-
|
86
|
-
|
87
|
-
features.delete(:action)
|
88
|
-
end
|
89
|
-
|
90
|
-
if features[:caliber].present?
|
91
|
-
item[:caliber] = features[:caliber]
|
92
|
-
|
93
|
-
features.delete(:caliber)
|
94
|
-
end
|
95
|
-
|
96
|
-
if features[:weight].present?
|
97
|
-
item[:weight] = features[:weight]
|
98
|
-
|
99
|
-
features.delete(:weight)
|
100
|
-
end
|
85
|
+
item[:action] = features.delete(:action) if features[:action].present?
|
86
|
+
item[:caliber] = features.delete(:caliber) if features[:caliber].present?
|
87
|
+
item[:weight] = features.delete(:weight) if features[:weight].present?
|
101
88
|
|
102
89
|
item[:features] = features
|
103
90
|
end
|
104
|
-
end
|
105
91
|
|
106
|
-
|
92
|
+
yield item
|
93
|
+
end
|
107
94
|
end
|
108
95
|
|
109
96
|
tempfile.unlink
|
data/lib/bill_hicks/inventory.rb
CHANGED
@@ -8,6 +8,7 @@ module BillHicks
|
|
8
8
|
# }
|
9
9
|
class Inventory < Base
|
10
10
|
|
11
|
+
CHUNK_SIZE = 2000
|
11
12
|
INVENTORY_FILENAME = 'billhicksinventory.csv'
|
12
13
|
|
13
14
|
def initialize(options = {})
|
@@ -20,21 +21,21 @@ module BillHicks
|
|
20
21
|
new(options).get_quantity_file
|
21
22
|
end
|
22
23
|
|
23
|
-
def self.quantity(
|
24
|
+
def self.quantity(options = {}, &block)
|
24
25
|
requires!(options, :username, :password)
|
25
|
-
new(options).all
|
26
|
+
new(options).all &block
|
26
27
|
end
|
27
28
|
|
28
|
-
def self.all(
|
29
|
+
def self.all(options = {}, &block)
|
29
30
|
requires!(options, :username, :password)
|
30
|
-
new(options).all
|
31
|
+
new(options).all &block
|
31
32
|
end
|
32
33
|
|
33
|
-
def all(
|
34
|
+
def all(&block)
|
34
35
|
quantity_tempfile = get_file(INVENTORY_FILENAME)
|
35
36
|
|
36
|
-
SmarterCSV.process(quantity_tempfile
|
37
|
-
chunk_size:
|
37
|
+
SmarterCSV.process(quantity_tempfile, {
|
38
|
+
chunk_size: CHUNK_SIZE,
|
38
39
|
force_utf8: true,
|
39
40
|
convert_values_to_numeric: false,
|
40
41
|
key_mapping: {
|
@@ -43,21 +44,21 @@ module BillHicks
|
|
43
44
|
}
|
44
45
|
}) do |chunk|
|
45
46
|
chunk.each do |item|
|
46
|
-
item
|
47
|
+
yield item
|
47
48
|
end
|
48
|
-
|
49
|
-
yield(chunk)
|
50
49
|
end
|
51
50
|
|
51
|
+
quantity_tempfile.close
|
52
52
|
quantity_tempfile.unlink
|
53
|
+
true
|
53
54
|
end
|
54
55
|
|
55
56
|
def get_quantity_file
|
56
57
|
quantity_tempfile = get_file(INVENTORY_FILENAME)
|
57
58
|
tempfile = Tempfile.new
|
58
59
|
|
59
|
-
SmarterCSV.process(quantity_tempfile
|
60
|
-
chunk_size:
|
60
|
+
SmarterCSV.process(quantity_tempfile, {
|
61
|
+
chunk_size: CHUNK_SIZE,
|
61
62
|
force_utf8: true,
|
62
63
|
convert_values_to_numeric: false,
|
63
64
|
key_mapping: {
|
@@ -70,9 +71,9 @@ module BillHicks
|
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
74
|
+
quantity_tempfile.close
|
73
75
|
quantity_tempfile.unlink
|
74
76
|
tempfile.close
|
75
|
-
|
76
77
|
tempfile.path
|
77
78
|
end
|
78
79
|
|
data/lib/bill_hicks/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bill_hicks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.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-
|
11
|
+
date: 2018-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: smarter_csv
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.1.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
130
|
version: '0'
|
117
131
|
requirements: []
|
118
132
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.
|
133
|
+
rubygems_version: 2.6.12
|
120
134
|
signing_key:
|
121
135
|
specification_version: 4
|
122
136
|
summary: Ruby library for Bill Hicks ERP system
|