gill 0.0.7 → 0.0.8
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.
- data/README.rdoc +22 -7
 - data/Rakefile +0 -1
 - data/gill.gemspec +2 -2
 - data/lib/gill/app.rb +44 -122
 - data/lib/gill/config.rb +21 -1
 - data/lib/gill/exceptions/error.rb +1 -1
 - data/lib/gill/git.rb +38 -3
 - data/lib/gill/remove.rb +18 -38
 - data/lib/gill/version.rb +1 -1
 - data/lib/gill.rb +174 -1
 - metadata +3 -3
 
    
        data/README.rdoc
    CHANGED
    
    | 
         @@ -1,5 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            = gill
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            *NOTICE: THIS IS BETA SOFTWARE!
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       3 
5 
     | 
    
         
             
            Gill is a simple Ruby app to help keep your git clones clean and organized. Gill creates a source directory (~/source) in the users home path were all cloned repos will be stored. The gill default source location can be changed at any time by simply editing the ".gillrc" in the users home directory.
         
     | 
| 
       4 
6 
     | 
    
         | 
| 
       5 
7 
     | 
    
         
             
            Files created by gill:
         
     | 
| 
         @@ -9,8 +11,6 @@ Files created by gill: 
     | 
|
| 
       9 
11 
     | 
    
         
             
            == Install
         
     | 
| 
       10 
12 
     | 
    
         | 
| 
       11 
13 
     | 
    
         
             
             gem install gill
         
     | 
| 
       12 
     | 
    
         
            -
             
         
     | 
| 
       13 
     | 
    
         
            -
            * NOTE: if you are using gill <= 0.0.3 please upgrade to version >= 0.0.6.
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
            == Example
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
         @@ -42,7 +42,7 @@ This will create a folder called 'rails' and clone the repo inside a folder call 
     | 
|
| 
       42 
42 
     | 
    
         
             
              gill http://github.com/jruby/jruby.git#jruby
         
     | 
| 
       43 
43 
     | 
    
         
             
              gill http://github.com/ronin-ruby/ronin.git#security#ronin-dev
         
     | 
| 
       44 
44 
     | 
    
         
             
              gill http://github.com/postmodern/spidr.git#security#spidr-dev
         
     | 
| 
       45 
     | 
    
         
            -
              gill https://mephux@github.com/mephux/Snorby.git#rails 
     | 
| 
      
 45 
     | 
    
         
            +
              gill https://mephux@github.com/mephux/Snorby.git#rails#snorby-dev
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
       47 
47 
     | 
    
         
             
            etc...
         
     | 
| 
       48 
48 
     | 
    
         | 
| 
         @@ -65,16 +65,31 @@ Listing cloned repositories: 
     | 
|
| 
       65 
65 
     | 
    
         
             
             	  ronin-dev => http://github.com/ronin-ruby/ronin.git
         
     | 
| 
       66 
66 
     | 
    
         
             
             	  spidr-dev => http://github.com/postmodern/spidr.git
         
     | 
| 
       67 
67 
     | 
    
         | 
| 
       68 
     | 
    
         
            -
             	rails 
     | 
| 
       69 
     | 
    
         
            -
             	  snorby 
     | 
| 
      
 68 
     | 
    
         
            +
             	rails:
         
     | 
| 
      
 69 
     | 
    
         
            +
             	  snorby-dev => https://mephux@github.com/mephux/Snorby.git
         
     | 
| 
       70 
70 
     | 
    
         | 
| 
       71 
71 
     | 
    
         
             
            Removing cloned repositories:
         
     | 
| 
       72 
72 
     | 
    
         | 
| 
       73 
     | 
    
         
            -
             $ gill -r rails 
     | 
| 
       74 
     | 
    
         
            -
             Removing: rails 
     | 
| 
      
 73 
     | 
    
         
            +
             $ gill -r rails#snorby-dev
         
     | 
| 
      
 74 
     | 
    
         
            +
             Removing: rails => snorby-dev
         
     | 
| 
       75 
75 
     | 
    
         
             
             Repository Removed Successfully.
         
     | 
| 
       76 
76 
     | 
    
         
             
             Updating Cache...
         
     | 
| 
       77 
77 
     | 
    
         | 
| 
      
 78 
     | 
    
         
            +
            Updating cloned repositories:
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
             $ gill -u rails#snorby-dev
         
     | 
| 
      
 81 
     | 
    
         
            +
             Updating snorby-dev repository.
         
     | 
| 
      
 82 
     | 
    
         
            +
             From https://github.com/mephux/Snorby
         
     | 
| 
      
 83 
     | 
    
         
            +
              * branch            master     -> FETCH_HEAD
         
     | 
| 
      
 84 
     | 
    
         
            +
             Already up-to-date.
         
     | 
| 
      
 85 
     | 
    
         
            +
             Snorby-dev updated successfully.
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
            == Current Issues
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
            * Listing cloned repos is not standardized.
         
     | 
| 
      
 90 
     | 
    
         
            +
            * Nested/Sub categories with empty folders will not be removed when uninstalling a cloned repo. 
         
     | 
| 
      
 91 
     | 
    
         
            +
            Only the parent folder to the cloned repo will be removed.
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
       78 
93 
     | 
    
         
             
            == Note on Patches/Pull Requests
         
     | 
| 
       79 
94 
     | 
    
         | 
| 
       80 
95 
     | 
    
         
             
            * Fork the project.
         
     | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/gill.gemspec
    CHANGED
    
    | 
         @@ -5,11 +5,11 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.name = %q{gill}
         
     | 
| 
       8 
     | 
    
         
            -
              s.version = "0.0. 
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "0.0.8"
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.authors = ["Dustin Willis Webber"]
         
     | 
| 
       12 
     | 
    
         
            -
              s.date = %q{2010-07- 
     | 
| 
      
 12 
     | 
    
         
            +
              s.date = %q{2010-07-04}
         
     | 
| 
       13 
13 
     | 
    
         
             
              s.default_executable = %q{gill}
         
     | 
| 
       14 
14 
     | 
    
         
             
              s.description = %q{Gill is a simple Ruby app to help keep your git clones clean and organized.}
         
     | 
| 
       15 
15 
     | 
    
         
             
              s.email = %q{dustin.webber@gmail.com}
         
     | 
    
        data/lib/gill/app.rb
    CHANGED
    
    | 
         @@ -1,136 +1,58 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'gill/config'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'gill/git'
         
     | 
| 
       3 
     | 
    
         
            -
            require 'gill/remove'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'gill/parse'
         
     | 
| 
       5 
     | 
    
         
            -
            require 'gill/version'
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            require 'gill/exceptions/error'
         
     | 
| 
       8 
     | 
    
         
            -
            require 'gill/exceptions/argument_error'
         
     | 
| 
       9 
     | 
    
         
            -
            require 'gill/exceptions/repository_error'
         
     | 
| 
       10 
     | 
    
         
            -
            require 'gill/exceptions/directory_error'
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            require 'fileutils'
         
     | 
| 
       13 
     | 
    
         
            -
            require 'yaml'
         
     | 
| 
       14 
     | 
    
         
            -
            require 'optparse'
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
1 
     | 
    
         
             
            module Gill
         
     | 
| 
       17 
2 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
               
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
              #
         
     | 
| 
       21 
     | 
    
         
            -
              GILL_CONFIG = Gill::Config.new.yaml
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
              #
         
     | 
| 
       24 
     | 
    
         
            -
              # Run Gill
         
     | 
| 
       25 
     | 
    
         
            -
              #
         
     | 
| 
       26 
     | 
    
         
            -
              def Gill.run
         
     | 
| 
       27 
     | 
    
         
            -
                Gill.check_cache
         
     | 
| 
       28 
     | 
    
         
            -
                Gill.optparse(*ARGV)
         
     | 
| 
       29 
     | 
    
         
            -
                begin
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                  uri = Parse.new(@options[:uri])
         
     | 
| 
       32 
     | 
    
         
            -
                  git = Git.new(uri.category, uri.folder, uri.repo)
         
     | 
| 
       33 
     | 
    
         
            -
                  git.clone
         
     | 
| 
      
 3 
     | 
    
         
            +
              class App
         
     | 
| 
      
 4 
     | 
    
         
            +
                attr_accessor :gill, :cache, :source, :cache_file
         
     | 
| 
       34 
5 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
                 
     | 
| 
       36 
     | 
    
         
            -
                   
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                   
     | 
| 
      
 6 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 7 
     | 
    
         
            +
                  @gill = Gill::Config.new.yaml
         
     | 
| 
      
 8 
     | 
    
         
            +
                  @cache = @gill[:cache]
         
     | 
| 
      
 9 
     | 
    
         
            +
                  @source = @gill[:source]
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @cache_file = cache
         
     | 
| 
       39 
11 
     | 
    
         
             
                end
         
     | 
| 
       40 
     | 
    
         
            -
              end
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
              private
         
     | 
| 
       43 
12 
     | 
    
         | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                 
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
                   
     | 
| 
       49 
     | 
    
         
            -
                  @new_cache.each do |key,value|
         
     | 
| 
       50 
     | 
    
         
            -
                    if File.directory?("#{source_dir}/#{key}")
         
     | 
| 
       51 
     | 
    
         
            -
                      value.each do |skey,svalue|
         
     | 
| 
       52 
     | 
    
         
            -
                        unless File.directory?("#{source_dir}/#{key}/#{skey}")
         
     | 
| 
       53 
     | 
    
         
            -
                          @new_cache[:"#{key}"].delete(:"#{skey}")
         
     | 
| 
       54 
     | 
    
         
            -
                        end
         
     | 
| 
       55 
     | 
    
         
            -
                      end
         
     | 
| 
       56 
     | 
    
         
            -
                    else
         
     | 
| 
       57 
     | 
    
         
            -
                      @new_cache.delete(:"#{key}")
         
     | 
| 
       58 
     | 
    
         
            -
                    end
         
     | 
| 
       59 
     | 
    
         
            -
                  end
         
     | 
| 
       60 
     | 
    
         
            -
                  Gill::Config.rebuild_cache(cache, @new_cache)
         
     | 
| 
      
 13 
     | 
    
         
            +
                #
         
     | 
| 
      
 14 
     | 
    
         
            +
                # Return the gill YAML configuration file.
         
     | 
| 
      
 15 
     | 
    
         
            +
                #
         
     | 
| 
      
 16 
     | 
    
         
            +
                def cache
         
     | 
| 
      
 17 
     | 
    
         
            +
                  YAML.load_file(@cache)
         
     | 
| 
       61 
18 
     | 
    
         
             
                end
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
                 
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
      
 19 
     | 
    
         
            +
                
         
     | 
| 
      
 20 
     | 
    
         
            +
                #
         
     | 
| 
      
 21 
     | 
    
         
            +
                # Return the path for the passed type.
         
     | 
| 
      
 22 
     | 
    
         
            +
                #
         
     | 
| 
      
 23 
     | 
    
         
            +
                def path(type)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  return @gill[:'#{type}'] if %w(source cache).include?(type.to_sym)
         
     | 
| 
       66 
25 
     | 
    
         
             
                end
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                def  
     | 
| 
       69 
     | 
    
         
            -
                   
     | 
| 
       70 
     | 
    
         
            -
                   
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                     
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
                
         
     | 
| 
      
 27 
     | 
    
         
            +
                def ask(msg, options={})
         
     | 
| 
      
 28 
     | 
    
         
            +
                  default = options[:default] || :yes
         
     | 
| 
      
 29 
     | 
    
         
            +
                  if default == :yes
         
     | 
| 
      
 30 
     | 
    
         
            +
                    STDOUT.print "#{msg} [Y/n] "
         
     | 
| 
      
 31 
     | 
    
         
            +
                  else
         
     | 
| 
      
 32 
     | 
    
         
            +
                    STDOUT.print "#{msg} [y/N] "
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
                  input = STDIN.gets.chomp
         
     | 
| 
      
 35 
     | 
    
         
            +
                  STDOUT.flush
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  if block_given?
         
     | 
| 
      
 38 
     | 
    
         
            +
                    if input[/([Yy]|[Yy]es)$/i]
         
     | 
| 
      
 39 
     | 
    
         
            +
                      yield
         
     | 
| 
      
 40 
     | 
    
         
            +
                    elsif input[/([Nn]|[Nn]o)$/i]
         
     | 
| 
      
 41 
     | 
    
         
            +
                      exit -1
         
     | 
| 
      
 42 
     | 
    
         
            +
                    else
         
     | 
| 
      
 43 
     | 
    
         
            +
                      yield if default == :yes
         
     | 
| 
       75 
44 
     | 
    
         
             
                    end
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
                  end
         
     | 
| 
       78 
     | 
    
         
            -
                  exit -1
         
     | 
| 
       79 
     | 
    
         
            -
                end
         
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
                def Gill.remove
         
     | 
| 
       82 
     | 
    
         
            -
                  begin
         
     | 
| 
       83 
     | 
    
         
            -
                    Remove.new(@options[:remove]).remove_repo
         
     | 
| 
       84 
     | 
    
         
            -
                  rescue Gill::DirectoryError => e
         
     | 
| 
       85 
     | 
    
         
            -
                    STDERR.puts "Error: #{e}"
         
     | 
| 
       86 
     | 
    
         
            -
                  rescue => e
         
     | 
| 
       87 
     | 
    
         
            -
                    STDERR.puts "Error: #{e}"
         
     | 
| 
       88 
     | 
    
         
            -
                  end
         
     | 
| 
       89 
     | 
    
         
            -
                  exit -1
         
     | 
| 
       90 
     | 
    
         
            -
                end
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
                def Gill.optparse(*args)
         
     | 
| 
       93 
     | 
    
         
            -
                  @opts = OptionParser.new
         
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
                  @options = {}
         
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
                  @opts.banner = "Gill - Git, Clone, Cleanliness.\nUsage: gill git://host/repository.git#category/sub-category/...\n\n"
         
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
                  @opts.on('-l','--list','List all cloned repositories.') do |list|
         
     | 
| 
       100 
     | 
    
         
            -
                    @options[:list] = list
         
     | 
| 
       101 
     | 
    
         
            -
                  end
         
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
                  @opts.on('-r ','--remove ','Remove a cloned repository. ie. -r category#folder') do |remove|
         
     | 
| 
       104 
     | 
    
         
            -
                    @options[:remove] = remove
         
     | 
| 
       105 
     | 
    
         
            -
                  end
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
                  @opts.on('-h','--help','This help summary page.') do |help|
         
     | 
| 
       108 
     | 
    
         
            -
                    @options[:help] = help
         
     | 
| 
       109 
     | 
    
         
            -
                  end
         
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
                  @opts.on('-v','--version','Version number') do |version|
         
     | 
| 
       112 
     | 
    
         
            -
                    STDERR.puts "Version: #{Gill::VERSION}"
         
     | 
| 
      
 45 
     | 
    
         
            +
                  else
         
     | 
| 
       113 
46 
     | 
    
         
             
                    exit -1
         
     | 
| 
       114 
47 
     | 
    
         
             
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
       115 
49 
     | 
    
         | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
                    Gill.remove if @options[:remove]
         
     | 
| 
       122 
     | 
    
         
            -
                    Gill.error if @options.empty? or @options[:uri].nil?
         
     | 
| 
       123 
     | 
    
         
            -
                  rescue OptionParser::MissingArgument => e
         
     | 
| 
       124 
     | 
    
         
            -
                    STDERR.puts e.message
         
     | 
| 
       125 
     | 
    
         
            -
                    STDERR.puts @opts
         
     | 
| 
       126 
     | 
    
         
            -
                    STDERR.puts "\n"
         
     | 
| 
       127 
     | 
    
         
            -
                    exit -1
         
     | 
| 
       128 
     | 
    
         
            -
                  rescue OptionParser::InvalidOption => e
         
     | 
| 
       129 
     | 
    
         
            -
                    STDERR.puts e.message
         
     | 
| 
       130 
     | 
    
         
            -
                    STDERR.puts @opts
         
     | 
| 
       131 
     | 
    
         
            -
                    STDERR.puts "\n"
         
     | 
| 
       132 
     | 
    
         
            -
                    exit -1
         
     | 
| 
       133 
     | 
    
         
            -
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
                #
         
     | 
| 
      
 51 
     | 
    
         
            +
                # Return the gill configuration file.
         
     | 
| 
      
 52 
     | 
    
         
            +
                #
         
     | 
| 
      
 53 
     | 
    
         
            +
                def self.config
         
     | 
| 
      
 54 
     | 
    
         
            +
                  @gill || Gill::Config.new.yaml
         
     | 
| 
       134 
55 
     | 
    
         
             
                end
         
     | 
| 
      
 56 
     | 
    
         
            +
              end
         
     | 
| 
       135 
57 
     | 
    
         | 
| 
       136 
58 
     | 
    
         
             
            end
         
     | 
    
        data/lib/gill/config.rb
    CHANGED
    
    | 
         @@ -15,10 +15,12 @@ module Gill 
     | 
|
| 
       15 
15 
     | 
    
         
             
                # Build the initial .gillrc configuration file.
         
     | 
| 
       16 
16 
     | 
    
         
             
                #
         
     | 
| 
       17 
17 
     | 
    
         
             
                def build_config
         
     | 
| 
      
 18 
     | 
    
         
            +
                  
         
     | 
| 
       18 
19 
     | 
    
         
             
                  config = { :home => @home, :config => @path, :source => "#{@home}/source", :cache => @cache }
         
     | 
| 
       19 
20 
     | 
    
         
             
                  File.open(@path, 'w') do |out|
         
     | 
| 
       20 
21 
     | 
    
         
             
                     YAML.dump(config, out)
         
     | 
| 
       21 
22 
     | 
    
         
             
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
                  
         
     | 
| 
       22 
24 
     | 
    
         
             
                end
         
     | 
| 
       23 
25 
     | 
    
         | 
| 
       24 
26 
     | 
    
         
             
                #
         
     | 
| 
         @@ -27,29 +29,41 @@ module Gill 
     | 
|
| 
       27 
29 
     | 
    
         
             
                # The initial source directory is only created if it does not exist.
         
     | 
| 
       28 
30 
     | 
    
         
             
                #
         
     | 
| 
       29 
31 
     | 
    
         
             
                def build_source_folder
         
     | 
| 
      
 32 
     | 
    
         
            +
                  
         
     | 
| 
       30 
33 
     | 
    
         
             
                  unless File.directory?(self.config[:source])
         
     | 
| 
       31 
     | 
    
         
            -
                     
     | 
| 
      
 34 
     | 
    
         
            +
                    
         
     | 
| 
      
 35 
     | 
    
         
            +
                    STDOUT.puts "Creating Source Directory: " + "#{self.config[:source]}"
         
     | 
| 
       32 
36 
     | 
    
         
             
                    Dir.mkdir(self.config[:source])
         
     | 
| 
      
 37 
     | 
    
         
            +
                    
         
     | 
| 
       33 
38 
     | 
    
         
             
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
                  
         
     | 
| 
       34 
40 
     | 
    
         
             
                end
         
     | 
| 
       35 
41 
     | 
    
         | 
| 
       36 
42 
     | 
    
         
             
                #
         
     | 
| 
       37 
43 
     | 
    
         
             
                # Build the inital .gillache file in the user home directory.
         
     | 
| 
       38 
44 
     | 
    
         
             
                #
         
     | 
| 
       39 
45 
     | 
    
         
             
                def build_cache
         
     | 
| 
      
 46 
     | 
    
         
            +
                  
         
     | 
| 
       40 
47 
     | 
    
         
             
                  cache = { }
         
     | 
| 
       41 
48 
     | 
    
         
             
                  File.open(@cache, 'w') do |out|
         
     | 
| 
      
 49 
     | 
    
         
            +
                    
         
     | 
| 
       42 
50 
     | 
    
         
             
                    YAML.dump(cache, out)
         
     | 
| 
      
 51 
     | 
    
         
            +
                    
         
     | 
| 
       43 
52 
     | 
    
         
             
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
                  
         
     | 
| 
       44 
54 
     | 
    
         
             
                end
         
     | 
| 
       45 
55 
     | 
    
         | 
| 
       46 
56 
     | 
    
         
             
                #
         
     | 
| 
       47 
57 
     | 
    
         
             
                # Rebuild cache writes updated entries to the .gillache file in the user home directory.
         
     | 
| 
       48 
58 
     | 
    
         
             
                #
         
     | 
| 
       49 
59 
     | 
    
         
             
                def self.rebuild_cache(path, cache)
         
     | 
| 
      
 60 
     | 
    
         
            +
                  
         
     | 
| 
       50 
61 
     | 
    
         
             
                  File.open(path, 'w+') do |out|
         
     | 
| 
      
 62 
     | 
    
         
            +
                    
         
     | 
| 
       51 
63 
     | 
    
         
             
                    YAML.dump(cache, out)
         
     | 
| 
      
 64 
     | 
    
         
            +
                    
         
     | 
| 
       52 
65 
     | 
    
         
             
                  end
         
     | 
| 
      
 66 
     | 
    
         
            +
                  
         
     | 
| 
       53 
67 
     | 
    
         
             
                end
         
     | 
| 
       54 
68 
     | 
    
         | 
| 
       55 
69 
     | 
    
         
             
                #
         
     | 
| 
         @@ -57,16 +71,22 @@ module Gill 
     | 
|
| 
       57 
71 
     | 
    
         
             
                # or return the current configuration files.
         
     | 
| 
       58 
72 
     | 
    
         
             
                #
         
     | 
| 
       59 
73 
     | 
    
         
             
                def setup
         
     | 
| 
      
 74 
     | 
    
         
            +
                  
         
     | 
| 
       60 
75 
     | 
    
         
             
                  if File.exists?("#{@path}")
         
     | 
| 
      
 76 
     | 
    
         
            +
                    
         
     | 
| 
       61 
77 
     | 
    
         
             
                    self.build_cache unless File.exists?("#{@cache}")
         
     | 
| 
       62 
78 
     | 
    
         
             
                    self.config = YAML.load_file(@path)
         
     | 
| 
       63 
79 
     | 
    
         
             
                    self.build_source_folder
         
     | 
| 
      
 80 
     | 
    
         
            +
                    
         
     | 
| 
       64 
81 
     | 
    
         
             
                  else
         
     | 
| 
      
 82 
     | 
    
         
            +
                    
         
     | 
| 
       65 
83 
     | 
    
         
             
                    self.build_config
         
     | 
| 
       66 
84 
     | 
    
         
             
                    self.build_cache unless File.exists?("#{@cache}")
         
     | 
| 
       67 
85 
     | 
    
         
             
                    self.config = YAML.load_file(@path)
         
     | 
| 
       68 
86 
     | 
    
         
             
                    self.build_source_folder
         
     | 
| 
      
 87 
     | 
    
         
            +
                    
         
     | 
| 
       69 
88 
     | 
    
         
             
                  end
         
     | 
| 
      
 89 
     | 
    
         
            +
                  
         
     | 
| 
       70 
90 
     | 
    
         
             
                end
         
     | 
| 
       71 
91 
     | 
    
         | 
| 
       72 
92 
     | 
    
         
             
                #
         
     | 
    
        data/lib/gill/git.rb
    CHANGED
    
    | 
         @@ -1,42 +1,76 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Gill
         
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
      
 2 
     | 
    
         
            +
              
         
     | 
| 
      
 3 
     | 
    
         
            +
              class Git < App
         
     | 
| 
       3 
4 
     | 
    
         | 
| 
       4 
5 
     | 
    
         
             
                def initialize(category,folder,repo)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  super()
         
     | 
| 
      
 7 
     | 
    
         
            +
                  
         
     | 
| 
       5 
8 
     | 
    
         
             
                  @repo, @category, @folder = repo, category, folder
         
     | 
| 
       6 
     | 
    
         
            -
                  @cache, @source = GILL_CONFIG[:cache], GILL_CONFIG[:source]
         
     | 
| 
       7 
9 
     | 
    
         
             
                  @category_path = File.join(@source, @category)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  
         
     | 
| 
       8 
11 
     | 
    
         
             
                  if @folder
         
     | 
| 
       9 
12 
     | 
    
         
             
                    @folder_path = File.join(@category_path, @folder)
         
     | 
| 
       10 
13 
     | 
    
         
             
                  else
         
     | 
| 
       11 
14 
     | 
    
         
             
                    @folder_path = @category_path
         
     | 
| 
       12 
15 
     | 
    
         
             
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
                  
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
                
         
     | 
| 
      
 19 
     | 
    
         
            +
                
         
     | 
| 
      
 20 
     | 
    
         
            +
                def update(branch='master')
         
     | 
| 
      
 21 
     | 
    
         
            +
                  Dir.chdir(@folder_path)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  STDOUT.puts "Updating #{@folder} repository."
         
     | 
| 
      
 23 
     | 
    
         
            +
                  if system('git', 'pull', 'origin', branch)
         
     | 
| 
      
 24 
     | 
    
         
            +
                    STDOUT.puts "#{@folder.capitalize} updated successfully."
         
     | 
| 
      
 25 
     | 
    
         
            +
                  else
         
     | 
| 
      
 26 
     | 
    
         
            +
                    STDOUT.puts "Failed to update #{@folder.capitalize} successfully."
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
       13 
28 
     | 
    
         
             
                end
         
     | 
| 
       14 
29 
     | 
    
         | 
| 
       15 
30 
     | 
    
         
             
                def build_cache
         
     | 
| 
       16 
     | 
    
         
            -
                   
     | 
| 
      
 31 
     | 
    
         
            +
                  
         
     | 
| 
      
 32 
     | 
    
         
            +
                  old_cache = @cache_file
         
     | 
| 
      
 33 
     | 
    
         
            +
                  
         
     | 
| 
       17 
34 
     | 
    
         
             
                  if old_cache[:"#{@category}"]
         
     | 
| 
      
 35 
     | 
    
         
            +
                    
         
     | 
| 
       18 
36 
     | 
    
         
             
                    old_cache[:"#{@category}"] = old_cache[:"#{@category}"].merge!({:"#{@folder}" => @repo})
         
     | 
| 
      
 37 
     | 
    
         
            +
                    
         
     | 
| 
       19 
38 
     | 
    
         
             
                  else
         
     | 
| 
      
 39 
     | 
    
         
            +
                    
         
     | 
| 
       20 
40 
     | 
    
         
             
                    old_cache = old_cache.merge!({:"#{@category}" => {:"#{@folder}" => @repo}})
         
     | 
| 
      
 41 
     | 
    
         
            +
                    
         
     | 
| 
       21 
42 
     | 
    
         
             
                  end
         
     | 
| 
      
 43 
     | 
    
         
            +
                  
         
     | 
| 
       22 
44 
     | 
    
         
             
                  Gill::Config.rebuild_cache(@cache, old_cache)
         
     | 
| 
      
 45 
     | 
    
         
            +
                  
         
     | 
| 
       23 
46 
     | 
    
         
             
                end
         
     | 
| 
       24 
47 
     | 
    
         | 
| 
       25 
48 
     | 
    
         
             
                def build_type_folder(make_folder=true)
         
     | 
| 
      
 49 
     | 
    
         
            +
                  
         
     | 
| 
       26 
50 
     | 
    
         
             
                  unless File.directory?(@category_path)
         
     | 
| 
      
 51 
     | 
    
         
            +
                    
         
     | 
| 
       27 
52 
     | 
    
         
             
                    FileUtils.mkdir_p(@category_path)
         
     | 
| 
      
 53 
     | 
    
         
            +
                    
         
     | 
| 
       28 
54 
     | 
    
         
             
                    if make_folder
         
     | 
| 
      
 55 
     | 
    
         
            +
                      
         
     | 
| 
       29 
56 
     | 
    
         
             
                      unless File.directory?(@folder_path)
         
     | 
| 
      
 57 
     | 
    
         
            +
                        
         
     | 
| 
       30 
58 
     | 
    
         
             
                        FileUtils.mkdir_p(@folder_path)
         
     | 
| 
      
 59 
     | 
    
         
            +
                        
         
     | 
| 
       31 
60 
     | 
    
         
             
                      end
         
     | 
| 
      
 61 
     | 
    
         
            +
                      
         
     | 
| 
       32 
62 
     | 
    
         
             
                    end
         
     | 
| 
       33 
63 
     | 
    
         
             
                  end
         
     | 
| 
       34 
64 
     | 
    
         
             
                end
         
     | 
| 
       35 
65 
     | 
    
         | 
| 
       36 
66 
     | 
    
         
             
                def clone
         
     | 
| 
      
 67 
     | 
    
         
            +
                  
         
     | 
| 
       37 
68 
     | 
    
         
             
                  if File.directory?(@folder_path) && @folder
         
     | 
| 
      
 69 
     | 
    
         
            +
                    
         
     | 
| 
       38 
70 
     | 
    
         
             
                    raise(DirectoryError, "destination path '#{@folder_path}' already exists and is not an empty directory.")
         
     | 
| 
      
 71 
     | 
    
         
            +
                    
         
     | 
| 
       39 
72 
     | 
    
         
             
                  else
         
     | 
| 
      
 73 
     | 
    
         
            +
                    
         
     | 
| 
       40 
74 
     | 
    
         
             
                    if @folder
         
     | 
| 
       41 
75 
     | 
    
         
             
                      build_type_folder
         
     | 
| 
       42 
76 
     | 
    
         
             
                      build_cache if system('git', 'clone', @repo, @folder_path)
         
     | 
| 
         @@ -45,6 +79,7 @@ module Gill 
     | 
|
| 
       45 
79 
     | 
    
         
             
                      Dir.chdir(@folder_path)
         
     | 
| 
       46 
80 
     | 
    
         
             
                      build_cache if system('git', 'clone', @repo)
         
     | 
| 
       47 
81 
     | 
    
         
             
                    end
         
     | 
| 
      
 82 
     | 
    
         
            +
                    
         
     | 
| 
       48 
83 
     | 
    
         
             
                  end
         
     | 
| 
       49 
84 
     | 
    
         
             
                end
         
     | 
| 
       50 
85 
     | 
    
         | 
    
        data/lib/gill/remove.rb
    CHANGED
    
    | 
         @@ -1,36 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Gill
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
              class Remove
         
     | 
| 
      
 3 
     | 
    
         
            +
              class Remove < App
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
                def initialize(args)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  data = args.split('#')
         
     | 
| 
       7 
7 
     | 
    
         
             
                  raise(ArgumentError, 'Wrong number of arguments.') if data.length != 2
         
     | 
| 
       8 
8 
     | 
    
         
             
                  @category = data.first
         
     | 
| 
       9 
9 
     | 
    
         
             
                  @folder = data.last
         
     | 
| 
       10 
     | 
    
         
            -
                   
     | 
| 
       11 
     | 
    
         
            -
                  @source = GILL_CONFIG[:source]
         
     | 
| 
       12 
     | 
    
         
            -
                end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                def remove_cache
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                  old_cache = YAML.load_file(@cache)
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                  if old_cache[:"#{@category}"]
         
     | 
| 
       19 
     | 
    
         
            -
                    old_cache[:"#{@category}"].delete(:"#{@folder}")
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                    if old_cache[:"#{@category}"].empty?
         
     | 
| 
       22 
     | 
    
         
            -
                      old_cache.delete(:"#{@category}")
         
     | 
| 
       23 
     | 
    
         
            -
                      Gill::Config.rebuild_cache(@cache, old_cache)
         
     | 
| 
       24 
     | 
    
         
            -
                      return true
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                    else
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                      Gill::Config.rebuild_cache(@cache, old_cache)
         
     | 
| 
       29 
     | 
    
         
            -
                      return false
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                    end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                  end
         
     | 
| 
      
 10 
     | 
    
         
            +
                  super()
         
     | 
| 
       34 
11 
     | 
    
         
             
                end
         
     | 
| 
       35 
12 
     | 
    
         | 
| 
       36 
13 
     | 
    
         
             
                def remove_repo
         
     | 
| 
         @@ -38,27 +15,30 @@ module Gill 
     | 
|
| 
       38 
15 
     | 
    
         
             
                  type_folder = "#{@source}/#{@category}"
         
     | 
| 
       39 
16 
     | 
    
         
             
                  folder = "#{@source}/#{@category}/#{@folder}"
         
     | 
| 
       40 
17 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
                  if File.directory?(type_folder) && File.directory?(folder) &&  
     | 
| 
      
 18 
     | 
    
         
            +
                  if File.directory?(type_folder) && File.directory?(folder) && !@cache_file.empty?
         
     | 
| 
      
 19 
     | 
    
         
            +
                    
         
     | 
| 
      
 20 
     | 
    
         
            +
                    if @cache_file[:"#{@category}"][:"#{@folder}"]
         
     | 
| 
      
 21 
     | 
    
         
            +
                      
         
     | 
| 
      
 22 
     | 
    
         
            +
                      ask "Are you sure you want to remove #{@folder}?", :default => :no do
         
     | 
| 
      
 23 
     | 
    
         
            +
                        STDOUT.puts "#{@folder.capitalize} removed successfully."
         
     | 
| 
      
 24 
     | 
    
         
            +
                        FileUtils.rm_rf(folder)
         
     | 
| 
      
 25 
     | 
    
         
            +
                      end
         
     | 
| 
       42 
26 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
                        STDERR.puts "Reviewing folder #{@category}."
         
     | 
| 
       48 
     | 
    
         
            -
                        if Dir.enum_for(:foreach, type_folder).any? {|n| /\A\.\.?\z/ !~ n}
         
     | 
| 
       49 
     | 
    
         
            -
                          STDERR.puts "Skipping folder #{@category} - directory not empty."
         
     | 
| 
       50 
     | 
    
         
            -
                        else
         
     | 
| 
       51 
     | 
    
         
            -
                          STDERR.puts "Removing folder #{@category} - directory empty."
         
     | 
| 
      
 27 
     | 
    
         
            +
                      unless Dir.enum_for(:foreach, type_folder).any? {|n| /\A\.\.?\z/ !~ n}
         
     | 
| 
      
 28 
     | 
    
         
            +
                        
         
     | 
| 
      
 29 
     | 
    
         
            +
                        ask "The `#{@category}` directory is empty. Would you like to remove it?", :default => :no do
         
     | 
| 
      
 30 
     | 
    
         
            +
                          STDOUT.puts "#{@category.capitalize} directory removed successfully."
         
     | 
| 
       52 
31 
     | 
    
         
             
                          FileUtils.rm_rf(type_folder)
         
     | 
| 
       53 
32 
     | 
    
         
             
                        end
         
     | 
| 
      
 33 
     | 
    
         
            +
                        
         
     | 
| 
       54 
34 
     | 
    
         
             
                      end
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
                      STDERR.puts "Updating Gill Cache..."
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
       57 
36 
     | 
    
         
             
                    end
         
     | 
| 
       58 
37 
     | 
    
         | 
| 
       59 
38 
     | 
    
         
             
                  else
         
     | 
| 
       60 
     | 
    
         
            -
                     
     | 
| 
      
 39 
     | 
    
         
            +
                    
         
     | 
| 
       61 
40 
     | 
    
         
             
                    raise(DirectoryError, "The directory #{@source}/#{@category}/#{@folder} does not exist or was not cloned with gill.")
         
     | 
| 
      
 41 
     | 
    
         
            +
                    
         
     | 
| 
       62 
42 
     | 
    
         
             
                  end
         
     | 
| 
       63 
43 
     | 
    
         
             
                end
         
     | 
| 
       64 
44 
     | 
    
         | 
    
        data/lib/gill/version.rb
    CHANGED
    
    
    
        data/lib/gill.rb
    CHANGED
    
    | 
         @@ -1 +1,174 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'gill/app'
         
     | 
| 
      
 1 
     | 
    
         
            +
            require 'gill/app'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'gill/config'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'gill/git'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'gill/remove'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'gill/parse'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'gill/version'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            require 'gill/exceptions/error'
         
     | 
| 
      
 9 
     | 
    
         
            +
            require 'gill/exceptions/argument_error'
         
     | 
| 
      
 10 
     | 
    
         
            +
            require 'gill/exceptions/repository_error'
         
     | 
| 
      
 11 
     | 
    
         
            +
            require 'gill/exceptions/directory_error'
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            require 'fileutils'
         
     | 
| 
      
 14 
     | 
    
         
            +
            require 'yaml'
         
     | 
| 
      
 15 
     | 
    
         
            +
            require 'optparse'
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            module Gill
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              #
         
     | 
| 
      
 21 
     | 
    
         
            +
              # Load Gill Configuration
         
     | 
| 
      
 22 
     | 
    
         
            +
              #
         
     | 
| 
      
 23 
     | 
    
         
            +
              GILL_CONFIG = App.config
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              #
         
     | 
| 
      
 26 
     | 
    
         
            +
              # Run Gill
         
     | 
| 
      
 27 
     | 
    
         
            +
              #
         
     | 
| 
      
 28 
     | 
    
         
            +
              def Gill.run
         
     | 
| 
      
 29 
     | 
    
         
            +
                Gill.check_cache
         
     | 
| 
      
 30 
     | 
    
         
            +
                Gill.optparse(*ARGV)
         
     | 
| 
      
 31 
     | 
    
         
            +
                begin
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                  uri = Parse.new(@options[:uri])
         
     | 
| 
      
 34 
     | 
    
         
            +
                  git = Git.new(uri.category, uri.folder, uri.repo)
         
     | 
| 
      
 35 
     | 
    
         
            +
                  git.clone
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                rescue TypeError => e
         
     | 
| 
      
 38 
     | 
    
         
            +
                  STDERR.puts "Error: #{e}\nError: Please make sure to remove all whitespace from the category and/or folder name."
         
     | 
| 
      
 39 
     | 
    
         
            +
                  exit -1
         
     | 
| 
      
 40 
     | 
    
         
            +
                rescue => e
         
     | 
| 
      
 41 
     | 
    
         
            +
                  STDERR.puts "Error: #{e}"
         
     | 
| 
      
 42 
     | 
    
         
            +
                  exit -1
         
     | 
| 
      
 43 
     | 
    
         
            +
                end
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              def Gill.update
         
     | 
| 
      
 47 
     | 
    
         
            +
                begin
         
     | 
| 
      
 48 
     | 
    
         
            +
                  args = @options[:update].split(/\#/)
         
     | 
| 
      
 49 
     | 
    
         
            +
                  raise(ArgumentError, "Requires three arguments. category#title#branch") if args.length > 4
         
     | 
| 
      
 50 
     | 
    
         
            +
                  category, folder, branch = args
         
     | 
| 
      
 51 
     | 
    
         
            +
                  git = Git.new(category, folder, false)
         
     | 
| 
      
 52 
     | 
    
         
            +
                  if branch
         
     | 
| 
      
 53 
     | 
    
         
            +
                    git.update(branch)
         
     | 
| 
      
 54 
     | 
    
         
            +
                  else
         
     | 
| 
      
 55 
     | 
    
         
            +
                    git.update
         
     | 
| 
      
 56 
     | 
    
         
            +
                  end
         
     | 
| 
      
 57 
     | 
    
         
            +
                  exit -1
         
     | 
| 
      
 58 
     | 
    
         
            +
                rescue TypeError => e
         
     | 
| 
      
 59 
     | 
    
         
            +
                  STDERR.puts "Error: #{e}\nError: Please make sure to remove all whitespace from the category and/or folder name."
         
     | 
| 
      
 60 
     | 
    
         
            +
                  exit -1
         
     | 
| 
      
 61 
     | 
    
         
            +
                rescue => e
         
     | 
| 
      
 62 
     | 
    
         
            +
                  STDERR.puts "Error: #{e}"
         
     | 
| 
      
 63 
     | 
    
         
            +
                  exit -1
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
              end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
              private
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                def Gill.check_cache
         
     | 
| 
      
 70 
     | 
    
         
            +
                  cache = GILL_CONFIG[:cache]
         
     | 
| 
      
 71 
     | 
    
         
            +
                  @new_cache = YAML.load_file(GILL_CONFIG[:cache])
         
     | 
| 
      
 72 
     | 
    
         
            +
                  source_dir = GILL_CONFIG[:source]
         
     | 
| 
      
 73 
     | 
    
         
            +
                  @new_cache.each do |key,value|
         
     | 
| 
      
 74 
     | 
    
         
            +
                    if File.directory?("#{source_dir}/#{key}")
         
     | 
| 
      
 75 
     | 
    
         
            +
                      value.each do |skey,svalue|
         
     | 
| 
      
 76 
     | 
    
         
            +
                        unless File.directory?("#{source_dir}/#{key}/#{skey}")
         
     | 
| 
      
 77 
     | 
    
         
            +
                          @new_cache[:"#{key}"].delete(:"#{skey}")
         
     | 
| 
      
 78 
     | 
    
         
            +
                        end
         
     | 
| 
      
 79 
     | 
    
         
            +
                      end
         
     | 
| 
      
 80 
     | 
    
         
            +
                    else
         
     | 
| 
      
 81 
     | 
    
         
            +
                      @new_cache.delete(:"#{key}")
         
     | 
| 
      
 82 
     | 
    
         
            +
                    end
         
     | 
| 
      
 83 
     | 
    
         
            +
                  end
         
     | 
| 
      
 84 
     | 
    
         
            +
                  Config.rebuild_cache(cache, @new_cache)
         
     | 
| 
      
 85 
     | 
    
         
            +
                end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                def Gill.error
         
     | 
| 
      
 88 
     | 
    
         
            +
                  STDERR.puts "#{@opts}\n"
         
     | 
| 
      
 89 
     | 
    
         
            +
                  exit -1
         
     | 
| 
      
 90 
     | 
    
         
            +
                end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                def Gill.list
         
     | 
| 
      
 93 
     | 
    
         
            +
                  cache = YAML.load_file(GILL_CONFIG[:cache])
         
     | 
| 
      
 94 
     | 
    
         
            +
                  STDOUT.puts "\n*** Listing Cloned Repositories ***\n\n"
         
     | 
| 
      
 95 
     | 
    
         
            +
                  cache.each do |type,repos|
         
     | 
| 
      
 96 
     | 
    
         
            +
                    STDOUT.puts " #{type}:"
         
     | 
| 
      
 97 
     | 
    
         
            +
                    repos.each do |repo|
         
     | 
| 
      
 98 
     | 
    
         
            +
                      STDOUT.puts "  - #{repo[0]} => " + "#{repo[1]}"
         
     | 
| 
      
 99 
     | 
    
         
            +
                    end
         
     | 
| 
      
 100 
     | 
    
         
            +
                    STDOUT.puts "\n"
         
     | 
| 
      
 101 
     | 
    
         
            +
                  end
         
     | 
| 
      
 102 
     | 
    
         
            +
                  exit -1
         
     | 
| 
      
 103 
     | 
    
         
            +
                end
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                def Gill.remove
         
     | 
| 
      
 106 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 107 
     | 
    
         
            +
                    Remove.new(@options[:remove]).remove_repo
         
     | 
| 
      
 108 
     | 
    
         
            +
                  rescue Gill::DirectoryError => e
         
     | 
| 
      
 109 
     | 
    
         
            +
                    STDERR.puts "Error: #{e}"
         
     | 
| 
      
 110 
     | 
    
         
            +
                    exit -1
         
     | 
| 
      
 111 
     | 
    
         
            +
                  rescue => e
         
     | 
| 
      
 112 
     | 
    
         
            +
                    STDERR.puts "Error: #{e}"
         
     | 
| 
      
 113 
     | 
    
         
            +
                    exit -1
         
     | 
| 
      
 114 
     | 
    
         
            +
                  end
         
     | 
| 
      
 115 
     | 
    
         
            +
                  exit -1
         
     | 
| 
      
 116 
     | 
    
         
            +
                end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                def Gill.optparse(*args)
         
     | 
| 
      
 119 
     | 
    
         
            +
                  @opts = OptionParser.new
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
                  @options = {}
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                  @opts.banner = "Gill - Git, Clone, Cleanliness.\nUsage: gill git://host/repository.git#category/sub-category/...\n\n"
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
                  @opts.on('-l','--list','List repositories.') do |list|
         
     | 
| 
      
 126 
     | 
    
         
            +
                    @options[:list] = list
         
     | 
| 
      
 127 
     | 
    
         
            +
                  end
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
                  @opts.on('-r ', '--remove ','Remove repository. ie. -r category#folder') do |remove|
         
     | 
| 
      
 130 
     | 
    
         
            +
                    @options[:remove] = remove
         
     | 
| 
      
 131 
     | 
    
         
            +
                  end
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
                  @opts.on('-u ', '--update ','Update repository. ie. -u category#folder#branch') do |update|
         
     | 
| 
      
 134 
     | 
    
         
            +
                    @options[:update] = update
         
     | 
| 
      
 135 
     | 
    
         
            +
                  end
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
                  @opts.on('-x','--reload','Force gill cache reload.') do |remove|
         
     | 
| 
      
 138 
     | 
    
         
            +
                    STDOUT.print "Updating Gill Cache... "
         
     | 
| 
      
 139 
     | 
    
         
            +
                    Gill.check_cache
         
     | 
| 
      
 140 
     | 
    
         
            +
                    STDOUT.puts "Done."
         
     | 
| 
      
 141 
     | 
    
         
            +
                    exit -1
         
     | 
| 
      
 142 
     | 
    
         
            +
                  end
         
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
      
 144 
     | 
    
         
            +
                  @opts.on('-h','--help','This help summary page.') do |help|
         
     | 
| 
      
 145 
     | 
    
         
            +
                    @options[:help] = help
         
     | 
| 
      
 146 
     | 
    
         
            +
                  end
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
                  @opts.on('-v','--version','Version number') do |version|
         
     | 
| 
      
 149 
     | 
    
         
            +
                    puts "Version: #{Gill::VERSION}"
         
     | 
| 
      
 150 
     | 
    
         
            +
                    exit -1
         
     | 
| 
      
 151 
     | 
    
         
            +
                  end
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 154 
     | 
    
         
            +
                    @args = @opts.parse!(args)
         
     | 
| 
      
 155 
     | 
    
         
            +
                    @options[:uri] = @args[0]
         
     | 
| 
      
 156 
     | 
    
         
            +
                    Gill.error if @options[:help]
         
     | 
| 
      
 157 
     | 
    
         
            +
                    Gill.list if @options[:list]
         
     | 
| 
      
 158 
     | 
    
         
            +
                    Gill.remove if @options[:remove]
         
     | 
| 
      
 159 
     | 
    
         
            +
                    Gill.update if @options[:update]
         
     | 
| 
      
 160 
     | 
    
         
            +
                    Gill.error if @options.empty? or @options[:uri].nil?
         
     | 
| 
      
 161 
     | 
    
         
            +
                  rescue OptionParser::MissingArgument => e
         
     | 
| 
      
 162 
     | 
    
         
            +
                    STDERR.puts e.message
         
     | 
| 
      
 163 
     | 
    
         
            +
                    STDERR.puts @opts
         
     | 
| 
      
 164 
     | 
    
         
            +
                    STDERR.puts "\n"
         
     | 
| 
      
 165 
     | 
    
         
            +
                    exit -1
         
     | 
| 
      
 166 
     | 
    
         
            +
                  rescue OptionParser::InvalidOption => e
         
     | 
| 
      
 167 
     | 
    
         
            +
                    STDERR.puts e.message
         
     | 
| 
      
 168 
     | 
    
         
            +
                    STDERR.puts @opts
         
     | 
| 
      
 169 
     | 
    
         
            +
                    STDERR.puts "\n"
         
     | 
| 
      
 170 
     | 
    
         
            +
                    exit -1
         
     | 
| 
      
 171 
     | 
    
         
            +
                  end
         
     | 
| 
      
 172 
     | 
    
         
            +
                end
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
      
 174 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version 
     | 
|
| 
       5 
5 
     | 
    
         
             
              segments: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              - 0
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
     | 
    
         
            -
              -  
     | 
| 
       9 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 8 
     | 
    
         
            +
              - 8
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.0.8
         
     | 
| 
       10 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       11 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       12 
12 
     | 
    
         
             
            - Dustin Willis Webber
         
     | 
| 
         @@ -14,7 +14,7 @@ autorequire: 
     | 
|
| 
       14 
14 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       15 
15 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
            date: 2010-07- 
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2010-07-04 00:00:00 -04:00
         
     | 
| 
       18 
18 
     | 
    
         
             
            default_executable: gill
         
     | 
| 
       19 
19 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       20 
20 
     | 
    
         |