orion_wholesale 1.0.0 → 1.2.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
  SHA256:
3
- metadata.gz: 0f912eba82356f534ac1e312792ac9e0b97f861f3703ef51c6ed6627259977c8
4
- data.tar.gz: b227ce9f341ea67e794419c5fabfe3e447b76c582968a71cd241bc3195784805
3
+ metadata.gz: d86d91420ad8fbb4b61a9b8b282376f8fea820df10c17459dec9ac3a16e854cd
4
+ data.tar.gz: 2918d80f92b3a665b6c51a619893f775a16daa8e7de3348f1cdd93008518321a
5
5
  SHA512:
6
- metadata.gz: 8294e49274594cfc604879212042c2451cd5160562800c30eb3ffb1b05aa08369e04a1a31851266f4c7eb7db8d7cf4348c35bf6e258c00eeff3d5a148600856c
7
- data.tar.gz: 9df02007435a308a6649755711d4e75492e370068e189b02bd657b7ffae472ec21cfc77305ca4b25ea6c97de0dc0fe6e5a2625cdbeff0554fbffce38c79c2a7d
6
+ metadata.gz: 98fddca67ae56c44fff9810061b6a4aab42883088b64efbea3abe25d7d633cd1cdcbbd70434121abdbc0e6efdb45e890181517f6913541d450b8ce42df4f3de8
7
+ data.tar.gz: a8c494e532cffd8d28ac80be8d6349695bff436c4d1aecc22935be44b0506476b2f8bc5b2e0ddd7a7959dc39c11e69c3439def04d27c86ca51e80dfa2771adc5
data/.gitignore CHANGED
@@ -65,3 +65,5 @@ yarn-debug.log*
65
65
  # Ignore uploaded files in development
66
66
  /storage/*
67
67
  !/storage/.keep
68
+
69
+ /pkg/
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in orion.gemspec
3
+ # Specify your gem's dependencies in orion_wholesale.gemspec
4
4
  gemspec
@@ -1,25 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- orion_wholesale (1.0.0)
4
+ orion_wholesale (1.2.0)
5
5
  activesupport (>= 5, < 7)
6
+ net-sftp
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
- activesupport (5.2.4.3)
11
+ activesupport (5.2.4.4)
11
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
13
  i18n (>= 0.7, < 2)
13
14
  minitest (~> 5.1)
14
15
  tzinfo (~> 1.1)
15
- concurrent-ruby (1.1.6)
16
+ concurrent-ruby (1.1.7)
16
17
  diff-lcs (1.3)
17
18
  i18n (1.8.5)
18
19
  concurrent-ruby (~> 1.0)
19
- minitest (5.14.1)
20
- net-sftp (2.1.2)
21
- net-ssh (>= 2.6.5)
22
- net-ssh (5.2.0)
20
+ minitest (5.14.2)
21
+ net-sftp (3.0.0)
22
+ net-ssh (>= 5.0.0, < 7.0.0)
23
+ net-ssh (6.1.0)
23
24
  rake (12.3.3)
24
25
  rspec (3.9.0)
25
26
  rspec-core (~> 3.9.0)
@@ -43,7 +44,6 @@ PLATFORMS
43
44
 
44
45
  DEPENDENCIES
45
46
  bundler (>= 1.15)
46
- net-sftp
47
47
  orion_wholesale!
48
48
  rake (~> 12.3.0)
49
49
  rspec (~> 3.7)
@@ -36,12 +36,14 @@ module OrionWholesale
36
36
  attr_accessor :ftp_host
37
37
  attr_accessor :ftp_port
38
38
  attr_accessor :top_level_dir
39
+ attr_accessor :catalog_filename_prefix
39
40
 
40
41
  def initialize
41
- @debug_mode ||= false
42
- @ftp_host ||= "74.143.53.110"
43
- @ftp_port ||= "10022"
44
- @top_level_dir ||= "ffldealer"
42
+ @debug_mode ||= false
43
+ @ftp_host ||= "74.143.53.110"
44
+ @ftp_port ||= "10022"
45
+ @top_level_dir ||= "/ammoready"
46
+ @catalog_filename_prefix ||= 'orion_inv_arweb'
45
47
  end
46
48
  end
47
49
  end
@@ -1,8 +1,5 @@
1
1
  module OrionWholesale
2
2
  class Catalog < Base
3
-
4
- CATALOG_DIR = '/ammoready'
5
- CATALOG_FILENAME_PREFIX = 'orion_inv_arweb'
6
3
 
7
4
  def initialize(options = {})
8
5
  requires!(options, :username, :password)
@@ -15,7 +12,7 @@ module OrionWholesale
15
12
  end
16
13
 
17
14
  def all
18
- tempfile = get_most_recent_file(CATALOG_FILENAME_PREFIX, CATALOG_DIR)
15
+ tempfile = get_most_recent_file(OrionWholesale.config.catalog_filename_prefix, OrionWholesale.config.top_level_dir)
19
16
  items = []
20
17
 
21
18
  File.open(tempfile).each_with_index do |row, i|
@@ -26,31 +23,32 @@ module OrionWholesale
26
23
  next
27
24
  end
28
25
 
29
- if row[@headers.index('Category1')].strip == 'Guns'
26
+ if row[@headers.index('Category1')].try(:strip) == 'Guns'
30
27
  # Guns
31
- case row[@headers.index('Category2')].strip
28
+ case row[@headers.index('Category2')].try(:strip)
32
29
  when 'Long Guns'
33
- @category = row[@headers.index('Category3')].strip
34
- @subcategory = row[@headers.index("Category4\n")].strip
30
+ @category = row[@headers.index('Category3')].try(:strip)
31
+ @subcategory = row[@headers.index("Category4")].try(:strip)
35
32
  when 'Handguns'
36
- @category = row[@headers.index('Category2')].strip
37
- @subcategory = row[@headers.index("Category3")].strip
33
+ @category = row[@headers.index('Category2')].try(:strip)
34
+ @subcategory = row[@headers.index("Category3")].try(:strip)
38
35
  end
39
36
  else
40
37
  # Everything else
41
- @category = row[@headers.index('Category1')].strip
42
- @subcategory = row[@headers.index('Category2')].strip
38
+ @category = row[@headers.index('Category1')].try(:strip)
39
+ @subcategory = row[@headers.index('Category2')].try(:strip)
43
40
  end
44
41
 
45
42
  item = {
46
- mfg_number: row[@headers.index('Item ID')].strip,
47
- upc: row[@headers.index('Bar Code')].strip,
48
- name: row[@headers.index('Description')].strip,
49
- quantity: row[@headers.index('Qty available')].to_i,
50
- price: row[@headers.index('Price')].strip,
51
- brand: row[@headers.index('Brand')].strip,
52
- category: @category,
53
- subcategory: @subcategory,
43
+ mfg_number: row[@headers.index('Item ID')].try(:strip),
44
+ upc: row[@headers.index('Bar Code')].try(:strip),
45
+ name: row[@headers.index('Description')].try(:strip),
46
+ quantity: row[@headers.index('Qty available')].to_i,
47
+ price: row[@headers.index('Price')].try(:strip),
48
+ brand: row[@headers.index('Brand')].try(:strip),
49
+ item_identifier: row[@headers.index("ImageFileName\n")].try(:strip),
50
+ category: @category,
51
+ subcategory: @subcategory,
54
52
  }
55
53
 
56
54
  items << item
@@ -1,9 +1,6 @@
1
1
  module OrionWholesale
2
2
  class Inventory < Base
3
3
 
4
- CATALOG_DIR = '/ammoready'.freeze
5
- CATALOG_FILENAME_PREFIX = 'orion_inv_web'.freeze
6
-
7
4
  def initialize(options = {})
8
5
  requires!(options, :username, :password)
9
6
  @options = options
@@ -20,7 +17,7 @@ module OrionWholesale
20
17
  end
21
18
 
22
19
  def all
23
- tempfile = get_most_recent_file(CATALOG_FILENAME_PREFIX, CATALOG_DIR)
20
+ tempfile = get_most_recent_file(OrionWholesale.config.catalog_filename_prefix, OrionWholesale.config.top_level_dir)
24
21
  items = []
25
22
 
26
23
  File.open(tempfile).each_with_index do |row, i|
@@ -47,7 +44,7 @@ module OrionWholesale
47
44
  end
48
45
 
49
46
  def quantity
50
- tempfile = get_most_recent_file(CATALOG_FILENAME_PREFIX, CATALOG_DIR)
47
+ tempfile = get_most_recent_file(OrionWholesale.config.catalog_filename_prefix, OrionWholesale.config.top_level_dir)
51
48
  items = []
52
49
 
53
50
  File.open(tempfile).each_with_index do |row, i|
@@ -1,14 +1,24 @@
1
1
  module OrionWholesale
2
2
  class User < Base
3
3
 
4
+ USER_DIR = '/ammoready'
5
+ USER_FILENAME_PREFIX = 'orion_ardy_cust_tab'
6
+
4
7
  def initialize(options = {})
5
- requires!(options, :username, :password)
8
+ requires!(options, :username, :password, :account_id)
6
9
  @options = options
7
10
  end
8
11
 
9
12
  def authenticated?
10
- connect(@options) { |ftp| ftp.pwd }
11
- true
13
+ tempfile = get_most_recent_file(USER_FILENAME_PREFIX, USER_DIR)
14
+
15
+ File.open(tempfile).each_with_index do |row, i|
16
+ row = row.split("\t")
17
+
18
+ return true if row[0].strip.downcase == @options[:account_id].strip.downcase
19
+ end
20
+
21
+ false
12
22
  rescue OrionWholesale::NotAuthenticated
13
23
  false
14
24
  end
@@ -1,3 +1,3 @@
1
1
  module OrionWholesale
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ["lib"]
23
23
 
24
24
  spec.add_runtime_dependency "activesupport", ">= 5", "< 7"
25
+ spec.add_runtime_dependency "net-sftp"
25
26
 
26
27
  spec.add_development_dependency "bundler", ">= 1.15"
27
28
  spec.add_development_dependency "rake", "~> 12.3.0"
28
29
  spec.add_development_dependency "rspec", "~> 3.7"
29
- spec.add_development_dependency "net-sftp"
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orion_wholesale
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Beninate
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-29 00:00:00.000000000 Z
11
+ date: 2020-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,6 +30,20 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '7'
33
+ - !ruby/object:Gem::Dependency
34
+ name: net-sftp
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: bundler
35
49
  requirement: !ruby/object:Gem::Requirement
@@ -72,20 +86,6 @@ dependencies:
72
86
  - - "~>"
73
87
  - !ruby/object:Gem::Version
74
88
  version: '3.7'
75
- - !ruby/object:Gem::Dependency
76
- name: net-sftp
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '0'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: '0'
89
89
  description: ''
90
90
  email:
91
91
  - tonybeninate@icloud.com