From f28ac5100d66b833ddf0fbd042574c7cf85d60e1 Mon Sep 17 00:00:00 2001 From: Rob Watson Date: Thu, 11 Nov 2010 11:54:51 +0000 Subject: [PATCH] fix typo --- README.md | 12 ++++---- Rakefile | 8 ++--- bin/noprocast | 29 ------------------- bin/noprocrast | 29 +++++++++++++++++++ lib/{noprocast.rb => noprocrast.rb} | 14 ++++----- noprocast.gemspec => noprocrast.gemspec | 22 +++++++------- .../{noprocast_spec.rb => noprocrast_spec.rb} | 2 +- spec/spec_helper.rb | 2 +- 8 files changed, 59 insertions(+), 59 deletions(-) delete mode 100644 bin/noprocast create mode 100644 bin/noprocrast rename lib/{noprocast.rb => noprocrast.rb} (70%) rename noprocast.gemspec => noprocrast.gemspec (76%) rename spec/{noprocast_spec.rb => noprocrast_spec.rb} (87%) diff --git a/README.md b/README.md index 750d615..3eff216 100644 --- a/README.md +++ b/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. @@ -6,18 +6,18 @@ A gem to stop you procastinating. Noprocast automatically adds and removes items Installation ------------ -gem install noprocast +gem install noprocrast 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 ----- diff --git a/Rakefile b/Rakefile index c5a9197..b3065ca 100644 --- a/Rakefile +++ b/Rakefile @@ -4,11 +4,11 @@ require 'rake' begin require 'jeweler' Jeweler::Tasks.new do |gem| - gem.name = "noprocast" - gem.summary = %Q{Give procastination a swift kick in the balls.} + gem.name = "noprocrast" + 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.email = "rfwatson@gmail.com" - gem.homepage = "http://github.com/rfwatson/noprocast" + gem.homepage = "http://github.com/rfwatson/noprocrast" gem.authors = ["Rob Watson"] gem.add_development_dependency "rspec", ">= 1.2.9" # 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') : "" rdoc.rdoc_dir = 'rdoc' - rdoc.title = "noprocast #{version}" + rdoc.title = "noprocrast #{version}" rdoc.rdoc_files.include('README*') rdoc.rdoc_files.include('lib/**/*.rb') end diff --git a/bin/noprocast b/bin/noprocast deleted file mode 100644 index 2a3489a..0000000 --- a/bin/noprocast +++ /dev/null @@ -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 diff --git a/bin/noprocrast b/bin/noprocrast new file mode 100644 index 0000000..40fad04 --- /dev/null +++ b/bin/noprocrast @@ -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 diff --git a/lib/noprocast.rb b/lib/noprocrast.rb similarity index 70% rename from lib/noprocast.rb rename to lib/noprocrast.rb index 9345182..5237bfe 100644 --- a/lib/noprocast.rb +++ b/lib/noprocrast.rb @@ -1,6 +1,6 @@ require 'fileutils' -class Noprocast +class Noprocrast class << self def default_hosts ['news.ycombinator.com', 'twitter.com', 'facebook.com', 'reddit.com'] @@ -23,29 +23,29 @@ class Noprocast backup_hosts_file_if_required! deactivate! # ensure that /etc/hosts is clean 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 system "dscacheutil -flushcache" # only for OSX >= 10.5: flush the DNS cache end 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 << clean_hosts end end def active? - hosts_file_content.match(/\# noprocast start/) + hosts_file_content.match(/\# noprocrast start/) end def status_message - active? ? "noprocast enabled for #{current_hosts.size} hosts" : "noprocast disabled" + active? ? "noprocrast enabled for #{current_hosts.size} hosts" : "noprocrast disabled" end def backup_hosts_file_if_required! - unless File.exists?("/etc/.hosts.noprocastbackup") - FileUtils.cp("/etc/hosts", "/etc/.hosts.noprocastbackup") + unless File.exists?("/etc/.hosts.noprocrastbackup") + FileUtils.cp("/etc/hosts", "/etc/.hosts.noprocrastbackup") end end diff --git a/noprocast.gemspec b/noprocrast.gemspec similarity index 76% rename from noprocast.gemspec rename to noprocrast.gemspec index de197b2..99e3a2c 100644 --- a/noprocast.gemspec +++ b/noprocrast.gemspec @@ -4,16 +4,16 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| - s.name = %q{noprocast} - s.version = "0.1.4" + s.name = %q{noprocrast} + s.version = "0.1.6" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Rob Watson"] 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.email = %q{rfwatson@gmail.com} - s.executables = ["noprocast"] + s.executables = ["noprocrast"] s.extra_rdoc_files = [ "LICENSE", "README.md" @@ -25,20 +25,20 @@ Gem::Specification.new do |s| "README.md", "Rakefile", "VERSION", - "bin/noprocast", - "lib/noprocast.rb", - "noprocast.gemspec", - "spec/noprocast_spec.rb", + "bin/noprocrast", + "lib/noprocrast.rb", + "noprocrast.gemspec", + "spec/noprocrast_spec.rb", "spec/spec.opts", "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.require_paths = ["lib"] 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 = [ - "spec/noprocast_spec.rb", + "spec/noprocrast_spec.rb", "spec/spec_helper.rb" ] diff --git a/spec/noprocast_spec.rb b/spec/noprocrast_spec.rb similarity index 87% rename from spec/noprocast_spec.rb rename to spec/noprocrast_spec.rb index 423cdb1..3c022ed 100644 --- a/spec/noprocast_spec.rb +++ b/spec/noprocrast_spec.rb @@ -1,6 +1,6 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper') -describe "Noprocast" do +describe "Noprocrast" do it "fails" do fail "hey buddy, you should probably rename this file and start specing for real" end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 18a7b5c..0b5da63 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,6 @@ $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) -require 'noprocast' +require 'noprocrast' require 'spec' require 'spec/autorun'