mtgsy 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
  SHA1:
3
- metadata.gz: 5eb81b3ca3aa7b5260a4ac6ffdaa495443a50c07
4
- data.tar.gz: 3c3bc8c0a0606530490ba26b4957f685d3edf2d6
3
+ metadata.gz: bc6b8e0b7879d36ff3ab5654de17ba77eb69d8c4
4
+ data.tar.gz: ce784a9ed3e24a25a7f78376c61e4148ad9c101b
5
5
  SHA512:
6
- metadata.gz: ceec4d977f42565e3623d94045ee0414ea21240d15fbde873aadd9fd673785af1cb817436d8526f9ddf6e1243a9083bec77fcf2292309e131611a00048141381
7
- data.tar.gz: 592b20fd9d189d2356419eb84b467154d691c2aacf9e9c5c8198a59043a24b02c99a3ec34916f70b0924e6b55b4b41d6a55544db8392e637826e1027c507bc87
6
+ metadata.gz: e09afa49dbad2e5ad2be48a5eddd42cf7db900e02595997e38b03785d82b88f432a8b68b184bb3dcd7a3be7e8806af66f1d1fd65ee4a7400e1af8af6637b8d59
7
+ data.tar.gz: 0d91bb1e5c49c9413660afd95b35247937fdbde74a7667b3611e5ee081bcf4f1b7954dcfc0c10adeb842cd73658fce98010de4444458aa0787eb7c72d2e38f28
data/README.md CHANGED
@@ -18,8 +18,31 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
+ ## Start things off...
22
+ require 'mtgsy'
21
23
  client = Mtgsy::ApiClient.new(username: "my_username", password: "my_password", domainname: "mydomain.com")
22
- client.add_record(name: "www", type: "A", data: "127.0.0.1", aux: "0", ttl: "3600")
24
+
25
+ ## Add records
26
+ client.add_record(name: "www1", type: "A", data: "127.0.0.1")
27
+ client.add_record(name: "www2", type: "A", data: "127.0.0.2", ttl: "3600")
28
+ client.add_record(name: "www3", type: "A", data: "127.0.0.3", ttl: "3600", aux: "5")
29
+
30
+ ## Update records
31
+ client.update_record(name: "www1", type: "A", data: "127.0.0.11")
32
+
33
+ ## Delete records:
34
+ client.delete_record(name: "www1")
35
+ client.delete_record(name: "www2")
36
+ client.delete_record(name: "www3")
37
+
38
+ ## List all records in a zone:
39
+ client.records("ALL") # Returns an array of _all_ records in the zone
40
+ client.records("A") # Returns an array of all A records in the zone
41
+ client.records("CNAME") # Returns an array of all CNAME records in the zone
42
+ client.records("AAAA") # Returns an array of all AAAA records in the zone
43
+
44
+ ## List all possible records types:
45
+ client.record_types?
23
46
 
24
47
  ## Contributing
25
48
 
@@ -8,13 +8,14 @@ module Mtgsy
8
8
  @api_endpoint = "https://www.mtgsy.net/dns/api.php"
9
9
  @record_types = [ 'A', 'AAAA', 'CNAME', 'HINFO', 'MX', 'NS', 'PTR', 'RP', 'SRV', 'TXT' ]
10
10
 
11
- @debug = options[:debug] ? options[:debug] : false
11
+ @debug = options[:debug] ? options[:debug] : false
12
12
 
13
+ ## these are for setting up global defaults. they can be overridden though
13
14
  # attr_accessor
14
- @domainname = options[:domainname] ? options[:domainname] : nil
15
- @username = options[:username] ? options[:username] : nil
16
- @ttl = options[:ttl] ? options[:ttl] : 900
17
- @aux = 0
15
+ @domainname = options[:domainname] ? options[:domainname] : nil
16
+ @username = options[:username] ? options[:username] : nil
17
+ @aux = options[:aux] ? options[:aux] : 0
18
+ @ttl = options[:ttl] ? options[:ttl] : 900
18
19
 
19
20
  # attr_writer
20
21
  @password = options[:password] ? options[:password] : nil
@@ -62,6 +63,10 @@ module Mtgsy
62
63
  what_happened?(@agent, command)
63
64
  end
64
65
 
66
+ alias :add :add_record
67
+ alias :delete :delete_record
68
+ alias :update :update_record
69
+
65
70
  def refresh!
66
71
  command = "listrecords"
67
72
  post_to_mtgsy([ command ])
@@ -78,9 +83,12 @@ module Mtgsy
78
83
  end
79
84
  instance_variable_set("@records_#{x}", tmp_placeholder)
80
85
  end
86
+
87
+ nil
81
88
  end
82
89
 
83
90
  def records(type="ALL")
91
+ type.upcase!
84
92
  self.refresh! unless @records_ALL
85
93
 
86
94
  eval("@records_#{type}")
@@ -115,6 +123,7 @@ module Mtgsy
115
123
  @agent.post(@api_endpoint, post_data)
116
124
  end
117
125
 
126
+ ## I included `command` just in case one day the responses are different depending on the command used
118
127
  def what_happened?(mechanize_instance, command)
119
128
  mtgsy_return_code = mechanize_instance.page.body.match(/[0-9]+/)[0].to_i
120
129
 
data/lib/mtgsy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mtgsy
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.1.0
4
+ version: 0.1.1
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-09-17 00:00:00.000000000 Z
11
+ date: 2013-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize