jake-scripts 1.8.1 → 1.8.2

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
  SHA1:
3
- metadata.gz: a34cbe9ea9e4d0c3cbf59685f02af4c2ba6b14dd
4
- data.tar.gz: 306ef359ea24a32a13be29da2048020a60511a71
3
+ metadata.gz: 358c4f16383475ec478e659cb29b759c181c85bb
4
+ data.tar.gz: ead93a472d3b01d9524e7d2e9c429cbfd1cc5246
5
5
  SHA512:
6
- metadata.gz: 33e086690d360bff5046d2c684f0194fa3e9c4047156f830c3e9d99ae27a043115adde8ad5c2dada212b974c098e74cc010ed8cadcbe0c2df035fdb6fb6fa8a8
7
- data.tar.gz: fa1274919729323079da81ec5a327727ee3f03bd57c217ac0428b53e6439ae4ca3d99ea59c2cc77393f8f935390c7e570bf277c09b8993869c4966ebea7d8fba
6
+ metadata.gz: 7f50328b784ca2f94df658d6ce80d4b637fe04ca28922d450c590076d58759e9a30d462f764327c62f4c03d2f48ab9da1defc582815ff986cc07d1e551c0ccbd
7
+ data.tar.gz: 96ae76198ae46d488bdac364cba158e1095da64fcf6838f2e4f5cc4570ce7588a0e52423ef0666996ddbd1f1e1d6a355bd5e969dd8af036baa9af4990f213914
data/exe/ip_geo CHANGED
@@ -3,53 +3,90 @@
3
3
 
4
4
  require 'rest-client'
5
5
  require 'json'
6
+ require 'optparse'
6
7
 
7
- def ip_location
8
+
9
+ options = {}
10
+ OptionParser.new do |opts|
11
+ opts.banner = "Usage: example.rb [options]"
12
+
13
+ opts.on("-m", "--machine VARIABLE", "Machine Readable") do |v|
14
+ options[:var] = v
15
+ end
16
+ end.parse!
17
+
18
+ # Ex. ip
19
+ opt = options[:var]
20
+
21
+ # Ex. 8.8.8.8
22
+ *arg = ARGV
23
+
24
+ if opt == nil && arg == nil
8
25
  puts
9
26
  print 'IP => '
10
27
  ip = gets.chomp
11
28
 
12
- if ip == 'quit' || ip == 'exit'
13
- puts
14
- exit(1)
29
+ url = "http://ip-api.com/json/#{ip}"
30
+ response = RestClient.get(url)
31
+ info = JSON.parse(response)
32
+
33
+ if info['status'] == 'fail'
34
+ puts 'No IP found'
15
35
  else
36
+ puts
37
+ puts '============================='
38
+ puts "| IP: #{info['query']}"
39
+ puts "| City: #{info['city']}"
40
+ puts "| Region: #{info['region']}"
41
+ puts "| Country: #{info['country']}"
42
+ puts "| ZIP: #{info['zip']}"
43
+ puts "| ISP: #{info['isp']}"
44
+ puts '============================='
45
+ puts
46
+ end
47
+ elsif opt == nil && arg != nil
48
+ url = "http://ip-api.com/json/#{arg.join}"
49
+ response = RestClient.get(url)
50
+ info = JSON.parse(response)
16
51
 
17
- begin
18
- url = "http://ip-api.com/json/#{ip}"
19
- response = RestClient.get(url)
20
- info = JSON.parse(response)
21
- rescue
22
- puts
23
- puts 'IP not found.'
24
- puts
25
- exit(1)
26
- end
52
+ if info['status'] == 'fail'
53
+ puts 'No IP found'
54
+ else
55
+ puts
56
+ puts '============================='
57
+ puts "| IP: #{info['query']}"
58
+ puts "| City: #{info['city']}"
59
+ puts "| Region: #{info['region']}"
60
+ puts "| Country: #{info['country']}"
61
+ puts "| ZIP: #{info['zip']}"
62
+ puts "| ISP: #{info['isp']}"
63
+ puts '============================='
64
+ puts
65
+ end
66
+ elsif opt != nil && arg != nil
67
+ url = "http://ip-api.com/json/#{arg.join}"
68
+ response = RestClient.get(url)
69
+ info = JSON.parse(response)
27
70
 
28
- ip = info['query']
29
- city = info['city']
30
- region = info['region']
31
- country = info['country']
32
- isp = info['isp']
33
- zip = info['zip']
34
-
35
- if city.nil?
36
- puts
37
- puts 'IP not found.'
38
- puts
39
- exit(1)
71
+ if info['status'] == 'fail'
72
+ puts 'No IP info'
73
+ else
74
+ if opt == 'ip'
75
+ puts info['query']
76
+ elsif opt == 'city'
77
+ puts info['city']
78
+ elsif opt == 'region'
79
+ puts info['region']
80
+ elsif opt == 'country'
81
+ puts info['country']
82
+ elsif opt == 'zip'
83
+ puts info['zip']
84
+ elsif opt == 'isp'
85
+ puts info['isp']
40
86
  else
41
- puts
42
- puts '============================='
43
- puts "| IP: #{ip}"
44
- puts "| City: #{city}"
45
- puts "| Region: #{region}"
46
- puts "| Country: #{country}"
47
- puts "| ZIP: #{zip}"
48
- puts "| ISP: #{isp}"
49
- puts '============================='
50
- puts
87
+ puts 'Bad input'
51
88
  end
52
89
  end
90
+ else
91
+ puts 'Bad input'
53
92
  end
54
-
55
- ip_location
@@ -1,5 +1,5 @@
1
1
  module Jake
2
2
  module Scripts
3
- VERSION = "1.8.1"
3
+ VERSION = "1.8.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jake-scripts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Meyer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-23 00:00:00.000000000 Z
11
+ date: 2017-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler