dslimple 1.0.1 → 1.1.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/dslimple.gemspec +1 -1
- data/lib/dslimple/applier.rb +8 -7
- data/lib/dslimple/cli.rb +8 -4
- data/lib/dslimple/domain.rb +5 -4
- data/lib/dslimple/dsl.rb +1 -1
- data/lib/dslimple/exporter.rb +4 -3
- data/lib/dslimple/query.rb +10 -10
- data/lib/dslimple/record.rb +2 -2
- data/lib/dslimple/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dce8b719b5649f05c0aeb1797495cbba95c8498c
|
4
|
+
data.tar.gz: a3109feace113af1c23069889437e116d9684832
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2507e4cf8ddba6bc18f92e4e94e189952b7841a8fc3a6a466b38326b8f70f7f407ea0985c31b2459a0c43b32f9450150317ae4dc4ca4171af5d7384d840a133
|
7
|
+
data.tar.gz: 90a69e82def3664778c36c3617d7700ff8c5dbfd590a2d01d59addbede675bba08f3ced38638c69b6a132b1bb7c55f0344ca2391f6d5ee27c5d542c8a87a3dbd
|
data/dslimple.gemspec
CHANGED
@@ -23,6 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency 'rake', '~> 10.0'
|
24
24
|
spec.add_development_dependency 'rubocop'
|
25
25
|
|
26
|
-
spec.add_dependency 'dnsimple', '~>
|
26
|
+
spec.add_dependency 'dnsimple', '~> 3.0'
|
27
27
|
spec.add_dependency 'thor', '~> 0.19'
|
28
28
|
end
|
data/lib/dslimple/applier.rb
CHANGED
@@ -6,12 +6,13 @@ class Dslimple::Applier
|
|
6
6
|
addition: :green,
|
7
7
|
modification: :yellow,
|
8
8
|
deletion: :red
|
9
|
-
}
|
9
|
+
}.freeze
|
10
10
|
|
11
|
-
attr_reader :api_client, :shell, :options
|
11
|
+
attr_reader :api_client, :account, :shell, :options
|
12
12
|
|
13
|
-
def initialize(api_client, shell, options = {})
|
13
|
+
def initialize(api_client, account, shell, options = {})
|
14
14
|
@api_client = api_client
|
15
|
+
@account = account
|
15
16
|
@shell = shell
|
16
17
|
@options = options
|
17
18
|
end
|
@@ -41,14 +42,14 @@ class Dslimple::Applier
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def fetch_domains
|
44
|
-
domains = api_client.domains.
|
45
|
+
domains = api_client.domains.all_domains(account.id).data.map { |domain| Dslimple::Domain.new(domain.name, api_client, account, id: domain.id) }
|
45
46
|
domains.each(&:fetch_records!)
|
46
47
|
domains.select! { |domain| options[:only].include?(domain.name) } if options[:only].any?
|
47
48
|
domains
|
48
49
|
end
|
49
50
|
|
50
51
|
def show_plan(queries)
|
51
|
-
shell.say(
|
52
|
+
shell.say('Changes', :bold)
|
52
53
|
queries.each do |query|
|
53
54
|
show_query(query)
|
54
55
|
end
|
@@ -58,11 +59,11 @@ class Dslimple::Applier
|
|
58
59
|
shell.say('Apply', :bold)
|
59
60
|
queries.each do |query|
|
60
61
|
show_query(query)
|
61
|
-
query.execute(api_client)
|
62
|
+
query.execute(api_client, account)
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
66
|
def show_query(query)
|
66
|
-
shell.say("#{shell.set_color(query.operation.to_s[0..2], OPERATION_COLORS[query.operation])} #{query
|
67
|
+
shell.say("#{shell.set_color(query.operation.to_s[0..2], OPERATION_COLORS[query.operation])} #{query}")
|
67
68
|
end
|
68
69
|
end
|
data/lib/dslimple/cli.rb
CHANGED
@@ -23,7 +23,7 @@ class Dslimple::CLI < Thor
|
|
23
23
|
method_option :modeline, type: :boolean, default: false, aliases: %w(-m), desc: 'Export with modeline for Vim'
|
24
24
|
method_option :soa_and_ns, type: :boolean, default: false, desc: 'Export without SOA and NS records'
|
25
25
|
def export
|
26
|
-
exporter = Dslimple::Exporter.new(api_client, options)
|
26
|
+
exporter = Dslimple::Exporter.new(api_client, account, options)
|
27
27
|
|
28
28
|
exporter.execute
|
29
29
|
rescue => e
|
@@ -39,7 +39,7 @@ class Dslimple::CLI < Thor
|
|
39
39
|
method_option :deletion, type: :boolean, default: true, desc: 'Delete unspecified records'
|
40
40
|
method_option :yes, type: :boolean, default: false, aliases: %w(-y), desc: 'Do not confirm on before apply'
|
41
41
|
def apply
|
42
|
-
applier = Dslimple::Applier.new(api_client, self, options)
|
42
|
+
applier = Dslimple::Applier.new(api_client, account, self, options)
|
43
43
|
|
44
44
|
applier.execute
|
45
45
|
rescue => e
|
@@ -50,12 +50,16 @@ class Dslimple::CLI < Thor
|
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
+
def account
|
54
|
+
@account ||= api_client.identity.whoami.data[:account]
|
55
|
+
end
|
56
|
+
|
53
57
|
def api_client
|
54
58
|
@api_client ||= Dnsimple::Client.new(
|
55
59
|
username: options[:email] || ENV['DSLIMPLE_EMAIL'],
|
56
|
-
|
60
|
+
access_token: options[:api_token] || ENV['DSLIMPLE_API_TOKEN'] || ENV['DSLIMPLE_ACCESS_TOKEN'],
|
57
61
|
domain_api_token: options[:domain_token] || ENV['DSLIMPLE_DOMAIN_TOKEN'],
|
58
|
-
|
62
|
+
base_url: options[:sandbox] ? SANDBOX_API_ENDPOINT : nil,
|
59
63
|
user_agent: USER_AGENT
|
60
64
|
)
|
61
65
|
end
|
data/lib/dslimple/domain.rb
CHANGED
@@ -2,12 +2,13 @@ require 'dslimple'
|
|
2
2
|
|
3
3
|
class Dslimple::Domain
|
4
4
|
attr_reader :name, :id
|
5
|
-
attr_accessor :api_client, :records
|
5
|
+
attr_accessor :api_client, :account, :records
|
6
6
|
|
7
|
-
def initialize(name, api_client, options = {})
|
7
|
+
def initialize(name, api_client, account, options = {})
|
8
8
|
@name = name
|
9
9
|
@id = options[:id]
|
10
10
|
@api_client = api_client
|
11
|
+
@account = account
|
11
12
|
@records = []
|
12
13
|
end
|
13
14
|
|
@@ -20,8 +21,8 @@ class Dslimple::Domain
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def fetch_records
|
23
|
-
api_client.
|
24
|
-
Dslimple::Record.new(self, record.
|
24
|
+
api_client.zones.all_records(account.id, name).data.map do |record|
|
25
|
+
Dslimple::Record.new(self, record.type, record.name, record.content, ttl: record.ttl, priority: record.priority, id: record.id)
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
data/lib/dslimple/dsl.rb
CHANGED
@@ -40,7 +40,7 @@ class Dslimple::DSL
|
|
40
40
|
|
41
41
|
def transform
|
42
42
|
@domains.map do |domain|
|
43
|
-
Dslimple::Domain.new(domain.name, nil).tap do |model|
|
43
|
+
Dslimple::Domain.new(domain.name, nil, nil).tap do |model|
|
44
44
|
model.records = domain.records.map do |record|
|
45
45
|
Dslimple::Record.new(model, record.options[:type], record.name, record.content, record.options)
|
46
46
|
end
|
data/lib/dslimple/exporter.rb
CHANGED
@@ -2,10 +2,11 @@ require 'pathname'
|
|
2
2
|
require 'dslimple'
|
3
3
|
|
4
4
|
class Dslimple::Exporter
|
5
|
-
attr_reader :api_client, :options, :domains
|
5
|
+
attr_reader :api_client, :account, :options, :domains
|
6
6
|
|
7
|
-
def initialize(api_client, options)
|
7
|
+
def initialize(api_client, account, options)
|
8
8
|
@api_client = api_client
|
9
|
+
@account = account
|
9
10
|
@options = options
|
10
11
|
@domains = []
|
11
12
|
end
|
@@ -21,7 +22,7 @@ class Dslimple::Exporter
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def fetch_domains
|
24
|
-
domains = api_client.domains.
|
25
|
+
domains = api_client.domains.all_domains(account.id).data.map { |domain| Dslimple::Domain.new(domain.name, api_client, account) }
|
25
26
|
domains.each(&:fetch_records!)
|
26
27
|
domains.select! { |domain| options[:only].include?(domain.name) } unless options[:only].empty?
|
27
28
|
domains
|
data/lib/dslimple/query.rb
CHANGED
@@ -20,7 +20,7 @@ class Dslimple::Query
|
|
20
20
|
|
21
21
|
def to_s
|
22
22
|
if target == :domain
|
23
|
-
|
23
|
+
domain.name.to_s
|
24
24
|
else
|
25
25
|
%(#{params[:record_type].to_s.rjust(5)} #{params[:name].to_s.rjust(10)}.#{domain.name} (#{record_options.join(', ')}) "#{params[:content]}")
|
26
26
|
end
|
@@ -34,27 +34,27 @@ class Dslimple::Query
|
|
34
34
|
options
|
35
35
|
end
|
36
36
|
|
37
|
-
def execute(api_client)
|
38
|
-
__send__("execute_#{target}", api_client)
|
37
|
+
def execute(api_client, account)
|
38
|
+
__send__("execute_#{target}", api_client, account)
|
39
39
|
end
|
40
40
|
|
41
|
-
def execute_domain(api_client)
|
41
|
+
def execute_domain(api_client, account)
|
42
42
|
case operation
|
43
43
|
when :addition
|
44
|
-
api_client.
|
44
|
+
api_client.registrar.register_domain(account.id, domain.name, registrant_id: account.id, auto_renew: true)
|
45
45
|
when :deletion
|
46
|
-
api_client.domains.
|
46
|
+
api_client.domains.delete_domain(account.id, domain.name)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
def execute_record(api_client)
|
50
|
+
def execute_record(api_client, account)
|
51
51
|
case operation
|
52
52
|
when :addition
|
53
|
-
api_client.
|
53
|
+
api_client.zones.create_record(account.id, domain.name, params)
|
54
54
|
when :modification
|
55
|
-
api_client.
|
55
|
+
api_client.zones.update_record(account.id, domain.name, params[:id], params)
|
56
56
|
when :deletion
|
57
|
-
api_client.
|
57
|
+
api_client.zones.delete_record(account.id, domain.name, params[:id])
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
data/lib/dslimple/record.rb
CHANGED
data/lib/dslimple/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dslimple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Kusano
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02
|
11
|
+
date: 2016-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: thor
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|