bill_hicks 2.0.13 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b61aa4a036933ec43c3d65f986ea0fd556e47677
4
- data.tar.gz: 4e80b27203c64a6dd0899b914c961c0b3a717671
3
+ metadata.gz: 7f7483ccbb583a16feb2a6d9cba92df5e3aefcf1
4
+ data.tar.gz: 5942dfb526c3a38343f585a767fac6e010235a40
5
5
  SHA512:
6
- metadata.gz: 434f9e965ea80378a55c803d87c6a1039fe9d8bc071fe6d28ef779ac178a459c94825f513c7851a783e0aaadfd2f9588f0a43297227e0b36fa8a354526bbfd9d
7
- data.tar.gz: 62b10312932d05dd8f0c2b44e8723c232ca0a03d29323c93c5ba4b75fd7d01277c690c72dbb633b2b6d648a55ff33b7be19bb7d7739b90b8803dcb7129315cf8
6
+ metadata.gz: 516d4f62202175330666d29fc18a55d56529814e0566d4332b09ed3a15d2dab53ce8968ff22c59d716f85c3435887c7cda1cdd9882038fd37bf4f66188b160d8
7
+ data.tar.gz: 68404e5d4eb90cdc3b403a332db49c72ac5e9333c31a6ce5f61d41b9fbacbcac0b3352f852bd5748b5310f99cdd33315ef7ea8d4f063f565d4bcde33416551ff
@@ -6,6 +6,7 @@ require 'smarter_csv'
6
6
  require 'tempfile'
7
7
 
8
8
  require 'bill_hicks/base'
9
+ require 'bill_hicks/ftp'
9
10
  require 'bill_hicks/catalog'
10
11
  require 'bill_hicks/category'
11
12
  require 'bill_hicks/inventory'
@@ -100,8 +100,8 @@ module BillHicks
100
100
  { prefix: 'BEN', company: 'Crosman' },
101
101
  { prefix: 'CROS', company: 'Crosman' },
102
102
  { prefix: 'NT', company: 'Non Typical (Cuddeback)' },
103
- { prefix: 'BERG', company: 'Bergara' },
104
- { prefix: 'BGA', company: 'Bergara' },
103
+ { prefix: 'BERG', company: 'CVA' },
104
+ { prefix: 'BGA', company: 'CVA' },
105
105
  { prefix: 'CVA', company: 'CVA' },
106
106
  { prefix: 'QUA', company: 'CVA' },
107
107
  { prefix: 'CZ', company: 'Cz Usa' },
@@ -0,0 +1,23 @@
1
+ module BillHicks
2
+ class FTP
3
+
4
+ attr_reader :connection
5
+
6
+ def initialize(credentials)
7
+ @connection ||= Net::FTP.new(BillHicks.config.ftp_host)
8
+ @connection.passive = true
9
+ self.login(credentials[:username], credentials[:password])
10
+ end
11
+
12
+ def login(username, password)
13
+ @connection.login(username, password)
14
+ rescue Net::FTPPermError
15
+ raise BillHicks::NotAuthenticated
16
+ end
17
+
18
+ def close
19
+ @connection.close
20
+ end
21
+
22
+ end
23
+ end
@@ -7,23 +7,20 @@ module BillHicks
7
7
  # @option options [String] :username *required*
8
8
  # @option options [String] :password *required*
9
9
  # @option options [String] :filename *required*
10
- def initialize(options = {})
10
+ def initialize(ftp, options = {})
11
11
  requires!(options, :username, :password, :filename)
12
12
 
13
- @credentials = options.select { |k, v| [:username, :password].include?(k) }
14
- @filename = options[:filename]
13
+ @credentials = options.select { |k, v| [:username, :password].include?(k) }
14
+ @filename = options[:filename]
15
+ @ftp = ftp
15
16
  end
16
17
 
17
18
  # Return list of '855 Purchase Order Acknowledgement' files
18
19
  # @option options [String] :username *required*
19
20
  # @option options [String] :password *required*
20
- def self.all(options = {})
21
- requires!(options, :username, :password)
22
-
23
- Base.connect(options) do |ftp|
24
- ftp.chdir(BillHicks.config.full_response_dir)
25
- ftp.nlst("*.txt")
26
- end
21
+ def self.all(ftp)
22
+ ftp.chdir(BillHicks.config.full_response_dir)
23
+ ftp.nlst("*.txt")
27
24
  end
28
25
 
29
26
  # Is the file a '855 Purchase Order Acknowledgement'?
@@ -39,12 +36,11 @@ module BillHicks
39
36
  # Use '#gettextfile' to read file contents as a string
40
37
  def content
41
38
  return @content if @content
42
- connect(@credentials) do |ftp|
43
- ftp.chdir(BillHicks.config.full_response_dir)
44
- @content = ftp.gettextfile(@filename, nil)
45
- ftp.close
46
- @content
47
- end
39
+
40
+ @ftp.chdir(BillHicks.config.full_response_dir)
41
+ @content = @ftp.gettextfile(@filename, nil)
42
+
43
+ @content
48
44
  end
49
45
 
50
46
  # Convert to easily readable key-value pairs
@@ -74,5 +70,4 @@ module BillHicks
74
70
  end
75
71
 
76
72
  end
77
-
78
73
  end
@@ -1,3 +1,3 @@
1
1
  module BillHicks
2
- VERSION = '2.0.13'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
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: 2.0.13
4
+ version: 2.1.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-04-09 00:00:00.000000000 Z
11
+ date: 2018-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smarter_csv
@@ -90,6 +90,7 @@ files:
90
90
  - lib/bill_hicks/brand_converter.rb
91
91
  - lib/bill_hicks/catalog.rb
92
92
  - lib/bill_hicks/category.rb
93
+ - lib/bill_hicks/ftp.rb
93
94
  - lib/bill_hicks/inventory.rb
94
95
  - lib/bill_hicks/order.rb
95
96
  - lib/bill_hicks/response_file.rb
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
116
  version: '0'
116
117
  requirements: []
117
118
  rubyforge_project:
118
- rubygems_version: 2.6.12
119
+ rubygems_version: 2.5.1
119
120
  signing_key:
120
121
  specification_version: 4
121
122
  summary: Ruby library for Bill Hicks ERP system