local-domains 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0694e49238dc0f76873a3637cfd3535268289e5b
4
+ data.tar.gz: 42ab15898721b11e414ba2d71987adc9df8c2945
5
+ SHA512:
6
+ metadata.gz: c6f24a1f7188682ba19cd48b20bdb4b2a71c3b23f36b04e3f1de5919a5ae419b93bb0c760accd7954a1a5f170d107ffa246f2b28e5afd65883ffc085c730a912
7
+ data.tar.gz: a17cdfd8c754ca7f7843ca9da0defa8ae0686577d2966029150b78c5e443821aef342bc6ee7a0be37882aecc4d8492a5f7e2a983e44065053e2161986706b68e
@@ -0,0 +1,2 @@
1
+ my-domain.local.com
2
+ something.test.com
@@ -0,0 +1 @@
1
+ local-domains
@@ -0,0 +1 @@
1
+ ruby-2.0.0-p247
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+ ruby '2.0.0'
3
+
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ local-domains (0.1.0)
5
+ ghost (= 1.0.0.pre.2)
6
+ sys-host (= 0.6.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ghost (1.0.0.pre.2)
12
+ unindent (= 1.0)
13
+ sys-host (0.6.2)
14
+ unindent (1.0)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ local-domains!
@@ -0,0 +1,15 @@
1
+ # local-domains
2
+
3
+ Maps a list of domains to an ip address
4
+
5
+ ## Usage
6
+
7
+ Create a .local-domains file in your home directory, with a list of
8
+ domains, one on each line (see .local-domains.example)
9
+
10
+ Run it with rvmsudo
11
+
12
+ $ rvmsudo ruby local-domains.rb <ip address>
13
+
14
+ If the ip address is omitted, domains will be mapped to the first local ip
15
+ address
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'local-domains'))
4
+
5
+ LocalDomains.setup(ARGV[0])
@@ -0,0 +1,26 @@
1
+ require 'ghost'
2
+ require 'sys/host'
3
+
4
+ module LocalDomains
5
+ CONFIGURATION_FILE = "#{ENV["HOME"]}/.local-domains"
6
+
7
+ def self.setup(ip_address)
8
+ unless File.readable?(CONFIGURATION_FILE)
9
+ puts "File not found: #{CONFIGURATION_FILE}"
10
+ exit 1
11
+ end
12
+
13
+ @ip_address = ip_address || Sys::Host.ip_addr.first
14
+
15
+ File.readlines(CONFIGURATION_FILE).each do |domain|
16
+ add_domain(domain.gsub(/[ \n\t]/, ""))
17
+ end
18
+ end
19
+
20
+ private
21
+ def self.add_domain(domain)
22
+ host = Ghost::Host.new(domain, @ip_address)
23
+ puts "adding '#{domain}' to '#{@ip_address}'"
24
+ Ghost.store.set(host)
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module LocalDomains
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,22 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'local-domains/version'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "local-domains"
7
+ gem.version = LocalDomains::VERSION
8
+ gem.authors = ["Guilherme Garnier"]
9
+ gem.email = ["guilherme.garnier@gmail.com"]
10
+ gem.summary = "Maps a list of domains to an ip address"
11
+ gem.description = "A simple tool to help keeping your /etc/hosts file up-to-date"
12
+ gem.homepage = "https://github.com/ggarnier/local-domains"
13
+ gem.license = "MIT"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "ghost", "1.0.0.pre.2"
21
+ gem.add_dependency "sys-host", "0.6.2"
22
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: local-domains
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Guilherme Garnier
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ghost
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0.pre.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0.pre.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: sys-host
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.6.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.6.2
41
+ description: A simple tool to help keeping your /etc/hosts file up-to-date
42
+ email:
43
+ - guilherme.garnier@gmail.com
44
+ executables:
45
+ - local-domains
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .local-domains.example
50
+ - .ruby-gemset
51
+ - .ruby-version
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - README.md
55
+ - bin/local-domains
56
+ - lib/local-domains.rb
57
+ - lib/local-domains/version.rb
58
+ - local-domains.gemspec
59
+ homepage: https://github.com/ggarnier/local-domains
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.0.3
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Maps a list of domains to an ip address
83
+ test_files: []