changeset 3180:f43f91fbdce1

Tidied up code
author unexist
date Wed, 01 Feb 2012 13:53:40 +0100
parents 5f7a3ca7eae0
children 72af533a3bd3
files data/bin/subtler data/bin/sur data/bin/surserver data/sur/client.rb data/sur/runner.rb data/sur/server.rb data/sur/specification.rb data/sur/test.rb
diffstat 8 files changed, 175 insertions(+), 318 deletions(-) [+]
line wrap: on
line diff
--- a/data/bin/subtler	Tue Jan 31 21:03:36 2012 +0100
+++ b/data/bin/subtler	Wed Feb 01 13:53:40 2012 +0100
@@ -20,7 +20,7 @@
   # Check missing files
   if missing.match('subtle')
     puts <<-EOF
->>> ERROR: Couldn't find runtime files of subtler
+>>> ERROR: Cannot find runtime files of subtler
 >>>        Please make sure that you installed subtle into the
 >>>        current ruby environment (#{RUBY_VERSION})
       EOF
@@ -28,7 +28,7 @@
   end
 
   puts <<-EOF
->>> ERROR: Couldn't find the gem #{missing}
+>>> ERROR: Cannot find the gem #{missing}
 >>>        Please install it with following command:
 >>>        gem install #{missing}
     EOF
--- a/data/bin/sur	Tue Jan 31 21:03:36 2012 +0100
+++ b/data/bin/sur	Wed Feb 01 13:53:40 2012 +0100
@@ -22,11 +22,11 @@
   missing = error.to_s.split(" ").last
 
   # Check missing files
-  if("archive/tar/minitar" == missing)
+  if "archive/tar/minitar" == missing
     missing = "archive-tar-minitar"
-  elsif(missing.match("subtle"))
+  elsif missing.match("subtle")
     puts <<EOF
->>> ERROR: Couldn't find runtime files of sur
+>>> ERROR: Cannot find runtime files of sur
 >>>        Please make sure that you installed subtle into the
 >>>        current ruby environment (#{RUBY_VERSION})
 EOF
@@ -34,14 +34,14 @@
   end
 
   puts <<EOF
->>> ERROR: Couldn't find the gem `#{missing}'
+>>> ERROR: Cannot find the gem `#{missing}'
 >>>        Please install it with following command:
 >>>        gem install #{missing}
 EOF
 rescue => error
   puts ">>> ERROR: #{error}"
 
-  unless(error.is_a?(RuntimeError))
+  unless error.is_a?(RuntimeError)
     puts error.backtrace
   end
 end
--- a/data/bin/surserver	Tue Jan 31 21:03:36 2012 +0100
+++ b/data/bin/surserver	Wed Feb 01 13:53:40 2012 +0100
@@ -19,19 +19,19 @@
   missing = error.to_s.split(" ").last
 
   # Check missing files
-  if("archive/tar/minitar" == missing)
+  if "archive/tar/minitar" == missing
     missing = "archive-tar-minitar"
   end
 
   puts <<EOF
->>> ERROR: Couldn't find the gem #{missing}
+>>> ERROR: Cannot find the gem #{missing}
 >>>        Please install it with following command:
 >>>        gem install #{missing}
 EOF
 rescue => error
   puts ">>> ERROR: #{error}"
 
-  unless(error.is_a?(RuntimeError))
+  unless error.is_a?(RuntimeError)
     puts error.backtrace
   end
 end
--- a/data/sur/client.rb	Tue Jan 31 21:03:36 2012 +0100
+++ b/data/sur/client.rb	Wed Feb 01 13:53:40 2012 +0100
@@ -77,7 +77,7 @@
         # Create folders
         [ xdg_cache_home, xdg_data_home, @path_icons,
             @path_specs, @path_sublets ].each do |p|
-          FileUtils.mkdir_p([ p ]) unless(File.exist?(p))
+          FileUtils.mkdir_p([ p ]) unless File.exist?(p)
         end
       end # }}}
 
@@ -99,7 +99,7 @@
         build_remote
 
         # Check if sublet exists
-        if((specs = search(name, @cache_remote, version, false)) and specs.empty?)
+        if (specs = search(name, @cache_remote, version, false)) and specs.empty?
           raise "Sublet `#{name}' does not exist"
         end
 
@@ -112,7 +112,7 @@
           }
         )
 
-        raise "Couldn't annotate sublet: Sublet not found" if(404 == res.code)
+        raise "Cannot annotate sublet: Sublet not found" if 404 == res.code
       end # }}}
 
       ## Sur::Client::build {{{
@@ -132,7 +132,7 @@
         spec = Sur::Specification.load_spec(file)
 
         # Check specification
-        if(spec.valid?)
+        if spec.valid?
           begin
             sublet = "%s-%s.sublet" % [
               File.join(Dir.pwd, spec.name.downcase),
@@ -142,15 +142,15 @@
 
             # Check if files exist
             (spec.files | spec.icons).each do |f|
-              unless(File.exist?(File.join(File.dirname(file), f)))
-                raise "Couldn't find file `#{f}'"
+              unless File.exist?(File.join(File.dirname(file), f))
+                raise "Cannot find file `#{f}'"
               end
             end
 
             # Check gem version
-            unless(spec.dependencies.empty?)
+            unless spec.dependencies.empty?
               spec.dependencies.each do |name, version|
-                if(version.match(/^(\d*\.){1,2}\d*$/))
+                if version.match(/^(\d*\.){1,2}\d*$/)
                   puts ">>> WARNING: Gem dependency `%s' " \
                        "requires exact gem version (=%s)" % [ name, version ]
                 end
@@ -208,7 +208,7 @@
         build_local
 
         # Check if sublet is installed
-        if((specs = search(name, @cache_local)) and !specs.empty?)
+        if (specs = search(name, @cache_local)) and !specs.empty?
           spec = specs.first
 
           show_config(spec, use_color)
@@ -236,9 +236,9 @@
         # Install all sublets
         names.each do |name|
           # Check if remote sublet exists
-          if((specs = search(name, @cache_remote, version, use_tags)) and
-              specs.empty?)
-            puts ">>> WARNING: Couldn't find sublet `#{name}' " \
+          if (specs = search(name, @cache_remote, version, use_tags)) and
+              specs.empty?
+            puts ">>> WARNING: Cannot find sublet `#{name}' " \
                  "in remote repository"
 
             next
@@ -247,7 +247,7 @@
           spec = specs.first
 
           # Download and copy sublet to current directory
-          unless((temp = download(spec)).nil?)
+          unless (temp = download(spec)).nil?
             FileUtils.cp(temp.path,
               File.join(
                 Dir.getwd,
@@ -276,7 +276,7 @@
         build_local
 
         # Check if sublet is installed
-        if((specs = search(name, @cache_local)) and !specs.empty?)
+        if (specs = search(name, @cache_local)) and !specs.empty?
           spec = specs.first
 
           show_grabs(spec, use_color)
@@ -304,7 +304,7 @@
         # Show info for all sublets
         names.each do |name|
           # Check if sublet is installed
-          if((specs = search(name, @cache_local)) and !specs.empty?)
+          if (specs = search(name, @cache_local)) and !specs.empty?
             spec = specs.first
 
             show_info(spec, use_color)
@@ -335,24 +335,24 @@
         # Install all sublets
         names.each do |name|
           # Check if sublet is already installed
-          if((specs = search(name, @cache_local, version, use_tags)) and
-              !specs.empty?)
+          if (specs = search(name, @cache_local, version, use_tags)) and
+              !specs.empty?
             puts ">>> WARNING: Sublet `#{name}' is already installed"
 
             next
           end
 
           # Check if sublet is local
-          if(File.exist?(name))
+          if File.exist?(name)
             install_sublet(name)
 
             next
           end
 
           # Check if remote sublet exists
-          if((specs = search(name, @cache_remote, version, use_tags)) and
-              specs.empty?)
-            puts ">>> WARNING: Couldn't find sublet `#{name}' " \
+          if (specs = search(name, @cache_remote, version, use_tags)) and
+              specs.empty?
+            puts ">>> WARNING: Cannot find sublet `#{name}' " \
                  "in remote repository"
 
             next
@@ -360,17 +360,17 @@
 
           # Check dependencies
           spec = specs.first
-          next unless(spec.satisfied?)
+          next unless spec.satisfied?
 
           # Download and install sublet
-          unless((temp = download(spec)).nil?)
+          unless (temp = download(spec)).nil?
             install_sublet(temp.path)
           end
         end
 
         build_local(true)
 
-        reload_sublets if(reload)
+        reload_sublets if reload
       end # }}}
 
       ## Sur::Client::list {{{
@@ -416,7 +416,7 @@
         build_local
 
         # Check if sublet is installed
-        if((specs = search(name, @cache_local)) and !specs.empty?)
+        if (specs = search(name, @cache_local)) and !specs.empty?
           spec = specs.first
 
           show_notes(spec)
@@ -444,16 +444,16 @@
         case repo
           when "local"
             build_local
-            unless((specs = search(query, @cache_local, version,
-                use_regex, use_tags)) and !specs.empty?)
-              raise "Couldn't find `#{query}' in local repository"
+            unless (specs = search(query, @cache_local, version,
+                use_regex, use_tags)) and !specs.empty?
+              raise "Cannot find `#{query}' in local repository"
             end
           when "remote"
             build_local
             build_remote
-            unless((specs = search(query, @cache_remote, version,
-                use_regex, use_tags)) and !specs.empty?)
-              raise "Couldn't find `#{query}' in remote repository"
+            unless (specs = search(query, @cache_remote, version,
+                use_regex, use_tags)) and !specs.empty?
+              raise "Cannot find `#{query}' in remote repository"
             end
         end
 
@@ -484,7 +484,7 @@
               a = File.basename(f)
               b = File.basename(sf)
 
-              if(a == b || File.fnmatch("[0-9_]*#{b}", a))
+              if a == b or File.fnmatch("[0-9_]*#{b}", a)
                 list.push([ s.name.downcase, a])
               end
             end
@@ -500,7 +500,7 @@
         line = STDIN.readline
         i    = 0
 
-        if("\n" != line)
+        if "\n" != line
           line.split(" ").each do |tok|
             idx = tok.to_i
 
@@ -510,7 +510,7 @@
             new_path  = '%s/%d_%s.rb' % [ @path_sublets, i, name ]
 
             # Check if file exists before moving
-            unless(File.exist?(new_path))
+            unless File.exist?(new_path)
               FileUtils.mv(File.join(@path_sublets, file), new_path)
             end
           end
@@ -532,17 +532,17 @@
       #   => nil
 
       def submit(file)
-        if(!file.nil? and File.file?(file) and ".sublet" == File.extname(file))
+        if !file.nil? and File.file?(file) and ".sublet" == File.extname(file)
           spec = Sur::Specification.extract_spec(file)
 
-          if(spec.valid?)
+          if spec.valid?
             upload(file)
             build_remote(true)
           else
             spec.validate
           end
         else
-          raise "Couldn't find file `#{file}'"
+          raise "Cannot find file `#{file}'"
         end
       end # }}}
 
@@ -567,8 +567,8 @@
         # Install all sublets
         names.each do |name|
           # Check if sublet is installed
-          if((specs = search(name, @cache_local, version, use_tags)) and
-              !specs.empty?)
+          if (specs = search(name, @cache_local, version, use_tags)) and
+              !specs.empty?
             spec = specs.first
 
             # Uninstall files
@@ -578,7 +578,7 @@
                 a = File.basename(f)
                 b = File.basename(file)
 
-                if(a == b || File.fnmatch("[0-9_]*#{a}", b))
+                if a == b or File.fnmatch("[0-9_]*#{a}", b)
                   puts ">>>>>> Uninstalling file `#{b}'"
                   FileUtils.remove_file(File.join(@path_sublets, b), true)
                 end
@@ -602,14 +602,14 @@
 
             puts ">>> Uninstalled sublet #{spec.to_s}"
           else
-            puts ">>> WARNING: Couldn't find sublet `#{name}' in local " \
+            puts ">>> WARNING: Cannot find sublet `#{name}' in local " \
                  "repository"
           end
         end
 
         build_local(true)
 
-        reload_sublets if(reload)
+        reload_sublets if reload
       end # }}}
 
       ## Sur::Client::unpack {{{
@@ -632,12 +632,12 @@
         # Install all sublets
         names.each do |name|
           # Check if sublet is installed
-          if((specs = search(name, @cache_remote, version, use_tags)) and
-              !specs.empty?)
+          if (specs = search(name, @cache_remote, version, use_tags)) and
+              !specs.empty?
             spec = specs.first
 
             # Download and unpack sublet
-            unless((temp = download(spec)).nil?)
+            unless (temp = download(spec)).nil?
               base  = File.join(Dir.pwd, spec.to_str)
               icons = File.join(base, "icons")
 
@@ -694,11 +694,11 @@
         # Iterate over server-side sorted list
         @cache_local.each do |spec_a|
           @cache_remote.each do |spec_b|
-            if(spec_a.name == spec_b.name and
-                spec_a.version.to_f < spec_b.version.to_f)
+            if spec_a.name == spec_b.name and
+                spec_a.version.to_f < spec_b.version.to_f
               list << spec_b.name
 
-              if(use_color)
+              if use_color
                 puts ">>> %s: %s -> %s" % [
                   spec_a.name,
                   colorize(5, spec_a.version),
@@ -715,20 +715,20 @@
           end
         end
 
-        return if(list.empty?)
+        return if list.empty?
 
         # Really?
-        unless(assume)
+        unless assume
           print ">>> Upgrade sublets (y/n)? "
 
-          return unless("y" == STDIN.readline.strip.downcase)
+          return unless "y" == STDIN.readline.strip.downcase
         end
 
         # Finally upgrade
         uninstall(list)
         install(list)
 
-        reload_sublets if(reload)
+        reload_sublets if reload
       end # }}}
 
       ## Sur::Client::yank {{{
@@ -753,8 +753,8 @@
       def see_also(spec) # {{{
         also = [ "info", "config" ]
 
-        also << "notes" unless(spec.notes.nil?)
-        also << "grabs" unless(spec.grabs.nil?)
+        also << "notes" unless spec.notes.nil?
+        also << "grabs" unless spec.grabs.nil?
 
         puts "See also: #{also.join(", ")}"
       end # }}}
@@ -781,15 +781,15 @@
         req["Content-Type"] = "multipart/form-data; boundary=#{BOUNDARY}"
 
         # Check result
-        case(http.request(req).code.to_i)
+        case http.request(req).code.to_i
           when 200
              puts ">>> Submitted sublet `#{base}'"
 
             build_remote
-          when 405 then raise "Couldn't submit sublet: Invalid request"
-          when 415 then raise "Couldn't submit sublet: Invalid Spec"
-          when 500 then raise "Couldn't submit sublet: Server error"
-          else raise "Couldn't submit sublet"
+          when 405 then raise "Cannot submit sublet: Invalid request"
+          when 415 then raise "Cannot submit sublet: Invalid Spec"
+          when 500 then raise "Cannot submit sublet: Server error"
+          else raise "Cannot submit sublet"
         end
       end # }}}
 
@@ -809,7 +809,7 @@
         # Fetch file
         http.request_get("/get/" + spec.digest) do |response|
           # Check result
-          case(response.code.to_i)
+          case response.code.to_i
             when 200
               total = 0
 
@@ -826,8 +826,8 @@
               end
 
               temp.close
-            when 404 then raise "Couldn't download sublet: Sublet not found"
-            else raise "Couldn't download sublet: Server error"
+            when 404 then raise "Cannot download sublet: Sublet not found"
+            else raise "Cannot download sublet: Server error"
           end
         end
 
@@ -837,7 +837,7 @@
       end # }}}
 
       def progress(mesg, total, now) # {{{
-        if(0.0 < total)
+        if 0.0 < total
           percent = (now.to_f * 100 / total.to_f).floor
 
           $stdout.sync = true
@@ -851,11 +851,11 @@
 
         # Search in repo
         repo.each do |s|
-          if(!query.nil? and (s.name.downcase == query.downcase ||
-              (use_regex and s.name.downcase.match(query)) ||
-              (use_tags  and s.tags.include?(query.capitalize))))
+          if !query.nil? and (s.name.downcase == query.downcase or
+              (use_regex and s.name.downcase.match(query)) or
+              (use_tags  and s.tags.include?(query.capitalize)))
             # Check version?
-            if(version.nil? || s.version == version)
+            if version.nil? or s.version == version
               results.push(s)
             end
           end
@@ -875,7 +875,7 @@
         @cache_local = []
 
         # Load local cache
-        if(!force and File.exist?(@path_local))
+        if !force and File.exist?(@path_local)
           yaml = YAML::load(File.open(@path_local))
 
           @cache_local = YAML::load(yaml)
@@ -889,14 +889,14 @@
             spec = Sur::Specification.load_spec(file)
 
             # Validate
-            if(spec.valid?)
+            if spec.valid?
               spec.path = file
               @cache_local.push(spec)
             else
               spec.validate
             end
           rescue
-            puts ">>> WARNING: Couldn't parse specification `#{file}'"
+            puts ">>> WARNING: Cannot parse specification `#{file}'"
           end
         end
 
@@ -917,8 +917,8 @@
         http          = Net::HTTP.new(uri.host, uri.port)
 
         # Check age of cache
-        if(!force and File.exist?(@path_remote) and
-            86400 > (Time.now - File.new(@path_remote).ctime))
+        if !force and File.exist?(@path_remote) and
+            86400 > (Time.now - File.new(@path_remote).ctime)
           yaml = YAML::load(File.open(@path_remote))
 
           @cache_remote = YAML::load(yaml)
@@ -929,7 +929,7 @@
         # Fetch file
         http.request_get("/list") do |response|
           # Check result
-          case(response.code.to_i)
+          case response.code.to_i
             when 200
               total = 0
               data  = ""
@@ -958,7 +958,7 @@
               end
 
               puts ">>> Updated remote cache with #{@cache_remote.size} entries"
-            else raise "Couldn't download sublet list: Server error"
+            else raise "Cannot download sublet list: Server error"
           end
         end
       end # }}}
@@ -967,26 +967,26 @@
         list = []
 
         # Skip if specs list is empty
-        if(specs.any?)
+        if specs.any?
           prev = nil
 
           specs.sort { |a, b| [ a.name, a.version ] <=> [ b.name, b.version ] }.reverse!
 
           # Compress versions
           specs.each do |s|
-            if(!prev.nil? and prev.name == s.name)
-              if(prev.version.is_a?(Array))
+            if !prev.nil? and prev.name == s.name
+              if prev.version.is_a?(Array)
                 prev.version << s.version
               else
                 prev.version = [ prev.version, s.version ]
               end
             else
-              list << prev unless(prev.nil?)
+              list << prev unless prev.nil?
               prev = s
             end
           end
 
-          list << prev unless(prev.nil? and prev.name == s.name)
+          list << prev unless prev.nil? and prev.name == s.name
         end
 
         list
@@ -1000,7 +1000,7 @@
           # Find if installed
           installed = ""
           @cache_local.each do |cs|
-            if(cs.name == s.name)
+            if cs.name == s.name
               installed = "[%s installed]" % [ cs.version ]
               break
             end
@@ -1010,7 +1010,7 @@
           version = s.version.is_a?(Array) ? s.version.join(", ") : s.version
 
           # Do we like colors?
-          if(use_color)
+          if use_color
             puts "%s %s (%s) %s" % [
               colorize(2, i.to_s, false, :bg),
               colorize(1, s.name.downcase, true),
@@ -1019,14 +1019,14 @@
             ]
             puts "   %s" % [ s.description ]
 
-            unless(s.tags.empty?)
+            unless s.tags.empty?
               puts "   %s" % [ s.tags.map { |t| colorize(5, "##{t}") }.join(" ") ]
             end
           else
             puts "(%d) %s (%s) %s" % [ i, s.name.downcase, version, installed ]
             puts "   %s" % [ s.description ]
 
-            unless(s.tags.empty?)
+            unless s.tags.empty?
               puts "   %s" % [ s.tags.map { |t| "##{t}" }.join(" ") ]
             end
           end
@@ -1036,7 +1036,7 @@
       end # }}}
 
       def show_notes(spec) # {{{
-        unless(spec.notes.nil? or spec.notes.empty?)
+        unless spec.notes.nil? or spec.notes.empty?
           puts
           puts spec.notes
           puts
@@ -1044,7 +1044,7 @@
       end # }}}
 
       def show_config(spec, use_color) # {{{
-        unless(spec.nil?)
+        unless spec.nil?
           puts
 
           # Add default config settings
@@ -1065,7 +1065,7 @@
           ]
 
           # Merge configs
-          unless(spec.config.nil?)
+          unless spec.config.nil?
             skip = []
 
             spec.config.each do |c|
@@ -1081,7 +1081,7 @@
           end
 
           # Header
-          if(use_color)
+          if use_color
             puts "%-24s  %-19s  %-39s  %s" % [
               colorize(1, "Name", true),
               colorize(1, "Type", true),
@@ -1096,7 +1096,7 @@
 
           # Dump all settings
           config.each do |c|
-            if(use_color)
+            if use_color
               puts "%-25s  %-20s  %-40s  %s" % [
                 colorize(2, c[:name][0..24]).ljust(25),
                 colorize(5, c[:type][0..19]).ljust(20),
@@ -1118,11 +1118,11 @@
       end # }}}
 
       def show_grabs(spec, use_color) # {{{
-        unless(spec.nil? or spec.grabs.nil? or spec.grabs.empty?)
+        unless spec.nil? or spec.grabs.nil? or spec.grabs.empty?
           puts
 
           # Header
-          if(use_color)
+          if use_color
             puts "%-24s  %s" % [
               colorize(1, "Name", true),
               colorize(1, "Description", true)
@@ -1135,7 +1135,7 @@
 
           # Dump all settings
           spec.grabs.each do |k, v|
-            if(use_color)
+            if use_color
               puts "%-25s  %s" % [
                 colorize(2, k[0..24]).ljust(25), v
               ]
@@ -1151,15 +1151,15 @@
       end # }}}
 
       def show_info(spec, use_color) # {{{
-        unless(spec.nil?)
+        unless spec.nil?
           authors = spec.authors.join(", ")
           tags    = spec.tags.map { |t| "##{t}" }.join(" ")
           files   = spec.files.join(", ")
           icons   = spec.icons.map { |i| File.basename(i) }.join(", ")
           deps    = spec.dependencies.map { |k, v| "#{k} (#{v})" }.join(", ")
 
-          if(use_color)
-            puts <<EOF
+          if use_color
+            puts <<-EOF
 
 #{colorize(1, "Name:", true)}     #{spec.name}
 #{colorize(1, "Version:", true)}  #{colorize(2, spec.version)}
@@ -1170,9 +1170,9 @@
 #{colorize(1, "Icons:", true)}    #{icons}
 #{colorize(1, "Deps:", true)}     #{spec.dependencies.map { |k, v| "#{k} (#{colorize(2, v)})" }.join(", ")}
 
-EOF
+            EOF
           else
-            puts <<EOF
+            puts <<-EOF
 
 Name:     #{spec.name}
 Version:  #{spec.version}
@@ -1183,7 +1183,7 @@
 Icons:    #{icons}
 Deps:     #{spec.dependencies.map { |k, v| "#{k} (#{v})" }.join(", ")}
 
-EOF
+            EOF
           end
         end
       end # }}}
@@ -1196,7 +1196,7 @@
         File.open(sublet, "rb") do |input|
           Archive::Tar::Minitar::Input.open(input) do |tar|
             tar.each do |entry|
-              case(File.extname(entry.full_name))
+              case File.extname(entry.full_name)
                 when ".spec" then
                   puts ">>>>>> Installing specification `#{spec.to_s}.spec'"
                   path = File.join(specs, spec.to_s + ".spec")
@@ -1227,7 +1227,7 @@
 
           Subtlext::Subtle.reload
         rescue
-          raise "Couldn't reload sublets"
+          raise "Cannot reload sublets"
         end
       end # }}}
     end # }}}
--- a/data/sur/runner.rb	Tue Jan 31 21:03:36 2012 +0100
+++ b/data/sur/runner.rb	Wed Feb 01 13:53:40 2012 +0100
@@ -85,49 +85,49 @@
 
           args = no_opt
         rescue
-          raise "Couldn't find required arguments"
+          raise "Cannot find required arguments"
         end
 
         # Run
         cmd  = args.shift
         case cmd
           when "annotate"
-            usage(cmd) if(args.empty?)
+            usage(cmd) if args.empty?
 
             Subtle::Sur::Client.new.annotate(args.first, @version)
           when "build"
-            usage(cmd) if(args.empty?)
+            usage(cmd) if args.empty?
 
             Subtle::Sur::Client.new.build(args.first)
           when "config"
-            usage(cmd) if(args.empty?)
+            usage(cmd) if args.empty?
 
             Subtle::Sur::Client.new.config(args.first, @use_color)
           when "fetch"
-            usage(cmd) if(args.empty?)
+            usage(cmd) if args.empty?
 
             Subtle::Sur::Client.new.fetch(args, @version, @use_tags)
           when "grabs"
-            usage(cmd) if(args.empty?)
+            usage(cmd) if args.empty?
 
             Subtle::Sur::Client.new.grabs(args.first, @use_color)
           when "help" then usage(nil)
           when "info"
-            usage(cmd) if(args.empty?)
+            usage(cmd) if args.empty?
 
             Sur::Client.new.info(args, @use_color)
           when "install"
-            usage(cmd) if(args.empty?)
+            usage(cmd) if args.empty?
 
             Sur::Client.new.install(args, @version, @use_tags, @reload)
           when "list"
             Subtle::Sur::Client.new.list(@repo, @use_color)
           when "notes"
-            usage(cmd) if(args.empty?)
+            usage(cmd) if args.empty?
 
             Subtle::Sur::Client.new.notes(args.first)
           when "query"
-            usage(cmd) if(args.empty?)
+            usage(cmd) if args.empty?
 
             Subtle::Sur::Client.new.query(args.first, @repo,
               @version, @use_regex, @use_tags, @use_color
@@ -139,21 +139,21 @@
 
             Sur::Server.new(@port).run
           when "submit"
-            usage(cmd) if(args.empty?)
+            usage(cmd) if args.empty?
 
             Subtle::Sur::Client.new.submit(args.first)
           when "template"
-            usage(cmd) if(args.empty?)
+            usage(cmd) if args.empty?
 
             Subtle::Sur::Specification.template(args.first)
           when "test"
-            usage(cmd) if(args.empty?)
+            usage(cmd) if args.empty?
 
             require "subtle/sur/test"
 
             Subtle::Sur::Test.run(@config, args)
           when "uninstall"
-            usage(cmd) if(args.empty?)
+            usage(cmd) if args.empty?
 
             Subtle::Sur::Client.new.uninstall(args,
               @version, @use_tags, @reload)
@@ -166,7 +166,7 @@
             Subtle::Sur::Client.new.upgrade(@use_color, @assume, @reload)
           when "version" then version
           when "yank"
-            usage(cmd) if(args.empty?)
+            usage(cmd) if args.empty?
 
             Subtle::Sur::Client.new.update(args.first, @version)
           else usage(nil)
--- a/data/sur/server.rb	Tue Jan 31 21:03:36 2012 +0100
+++ b/data/sur/server.rb	Wed Feb 01 13:53:40 2012 +0100
@@ -147,8 +147,8 @@
         #DataMapper::Model.raise_on_save_failure = true
 
         # Create database and store
-        DataMapper.auto_migrate!  unless(File.exists?(DATABASE))
-        Dir.mkdir(REPOSITORY)     unless(File.exists?(REPOSITORY))
+        DataMapper.auto_migrate!  unless File.exists?(DATABASE)
+        Dir.mkdir(REPOSITORY)     unless File.exists?(REPOSITORY)
 
         # Configure sinatra application
         set :port, port
@@ -212,7 +212,7 @@
             sublets = []
 
             # Find sublets in interval
-            if(2 == args.size)
+            if 2 == args.size
               Sur::Model::Sublet.all(
                   :created_at.gte => Time.at(args[0]),
                   :created_at.lte => Time.at(args[1])
@@ -391,7 +391,7 @@
     %span.italic= @tag
 
   %ul
-    -if(!@list.nil?)
+    -if !@list.nil?
       -@list.each do |s|
         %li
           %a#download{:href => "/get/%s" % [ s.digest ] }
@@ -455,30 +455,7 @@
           haml(:index)
         end # }}}
 
-        get "/get/:digest" do # {{{
-          if((s = Sur::Model::Sublet.first(:digest => params[:digest])))
-            # Increment count
-            s.downloads = s.downloads + 1
-            s.save
 
-            # Send requested file
-            send_file(File.join(REPOSITORY, s.path),
-              :type     => "application/x-tar",
-              :filename => File.basename(s.path)
-            )
-          else
-            halt 404
-          end
-        end # }}}
-
-        get "/list" do # {{{
-          # Check cache age
-          if(!File.exist?(CACHE) or (86400 < (Time.now - File.new(CACHE).ctime)))
-            build_cache
-          end
-
-          send_file(CACHE, :type => "text/plain", :last_modified => File.new(CACHE).ctime)
-        end # }}}
 
         get "/tag/:tag" do # {{{
           @tag  = params[:tag].capitalize
@@ -505,7 +482,7 @@
         end # }}}
 
         post "/annotate" do # {{{
-          if((s = Sur::Model::Sublet.first(:digest => params[:digest])))
+          if (s = Sur::Model::Sublet.first(:digest => params[:digest]))
             # Find or create user
             u = Sur::Model::User.first_or_create(
               { :name       => params[:user] },
@@ -525,131 +502,11 @@
 
             puts ">>> Added annotation from `#{u.name}` for `#{s.name}'"
           else
-            puts ">>> WARNING: Couldn't find sublet with digest `#{params[:digest]}`"
+            puts ">>> WARNING: Cannot find sublet with digest `#{params[:digest]}`"
             halt 404
           end
         end # }}}
 
-        post "/submit" do # {{{
-          # Check if required params are available
-          if(params[:file] and params[:file][:tempfile] and params[:user])
-            file = params[:file][:tempfile]
-
-            # Validate spec
-            spec = Sur::Specification.extract_spec(file.path)
-            halt 415 unless(spec.valid?)
-
-            begin
-              # Create or find sublet
-              s = Sur::Model::Sublet.first_or_create(
-                { :name => spec.name, :version => spec.version },
-                {
-                  :contact     => spec.contact,
-                  :description => spec.description,
-                  :date        => spec.date,
-                  :path        => spec.to_s + ".sublet",
-                  :digest      => Digest::MD5.hexdigest(File.read(file.path)),
-                  :ip          => request.env["REMOTE_ADDR"][/.[^,]+/],
-                  :required    => spec.required_version,
-                  :created_at  => Time.now
-                }
-              )
-
-              # Create or find user
-              u = Sur::Model::User.first_or_create(
-                { :name       => params[:user] },
-                { :created_at => Time.now      }
-              )
-
-              # Parse authors
-              spec.authors.each do |user|
-                # Check if user exists
-                u = Sur::Model::User.first_or_create(
-                  { :name       => user     },
-                  { :created_at => Time.now }
-                )
-
-                # Find or create assoc
-                assoc = Sur::Model::Assoc::Author.first_or_create(
-                  { :user_id    => u.id, :sublet_id => s.id },
-                  { :created_at => Time.now                 }
-                )
-              end
-
-              # Parse tags
-              spec.tags.each do |tag|
-                # Find or create tag
-                t = Sur::Model::Tag.first_or_create(
-                  { :name       => tag      },
-                  { :created_at => Time.now }
-                )
-
-                # Find or create assoc
-                assoc = Sur::Model::Assoc::Tag.first_or_create(
-                  { :tag_id     => t.id, :sublet_id => s.id },
-                  { :created_at => Time.now                 }
-                )
-              end
-            rescue => error
-              p error
-              halt 500
-            end
-
-            # Copy file and update cache
-            begin
-              FileUtils.copy(file.path, File.join(REPOSITORY, s.path))
-              build_cache
-            rescue => error
-              p error
-              halt 500
-            end
-
-            # Post via identi.ca
-            unless(USERNAME.empty? or PASSWORD.empty?)
-              uri = URI.parse("http://identi.ca/api/statuses/update.xml")
-
-              # Create request
-              req = Net::HTTP::Post.new(uri.path)
-              req.basic_auth(USERNAME, PASSWORD)
-              req.set_form_data(
-                {
-                  "status" => "New sublet: %s (%s) !subtle" % [
-                    spec.name, spec.version
-                  ]
-                }, ";"
-              )
-
-              # Finally send request
-              Net::HTTP.new(uri.host).start { |http| http.request(req) }
-            end
-
-            halt 200
-          else
-            halt 405
-          end
-        end # }}}
-
-        post "/xmlrpc" do # {{{
-          xml = @request.body.read
-
-          if(xml.empty?)
-            error = 400
-            return
-          end
-
-          # Parse xml
-          method, arguments = XMLRPC::Marshal.load_call(xml)
-          method = method.gsub(/([A-Z])/, '_\1').downcase
-
-          # Check if method exists
-          if(respond_to?(method))
-            content_type("text/xml", :charset => "utf-8")
-            send(method, arguments)
-          else
-            error = 404
-          end
-        end # }}}
-
         Sinatra::Application.run!
       end # }}}
     end # }}}
--- a/data/sur/specification.rb	Tue Jan 31 21:03:36 2012 +0100
+++ b/data/sur/specification.rb	Wed Feb 01 13:53:40 2012 +0100
@@ -88,7 +88,7 @@
         @path             = Dir.pwd
 
         # Pass to block
-        yield(self) if(block_given?)
+        yield(self) if block_given?
       end # }}}
 
       ## Subtle::Sur::Specification::load_spec {{{
@@ -117,9 +117,9 @@
         end
 
         # Check object
-        if(spec.nil? || !spec.is_a?(Specification))
-          raise "Can't extract specification from file `#{file}'"
-        elsif(!spec.valid?)
+        if spec.nil? or !spec.is_a?(Specification)
+          raise "Cannot read specification file `#{file}'"
+        elsif !spec.valid?
           raise spec.validate
         end
 
@@ -147,7 +147,7 @@
           File.open(file, "rb") do |input|
             Archive::Tar::Minitar::Input.open(input) do |tar|
               tar.each do |entry|
-                if(".spec" == File.extname(entry.full_name))
+                if ".spec" == File.extname(entry.full_name)
                   spec = eval(entry.read)
                 end
               end
@@ -158,9 +158,9 @@
         end
 
         # Check object
-        if(spec.nil? || !spec.is_a?(Specification))
-          raise "Can't extract specification from file `#{file}'"
-        elsif(!spec.valid?)
+        if spec.nil? or !spec.is_a?(Specification)
+          raise "Cannot extract specification from file `#{file}'"
+        elsif !spec.valid?
           raise spec.validate
         end
 
@@ -190,7 +190,7 @@
         spec    = File.join(folder, name + ".spec")
         sublet  = File.join(folder, name + ".rb")
 
-        unless(File.exist?(name))
+        unless File.exist?(name)
           FileUtils.mkdir_p([ folder ])
 
           # Create spec
@@ -273,8 +273,8 @@
       #   => true
 
       def valid?
-        (!@name.nil? && !@authors.empty? && !@contact.nil? && \
-          !@description.nil? && !@version.nil? && !@files.empty?)
+        (!@name.nil? and !@authors.empty? and !@contact.nil? and \
+          !@description.nil? and !@version.nil? and !@files.empty?)
       end # }}}
 
       ## Subtle::Sur::Specification::validate {{{
@@ -298,7 +298,7 @@
         fields.push("version")     if(@version.nil?)
         fields.push("files")       if(@files.empty?)
 
-        unless(fields.empty?)
+        unless fields.empty?
           raise SpecificationValidationError,
             "Couldn't find `#{fields.join(", ")}' in specification"
         end
@@ -337,7 +337,7 @@
         missing   = []
 
         # Check subtlext version
-        unless(@required_version.nil?)
+        unless @required_version.nil?
           begin
             require "subtle/subtlext"
 
@@ -375,7 +375,7 @@
         end
 
         # Dump errors
-        unless(satisfied_version or satisfied_deps)
+        unless satisfied_version or satisfied_deps
           puts ">>> ERROR: Couldn't install `#{@name}' due to unsatisfied requirements."
 
           unless(satisfied_version)
@@ -417,7 +417,7 @@
         ret = nil
 
         # Check if symbol is a method or a var
-        if(self.respond_to?(meth))
+        if self.respond_to?(meth)
           ret = self.send(meth, args)
         else
           sym = ("@" + meth.to_s).to_sym #< Construct symbol
--- a/data/sur/test.rb	Tue Jan 31 21:03:36 2012 +0100
+++ b/data/sur/test.rb	Wed Feb 01 13:53:40 2012 +0100
@@ -89,17 +89,17 @@
           ret = nil
 
           # Check if symbol is a method or a var
-          if(self.respond_to?(meth))
+          if self.respond_to?(meth)
             ret = self.send(meth, args)
           else
             sym = ("@" + meth.to_s).to_sym #< Construct symbol
 
             # Check getter or setter
-            if(meth.to_s.index("="))
+            if meth.to_s.index("=")
               sym = sym.to_s.chop.to_sym
 
               self.instance_variable_set(sym, args.first)
-            elsif(self.instance_variable_defined?(sym))
+            elsif self.instance_variable_defined?(sym)
               ret = self.instance_variable_get(sym)
             end
           end
@@ -135,7 +135,7 @@
         #   => nil
 
         def interval=(interval)
-          raise ArgumentError.new("Unknown value type") unless(interval.is_a?(Fixnum))
+          raise ArgumentError.new("Unknown value type") unless interval.is_a?(Fixnum)
           @interval = interval
         end # }}}
 
@@ -167,7 +167,7 @@
         #   => nil
 
         def data=(data)
-          raise ArgumentError.new("Unknown value type") unless(data.is_a?(String))
+          raise ArgumentError.new("Unknown value type") unless data.is_a?(String)
           @data = data
         end # }}}
 
@@ -184,7 +184,7 @@
         #   => nil
 
         def background=(value)
-          unless(value.is_a?(String) or value.is_a?(Object))
+          unless value.is_a?(String) or value.is_a?(Object)
             raise ArgumentError.new("Unknown value type") 
           end
         end # }}}
@@ -216,8 +216,8 @@
         #   => nil
 
         def watch(path)
-          raise ArgumentError.new("Unknown value type") unless(path.is_a?(String))
-          raise "File not found" unless(File.exist?(path))
+          raise ArgumentError.new("Unknown value type") unless path.is_a?(String)
+          raise "File not found" unless File.exist?(path)
           @path = path
         end # }}}
 
@@ -289,8 +289,8 @@
         #   end
 
         def configure(name, &blk)
-          raise LocalJumpError.new("No block given") unless(block_given?)
-          raise ArgumentError.new("Unknown value type") unless(name.is_a?(Symbol))
+          raise LocalJumpError.new("No block given") unless block_given?
+          raise ArgumentError.new("Unknown value type") unless name.is_a?(Symbol)
 
           @name = name
 
@@ -314,18 +314,18 @@
         #   end
 
         def on(event, &blk)
-          raise LocalJumpError.new("No block given") unless(block_given?)
-          raise ArgumentError.new("Unknown value type") unless(event.is_a?(Symbol))
+          raise LocalJumpError.new("No block given") unless block_given?
+          raise ArgumentError.new("Unknown value type") unless event.is_a?(Symbol)
 
           # Get proc information
           arity = blk.arity
           sing  = self.class
 
           # Check events
-          if(Subtle::Sur::Test::Sublet::EVENTS.has_key?(event))
+          if Subtle::Sur::Test::Sublet::EVENTS.has_key?(event)
             need = Subtle::Sur::Test::Sublet::EVENTS[event]
 
-            if(-1 == arity || (1 <= arity && need >= arity))
+            if -1 == arity or (1 <= arity and need >= arity)
               sing.send(:define_method, ("__%s" % [ event ]).to_sym, blk)
             else
               raise "Wrong number of arguments (%d for %d)" % [ arity, need ]
@@ -333,7 +333,7 @@
           end
 
           # Check hooks
-          if(Subtle::Sur::Test::Sublet::HOOKS.include?(event))
+          if Subtle::Sur::Test::Sublet::HOOKS.include?(event)
             sing.send(:define_method, ("__%s" % [ event ]).to_sym, blk)
           end
         end # }}}
@@ -354,7 +354,7 @@
         #   end
 
         def helper(&blk)
-          raise LocalJumpError.new("No block given") unless(block_given?)
+          raise LocalJumpError.new("No block given") unless block_given?
 
           # Yield and eval block
           yield(self)
@@ -377,19 +377,19 @@
         ret = nil
 
         # Check if symbol is a method or a var
-        if(self.respond_to?(meth))
+        if self.respond_to?(meth)
           ret = self.send(meth, args)
         else
           sym = ("@" + meth.to_s).to_sym #< Construct symbol
 
           # Check getter or setter
-          if(meth.to_s.index("="))
+          if meth.to_s.index("=")
             sym = sym.to_s.chop.to_sym
 
             self.instance_variable_set(sym, args.first)
           else
             ret = self.instance_variable_get(sym)
-            ret = self if(ret.nil?)
+            ret = self if ret.nil?
           end
         end
 
@@ -410,18 +410,18 @@
       def self.run(config, args)
         args.each do |arg|
           # Load sublet
-          if(File.exist?(arg))
+          if File.exist?(arg)
             begin
               sublet = Subtle::Sur::Test::Sublet.new
 
               # Eval sublet in anonymous module
               sublet.instance_eval(File.read(arg))
             rescue => err
-              puts ">>> WARNING: Couldn't load sublet: %s" % [
+              puts ">>> WARNING: Cannot load sublet: %s" % [
                 err.message
               ]
 
-              unless(error.is_a?(RuntimeError))
+              unless error.is_a?(RuntimeError)
                 puts error.backtrace
               end
 
@@ -429,7 +429,7 @@
             end
 
             # Check if sublet exists
-            unless(sublet.nil?)
+            unless sublet.nil?
               methods = []
               dummy   = Subtle::Sur::Test::Dummy.new
 
@@ -438,11 +438,11 @@
 
               # Configure and run sublet
               sublet.__configure(sublet)
-              sublet.__run(sublet) if(sublet.respond_to?(:__run))
+              sublet.__run(sublet) if sublet.respond_to?(:__run)
 
               # Sanitize
-              if(!sublet.instance_variable_defined?("@interval") or
-                  0 >= sublet.interval)
+              if !sublet.instance_variable_defined?("@interval") or
+                  0 >= sublet.interval
                 sublet.interval = 60
               end
 
@@ -450,7 +450,7 @@
               Subtle::Sur::Test::Sublet::EVENTS.each do |k, v|
                 name = ("__%s" % [ k ]).to_sym
 
-                if(sublet.respond_to?(name))
+                if sublet.respond_to?(name)
                   methods.push({
                     :name      => k,
                     :arity     => sublet.method(name).arity,
@@ -463,7 +463,7 @@
               Subtle::Sur::Test::Sublet::HOOKS.each do |k|
                 name = ("__%s" % [ k ]).to_sym
 
-                if(sublet.respond_to?(name))
+                if sublet.respond_to?(name)
                   methods.push({
                     :name      => k,
                     :arity     => sublet.method(name).arity,
@@ -513,7 +513,7 @@
                 num = STDIN.readline.to_i
 
                 begin
-                  if(0 < num && methods.size >= num)
+                  if 0 < num and methods.size >= num
                     meth = methods[num - 1]
                     name = meth[:singleton] ? meth[:name] :
                       ("__%s" % [ meth[:name] ]).to_sym
@@ -533,7 +533,7 @@
                 rescue => error
                   puts ">>> ERROR: #{error}"
 
-                  unless(error.is_a?(RuntimeError))
+                  unless error.is_a?(RuntimeError)
                     puts error.backtrace
                   end
                 end