mtgsy 0.2.2 → 0.3.0
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 +4 -4
- data/CHANGELOG.rdoc +7 -0
- data/bin/mtgsyCommand.rb +112 -0
- data/lib/mtgsy/api_client.rb +6 -14
- data/lib/mtgsy/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8de684ba598b5206bc2766c30b62cb6609bdc76
|
4
|
+
data.tar.gz: 6e9bb17d708a1d88f894b07f1dde106a2cfa0c29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a77fc5398d06bf09d7d3222c9aaac3df01efc3bd9c75a48a46e2b1aef4bc5d668c8a18c7ee2cac3b0a62ddbe8743f0693890c1687399f774333c2e06c83d9a4
|
7
|
+
data.tar.gz: 439c005fe1896d5d46cc7858531bad6fdf107c6f5779ffb1242ea29e7d237146efb93a0cf60eda0a2fee50f022d1638fb80265c93eb16cc454e7646ff3f808c2
|
data/CHANGELOG.rdoc
CHANGED
data/bin/mtgsyCommand.rb
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
require 'mtgsy'
|
4
|
+
begin
|
5
|
+
require 'io/console'
|
6
|
+
rescue LoadError
|
7
|
+
end
|
8
|
+
|
9
|
+
more_than_one_command_flag=false
|
10
|
+
options = {}
|
11
|
+
optparse = OptionParser.new do |opts|
|
12
|
+
opts.banner = "Usage: #{File.basename($0)} [options]"
|
13
|
+
|
14
|
+
opts.on("-u", "--username USERNAME",
|
15
|
+
"Username to authenticate to mtgsy.net"
|
16
|
+
) { |value| options[:username] = value }
|
17
|
+
|
18
|
+
opts.on("-p", "--password PASSWORD",
|
19
|
+
"Password to authenticate to mtgsy.net"
|
20
|
+
) { |value| options[:password] = value }
|
21
|
+
|
22
|
+
opts.on("--add",
|
23
|
+
"Use this opt to add the record."
|
24
|
+
) { |value| more_than_one_command_flag=true if options[:command]; options[:command] = "add" }
|
25
|
+
|
26
|
+
opts.on("--delete",
|
27
|
+
"Use this opt to delete the record."
|
28
|
+
) { |value| more_than_one_command_flag=true if options[:command]; options[:command] = "delete" }
|
29
|
+
|
30
|
+
opts.on("--update",
|
31
|
+
"Use this opt to udate the record."
|
32
|
+
) { |value| more_than_one_command_flag=true if options[:command]; options[:command] = "update" }
|
33
|
+
|
34
|
+
opts.on("--domain DOMAINNAME",
|
35
|
+
"Domain name / Zone to interact with"
|
36
|
+
) { |value| options[:domainname] = value }
|
37
|
+
|
38
|
+
opts.on("--name NAME",
|
39
|
+
"Record name, e.g. www, *.cust, random.thing, etc..."
|
40
|
+
) { |value| options[:name] = value }
|
41
|
+
|
42
|
+
opts.on("--type TYPE",
|
43
|
+
"Record type, e.g. A, CNAME, TXT, etc..."
|
44
|
+
) { |value| options[:type] = value }
|
45
|
+
|
46
|
+
opts.on("--data DATA",
|
47
|
+
"Record data, e.g. 56.56.23.233, my.ssl.zendesk.com., etc..."
|
48
|
+
) { |value| options[:data] = value }
|
49
|
+
|
50
|
+
opts.on("--aux AUX",
|
51
|
+
"Record aux, info: http://www.mtgsy.net/dns/record_aux.htm"
|
52
|
+
) { |value| options[:aux] = value }
|
53
|
+
|
54
|
+
opts.on("--ttl TTL",
|
55
|
+
"Record TTL, e.g. 300, 900, 1800, 3600, etc..."
|
56
|
+
) { |value| options[:ttl] = value }
|
57
|
+
|
58
|
+
opts.on("-x", "--debug",
|
59
|
+
"Enables some helpful debugging output."
|
60
|
+
) { |value| options[:debug] = true }
|
61
|
+
|
62
|
+
opts.on("-h", "--help", "Display this help message.") do
|
63
|
+
puts opts
|
64
|
+
exit
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
begin
|
69
|
+
optparse.parse!
|
70
|
+
rescue OptionParser::MissingArgument
|
71
|
+
puts "You're missing an argument...\n\n"
|
72
|
+
puts optparse
|
73
|
+
exit 1
|
74
|
+
end
|
75
|
+
|
76
|
+
if more_than_one_command_flag
|
77
|
+
$stderr.puts "You must only specify ONE command: --add, --update or --delete"
|
78
|
+
puts optparse
|
79
|
+
exit 1
|
80
|
+
end
|
81
|
+
|
82
|
+
p options if options[:debug]
|
83
|
+
p ARGV if options[:debug]
|
84
|
+
|
85
|
+
|
86
|
+
#######
|
87
|
+
## MAIN
|
88
|
+
#######
|
89
|
+
|
90
|
+
|
91
|
+
client = Mtgsy::ApiClient.new
|
92
|
+
|
93
|
+
client.username = options[:username] if options[:username]
|
94
|
+
client.domainname = options[:domainname] if options[:domainname]
|
95
|
+
|
96
|
+
if options[:password]
|
97
|
+
client.password = options[:password]
|
98
|
+
else
|
99
|
+
print "Please enter your password: "
|
100
|
+
client.password = STDIN.noecho(&:gets).chomp
|
101
|
+
puts
|
102
|
+
end
|
103
|
+
|
104
|
+
name = options[:name] ? options[:name].to_s : nil
|
105
|
+
type = options[:type] ? options[:type].to_s : nil
|
106
|
+
data = options[:data] ? options[:data].to_s : nil
|
107
|
+
aux = options[:aux ] ? options[:aux].to_s : nil
|
108
|
+
ttl = options[:ttl ] ? options[:ttl].to_s : nil
|
109
|
+
|
110
|
+
client.add(name: name, type: type, data: data, aux: aux, ttl: ttl) if options[:command] == "add"
|
111
|
+
client.delete(name: name, type: type, data: data, aux: aux, ttl: ttl) if options[:command] == "delete"
|
112
|
+
client.update(name: name, type: type, data: data, aux: aux, ttl: ttl) if options[:command] == "update"
|
data/lib/mtgsy/api_client.rb
CHANGED
@@ -110,21 +110,13 @@ module Mtgsy
|
|
110
110
|
|
111
111
|
search_data = [ name, type, data, aux, ttl ]
|
112
112
|
|
113
|
-
num_of_search_elements = 0
|
114
|
-
0.upto(4) do |x|
|
115
|
-
unless search_data[x] == nil
|
116
|
-
num_of_search_elements += 1
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
113
|
results = @records_ALL.select do |x|
|
121
|
-
|
122
|
-
(
|
123
|
-
(
|
124
|
-
(
|
125
|
-
(
|
126
|
-
|
127
|
-
true if matched == num_of_search_elements
|
114
|
+
( return false unless x[Mtgsy::RECORD_NAME] == search_data[Mtgsy::RECORD_NAME] ) if search_data[Mtgsy::RECORD_NAME]
|
115
|
+
( return false unless x[Mtgsy::RECORD_TYPE] == search_data[Mtgsy::RECORD_TYPE] ) if search_data[Mtgsy::RECORD_TYPE]
|
116
|
+
( return false unless x[Mtgsy::RECORD_DATA] == search_data[Mtgsy::RECORD_DATA] ) if search_data[Mtgsy::RECORD_DATA]
|
117
|
+
( return false unless x[Mtgsy::RECORD_AUX] == search_data[Mtgsy::RECORD_AUX] ) if search_data[Mtgsy::RECORD_AUX]
|
118
|
+
( return false unless x[Mtgsy::RECORD_TTL] == search_data[Mtgsy::RECORD_TTL] ) if search_data[Mtgsy::RECORD_TTL]
|
119
|
+
true
|
128
120
|
end
|
129
121
|
|
130
122
|
results
|
data/lib/mtgsy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mtgsy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Barnett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|
@@ -55,7 +55,8 @@ dependencies:
|
|
55
55
|
description: This is a ruby library for interacting with mtgsy (CloudFloor DNS).
|
56
56
|
email:
|
57
57
|
- jason.w.barnett@gmail.com
|
58
|
-
executables:
|
58
|
+
executables:
|
59
|
+
- mtgsyCommand.rb
|
59
60
|
extensions: []
|
60
61
|
extra_rdoc_files: []
|
61
62
|
files:
|
@@ -65,6 +66,7 @@ files:
|
|
65
66
|
- LICENSE.txt
|
66
67
|
- README.md
|
67
68
|
- Rakefile
|
69
|
+
- bin/mtgsyCommand.rb
|
68
70
|
- lib/mtgsy.rb
|
69
71
|
- lib/mtgsy/api_client.rb
|
70
72
|
- lib/mtgsy/version.rb
|