noprocrast 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -6
- data/VERSION +1 -1
- data/bin/noprocrast +11 -11
- data/lib/{noprocast.rb → noprocrast.rb} +7 -7
- data/{noprocast.gemspec → noprocrast.gemspec} +11 -11
- data/spec/{noprocast_spec.rb → noprocrast_spec.rb} +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +8 -8
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
noprocrast
|
2
2
|
=========
|
3
3
|
|
4
4
|
A gem to stop you procastinating. Noprocast automatically adds and removes items from your /etc/hosts, rendering addictive websites useless.
|
@@ -6,18 +6,18 @@ A gem to stop you procastinating. Noprocast automatically adds and removes items
|
|
6
6
|
Installation
|
7
7
|
------------
|
8
8
|
|
9
|
-
gem install
|
9
|
+
gem install noprocrast
|
10
10
|
|
11
11
|
Usage
|
12
12
|
-----
|
13
13
|
|
14
|
-
`
|
14
|
+
`noprocrast status` check if noprocrast is enabled or not
|
15
15
|
|
16
|
-
`
|
16
|
+
`noprocrast edit` edit noprocrast's list of banned websites
|
17
17
|
|
18
|
-
`
|
18
|
+
`noprocrast on` enable noprocrast
|
19
19
|
|
20
|
-
`
|
20
|
+
`noprocrast off` disable noprocrast
|
21
21
|
|
22
22
|
Notes
|
23
23
|
-----
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/bin/noprocrast
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', '
|
3
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'noprocrast')
|
4
4
|
|
5
5
|
begin
|
6
6
|
case ARGV.first
|
7
7
|
when 'on', 'reload'
|
8
|
-
|
8
|
+
Noprocrast.activate!
|
9
9
|
when 'off'
|
10
|
-
|
10
|
+
Noprocrast.deactivate!
|
11
11
|
when 'status'
|
12
|
-
puts
|
12
|
+
puts Noprocrast.status_message
|
13
13
|
when 'edit'
|
14
|
-
if File.exists?(
|
14
|
+
if File.exists?(Noprocrast.deny_file_path) && (Process.uid != File.stat(Noprocrast.deny_file_path).uid)
|
15
15
|
puts "Can't edit this file as it belongs to another user (hint: don't use sudo)"
|
16
16
|
exit
|
17
17
|
end
|
18
|
-
|
19
|
-
if
|
20
|
-
puts "Saved. Now:
|
18
|
+
Noprocrast.edit!
|
19
|
+
if Noprocrast.active?
|
20
|
+
puts "Saved. Now: noprocrast reload"
|
21
21
|
else
|
22
|
-
puts "Saved. Now:
|
22
|
+
puts "Saved. Now: noprocrast on"
|
23
23
|
end
|
24
24
|
when 'help', '-h', '--help', nil
|
25
|
-
puts "Usage: [sudo]
|
25
|
+
puts "Usage: [sudo] noprocrast [on|off|status|edit]"
|
26
26
|
end
|
27
27
|
rescue Errno::EACCES
|
28
|
-
puts "Permission denied: try sudo
|
28
|
+
puts "Permission denied: try sudo noprocrast"
|
29
29
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
|
-
class
|
3
|
+
class Noprocrast
|
4
4
|
class << self
|
5
5
|
def default_hosts
|
6
6
|
['news.ycombinator.com', 'twitter.com', 'facebook.com', 'reddit.com']
|
@@ -23,29 +23,29 @@ class Noprocast
|
|
23
23
|
backup_hosts_file_if_required!
|
24
24
|
deactivate! # ensure that /etc/hosts is clean
|
25
25
|
File.open("/etc/hosts", 'a') do |file|
|
26
|
-
file << "\n\n#
|
26
|
+
file << "\n\n# noprocrast start\n#{current_hosts.map { |host| "127.0.0.1 #{host}" }.join("\n")}\n# noprocrast end"
|
27
27
|
end
|
28
28
|
system "dscacheutil -flushcache" # only for OSX >= 10.5: flush the DNS cache
|
29
29
|
end
|
30
30
|
|
31
31
|
def deactivate!
|
32
|
-
clean_hosts = hosts_file_content.gsub(/(\n\n)?\#
|
32
|
+
clean_hosts = hosts_file_content.gsub(/(\n\n)?\# noprocrast start.*\# noprocrast end/m, '')
|
33
33
|
File.open("/etc/hosts", 'w') do |file|
|
34
34
|
file << clean_hosts
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
def active?
|
39
|
-
hosts_file_content.match(/\#
|
39
|
+
hosts_file_content.match(/\# noprocrast start/)
|
40
40
|
end
|
41
41
|
|
42
42
|
def status_message
|
43
|
-
active? ? "
|
43
|
+
active? ? "noprocrast enabled for #{current_hosts.size} hosts" : "noprocrast disabled"
|
44
44
|
end
|
45
45
|
|
46
46
|
def backup_hosts_file_if_required!
|
47
|
-
unless File.exists?("/etc/.hosts.
|
48
|
-
FileUtils.cp("/etc/hosts", "/etc/.hosts.
|
47
|
+
unless File.exists?("/etc/.hosts.noprocrastbackup")
|
48
|
+
FileUtils.cp("/etc/hosts", "/etc/.hosts.noprocrastbackup")
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -4,16 +4,16 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{
|
8
|
-
s.version = "0.1.
|
7
|
+
s.name = %q{noprocrast}
|
8
|
+
s.version = "0.1.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Rob Watson"]
|
12
12
|
s.date = %q{2010-11-11}
|
13
|
-
s.default_executable = %q{
|
13
|
+
s.default_executable = %q{noprocrast}
|
14
14
|
s.description = %q{Block access to addictive websites in one command-line swoop.}
|
15
15
|
s.email = %q{rfwatson@gmail.com}
|
16
|
-
s.executables = ["
|
16
|
+
s.executables = ["noprocrast"]
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE",
|
19
19
|
"README.md"
|
@@ -25,20 +25,20 @@ Gem::Specification.new do |s|
|
|
25
25
|
"README.md",
|
26
26
|
"Rakefile",
|
27
27
|
"VERSION",
|
28
|
-
"bin/
|
29
|
-
"lib/
|
30
|
-
"
|
31
|
-
"spec/
|
28
|
+
"bin/noprocrast",
|
29
|
+
"lib/noprocrast.rb",
|
30
|
+
"noprocrast.gemspec",
|
31
|
+
"spec/noprocrast_spec.rb",
|
32
32
|
"spec/spec.opts",
|
33
33
|
"spec/spec_helper.rb"
|
34
34
|
]
|
35
|
-
s.homepage = %q{http://github.com/rfwatson/
|
35
|
+
s.homepage = %q{http://github.com/rfwatson/noprocrast}
|
36
36
|
s.rdoc_options = ["--charset=UTF-8"]
|
37
37
|
s.require_paths = ["lib"]
|
38
38
|
s.rubygems_version = %q{1.3.7}
|
39
|
-
s.summary = %q{Give
|
39
|
+
s.summary = %q{Give procrastination a swift kick in the balls.}
|
40
40
|
s.test_files = [
|
41
|
-
"spec/
|
41
|
+
"spec/noprocrast_spec.rb",
|
42
42
|
"spec/spec_helper.rb"
|
43
43
|
]
|
44
44
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noprocrast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rob Watson
|
@@ -50,12 +50,12 @@ files:
|
|
50
50
|
- README.md
|
51
51
|
- Rakefile
|
52
52
|
- VERSION
|
53
|
-
-
|
54
|
-
-
|
55
|
-
-
|
53
|
+
- bin/noprocrast
|
54
|
+
- lib/noprocrast.rb
|
55
|
+
- noprocrast.gemspec
|
56
|
+
- spec/noprocrast_spec.rb
|
56
57
|
- spec/spec.opts
|
57
58
|
- spec/spec_helper.rb
|
58
|
-
- bin/noprocrast
|
59
59
|
has_rdoc: true
|
60
60
|
homepage: http://github.com/rfwatson/noprocrast
|
61
61
|
licenses: []
|
@@ -91,5 +91,5 @@ signing_key:
|
|
91
91
|
specification_version: 3
|
92
92
|
summary: Give procrastination a swift kick in the balls.
|
93
93
|
test_files:
|
94
|
-
- spec/
|
94
|
+
- spec/noprocrast_spec.rb
|
95
95
|
- spec/spec_helper.rb
|