equitrac_utilities 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 18c56d5baffe1fc3d4fed4283391c508869b24faaa73ad76406211ffc906a166
4
- data.tar.gz: f36337e3cecaf50ec47dee44180a69ae5df8cfb51bb233912865c9192af30542
3
+ metadata.gz: 6e050a9a78e9b6ab78759ccae31433163b684e5143e05ae4466c86cf4129fcff
4
+ data.tar.gz: c803665fd91de1510dc6bc53f29968f18e4acaf0e17e7be1cf5d0555e0c8e11e
5
5
  SHA512:
6
- metadata.gz: 3545e140782698895a8671b1c6f343bc3a7a6335e63ced8f80e23be8145df845710c9e063b94feafc9fb23be325462654e1a16626d8383825af91ed79febe167
7
- data.tar.gz: b04e946ccdf95b44a6f182519d5bc7ef5fe740e4148b92ba1e546ff9b3aadbe801aa06a4884c6ec7509e5468f90c0de2c759dcf3a9b0c9f6ac568693c919415b
6
+ metadata.gz: 7d757129d5456af4dbed26f789d9ec6d3106f142b0a6496ed08bee1e3844129dcce238dbcdf16a671b82b4f2ecb11cbdcd9761265b7d12fc4f5c4ae2571217ea
7
+ data.tar.gz: c24d3fb9d4fa174a305cc79793858ca4b5258d9a2a5979cd5934c80767cbec442911eb53804b8f6de00dd38e8fb5f2b898aa5b19d44646c248b8dd8f534a4214
@@ -36,16 +36,16 @@ module EquitracUtilities
36
36
  # @param attributes [Hash] attributes needed to perform command
37
37
  # @return [String] the restult from the ssh command
38
38
  def run(command:, attributes:)
39
- unless attributes[:user_id].nil? or attributes[:user_id].empty? or attributes[:user_id].eql? ''
40
- # Prep command
41
- action = send(command, attributes)
42
- ssh_cmd = build_full_command(action)
43
- # Execute command
44
- answer = send_eqcmd(ssh_cmd)
45
- # Post processing answer
46
- return post_processing(command, answer)
39
+ result = ''
40
+ begin
41
+ action = send(:check_user_id, command, attributes)
42
+ ssh_cmd = build_full_command(action)
43
+ response = send_eqcmd(ssh_cmd)
44
+ result = post_processing(command, response)
45
+ rescue ArgumentError, NoMethodError => error
46
+ result = "#{error.message} -- :#{command} using #{attributes}"
47
47
  end
48
- return "user_id missing -- #{attributes}"
48
+ return result
49
49
  end
50
50
 
51
51
  private
@@ -3,6 +3,20 @@ module EquitracUtilities
3
3
  # @note Equitrac Administration Guide - https://download.equitrac.com/271828/EE5.6/Docs/Administration_Guide.pdf
4
4
  module UserActions
5
5
 
6
+
7
+ # Be sure Actions have correct user_id data
8
+ #
9
+ # @param action [Symbol] the action to be formatted
10
+ # @return [String] this attribute MUST include: { user_id: "userid" }
11
+ def check_user_id(action, attribs)
12
+ attribs[:user_id] = attribs[:user_id]&.strip
13
+ answer = send(action, attribs)
14
+ raise ArgumentError, "missing user_id" if attribs[:user_id].nil? or
15
+ attribs[:user_id].empty?
16
+ raise ArgumentError, "user_id has space" if attribs[:user_id].include?(' ')
17
+ return answer
18
+ end
19
+
6
20
  # Get Equitrac User Info
7
21
  #
8
22
  # @param attr [Hash] this attribute MUST include: { user_id: "userid" }
@@ -1,5 +1,5 @@
1
1
  module EquitracUtilities
2
2
  module Version
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: equitrac_utilities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill Tihen