value-domain-ddns 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4efeb73b63b1124f5425f79bde38f751d334aefe
4
- data.tar.gz: 2f87111e32b4f5a9611d1dbd5af865dec9e80c7a
3
+ metadata.gz: dc88e0426489f0df3b22c1d169a3f4919c15c115
4
+ data.tar.gz: 6cc724f0354f7ec0cdaf8ed91228de0263e3c228
5
5
  SHA512:
6
- metadata.gz: 1886c08270895a5306d427ffdb5d2aad04b31ab659e82268fc87166daa6eb25309b6ef1b37c18bfc53844ee0b4dfcabe09fd5abd6af0c1903c19da2c3e511b80
7
- data.tar.gz: 1b7ec8ab013a39bdd914523b4dee53da7446fc7fb979966d09f95e0789f2a1b0f418f39ceb8582fff5a28c081f05079dab9daeb874bf7b6f917338ba0b26194b
6
+ metadata.gz: 233f1805b0f261ae45535136d851bfc1d8aec67df7c70e6dc6218d9939f9f520a46b8c615bb5f16857ab34d9d6888af50c32072627f9fd329dd0055087004e0c
7
+ data.tar.gz: 54d088030f66eaec346c9fd9b19e0501725d625fa2f8406d22a24862f6967859455ba62f99d37fb924ba6cc5f8007cb3500d8daf869e74506654bee6afc0954a
@@ -2,36 +2,7 @@
2
2
 
3
3
  $:.unshift File.expand_path("../../lib", __FILE__)
4
4
 
5
- require "value-domain-ddns"
6
-
7
5
  require 'rubygems'
8
- require 'thor'
9
-
10
- class ValueDomainDdns::Cli < Thor
11
- options :domain => :string, :password => :string,
12
- :hostname => :string, :ip => :string
13
- options :config => :string
14
- desc "sync", "update and sync ddns record"
15
- long_desc <<-EOD
16
- Update and sync ddns record.
17
- Default config file is `./config.json`.
18
- If other fields are set, it overwrites config file's value.
19
- EOD
20
- def sync
21
- config_file = options[:config] || "./config.json"
22
- config = ValueDomainDdns::Config.load(config_file)
23
- ddns = ValueDomainDdns::Core.new(config)
24
- if !ddns.validate
25
- STDERR.puts "domain, password, hostname are required."
26
- exit
27
- end
28
- config[:ip] = ddns.get_ip if !config[:ip]
29
- params = ddns.submit_params
30
- params["p"] = '******'
31
- puts "update to #{ValueDomainDdns::SUBMIT_BASE_URL} with params:"
32
- p params
33
- puts ddns.sync()
34
- end
35
- end
6
+ require "value-domain-ddns"
36
7
 
37
8
  ValueDomainDdns::Cli.start(ARGV)
@@ -2,5 +2,7 @@ module ValueDomainDdns
2
2
  require "value-domain-ddns/version"
3
3
  require "value-domain-ddns/constant"
4
4
  require 'value-domain-ddns/core'
5
+ require 'value-domain-ddns/cli'
5
6
  require 'value-domain-ddns/config'
7
+ require 'value-domain-ddns/logger'
6
8
  end
@@ -0,0 +1,29 @@
1
+ require 'thor'
2
+
3
+ class ValueDomainDdns::Cli < Thor
4
+ options :domain => :string, :password => :string,
5
+ :hostname => :string, :ip => :string
6
+ options :config => :string
7
+ options :logfile => :string
8
+ desc "sync", "update and sync ddns record"
9
+ long_desc <<-EOD
10
+ Update and sync ddns record.
11
+ Default config file is `./config.json`.
12
+ If other fields are set, it overwrites config file's value.
13
+ EOD
14
+ def sync
15
+ config_file = options[:config] || "./config.json"
16
+ config = ValueDomainDdns::Config.load(config_file)
17
+ ddns = ValueDomainDdns::Core.new(config)
18
+ log = ValueDomainDdns::Logger.new(options[:logfile] || STDOUT, Logger::INFO)
19
+ if !ddns.validate
20
+ STDERR.puts "domain, password, hostname are required."
21
+ exit
22
+ end
23
+ config[:ip] = ddns.get_ip if !config[:ip]
24
+ params = ddns.submit_params
25
+ params["p"] = '******'
26
+ log.info("update to #{ValueDomainDdns::SUBMIT_BASE_URL} with params:"+params.to_s)
27
+ log.info(ddns.sync())
28
+ end
29
+ end
@@ -0,0 +1,8 @@
1
+ require 'logger'
2
+
3
+ class ValueDomainDdns::Logger < ::Logger
4
+ def initialize(out, level)
5
+ super(out)
6
+ self.level = level
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module ValueDomainDdns
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: value-domain-ddns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - daimatz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-11 00:00:00.000000000 Z
11
+ date: 2014-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -83,9 +83,11 @@ files:
83
83
  - bin/value-domain-ddns
84
84
  - config.json
85
85
  - lib/value-domain-ddns.rb
86
+ - lib/value-domain-ddns/cli.rb
86
87
  - lib/value-domain-ddns/config.rb
87
88
  - lib/value-domain-ddns/constant.rb
88
89
  - lib/value-domain-ddns/core.rb
90
+ - lib/value-domain-ddns/logger.rb
89
91
  - lib/value-domain-ddns/version.rb
90
92
  - spec/spec_helper.rb
91
93
  - spec/value-domain-ddns/config_spec.rb