nifcloud-dns 0.2.1 → 0.2.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
  SHA256:
3
- metadata.gz: 8f3a3fc1d9128642de5a40c8e99b1853d440e6b53aca8cba454771a5db457f91
4
- data.tar.gz: 2c5e012db052685da59979ebbb470ef495fb781f7f8a6b71174bfc59ebc85425
3
+ metadata.gz: b585f8f84dca52fd6151e932116c7cc034df0b647ca5b0aefd0aeea719519ce9
4
+ data.tar.gz: f951f42ff6fdb35bcc608fd0347c30ff23b0c31f8c3c3a3ffcab16bd2045ea21
5
5
  SHA512:
6
- metadata.gz: '0874009fae77041884a4e6b1ada7cd5325be937e7d7f12a354084439ea388ad2ecca47775efba03e5f5cf7df94f9bc58db39e1caa0ae1d38a42bb67129650738'
7
- data.tar.gz: 3f2de2d2b72d1750a9bbd84e52ed25aee8516f7f330f359d8199a2e866feb71c91a3cecdc5be308de1f1629a9f6db77a9cb3b59ace15ce94681bc5517d7c255f
6
+ metadata.gz: 5bb32d868c2c843f1d118dd4b329d2ec98899ea55cbdb7fee6b94d1dfc66c3a314e55f919f2b619103adb240d55f89e3a9f5b8c20582c59cc9ec4cda2d6cfad1
7
+ data.tar.gz: ca638cc1312634747691d6d4eee9b10fa5f404096ad24c779268185f0157053d3704229d3bd119bd59dcddf42d2bf53f2f99189c59ad8093a52816d81acf9b62
data/.rubocop.yml ADDED
@@ -0,0 +1,3 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.2
3
+ NewCops: enable
data/.solargraph.yml ADDED
@@ -0,0 +1,21 @@
1
+ ---
2
+ include:
3
+ - "**/*.rb"
4
+ exclude:
5
+ - spec/**/*
6
+ - test/**/*
7
+ - vendor/**/*
8
+ - ".bundle/**/*"
9
+ require: []
10
+ domains: []
11
+ reporters:
12
+ - rubocop
13
+ formatter:
14
+ rubocop:
15
+ cops: safe
16
+ except: []
17
+ only: []
18
+ extra_args: []
19
+ require_paths: []
20
+ plugins: []
21
+ max_files: 5000
data/Gemfile CHANGED
@@ -1,6 +1,12 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ gem 'pry'
8
+ gem 'pry-doc'
9
+ gem 'solargraph'
4
10
 
5
11
  # Specify your gem's dependencies in nifcloud-dns.gemspec
6
12
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nifcloud-dns (0.2.1)
4
+ nifcloud-dns (0.2.2)
5
5
  ruby-hmac
6
6
  xml-simple
7
7
 
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,9 @@
1
- #!/usr/bin/env ruby
1
+ # frozen_string_literal: true
2
2
 
3
- require "bundler/setup"
4
- require "nifcloud/dns"
3
+ # !/usr/bin/env ruby
4
+
5
+ require 'bundler/setup'
6
+ require 'nifcloud/dns'
5
7
 
6
8
  # You can add fixtures and/or initialization code here to make experimenting
7
9
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +12,5 @@ require "nifcloud/dns"
10
12
  # require "pry"
11
13
  # Pry.start
12
14
 
13
- require "irb"
15
+ require 'irb'
14
16
  IRB.start(__FILE__)
data/lib/nifcloud/auth.rb CHANGED
@@ -1,20 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'hmac-sha1'
2
4
  require 'base64'
3
5
  require 'time'
4
6
 
5
7
  module Nifcloud
8
+ # Authentication for nifcloud api v3
6
9
  class Auth
7
10
  ALGORITHM = 'HmacSHA1'
8
11
 
9
12
  def initialize(access_key, secret_key)
10
- @access_key = access_key || ENV['ACCESS_KEY']
11
- @secret_key = secret_key || ENV['SECRET_KEY']
13
+ @access_key = access_key || ENV.fetch('ACCESS_KEY', nil)
14
+ @secret_key = secret_key || ENV.fetch('SECRET_KEY', nil)
12
15
  end
13
16
 
14
17
  def signature_header
15
18
  @time = Time.now.httpdate
16
19
  hmac = HMAC::SHA1.new(@secret_key).update(@time)
17
- signature = Base64.encode64("#{hmac.digest}")
20
+ signature = Base64.encode64(hmac.digest.to_s)
18
21
  "NIFTY3-HTTPS NiftyAccessKeyId=#{@access_key},Algorithm=#{ALGORITHM},Signature=#{signature.chomp}"
19
22
  end
20
23
 
@@ -1,8 +1,11 @@
1
- require "nifcloud/auth"
2
- require "nifcloud/dns/response"
1
+ # frozen_string_literal: true
2
+
3
+ require 'nifcloud/auth'
4
+ require 'nifcloud/dns/response'
3
5
  require 'net/https'
4
6
 
5
7
  module Nifcloud
8
+ # Client for nifcloud dns
6
9
  class Client < Auth
7
10
  ENDPOINT = 'https://dns.api.nifcloud.com/'
8
11
  VERSION = '2012-12-12N2013-12-16'
@@ -15,7 +18,7 @@ module Nifcloud
15
18
  @http, @req, @uri = nil
16
19
  end
17
20
 
18
- def get path
21
+ def get(path)
19
22
  init path
20
23
  @req = Net::HTTP::Get.new @uri.request_uri
21
24
  init_header
@@ -33,7 +36,7 @@ module Nifcloud
33
36
  Nifcloud::DNS::Response.new(XmlSimple.xml_in(res.body), res.code, res.body)
34
37
  end
35
38
 
36
- def delete path
39
+ def delete(path)
37
40
  init path
38
41
  @req = Net::HTTP::Delete.new @uri.request_uri
39
42
  init_header
@@ -43,7 +46,7 @@ module Nifcloud
43
46
 
44
47
  private
45
48
 
46
- def init path
49
+ def init(path)
47
50
  @uri = URI.parse("#{ENDPOINT}#{VERSION}/#{path}")
48
51
  @http = Net::HTTP.new(@uri.host, @uri.port)
49
52
  @http.use_ssl = true
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'nifcloud/client'
2
4
  require 'xmlsimple'
3
5
  require 'cgi'
4
6
 
5
7
  module Nifcloud
6
8
  module DNS
9
+ # Class that manages DNS record information
7
10
  class Record < Client
8
11
  RECORD_SET_WITH_ID = 'hostedzone/%s/rrset'
9
12
  RECORD_SET_WITH_PARAMS = 'hostedzone/%s/rrset?%s'
@@ -17,33 +20,37 @@ module Nifcloud
17
20
  if options.nil? || !options.instance_of?(Hash)
18
21
  get(RECORD_SET_WITH_ID % @zone_id)
19
22
  else
20
- get(RECORD_SET_WITH_PARAMS % [@zone_id, options.collect { |k, v| "#{k}=#{CGI::escape(v.to_s)}" }.join('&')])
23
+ list_path = format(RECORD_SET_WITH_PARAMS,
24
+ @zone_id,
25
+ options.collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&'))
26
+ get(list_path)
21
27
  end
22
28
  end
23
29
 
24
- def add(name, type, value, ttl: 86400, comment: '')
30
+ def add(name, type, value, ttl: 86_400, comment: '')
25
31
  post(RECORD_SET_WITH_ID % @zone_id, xml('CREATE', name, type, value, ttl, comment))
26
32
  end
27
33
 
28
- def del(name, type, value, ttl: 86400, comment: '')
34
+ def del(name, type, value, ttl: 86_400, comment: '')
29
35
  post(RECORD_SET_WITH_ID % @zone_id, xml('DELETE', name, type, value, ttl, comment))
30
36
  end
31
37
 
32
38
  private
33
39
 
34
- def xml(action, name, type, value, ttl, comment)
35
- body = { '@xmlns' => Nifcloud::Client::NAMESPACE,
36
- 'ChangeBatch' => {
37
- 'Comment' => ['content' => comment],
38
- 'Changes' => [
39
- 'Change' => {
40
- 'Action' => ['content' => action],
41
- 'ResourceRecordSet' => {
42
- 'Name' => ['content' => name],
43
- 'Type' => ['content' => type],
44
- 'TTL' => ['content' => ttl],
45
- 'ResourceRecords' => {
46
- 'Value' => ['content' => value]
40
+ def xml(action, name, type, value, ttl, comment) # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
41
+ body = {
42
+ '@xmlns': Nifcloud::Client::NAMESPACE,
43
+ ChangeBatch: {
44
+ Comment: ['content' => comment],
45
+ Changes: [
46
+ Change: {
47
+ Action: [content: action],
48
+ ResourceRecordSet: {
49
+ Name: [content: name],
50
+ Type: [content: type],
51
+ TTL: [content: ttl],
52
+ ResourceRecords: {
53
+ Value: [content: value]
47
54
  }
48
55
  }
49
56
  }
@@ -51,9 +58,9 @@ module Nifcloud
51
58
  }
52
59
  }
53
60
  options = {
54
- 'AttrPrefix' => true,
55
- 'RootName' => 'ChangeResourceRecordSetsRequest',
56
- 'ContentKey' => 'content'
61
+ AttrPrefix: true,
62
+ RootName: 'ChangeResourceRecordSetsRequest',
63
+ ContentKey: 'content'
57
64
  }
58
65
  XmlSimple.xml_out(body, options)
59
66
  end
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Nifcloud
2
4
  module DNS
5
+ # Class that manages api response information
3
6
  class Response
4
7
  def initialize(body, code, raw)
5
8
  @body = body
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Nifcloud
2
4
  module DNS
3
- VERSION = "0.2.1"
5
+ VERSION = '0.2.2'
4
6
  end
5
7
  end
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'nifcloud/client'
2
4
  require 'xmlsimple'
3
5
 
4
6
  module Nifcloud
5
7
  module DNS
8
+ # Class that manages DNS zone information
6
9
  class Zone < Client
7
10
  HOSTED_ZONE = 'hostedzone'
8
11
  HOSTED_ZONE_WITH_ID = 'hostedzone/%s'
@@ -15,26 +18,27 @@ module Nifcloud
15
18
  get HOSTED_ZONE
16
19
  end
17
20
 
18
- def show zone_id
21
+ def show(zone_id)
19
22
  get(HOSTED_ZONE_WITH_ID % zone_id)
20
23
  end
21
24
 
22
- def add(zone, comment: '')
23
- body = { '@xmlns' => Nifcloud::Client::NAMESPACE,
24
- 'Name' => ['content' => zone],
25
- 'CallerReference' => ['content' => ''],
26
- 'HostedZoneConfig' => ['content' => ''],
27
- 'Comment' => ['content' => comment]
25
+ def add(zone, comment: '') # rubocop:disable Metrics/MethodLength
26
+ body = {
27
+ '@xmlns': Nifcloud::Client::NAMESPACE,
28
+ Name: [content => zone],
29
+ CallerReference: [content => ''],
30
+ HostedZoneConfig: [content => ''],
31
+ Comment: [content => comment]
28
32
  }
29
33
  options = {
30
- 'AttrPrefix' => true,
31
- 'RootName' => 'CreateHostedZoneRequest',
32
- 'ContentKey' => 'content'
34
+ AttrPrefix: true,
35
+ RootName: 'CreateHostedZoneRequest',
36
+ ContentKey: 'content'
33
37
  }
34
38
  post(HOSTED_ZONE, XmlSimple.xml_out(body, options))
35
39
  end
36
40
 
37
- def del zone_id
41
+ def del(zone_id)
38
42
  delete(HOSTED_ZONE_WITH_ID % zone_id)
39
43
  end
40
44
  end
data/lib/nifcloud/dns.rb CHANGED
@@ -1,8 +1,11 @@
1
- require "nifcloud/dns/version"
2
- require "nifcloud/dns/zone"
3
- require "nifcloud/dns/record"
1
+ # frozen_string_literal: true
2
+
3
+ require 'nifcloud/dns/version'
4
+ require 'nifcloud/dns/zone'
5
+ require 'nifcloud/dns/record'
4
6
 
5
7
  module Nifcloud
8
+ # A module for nifcloud dns
6
9
  module DNS
7
10
  end
8
11
  end
data/nifcloud-dns.gemspec CHANGED
@@ -1,32 +1,32 @@
1
+ # frozen_string_literal: true
1
2
 
2
- lib = File.expand_path("../lib", __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "nifcloud/dns/version"
5
+ require 'nifcloud/dns/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "nifcloud-dns"
8
+ spec.name = 'nifcloud-dns'
8
9
  spec.version = Nifcloud::DNS::VERSION
9
- spec.authors = ["kakakikikeke"]
10
- spec.email = ["cdl.yoshinaka@gmail.com"]
10
+ spec.authors = ['kakakikikeke']
11
+ spec.email = ['cdl.yoshinaka@gmail.com']
11
12
 
12
- spec.summary = %q{Ruby SDK for nifcloud DNS.}
13
- spec.description = %q{You can control nifcloud DNS with ruby.}
14
- spec.homepage = "https://github.com/kakakikikeke/nifcloud-dns"
13
+ spec.summary = 'Ruby SDK for nifcloud DNS.'
14
+ spec.description = 'You can control nifcloud DNS with ruby.'
15
+ spec.homepage = 'https://github.com/kakakikikeke/nifcloud-dns'
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
18
  f.match(%r{^(test|spec|features)/})
18
19
  end
19
- spec.bindir = "exe"
20
+ spec.bindir = 'exe'
20
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ["lib"]
22
+ spec.require_paths = ['lib']
23
+ spec.required_ruby_version = '~> 3.2'
24
+ spec.metadata['rubygems_mfa_required'] = 'true'
22
25
 
23
- spec.add_development_dependency "bundler", "~> 2.0"
24
- spec.add_development_dependency "rake", "~> 12.3.3"
25
- spec.add_development_dependency "rspec", "~> 3.0"
26
- spec.add_development_dependency "simplecov", "~> 0.21"
27
- spec.add_development_dependency "solargraph"
28
- spec.add_development_dependency "pry"
29
- spec.add_development_dependency "pry-doc"
30
- spec.add_runtime_dependency "ruby-hmac"
31
- spec.add_runtime_dependency "xml-simple"
26
+ spec.add_development_dependency 'bundler', '~> 2.0'
27
+ spec.add_development_dependency 'rake', '~> 12.3.3'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'simplecov', '~> 0.21'
30
+ spec.add_runtime_dependency 'ruby-hmac'
31
+ spec.add_runtime_dependency 'xml-simple'
32
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nifcloud-dns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kakakikikeke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-13 00:00:00.000000000 Z
11
+ date: 2023-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,48 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.21'
69
- - !ruby/object:Gem::Dependency
70
- name: solargraph
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: pry
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: pry-doc
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
69
  - !ruby/object:Gem::Dependency
112
70
  name: ruby-hmac
113
71
  requirement: !ruby/object:Gem::Requirement
@@ -145,6 +103,8 @@ extra_rdoc_files: []
145
103
  files:
146
104
  - ".gitignore"
147
105
  - ".rspec"
106
+ - ".rubocop.yml"
107
+ - ".solargraph.yml"
148
108
  - ".travis.yml"
149
109
  - Gemfile
150
110
  - Gemfile.lock
@@ -163,16 +123,17 @@ files:
163
123
  - nifcloud-dns.gemspec
164
124
  homepage: https://github.com/kakakikikeke/nifcloud-dns
165
125
  licenses: []
166
- metadata: {}
126
+ metadata:
127
+ rubygems_mfa_required: 'true'
167
128
  post_install_message:
168
129
  rdoc_options: []
169
130
  require_paths:
170
131
  - lib
171
132
  required_ruby_version: !ruby/object:Gem::Requirement
172
133
  requirements:
173
- - - ">="
134
+ - - "~>"
174
135
  - !ruby/object:Gem::Version
175
- version: '0'
136
+ version: '3.2'
176
137
  required_rubygems_version: !ruby/object:Gem::Requirement
177
138
  requirements:
178
139
  - - ">="