noip 0.1 → 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: 1bcf997ac319fd48ed1b67f31f4d7f985d8b1be6
4
- data.tar.gz: c1ecfca9c825fc289cab3b515f6fad09d46c6d72
3
+ metadata.gz: 3e79babb898c9f0fc1f48a58a2897091f656ffd4
4
+ data.tar.gz: 30e0329f1be0f3e820d52fbfa66c47c1e00ad832
5
5
  SHA512:
6
- metadata.gz: 8f85d623a85aaffce2c67b140257a8ea77d9f5b49d5b01ae7df484c6665538d0083ffb01640d03fab26f4ce1ab7ecf6189919c4502efface892fa2b8ac4cc6f9
7
- data.tar.gz: dc13e1dacc583c0b739fb873e8c38351cd8c8a13df7887923f706068ccc6aa6ee34574c2859ef978bcc82c23d76338fae9d89f7983240d8117b5d2ae08ba2729
6
+ metadata.gz: 7c5e7cb3b5670ca2e589213d635c03c069c4611f6cd75dbdefc0b928693bfcb8883d37a219d672788387956875e4b2dcade0bc81e611549c14a7eb6699b62f6a
7
+ data.tar.gz: 8b0b61a1e4c5ec8dd6d971273b2ef0ab49eeda4162bb9914ed64126317b767cbc45d7c46598bf8eae9c9cf7ac4a4582ecbeb9865e494dfff8095b1cc9fe56602
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  pkg
2
+ coverage
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ gem "codeclimate-test-reporter", group: :test, require: nil
@@ -1,13 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- noip (0.1)
4
+ noip (0.2)
5
+ thor
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ codeclimate-test-reporter (0.4.8)
11
+ simplecov (>= 0.7.1, < 1.0.0)
9
12
  coderay (1.1.0)
10
13
  diff-lcs (1.2.5)
14
+ docile (1.1.5)
15
+ json (1.8.3)
11
16
  method_source (0.8.2)
12
17
  pry (0.10.3)
13
18
  coderay (~> 1.1.0)
@@ -27,13 +32,20 @@ GEM
27
32
  diff-lcs (>= 1.2.0, < 2.0)
28
33
  rspec-support (~> 3.3.0)
29
34
  rspec-support (3.3.0)
35
+ simplecov (0.10.0)
36
+ docile (~> 1.1.0)
37
+ json (~> 1.8)
38
+ simplecov-html (~> 0.10.0)
39
+ simplecov-html (0.10.0)
30
40
  slop (3.6.0)
41
+ thor (0.19.1)
31
42
 
32
43
  PLATFORMS
33
44
  ruby
34
45
 
35
46
  DEPENDENCIES
36
47
  bundler
48
+ codeclimate-test-reporter
37
49
  noip!
38
50
  pry
39
51
  rake
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # noip
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/noip.svg)](http://badge.fury.io/rb/noip)
4
+ [![Build Status](https://travis-ci.org/asellitt/noip.svg?branch=master)](https://travis-ci.org/asellitt/noip)
5
+ [![Code Climate](https://codeclimate.com/github/asellitt/noip/badges/gpa.svg)](https://codeclimate.com/github/asellitt/noip)
6
+ [![Test Coverage](https://codeclimate.com/github/asellitt/noip/badges/coverage.svg)](https://codeclimate.com/github/asellitt/noip/coverage)
7
+
3
8
  A simple utility for updating [noip](https://www.noip.com/integrate/request)
4
9
  dynamic DNS records for when your router kinda shit.
5
10
 
@@ -7,18 +12,20 @@ dynamic DNS records for when your router kinda shit.
7
12
 
8
13
  ### Command Line Interface
9
14
 
10
- You will need to provide your credentials and host to update as environment variables:
15
+ `noip` required three parameters: username, password, and host
11
16
 
12
17
  ```bash
13
- NOIP_HOST=host.to.update NOIP_USERNAME=username NOIP_PASSWORD=h4h-t0tez-l3g1t noip
18
+ noip update -u username -p h4h-t0tez-l3g1t -h host.to.update
14
19
  ```
15
20
 
21
+ See `noip help update` for more information
22
+
16
23
  ### Crontab
17
24
 
18
- As before, environment variables will need to be provided, here's a sample crontab that will run every 4 hours:
25
+ Here's a sample crontab entry that will schedule the update every 4 hours
19
26
 
20
27
  ```crontab
21
- 0 0,4,8,12,16,20 * * * NOIP_HOST=host.to.update NOIP_USERNAME=username NOIP_PASSWORD=h4h-t0tez-l3g1t noip
28
+ 0 0,4,8,12,16,20 * * * noip update -u username -p h4h-t0tez-l3g1t -h host.to.update
22
29
  ```
23
30
 
24
31
  ## Contributing
data/Rakefile CHANGED
@@ -4,4 +4,3 @@ require 'rspec/core/rake_task'
4
4
  task :default => :spec
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
- Rake.add_rakelib 'lib/tasks'
data/bin/noip CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require 'noip'
4
4
 
5
- Noip.update
5
+ Noip::Update.start( ARGV )
@@ -1,4 +1,5 @@
1
1
  require 'noip/agent'
2
+ require 'noip/cli'
2
3
  require 'noip/credentials'
3
4
  require 'noip/remote_ip'
4
5
  require 'noip/updater'
@@ -6,8 +7,11 @@ require 'noip/version'
6
7
 
7
8
  module Noip
8
9
 
9
- def self.update
10
- Noip::Updater.new.update
10
+ def self.update(username, password, host)
11
+ credentials = Noip::Credentials.new(username, password, host)
12
+ updater = Noip::Updater.new(credentials)
13
+
14
+ updater.update
11
15
  end
12
16
 
13
17
  end
@@ -0,0 +1,24 @@
1
+ require 'thor'
2
+
3
+ module Noip
4
+ class Update < Thor
5
+ option :username, :aliases => '-u', :type => :string, :required => true
6
+ option :password, :aliases => '-p', :type => :string, :required => true
7
+ option :host, :aliases => '-h', :type => :string, :required => true
8
+
9
+ desc "update", "Update the Dynamic DNS record at noip"
10
+
11
+ long_desc <<-DESC
12
+ `update` Update the Dynamic DNS record at noip.
13
+
14
+ A simple utility for updating noip (https://www.noip.com/integrate/request)
15
+ dynamic DNS records for when your router kinda shit.
16
+
17
+ https://github.com/asellitt/noip
18
+ DESC
19
+
20
+ def update
21
+ Noip.update(options[:username], options[:password], options[:host])
22
+ end
23
+ end
24
+ end
@@ -1,10 +1,10 @@
1
1
  module Noip
2
2
  class Credentials
3
3
 
4
- def initialize(username = nil, password = nil, host = nil)
5
- @username = username || ENV['NOIP_USERNAME']
6
- @password = password || ENV['NOIP_PASSWORD']
7
- @host = host || ENV['NOIP_HOST']
4
+ def initialize(username, password, host)
5
+ @username = username
6
+ @password = password
7
+ @host = host
8
8
  end
9
9
 
10
10
  attr_reader :username, :password, :host
@@ -3,7 +3,8 @@ require 'net/http'
3
3
  module Noip
4
4
  class Updater
5
5
 
6
- def initialize
6
+ def initialize(credentials)
7
+ @credentials = credentials
7
8
  initialize_http_request
8
9
  end
9
10
 
@@ -13,7 +14,7 @@ module Noip
13
14
 
14
15
  private
15
16
 
16
- attr_reader :http, :request, :response
17
+ attr_reader :credentials, :http, :request, :response
17
18
 
18
19
  def initialize_http_request
19
20
  @http = Net::HTTP.new('dynupdate.no-ip.com')
@@ -36,9 +37,5 @@ module Noip
36
37
  @remote_ip ||= Noip::RemoteIp.new
37
38
  end
38
39
 
39
- def credentials
40
- @credentials ||= Noip::Credentials.new
41
- end
42
-
43
40
  end
44
41
  end
@@ -1,3 +1,3 @@
1
1
  module Noip
2
- VERSION = "0.1"
2
+ VERSION = "0.2"
3
3
  end
@@ -6,7 +6,6 @@ require "noip/version"
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "noip"
8
8
  spec.version = Noip::VERSION
9
- spec.executables = ["noip"]
10
9
  spec.authors = ["Anthony Sellitti"]
11
10
  spec.email = ["anthony.noip_gem@asellitt.com"]
12
11
  spec.summary = "Dynamic DNS updater for No-IP"
@@ -18,6 +17,8 @@ Gem::Specification.new do |spec|
18
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
18
  spec.require_paths = ["lib"]
20
19
 
20
+ spec.add_dependency "thor"
21
+
21
22
  spec.add_development_dependency "bundler"
22
23
  spec.add_development_dependency "rake"
23
24
  spec.add_development_dependency "rspec"
@@ -1,71 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Noip::Credentials do
4
- context 'with ENV variables set' do
5
- before do
6
- allow(ENV).to receive(:[]).with('NOIP_USERNAME').and_return('env_noip_username')
7
- allow(ENV).to receive(:[]).with('NOIP_PASSWORD').and_return('env_noip_password')
8
- allow(ENV).to receive(:[]).with('NOIP_HOST').and_return('env_noip_host')
9
- end
4
+ subject(:credentials) { Noip::Credentials.new('username', 'password', 'host') }
10
5
 
11
- describe 'username' do
12
- subject(:username) { Noip::Credentials.new(username, password, host).username }
13
-
14
- context 'with values provided' do
15
- let(:username) { 'provided_username'}
16
- let(:password) { 'provided_password'}
17
- let(:host) { 'provided_host'}
18
-
19
- it { is_expected.to eq 'provided_username' }
20
- end
21
-
22
- context 'with no values provided' do
23
- let(:username) { nil }
24
- let(:password) { nil }
25
- let(:host) { nil }
26
-
27
- it { is_expected.to eq 'env_noip_username' }
28
- end
29
- end
30
-
31
- describe 'password' do
32
- subject(:password) { Noip::Credentials.new(username, password, host).password }
33
-
34
- context 'with values provided' do
35
- let(:username) { 'provided_username'}
36
- let(:password) { 'provided_password'}
37
- let(:host) { 'provided_host'}
38
-
39
- it { is_expected.to eq 'provided_password' }
40
- end
41
-
42
- context 'with no values provided' do
43
- let(:username) { nil }
44
- let(:password) { nil }
45
- let(:host) { nil }
46
-
47
- it { is_expected.to eq 'env_noip_password' }
48
- end
49
- end
50
-
51
- describe 'host' do
52
- subject(:host) { Noip::Credentials.new(username, password, host).host }
53
-
54
- context 'with values provided' do
55
- let(:username) { 'provided_username'}
56
- let(:password) { 'provided_password'}
57
- let(:host) { 'provided_host'}
58
-
59
- it { is_expected.to eq 'provided_host' }
60
- end
6
+ describe '.username' do
7
+ subject(:username) { credentials.username }
8
+ it { is_expected.to eq 'username' }
9
+ end
61
10
 
62
- context 'with no values provided' do
63
- let(:username) { nil }
64
- let(:password) { nil }
65
- let(:host) { nil }
11
+ describe '.password' do
12
+ subject(:password) { credentials.password }
13
+ it { is_expected.to eq 'password' }
14
+ end
66
15
 
67
- it { is_expected.to eq 'env_noip_host' }
68
- end
69
- end
16
+ describe '.host' do
17
+ subject(:host) { credentials.host }
18
+ it { is_expected.to eq 'host' }
70
19
  end
71
20
  end
@@ -16,15 +16,6 @@ describe Noip::Updater do
16
16
  end
17
17
  before { allow(Noip::RemoteIp).to receive(:new).and_return(remote_ip) }
18
18
 
19
- let(:credentials) do
20
- instance_double(Noip::Credentials,
21
- :username => 'username',
22
- :password => 'password',
23
- :host => 'host',
24
- )
25
- end
26
- before { allow(Noip::Credentials).to receive(:new).and_return(credentials) }
27
-
28
19
  let(:http) { instance_double(Net::HTTP) }
29
20
  before do
30
21
  allow(http).to receive(:request)
@@ -37,7 +28,15 @@ describe Noip::Updater do
37
28
  allow(Net::HTTP::Get).to receive(:new).and_return(request)
38
29
  end
39
30
 
40
- subject(:update) { Noip::Updater.new.update }
31
+ let(:credentials) do
32
+ instance_double(Noip::Credentials,
33
+ :username => 'username',
34
+ :password => 'password',
35
+ :host => 'host',
36
+ )
37
+ end
38
+
39
+ subject(:update) { Noip::Updater.new(credentials).update }
41
40
  before { update }
42
41
 
43
42
  it 'requests the correct domain' do
@@ -2,15 +2,26 @@ require 'spec_helper'
2
2
 
3
3
  describe Noip do
4
4
  describe '.update' do
5
+ let(:credentials) { instance_double(Noip::Credentials) }
6
+ before { allow(Noip::Credentials).to receive(:new).and_return(credentials) }
7
+
5
8
  let(:updater) { instance_double(Noip::Updater) }
6
9
  before do
7
10
  allow(updater).to receive(:update)
8
11
  allow(Noip::Updater).to receive(:new).and_return(updater)
9
12
  end
10
13
 
11
- subject(:update) { Noip.update }
14
+ subject(:update) { Noip.update('username', 'password', 'host') }
12
15
  before { update }
13
16
 
17
+ it 'properly constructs the credentials' do
18
+ expect(Noip::Credentials).to have_received(:new).with('username', 'password', 'host')
19
+ end
20
+
21
+ it 'provides the updater with the correct credentials' do
22
+ expect(Noip::Updater).to have_received(:new).with(credentials)
23
+ end
24
+
14
25
  it 'pushes a new update to noip' do
15
26
  expect(updater).to have_received(:update)
16
27
  end
@@ -1,5 +1,9 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
1
4
  require 'noip'
2
5
 
3
6
  RSpec.configure do |config|
4
7
  config.color = true
5
8
  end
9
+
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noip
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Sellitti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-19 00:00:00.000000000 Z
11
+ date: 2015-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -76,6 +90,7 @@ extra_rdoc_files: []
76
90
  files:
77
91
  - ".gitignore"
78
92
  - ".ruby_version"
93
+ - ".travis.yml"
79
94
  - Gemfile
80
95
  - Gemfile.lock
81
96
  - LICENSE.md
@@ -84,11 +99,11 @@ files:
84
99
  - bin/noip
85
100
  - lib/noip.rb
86
101
  - lib/noip/agent.rb
102
+ - lib/noip/cli.rb
87
103
  - lib/noip/credentials.rb
88
104
  - lib/noip/remote_ip.rb
89
105
  - lib/noip/updater.rb
90
106
  - lib/noip/version.rb
91
- - lib/tasks/noip.rake
92
107
  - noip.gemspec
93
108
  - spec/noip/agent_spec.rb
94
109
  - spec/noip/credentials_spec.rb
@@ -1,9 +0,0 @@
1
- require 'noip'
2
- namespace :noip do
3
-
4
- desc "Push a dynamic DNS update to noip"
5
- task :update do
6
- Noip.update
7
- end
8
-
9
- end