nomore 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 64c66055a45390d9fef292739acb43a8a1469bd6
4
+ data.tar.gz: 4fc1900778dfcaf8a97f49ced35abf90b0a771c9
5
+ SHA512:
6
+ metadata.gz: a033f831ec19a9bd5ad5ec75085d42baa589eb8b3c05f36ec5647ff3d7095caf6ac2f2d3b2f9c2dd8a76a46b52f4dcb289f70ba2b79b16230358e23d45275755
7
+ data.tar.gz: efd0a4cb6f0e3ddb2f444af0d9cf8fa02d361502e56f1ea3686f38a4254a9efbd854ec6f3863cf6b5599f7c82635b43de1365910f91444bca5ebbfb12f019506
@@ -0,0 +1,4 @@
1
+ ### 0.1.0 / 2014-09-10
2
+
3
+ * Initial release.
4
+
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Jan Lelis
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,30 @@
1
+ # nomore
2
+
3
+ Quickly rewrites a domain to 127.0.0.1 in your /etc/hosts file, so you can concentrate better.
4
+
5
+
6
+ ## Disclaimer
7
+
8
+ Use at your own risk. No tests and /etc/hosts is an important file for your system.
9
+
10
+
11
+ ## Install
12
+
13
+ Make sure you Ruby setup is also working for root. Then do
14
+
15
+ $ sudo gem install nomore
16
+
17
+
18
+ ## Usage
19
+ ### Disable a domain
20
+
21
+ $ sudo nomore twitter.com
22
+
23
+ ### Restore everything after your work is done (optionally takes a domain name)
24
+
25
+ $ sudo nomorework
26
+
27
+
28
+ ## Copyright
29
+
30
+ Copyright (c) 2014 Jan Lelis. MIT-LICENSE.
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'nomore'
4
+
5
+ Nomore.enable(ARGV[0])
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'nomore'
4
+
5
+ Nomore.disable(ARGV[0] || :all)
@@ -0,0 +1,43 @@
1
+ require_relative 'nomore/version'
2
+
3
+ module Nomore
4
+ HOSTS = '/etc/hosts'
5
+ START = '### begin nomore managed ###'
6
+ ENDE = '### end nomore managed ###'
7
+ REGEX = /^#{START}$(.*)\n^#{ENDE}$/m
8
+
9
+ def self.enable(domain)
10
+ hosts = File.read(HOSTS)
11
+ if hosts =~ REGEX
12
+ hosts[REGEX, 1] = hosts[REGEX, 1] + "\n127.0.0.1 #{domain}"
13
+ else
14
+ hosts += "\n" + START + "\n127.0.0.1 #{domain}\n" + ENDE
15
+ end
16
+
17
+ File.write('/etc/hosts', hosts)
18
+ rescue Errno::EACCES
19
+ warn 'nomore should be called as sudo'
20
+ end
21
+
22
+ def self.disable(domain = :all)
23
+ hosts = File.read(HOSTS)
24
+ if domain == :all
25
+ hosts[REGEX] = ''
26
+ else
27
+ if blocked_domains = hosts[REGEX, 1]
28
+ blocked_domains[/^.*#{domain}$/] = ''
29
+ if blocked_domains =~ /\A(\s)*\z/
30
+ hosts[REGEX] = ''
31
+ else
32
+ hosts[REGEX, 1] = blocked_domains
33
+ end
34
+ end
35
+ end
36
+
37
+ File.write('/etc/hosts', hosts)
38
+ rescue IndexError
39
+ warn 'Nothing done'
40
+ rescue Errno::EACCES
41
+ warn 'nomore should be called as sudo'
42
+ end
43
+ end
@@ -0,0 +1,4 @@
1
+ module Nomore
2
+ # nomore version
3
+ VERSION = "0.1.0"
4
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path('../lib/nomore/version', __FILE__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "nomore"
7
+ gem.version = Nomore::VERSION
8
+ gem.summary = 'Rewrites a domain to 127.0.0.1 in your /etc/hosts file.'
9
+ gem.description = 'Quickly rewrites a domain to 127.0.0.1 in your /etc/hosts file, so you can concentrate better.'
10
+ gem.license = "MIT"
11
+ gem.authors = ["Jan Lelis"]
12
+ gem.email = "mail@janlelis.de"
13
+ gem.homepage = "https://github.com/janlelis/nomore"
14
+
15
+ gem.files = Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
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
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nomore
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jan Lelis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Quickly rewrites a domain to 127.0.0.1 in your /etc/hosts file, so you
14
+ can concentrate better.
15
+ email: mail@janlelis.de
16
+ executables:
17
+ - nomore
18
+ - nomorework
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - ChangeLog.md
23
+ - LICENSE.txt
24
+ - README.md
25
+ - bin/nomore
26
+ - bin/nomorework
27
+ - lib/nomore.rb
28
+ - lib/nomore/version.rb
29
+ - nomore.gemspec
30
+ homepage: https://github.com/janlelis/nomore
31
+ licenses:
32
+ - MIT
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 2.4.1
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: Rewrites a domain to 127.0.0.1 in your /etc/hosts file.
54
+ test_files: []