callsigns 1.1.5 → 1.1.6

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: 3dbf79c05cdf7dd9c4aa96a15eb2c3215bdd1a5c4462ef78f47f97ecb94d08a2
4
- data.tar.gz: 2917c56ede4475b911cd0f312732078e2aed25ed85c22da210ac28c37f78c992
3
+ metadata.gz: 505baa52b37717a979325e5e502f76d7dc9fe4f97bd5c6797db3e10fff67942f
4
+ data.tar.gz: 062e5eb6b4f647265752a7393e86819a042a9d274ee8d20d859334b9e2b54bd2
5
5
  SHA512:
6
- metadata.gz: 03fa935f932d92a2c9182992b617a55639681ea2efcf221826da8af96a365de3d55b7a2b2cbcda3e52238dab0edbc65d9576d3ac13d778198ded53c9bab20a37
7
- data.tar.gz: 893ea9aedbca3ed1ebcf247b7389f84c8f53b9bf5731623f33fabeea9ac0fd16b03f8ecc48d852554b716efba1109a6aa749574b33ec2846f4468ee333b74fa9
6
+ metadata.gz: e35e5eedf90c7e4a44c09ec2373f607795249aa9f878794313715e1370b76599a59a1b3b7dfc656b50923cf1dce8576e363311ce5477e34217debffe14e5b14a
7
+ data.tar.gz: a2a78af4af305b8b1c47651e6c1a54bd76fcf37ad543014bcf711b70fe895ed1ff16bda91c93c7b1cefa48f55d86d2380d42a2793b46990f21fb46579406315d
@@ -4,5 +4,5 @@ require 'callsigns'
4
4
  require 'httparty'
5
5
  require 'json'
6
6
 
7
- Callsigns::CLI.main(ARGV[0])
7
+ Callsigns::TCP.main(ARGV[0])
8
8
 
@@ -1,4 +1,4 @@
1
1
  require_relative './callsigns/version'
2
2
  require_relative './callsigns/radioid'
3
3
  require_relative './callsigns/callook'
4
- require_relative './callsigns/cli'
4
+ require_relative './callsigns/tcp'
@@ -1,43 +1,43 @@
1
1
  class Callsigns::Callook
2
- def self.lookup(callsign)
2
+ def self.lookup(callsign, client)
3
3
  callook_uri = "https://callook.info/" + callsign.downcase + "/json"
4
4
  response = HTTParty.get(callook_uri).parsed_response
5
5
  if response["status"] == "INVALID"
6
- puts "Invalid callsign. Please make sure you entered a valid USA-Based callsign"
6
+ client.puts "Invalid callsign. Please make sure you entered a valid USA-Based callsign"
7
7
  elsif response["status"] == "VALID"
8
- puts "Callsign " + callsign.upcase + " is found!\n\n"
8
+ client.puts "Callsign " + callsign.upcase + " is found!\n\n"
9
9
  if response["previous"]["callsign"] == callsign.upcase
10
- puts "ATTENTION: The callsign " + callsign.upcase + " is out-of-date. Operator changed callsign to: " + response["current"]["callsign"]
10
+ client.puts "ATTENTION: The callsign " + callsign.upcase + " is out-of-date. Operator changed callsign to: " + response["current"]["callsign"]
11
11
  end
12
- puts response["current"]["callsign"]
13
- puts "========="
14
- puts "Type: " + response["type"].capitalize
15
- puts "Name: " + response["name"].upcase
12
+ client.puts response["current"]["callsign"]
13
+ client.puts "========="
14
+ client.puts "Type: " + response["type"].capitalize
15
+ client.puts "Name: " + response["name"].upcase
16
16
  if response["type"] == "CLUB"
17
- puts "Trustee: " + response["trustee"]["name"].upcase + " [" + response["trustee"]["callsign"] + "]"
17
+ client.puts "Trustee: " + response["trustee"]["name"].upcase + " [" + response["trustee"]["callsign"] + "]"
18
18
  elsif response["type"] == "PERSON"
19
- puts "Class: " + response["current"]["operClass"]
19
+ client.puts "Class: " + response["current"]["operClass"]
20
20
  end
21
- puts "Address: " + response["address"]["line1"]
22
- puts " " + response["address"]["line2"]
23
- puts " " + response["address"]["attn"] if response["address"]["attn"] != ""
24
- puts "Previous callsign: " + response["previous"]["callsign"]
21
+ client.puts "Address: " + response["address"]["line1"]
22
+ client.puts " " + response["address"]["line2"]
23
+ client.puts " " + response["address"]["attn"] if response["address"]["attn"] != ""
24
+ client.puts "Previous callsign: " + response["previous"]["callsign"]
25
25
 
26
26
  radioid_dmr_uri = "https://database.radioid.net/api/dmr/user/?callsign=" + callsign.downcase
27
27
  response = HTTParty.get(radioid_dmr_uri).parsed_response
28
- puts "DMR IDs: " + response["count"].to_s + " IDs found"
28
+ client.puts "DMR IDs: " + response["count"].to_s + " IDs found"
29
29
  if response["count"].to_i > 0
30
30
  response["results"].each do |r|
31
- puts " " + r["id"].to_s
31
+ client.puts " " + r["id"].to_s
32
32
  end
33
33
  end
34
34
 
35
35
  radioid_nxdn_uri = "https://database.radioid.net/api/nxdn/user/?callsign=" + callsign.downcase
36
36
  response = HTTParty.get(radioid_nxdn_uri).parsed_response
37
- puts "NXDN IDs: " + response["count"].to_s + " IDs found"
37
+ client.puts "NXDN IDs: " + response["count"].to_s + " IDs found"
38
38
  if response["count"].to_i > 0
39
39
  response["results"].each do |r|
40
- puts " " + r["id"].to_s
40
+ client.puts " " + r["id"].to_s
41
41
  end
42
42
  end
43
43
 
@@ -1,44 +1,44 @@
1
1
  class Callsigns::RadioID
2
- def self.dmr(id)
2
+ def self.dmr(id, client)
3
3
  radioid_dmr_uri = "https://database.radioid.net/api/dmr/user/?id=" + id.to_s
4
4
  response = HTTParty.get(radioid_dmr_uri).parsed_response
5
5
  if response["count"].to_i == 1
6
- puts "DMR ID " + id.to_s + " is found!\n\n"
7
- puts "DMR: " + response["results"][0]["id"].to_s
8
- puts "========="
9
- puts "Callsign: " + response["results"][0]["callsign"].upcase
10
- puts "Name: " + response["results"][0]["fname"] + " " + + response["results"][0]["surname"]
11
- puts "City: " + response["results"][0]["city"]
12
- puts "State: " + response["results"][0]["state"]
13
- puts "Country: " + response["results"][0]["country"]
6
+ client.puts "DMR ID " + id.to_s + " is found!\n\n"
7
+ client.puts "DMR: " + response["results"][0]["id"].to_s
8
+ client.puts "========="
9
+ client.puts "Callsign: " + response["results"][0]["callsign"].upcase
10
+ client.puts "Name: " + response["results"][0]["fname"] + " " + + response["results"][0]["surname"]
11
+ client.puts "City: " + response["results"][0]["city"]
12
+ client.puts "State: " + response["results"][0]["state"]
13
+ client.puts "Country: " + response["results"][0]["country"]
14
14
 
15
15
  if ["A", "K", "N", "W"].include? response["results"][0]["callsign"][0]
16
- puts "\nFor more information about this operator, enter [Lookup " + response["results"][0]["callsign"].upcase + "]"
16
+ client.puts "\nFor more information about this operator, enter [Lookup " + response["results"][0]["callsign"].upcase + "]"
17
17
  end
18
18
  else
19
- puts id.to_s + " is not a valid DMR ID."
19
+ client.puts id.to_s + " is not a valid DMR ID."
20
20
  end
21
21
  end
22
22
 
23
23
 
24
- def self.nxdn(id)
24
+ def self.nxdn(id, client)
25
25
  radioid_nxdn_uri = "https://database.radioid.net/api/nxdn/user/?id=" + id.to_s
26
26
  response = HTTParty.get(radioid_nxdn_uri).parsed_response
27
27
  if response["count"].to_i > 0 && response["results"][0]["id"].to_s == id.to_s
28
- puts "NXDN ID " + id.to_s + " is found!\n\n"
29
- puts "NXDN: " + response["results"][0]["id"].to_s
30
- puts "========="
31
- puts "Callsign: " + response["results"][0]["callsign"].upcase
32
- puts "Name: " + response["results"][0]["fname"] + " " + + response["results"][0]["surname"]
33
- puts "City: " + response["results"][0]["city"]
34
- puts "State: " + response["results"][0]["state"]
35
- puts "Country: " + response["results"][0]["country"]
28
+ client.puts "NXDN ID " + id.to_s + " is found!\n\n"
29
+ client.puts "NXDN: " + response["results"][0]["id"].to_s
30
+ client.puts "========="
31
+ client.puts "Callsign: " + response["results"][0]["callsign"].upcase
32
+ client.puts "Name: " + response["results"][0]["fname"] + " " + + response["results"][0]["surname"]
33
+ client.puts "City: " + response["results"][0]["city"]
34
+ client.puts "State: " + response["results"][0]["state"]
35
+ client.puts "Country: " + response["results"][0]["country"]
36
36
 
37
37
  if ["A", "K", "N", "W"].include? response["results"][0]["callsign"][0]
38
- puts "\nFor more information about this operator, enter [Lookup " + response["results"][0]["callsign"].upcase + "]"
38
+ client.puts "\nFor more information about this operator, enter [Lookup " + response["results"][0]["callsign"].upcase + "]"
39
39
  end
40
40
  else
41
- puts id.to_s + " is not a valid NXDN ID."
41
+ client.puts id.to_s + " is not a valid NXDN ID."
42
42
  end
43
43
  end
44
44
  end
@@ -0,0 +1,77 @@
1
+ require 'socket'
2
+
3
+ class Callsigns::TCP
4
+
5
+ def self.greet(client)
6
+ client.puts "\n\nWelcome to [Callsigns by AL0Y]"
7
+ client.puts "This is an interactive server to search information of ham radio operators"
8
+ client.puts "by their callsign [only USA-based], DMR ID or NXDN ID"
9
+ help(client)
10
+ end
11
+
12
+
13
+ def self.help(client)
14
+ client.puts "\n\nAvilable commands:\n"
15
+ client.puts " Lookup [callsign] - Gives information about the given callsign"
16
+ client.puts " As of now, the callsign must be USA-Based."
17
+ client.puts " DMR [number] - Gives information about a DMR ID\n "
18
+ client.puts " NXDN [number] - Gives information about a NXDN ID"
19
+ client.puts " HELP or ? - Shows this command list"
20
+ client.puts " Version - Shows the current version for this server"
21
+ client.puts " Bye - Disconnect from the Callsigns server and"
22
+ client.puts " return to node."
23
+
24
+ end
25
+
26
+ def self.goodbye(client)
27
+ client.puts "Thanks for using Callsigns by AL0Y. 73 de AL0Y\n\n"
28
+ end
29
+
30
+ def self.menu(client)
31
+ input = nil
32
+ while input != "bye"
33
+ client.puts "\nPlease enter a command, or type ? for a list of commands>"
34
+ input = client.gets.chomp.downcase
35
+
36
+ if input == "bye"
37
+ goodbye(client)
38
+
39
+ elsif input == "version"
40
+ client.puts "Callsigns by AL0Y - Version:" + Callsigns::VERSION.to_s
41
+
42
+ elsif input == "?" || input == "help"
43
+ help
44
+
45
+ elsif input.split(" ").count == 2 && input.split(" ")[0] == "lookup"
46
+ lookup_callsign = input.split(" ")[1]
47
+ client.puts "Getting information for " + lookup_callsign.to_s + "\n..."
48
+ Callsigns::Callook.lookup(lookup_callsign, client)
49
+ elsif input.split(" ").count == 2 && input.split(" ")[0] == "dmr"
50
+ dmr_id = input.split(" ")[1]
51
+ client.puts "Getting information for " + dmr_id.to_s
52
+ Callsigns::RadioID.dmr(dmr_id, client)
53
+
54
+ elsif input.split(" ").count == 2 && input.split(" ")[0] == "nxdn"
55
+ nxdn_id = input.split(" ")[1]
56
+ client.puts "Getting information for " + nxdn_id.to_s
57
+ Callsigns::RadioID.nxdn(nxdn_id, client)
58
+
59
+ else
60
+ client.puts "Unknown command!"
61
+ end
62
+
63
+ end
64
+ end
65
+
66
+ def self.main(port)
67
+ server = TCPServer.new port.to_i
68
+ loop do
69
+ Thread.start(server.accept) do |client|
70
+ greet(client)
71
+ menu(client)
72
+ client.close
73
+ end
74
+ end
75
+ end
76
+
77
+ end
@@ -1,3 +1,3 @@
1
1
  module Callsigns
2
- VERSION = "1.1.5"
2
+ VERSION = "1.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: callsigns
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aly Badawy
@@ -93,15 +93,15 @@ dependencies:
93
93
  description: A CLI to search hams by callsigns
94
94
  email: aly@al0y.com
95
95
  executables:
96
- - callsigns_cli
96
+ - callsigns_tcp
97
97
  extensions: []
98
98
  extra_rdoc_files: []
99
99
  files:
100
- - bin/callsigns_cli
100
+ - bin/callsigns_tcp
101
101
  - lib/callsigns.rb
102
102
  - lib/callsigns/callook.rb
103
- - lib/callsigns/cli.rb
104
103
  - lib/callsigns/radioid.rb
104
+ - lib/callsigns/tcp.rb
105
105
  - lib/callsigns/version.rb
106
106
  homepage: https://rubygems.org/gems/callsigns
107
107
  licenses:
@@ -1,70 +0,0 @@
1
- class Callsigns::CLI
2
-
3
- def self.greet
4
- puts "\n\nWelcome to [Callsigns by AL0Y]"
5
- puts "This is an interactive server to search information of ham radio operators"
6
- puts "by their callsign [only USA-based], DMR ID or NXDN ID"
7
- help
8
- end
9
-
10
-
11
- def self.help
12
- puts "\n\nAvilable commands:\n"
13
- puts " Lookup [callsign] - Gives information about the given callsign"
14
- puts " As of now, the callsign must be USA-Based."
15
- puts " DMR [number] - Gives information about a DMR ID\n "
16
- puts " NXDN [number] - Gives information about a NXDN ID"
17
- puts " HELP or ? - Shows this command list"
18
- puts " Version - Shows the current version for this server"
19
- puts " Bye - Disconnect from the Callsigns server and"
20
- puts " return to node."
21
-
22
- end
23
-
24
- def self.goodbye
25
- puts "Thanks for using Callsigns by AL0Y. 73 de AL0Y\n\n"
26
- end
27
-
28
- def self.menu
29
- input = nil
30
- while input != "bye"
31
- puts "\nPlease enter a command, or type ? for a list of commands>"
32
- input = STDIN.gets.chomp.downcase
33
-
34
- if input == "bye"
35
- goodbye
36
-
37
- elsif input == "version"
38
- puts "Callsigns by AL0Y - Version:" + Callsigns::VERSION.to_s
39
-
40
- elsif input == "?" || input == "help"
41
- help
42
-
43
- elsif input.split(" ").count == 2 && input.split(" ")[0] == "lookup"
44
- lookup_callsign = input.split(" ")[1]
45
- puts "Getting information for " + lookup_callsign.to_s + "\n..."
46
- Callsigns::Callook.lookup(lookup_callsign)
47
- elsif input.split(" ").count == 2 && input.split(" ")[0] == "dmr"
48
- dmr_id = input.split(" ")[1]
49
- puts "Getting information for " + dmr_id.to_s
50
- Callsigns::RadioID.dmr(dmr_id)
51
-
52
- elsif input.split(" ").count == 2 && input.split(" ")[0] == "nxdn"
53
- nxdn_id = input.split(" ")[1]
54
- puts "Getting information for " + nxdn_id.to_s
55
- Callsigns::RadioID.nxdn(nxdn_id)
56
-
57
- else
58
- puts "Unknown command!"
59
- end
60
-
61
- end
62
- end
63
-
64
- def self.main(args)
65
- current_user = args
66
- greet
67
- menu
68
- end
69
-
70
- end