fix typo
This commit is contained in:
parent
4a70eea676
commit
f28ac5100d
12
README.md
12
README.md
|
@ -1,4 +1,4 @@
|
||||||
noprocast
|
noprocrast
|
||||||
=========
|
=========
|
||||||
|
|
||||||
A gem to stop you procastinating. Noprocast automatically adds and removes items from your /etc/hosts, rendering addictive websites useless.
|
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
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
gem install noprocast
|
gem install noprocrast
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
||||||
`noprocast status` check if noprocast is enabled or not
|
`noprocrast status` check if noprocrast is enabled or not
|
||||||
|
|
||||||
`noprocast edit` edit noprocast's list of banned websites
|
`noprocrast edit` edit noprocrast's list of banned websites
|
||||||
|
|
||||||
`noprocast on` enable noprocast
|
`noprocrast on` enable noprocrast
|
||||||
|
|
||||||
`noprocast off` disable noprocast
|
`noprocrast off` disable noprocrast
|
||||||
|
|
||||||
Notes
|
Notes
|
||||||
-----
|
-----
|
||||||
|
|
8
Rakefile
8
Rakefile
|
@ -4,11 +4,11 @@ require 'rake'
|
||||||
begin
|
begin
|
||||||
require 'jeweler'
|
require 'jeweler'
|
||||||
Jeweler::Tasks.new do |gem|
|
Jeweler::Tasks.new do |gem|
|
||||||
gem.name = "noprocast"
|
gem.name = "noprocrast"
|
||||||
gem.summary = %Q{Give procastination a swift kick in the balls.}
|
gem.summary = %Q{Give procrastination a swift kick in the balls.}
|
||||||
gem.description = %Q{Block access to addictive websites in one command-line swoop.}
|
gem.description = %Q{Block access to addictive websites in one command-line swoop.}
|
||||||
gem.email = "rfwatson@gmail.com"
|
gem.email = "rfwatson@gmail.com"
|
||||||
gem.homepage = "http://github.com/rfwatson/noprocast"
|
gem.homepage = "http://github.com/rfwatson/noprocrast"
|
||||||
gem.authors = ["Rob Watson"]
|
gem.authors = ["Rob Watson"]
|
||||||
gem.add_development_dependency "rspec", ">= 1.2.9"
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
||||||
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
||||||
|
@ -39,7 +39,7 @@ Rake::RDocTask.new do |rdoc|
|
||||||
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
||||||
|
|
||||||
rdoc.rdoc_dir = 'rdoc'
|
rdoc.rdoc_dir = 'rdoc'
|
||||||
rdoc.title = "noprocast #{version}"
|
rdoc.title = "noprocrast #{version}"
|
||||||
rdoc.rdoc_files.include('README*')
|
rdoc.rdoc_files.include('README*')
|
||||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
#!/usr/bin/env ruby
|
|
||||||
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'noprocast')
|
|
||||||
|
|
||||||
begin
|
|
||||||
case ARGV.first
|
|
||||||
when 'on', 'reload'
|
|
||||||
Noprocast.activate!
|
|
||||||
when 'off'
|
|
||||||
Noprocast.deactivate!
|
|
||||||
when 'status'
|
|
||||||
puts Noprocast.status_message
|
|
||||||
when 'edit'
|
|
||||||
if File.exists?(Noprocast.deny_file_path) && (Process.uid != File.stat(Noprocast.deny_file_path).uid)
|
|
||||||
puts "Can't edit this file as it belongs to another user (hint: don't use sudo)"
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
Noprocast.edit!
|
|
||||||
if Noprocast.active?
|
|
||||||
puts "Saved. Now: noprocast reload"
|
|
||||||
else
|
|
||||||
puts "Saved. Now: noprocast on"
|
|
||||||
end
|
|
||||||
when 'help', '-h', '--help', nil
|
|
||||||
puts "Usage: [sudo] noprocast [on|off|status|edit]"
|
|
||||||
end
|
|
||||||
rescue Errno::EACCES
|
|
||||||
puts "Permission denied: try sudo noprocast"
|
|
||||||
end
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'noprocrast')
|
||||||
|
|
||||||
|
begin
|
||||||
|
case ARGV.first
|
||||||
|
when 'on', 'reload'
|
||||||
|
Noprocrast.activate!
|
||||||
|
when 'off'
|
||||||
|
Noprocrast.deactivate!
|
||||||
|
when 'status'
|
||||||
|
puts Noprocrast.status_message
|
||||||
|
when 'edit'
|
||||||
|
if File.exists?(Noprocrast.deny_file_path) && (Process.uid != File.stat(Noprocrast.deny_file_path).uid)
|
||||||
|
puts "Can't edit this file as it belongs to another user (hint: don't use sudo)"
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
Noprocrast.edit!
|
||||||
|
if Noprocrast.active?
|
||||||
|
puts "Saved. Now: noprocrast reload"
|
||||||
|
else
|
||||||
|
puts "Saved. Now: noprocrast on"
|
||||||
|
end
|
||||||
|
when 'help', '-h', '--help', nil
|
||||||
|
puts "Usage: [sudo] noprocrast [on|off|status|edit]"
|
||||||
|
end
|
||||||
|
rescue Errno::EACCES
|
||||||
|
puts "Permission denied: try sudo noprocrast"
|
||||||
|
end
|
|
@ -1,6 +1,6 @@
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
|
||||||
class Noprocast
|
class Noprocrast
|
||||||
class << self
|
class << self
|
||||||
def default_hosts
|
def default_hosts
|
||||||
['news.ycombinator.com', 'twitter.com', 'facebook.com', 'reddit.com']
|
['news.ycombinator.com', 'twitter.com', 'facebook.com', 'reddit.com']
|
||||||
|
@ -23,29 +23,29 @@ class Noprocast
|
||||||
backup_hosts_file_if_required!
|
backup_hosts_file_if_required!
|
||||||
deactivate! # ensure that /etc/hosts is clean
|
deactivate! # ensure that /etc/hosts is clean
|
||||||
File.open("/etc/hosts", 'a') do |file|
|
File.open("/etc/hosts", 'a') do |file|
|
||||||
file << "\n\n# noprocast start\n#{current_hosts.map { |host| "127.0.0.1 #{host}" }.join("\n")}\n# noprocast end"
|
file << "\n\n# noprocrast start\n#{current_hosts.map { |host| "127.0.0.1 #{host}" }.join("\n")}\n# noprocrast end"
|
||||||
end
|
end
|
||||||
system "dscacheutil -flushcache" # only for OSX >= 10.5: flush the DNS cache
|
system "dscacheutil -flushcache" # only for OSX >= 10.5: flush the DNS cache
|
||||||
end
|
end
|
||||||
|
|
||||||
def deactivate!
|
def deactivate!
|
||||||
clean_hosts = hosts_file_content.gsub(/(\n\n)?\# noprocast start.*\# noprocast end/m, '')
|
clean_hosts = hosts_file_content.gsub(/(\n\n)?\# noprocrast start.*\# noprocrast end/m, '')
|
||||||
File.open("/etc/hosts", 'w') do |file|
|
File.open("/etc/hosts", 'w') do |file|
|
||||||
file << clean_hosts
|
file << clean_hosts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def active?
|
def active?
|
||||||
hosts_file_content.match(/\# noprocast start/)
|
hosts_file_content.match(/\# noprocrast start/)
|
||||||
end
|
end
|
||||||
|
|
||||||
def status_message
|
def status_message
|
||||||
active? ? "noprocast enabled for #{current_hosts.size} hosts" : "noprocast disabled"
|
active? ? "noprocrast enabled for #{current_hosts.size} hosts" : "noprocrast disabled"
|
||||||
end
|
end
|
||||||
|
|
||||||
def backup_hosts_file_if_required!
|
def backup_hosts_file_if_required!
|
||||||
unless File.exists?("/etc/.hosts.noprocastbackup")
|
unless File.exists?("/etc/.hosts.noprocrastbackup")
|
||||||
FileUtils.cp("/etc/hosts", "/etc/.hosts.noprocastbackup")
|
FileUtils.cp("/etc/hosts", "/etc/.hosts.noprocrastbackup")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,16 +4,16 @@
|
||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
|
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = %q{noprocast}
|
s.name = %q{noprocrast}
|
||||||
s.version = "0.1.4"
|
s.version = "0.1.6"
|
||||||
|
|
||||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||||
s.authors = ["Rob Watson"]
|
s.authors = ["Rob Watson"]
|
||||||
s.date = %q{2010-11-11}
|
s.date = %q{2010-11-11}
|
||||||
s.default_executable = %q{noprocast}
|
s.default_executable = %q{noprocrast}
|
||||||
s.description = %q{Block access to addictive websites in one command-line swoop.}
|
s.description = %q{Block access to addictive websites in one command-line swoop.}
|
||||||
s.email = %q{rfwatson@gmail.com}
|
s.email = %q{rfwatson@gmail.com}
|
||||||
s.executables = ["noprocast"]
|
s.executables = ["noprocrast"]
|
||||||
s.extra_rdoc_files = [
|
s.extra_rdoc_files = [
|
||||||
"LICENSE",
|
"LICENSE",
|
||||||
"README.md"
|
"README.md"
|
||||||
|
@ -25,20 +25,20 @@ Gem::Specification.new do |s|
|
||||||
"README.md",
|
"README.md",
|
||||||
"Rakefile",
|
"Rakefile",
|
||||||
"VERSION",
|
"VERSION",
|
||||||
"bin/noprocast",
|
"bin/noprocrast",
|
||||||
"lib/noprocast.rb",
|
"lib/noprocrast.rb",
|
||||||
"noprocast.gemspec",
|
"noprocrast.gemspec",
|
||||||
"spec/noprocast_spec.rb",
|
"spec/noprocrast_spec.rb",
|
||||||
"spec/spec.opts",
|
"spec/spec.opts",
|
||||||
"spec/spec_helper.rb"
|
"spec/spec_helper.rb"
|
||||||
]
|
]
|
||||||
s.homepage = %q{http://github.com/rfwatson/noprocast}
|
s.homepage = %q{http://github.com/rfwatson/noprocrast}
|
||||||
s.rdoc_options = ["--charset=UTF-8"]
|
s.rdoc_options = ["--charset=UTF-8"]
|
||||||
s.require_paths = ["lib"]
|
s.require_paths = ["lib"]
|
||||||
s.rubygems_version = %q{1.3.7}
|
s.rubygems_version = %q{1.3.7}
|
||||||
s.summary = %q{Give procastination a swift kick in the balls.}
|
s.summary = %q{Give procrastination a swift kick in the balls.}
|
||||||
s.test_files = [
|
s.test_files = [
|
||||||
"spec/noprocast_spec.rb",
|
"spec/noprocrast_spec.rb",
|
||||||
"spec/spec_helper.rb"
|
"spec/spec_helper.rb"
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
||||||
|
|
||||||
describe "Noprocast" do
|
describe "Noprocrast" do
|
||||||
it "fails" do
|
it "fails" do
|
||||||
fail "hey buddy, you should probably rename this file and start specing for real"
|
fail "hey buddy, you should probably rename this file and start specing for real"
|
||||||
end
|
end
|
|
@ -1,6 +1,6 @@
|
||||||
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
||||||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||||
require 'noprocast'
|
require 'noprocrast'
|
||||||
require 'spec'
|
require 'spec'
|
||||||
require 'spec/autorun'
|
require 'spec/autorun'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue