dynamic53 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1db331e4f7b6371e4859fa1660ca52a1e75b794c
4
+ data.tar.gz: 1ca566d423cf74afaea476cbe2fb9812b4d8ef68
5
+ SHA512:
6
+ metadata.gz: 4e4f6d38f2b01a20de2ed222005b1f3af29a6fa751761d5e0b0d7b27083db5188587740fa65266b75fa0ba95899c883fdec7b4b5399fa216536d699485d8bc45
7
+ data.tar.gz: 4a6aac5157b4a9952416524b6bbbafb38b3d90fc8ca8723ec269ed0c35a290289ae2365f358a7f176c783800e7c037f8d468030c02c24e8a66b1244d10bd3ddd
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 2.0.0" > .rvmrc
9
+ environment_id="ruby-2.0.0-p353@dynamic53"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.24.7 (stable)" # 1.10.1 seems like a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | __rvm_awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ for __hook in "${rvm_path:-$HOME/.rvm}/hooks/after_use"*
27
+ do
28
+ if [[ -f "${__hook}" && -x "${__hook}" && -s "${__hook}" ]]
29
+ then \. "${__hook}" || true
30
+ fi
31
+ done
32
+ unset __hook
33
+ if (( ${rvm_use_flag:=1} >= 1 )) # display automatically
34
+ then
35
+ if [[ $- == *i* ]] # check for interactive shells
36
+ then printf "%b" "Using: $(tput setaf 2 2>/dev/null)$GEM_HOME$(tput sgr0 2>/dev/null)
37
+ " # show the user the ruby and gemset they are using in green
38
+ else printf "%b" "Using: $GEM_HOME
39
+ " # don't use colors in non-interactive shells
40
+ fi
41
+ fi
42
+ else
43
+ # If the environment file has not yet been created, use the RVM CLI to select.
44
+ rvm --create use "$environment_id" || {
45
+ echo "Failed to create RVM environment '${environment_id}'."
46
+ return 1
47
+ }
48
+ fi
49
+
50
+ # If you use bundler, this might be useful to you:
51
+ # if [[ -s Gemfile ]] && {
52
+ # ! builtin command -v bundle >/dev/null ||
53
+ # builtin command -v bundle | GREP_OPTIONS="" \grep $rvm_path/bin/bundle >/dev/null
54
+ # }
55
+ # then
56
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
57
+ # gem install bundler
58
+ # fi
59
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
60
+ # then
61
+ # bundle install | GREP_OPTIONS="" \grep -vE '^Using|Your bundle is complete'
62
+ # fi
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dynamic53.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Christopher Hein
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Dynamic53
2
+
3
+ Simple ruby executable that will allow you to setup 'dynamic dns' to a local network like dyndns or any other dynamic dns service using Route 53 and Ruby
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'dynamic53'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install dynamic53
18
+
19
+ Now setup a `~/.dynamic53` file in your home directory with the AWS access key and secret comma delimited like
20
+
21
+ echo "xxxx,xxxx" > ~/.dynamic53
22
+
23
+ ## Usage
24
+
25
+ Now that the gem is installed you can run
26
+
27
+ $ dynamic53 {{user}} {{zonename}} {{somesubdomain}}
28
+
29
+ Or if you'd like it to use a stringified version of the bonjour name use
30
+
31
+ $ dynamic53 {{user}} {{zonename}}
32
+
33
+ This will update the route 53 record with the machines current ip.
34
+
35
+ ## Simple Easy and Effective :)
36
+
37
+ If it doesn't work for you well I'm sorry maybe I'll fix it later.
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/dynamic53 ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.push File.expand_path("../../lib", __FILE__)
4
+ require 'dynamic53'
5
+
6
+ Dynamic53::Cli.start(ARGV)
data/dynamic53.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dynamic53/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dynamic53"
8
+ spec.version = Dynamic53::VERSION
9
+ spec.authors = ["Christopher Hein"]
10
+ spec.email = ["me@christopherhein.com"]
11
+ spec.description = %q{Setup dynamic dns service using Route 53 and Ruby}
12
+ spec.summary = %q{Simple ruby executable that will allow you to setup 'dynamic dns' to a local network like dyndns or any other dynamic dns service using Route 53 and Ruby}
13
+ spec.homepage = "https://github.com/christopherhein/dynamic53"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "route53"
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ end
@@ -0,0 +1,54 @@
1
+ module Dynamic53
2
+ class Cli
3
+
4
+ def self.start(params)
5
+ new(params)
6
+ end
7
+
8
+ attr_accessor :user, :hostname, :update_hostname, :local_ip, :route53, :zone, :record
9
+
10
+ def initialize(params)
11
+ @user = params[0]
12
+ @hostname = params[1]
13
+ @update_hostname = params[2] ? params[2] : stringify_computer
14
+ update_dns
15
+ end
16
+
17
+ def update_dns
18
+ if record
19
+ record.update(nil,nil,nil,[local_ip])
20
+ else
21
+ create_record
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def create_record
28
+ record = Route53::DNSRecord.new("#{update_hostname}.#{hostname}.","CNAME","60",[local_ip], zone)
29
+ record.create
30
+ end
31
+
32
+ def stringify_computer
33
+ `/usr/sbin/scutil --get ComputerName`.chomp.downcase.gsub(" ", "-").gsub(/[^a-z0-9]/i, "")
34
+ end
35
+
36
+ def record
37
+ @record ||= zone.get_records("CNAME").select {|r| r.name =~ /#{update_hostname}/ }.first
38
+ end
39
+
40
+ def zone
41
+ @zone ||= route53.get_zones(hostname).first
42
+ end
43
+
44
+ def route53
45
+ conf = File.read("/Users/#{user}/.dynamic53").split(',')
46
+ @route53 ||= Route53::Connection.new(conf.first.chomp, conf.last.chomp)
47
+ end
48
+
49
+ def local_ip
50
+ @local_ip ||= `/usr/bin/curl -s curlmyip.com`.chomp
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,3 @@
1
+ module Dynamic53
2
+ VERSION = "0.0.2"
3
+ end
data/lib/dynamic53.rb ADDED
@@ -0,0 +1,3 @@
1
+ require "route53"
2
+ require "dynamic53/version"
3
+ require "dynamic53/cli"
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dynamic53
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Christopher Hein
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: route53
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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Setup dynamic dns service using Route 53 and Ruby
56
+ email:
57
+ - me@christopherhein.com
58
+ executables:
59
+ - dynamic53
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - .rvmrc
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/dynamic53
70
+ - dynamic53.gemspec
71
+ - lib/dynamic53.rb
72
+ - lib/dynamic53/cli.rb
73
+ - lib/dynamic53/version.rb
74
+ homepage: https://github.com/christopherhein/dynamic53
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.2.2
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Simple ruby executable that will allow you to setup 'dynamic dns' to a local
98
+ network like dyndns or any other dynamic dns service using Route 53 and Ruby
99
+ test_files: []