gill 0.0.5 → 0.0.7

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/.gitignore CHANGED
@@ -11,6 +11,11 @@ tmtags
11
11
  ## PROJECT::GENERAL
12
12
  coverage
13
13
  rdoc
14
+ doc
15
+ .yardoc
14
16
  pkg
15
17
 
16
18
  ## PROJECT::SPECIFIC
19
+ .bundle/
20
+ .document
21
+ gill.gemspec
data/Gemfile CHANGED
@@ -1,16 +1,13 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- group(:runtime) do
4
- gem 'rainbow', '~> 1.1'
5
- end
6
-
7
3
  group(:development) do
8
4
  gem 'rake', '~> 0.8.7'
9
- gem 'jeweler', '~> 1.4.0', :git => 'git://github.com/technicalpickles/jeweler.git'
5
+ gem 'bluecloth', '~> 2.0.7'
6
+ gem 'jeweler', '~> 1.4.0'
10
7
  end
11
8
 
12
9
  group(:doc) do
13
- gem 'yard', '~> 0.5.3'
10
+ gem 'yard', '~> 0.5.3'
14
11
  end
15
12
 
16
- gem 'rspec', '~> 1.3.0', :group => [:development]
13
+ gem 'rspec', '~> 1.3.0', :group => [:development]
data/README.rdoc CHANGED
@@ -10,51 +10,68 @@ Files created by gill:
10
10
 
11
11
  gem install gill
12
12
 
13
- * NOTE: if you are using gill <= 0.0.3 please upgrade to version >= 0.0.4.
13
+ * NOTE: if you are using gill <= 0.0.3 please upgrade to version >= 0.0.6.
14
14
 
15
15
  == Example
16
16
 
17
17
  Gill Usage:
18
18
 
19
19
  $ gill --help
20
- Gill - Version: 0.0.1 - Git, Clone, Cleanliness.
21
- Usage: gill [TYPE]:[FOLDER]:[URI]
22
- Example: gill ruby:somelib:http://example.com/some_lib.git
20
+ Gill - Git, Clone, Cleanliness.
21
+ Usage: gill git://host/repository.git#category/sub-category/...
23
22
 
24
- -l, --list List Gilled Repos.
25
- -r, --remove Remove a Gilled Repo. ie. -r ruby:somelib
23
+ -l, --list List all cloned repositories.
24
+ -r, --remove Remove a cloned repository. ie. -r category#folder
26
25
  -h, --help This help summary page.
27
26
  -v, --version Version number
28
27
 
29
- Cloning a git repo with gill:
30
28
 
31
- $ gill rails:snorby:git@github.com:mephux/Snorby.git
32
- Initialized empty Git repository in /Users/mephux/Source/rails/snorby/.git/
29
+ Cloning a git repository with gill:
30
+
31
+ $ gill https://mephux@github.com/mephux/Snorby.git#rails#snorby-dev
32
+ Initialized empty Git repository in /Users/mephux/Source/rails/snorby-dev/.git/
33
33
  remote: Counting objects: 7958, done.
34
34
  remote: Compressing objects: 100% (3367/3367), done.
35
35
  remote: Total 7958 (delta 4199), reused 7946 (delta 4193)
36
36
  Receiving objects: 100% (7958/7958), 8.59 MiB | 568 KiB/s, done.
37
37
  Resolving deltas: 100% (4199/4199), done.
38
38
 
39
- This will create a folder called 'rails' and clone the repo inside a folder called 'snorby'. ie: '/Users/mephux/Source/rails/snorby/'
40
-
41
- gill jruby:jruby:http://github.com/jruby/jruby.git
42
- gill security:ronin:http://github.com/ronin-ruby/ronin.git
43
- gill work:project:uri_to_work_proejct
44
- etc...
39
+ This will create a folder called 'rails' and clone the repo inside a folder called 'snorby'. ie: '/Users/mephux/Source/rails/snorby-dev/'
40
+
41
+ gill https://mephux@github.com/mephux/gill.git#ruby
42
+ gill http://github.com/jruby/jruby.git#jruby
43
+ gill http://github.com/ronin-ruby/ronin.git#security#ronin-dev
44
+ gill http://github.com/postmodern/spidr.git#security#spidr-dev
45
+ gill https://mephux@github.com/mephux/Snorby.git#rails/3.0#snorby/dev/beta2.0
46
+
47
+ etc...
45
48
 
46
49
  Listing cloned repositories:
47
50
 
48
51
  $ gill --list
49
- Listing Cloned Repositories:
50
52
 
51
- rails:
52
- snorby => git@github.com:mephux/Snorby.git
53
-
53
+ *** Listing Cloned Repositories ***
54
+
55
+ vim:
56
+ neocomplcache => http://github.com/Shougo/neocomplcache.git
57
+
58
+ jruby:
59
+ jruby => http://github.com/jruby/jruby.git
60
+
61
+ ruby:
62
+ gill => git@github.com:mephux/gill.git
63
+
64
+ security:
65
+ ronin-dev => http://github.com/ronin-ruby/ronin.git
66
+ spidr-dev => http://github.com/postmodern/spidr.git
67
+
68
+ rails/3.0:
69
+ snorby/dev/beta2.0 => https://mephux@github.com/mephux/Snorby.git
70
+
54
71
  Removing cloned repositories:
55
72
 
56
- $ gill -r rails:snorby
57
- Removing: rails => snorby
73
+ $ gill -r rails/3.0#snorby/dev/beta2.0
74
+ Removing: rails/3.0 => snorby/dev/beta2.0
58
75
  Repository Removed Successfully.
59
76
  Updating Cache...
60
77
 
data/Rakefile CHANGED
@@ -13,16 +13,22 @@ require 'rake'
13
13
  require 'jeweler'
14
14
  require './lib/gill/version.rb'
15
15
 
16
- Jeweler::Tasks.new do |gem|
17
- gem.name = 'gill'
18
- gem.version = Gill::VERSION
19
- gem.license = 'MIT'
20
- gem.summary = %Q{Gill- Git, Clone, Cleanliness.}
21
- gem.description = %Q{Gill is a simple Ruby app to help keep your git clones clean and organized.}
22
- gem.email = 'dustin.webber@gmail.com'
23
- gem.homepage = 'http://github.com/mephux/gill'
24
- gem.authors = ['Dustin Willis Webber']
25
- gem.has_rdoc = 'yard'
16
+ begin
17
+ require 'jeweler'
18
+ Jeweler::Tasks.new do |gem|
19
+ gem.name = 'gill'
20
+ gem.version = Gill::VERSION
21
+ gem.license = 'MIT'
22
+ gem.summary = %Q{Gill- Git, Clone, Cleanliness.}
23
+ gem.description = %Q{Gill is a simple Ruby app to help keep your git clones clean and organized.}
24
+ gem.email = 'dustin.webber@gmail.com'
25
+ gem.homepage = 'http://github.com/mephux/gill'
26
+ gem.authors = ['Dustin Willis Webber']
27
+ gem.has_rdoc = 'yard'
28
+ end
29
+ Jeweler::GemcutterTasks.new
30
+ rescue LoadError
31
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
26
32
  end
27
33
 
28
34
  require 'spec/rake/spectask'
data/gill.gemspec CHANGED
@@ -5,51 +5,56 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gill}
8
- s.version = "0.0.5"
8
+ s.version = "0.0.7"
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-06-27}
12
+ s.date = %q{2010-07-01}
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}
16
16
  s.executables = ["gill"]
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE",
19
- "README.rdoc"
19
+ "README.rdoc"
20
20
  ]
21
21
  s.files = [
22
- ".bundle/config",
23
- ".document",
24
22
  ".gitignore",
25
- ".specopts",
26
- ".yardopts",
27
- "Gemfile",
28
- "LICENSE",
29
- "README.rdoc",
30
- "Rakefile",
31
- "bin/gill",
32
- "gill.gemspec",
33
- "lib/gill.rb",
34
- "lib/gill/app.rb",
35
- "lib/gill/config.rb",
36
- "lib/gill/git.rb",
37
- "lib/gill/parse.rb",
38
- "lib/gill/remove.rb",
39
- "lib/gill/version.rb",
40
- "spec/gill_spec.rb",
41
- "spec/spec.opts",
42
- "spec/spec_helper.rb"
23
+ ".specopts",
24
+ ".yardopts",
25
+ "Gemfile",
26
+ "LICENSE",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "bin/gill",
30
+ "gill.gemspec",
31
+ "lib/gill.rb",
32
+ "lib/gill/app.rb",
33
+ "lib/gill/config.rb",
34
+ "lib/gill/exceptions/argument_error.rb",
35
+ "lib/gill/exceptions/directory_error.rb",
36
+ "lib/gill/exceptions/error.rb",
37
+ "lib/gill/exceptions/repository_error.rb",
38
+ "lib/gill/git.rb",
39
+ "lib/gill/parse.rb",
40
+ "lib/gill/remove.rb",
41
+ "lib/gill/version.rb",
42
+ "spec/gill_spec.rb",
43
+ "spec/parse_spec.rb",
44
+ "spec/spec.opts",
45
+ "spec/spec_helper.rb"
43
46
  ]
44
47
  s.has_rdoc = %q{yard}
45
48
  s.homepage = %q{http://github.com/mephux/gill}
46
49
  s.licenses = ["MIT"]
50
+ s.rdoc_options = ["--charset=UTF-8"]
47
51
  s.require_paths = ["lib"]
48
52
  s.rubygems_version = %q{1.3.6}
49
53
  s.summary = %q{Gill- Git, Clone, Cleanliness.}
50
54
  s.test_files = [
51
55
  "spec/gill_spec.rb",
52
- "spec/spec_helper.rb"
56
+ "spec/parse_spec.rb",
57
+ "spec/spec_helper.rb"
53
58
  ]
54
59
 
55
60
  if s.respond_to? :specification_version then
@@ -57,21 +62,9 @@ Gem::Specification.new do |s|
57
62
  s.specification_version = 3
58
63
 
59
64
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
60
- s.add_runtime_dependency(%q<rainbow>, ["~> 1.1"])
61
- s.add_development_dependency(%q<rake>, ["~> 0.8.7"])
62
- s.add_development_dependency(%q<jeweler>, ["~> 1.4.0"])
63
- s.add_development_dependency(%q<rspec>, ["~> 1.3.0"])
64
65
  else
65
- s.add_dependency(%q<rainbow>, ["~> 1.1"])
66
- s.add_dependency(%q<rake>, ["~> 0.8.7"])
67
- s.add_dependency(%q<jeweler>, ["~> 1.4.0"])
68
- s.add_dependency(%q<rspec>, ["~> 1.3.0"])
69
66
  end
70
67
  else
71
- s.add_dependency(%q<rainbow>, ["~> 1.1"])
72
- s.add_dependency(%q<rake>, ["~> 0.8.7"])
73
- s.add_dependency(%q<jeweler>, ["~> 1.4.0"])
74
- s.add_dependency(%q<rspec>, ["~> 1.3.0"])
75
68
  end
76
69
  end
77
70
 
data/lib/gill/app.rb CHANGED
@@ -1,43 +1,65 @@
1
1
  require 'gill/config'
2
2
  require 'gill/git'
3
- require 'fileutils'
4
3
  require 'gill/remove'
5
4
  require 'gill/parse'
6
5
  require 'gill/version'
7
- require 'rainbow'
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'
8
13
  require 'yaml'
9
14
  require 'optparse'
10
15
 
11
16
  module Gill
12
17
 
18
+ #
13
19
  # Load Gill Configuration
20
+ #
14
21
  GILL_CONFIG = Gill::Config.new.yaml
15
22
 
23
+ #
24
+ # Run Gill
25
+ #
16
26
  def Gill.run
27
+ Gill.check_cache
17
28
  Gill.optparse(*ARGV)
18
29
  begin
19
30
 
20
- path = Parse.new(@options[:uri])
21
-
22
- if path.valid?
23
- gillgit = Git.new(path.type, path.folder, path.repo)
24
- gillgit.clone
25
- else
26
- STDERR.puts "Gill - Version: #{Gill::VERSION}\n"
27
- STDERR.puts "Error: Not a valid git repository \"#{path.repo}\" or is currently not supported."
28
- end
29
-
30
- rescue TypeError
31
- STDERR.puts "Gill - Version: #{Gill::VERSION}\n"
32
- STDERR.puts "Error: Please make sure to remove all whitespace from types and folder names."
31
+ uri = Parse.new(@options[:uri])
32
+ git = Git.new(uri.category, uri.folder, uri.repo)
33
+ git.clone
34
+
35
+ rescue TypeError => e
36
+ STDERR.puts "Error: #{e}\nError: Please make sure to remove all whitespace from the category and/or folder name."
33
37
  rescue => e
34
- STDERR.puts "Gill - Version: #{Gill::VERSION}\n"
35
38
  STDERR.puts "Error: #{e}"
36
39
  end
37
40
  end
38
41
 
39
42
  private
40
43
 
44
+
45
+ def Gill.check_cache
46
+ cache = GILL_CONFIG[:cache]
47
+ @new_cache = YAML.load_file(GILL_CONFIG[:cache])
48
+ source_dir = GILL_CONFIG[:source]
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)
61
+ end
62
+
41
63
  def Gill.error
42
64
  STDERR.puts "#{@opts}\n"
43
65
  exit -1
@@ -49,7 +71,7 @@ module Gill
49
71
  cache.each do |type,repos|
50
72
  STDERR.puts "\t#{type}:"
51
73
  repos.each do |repo|
52
- STDERR.puts "\t #{repo[0]} => " + "#{repo[1]}".foreground(:green)
74
+ STDERR.puts "\t #{repo[0]} => " + "#{repo[1]}"
53
75
  end
54
76
  STDERR.puts "\n"
55
77
  end
@@ -57,9 +79,13 @@ module Gill
57
79
  end
58
80
 
59
81
  def Gill.remove
60
- remove = @options[:remove].split(':', 2)
61
- removerepo = Remove.new(remove[0], remove[1]).remove_repo
62
- STDERR.puts "\n"
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
63
89
  exit -1
64
90
  end
65
91
 
@@ -68,13 +94,13 @@ module Gill
68
94
 
69
95
  @options = {}
70
96
 
71
- @opts.banner = "Gill - Version: #{Gill::VERSION} - Git, Clone, Cleanliness.\nUsage: gill [TYPE]:[FOLDER]:[URI]\nExample: gill ruby:somelib:http://example.com/some_lib.git\n\n"
97
+ @opts.banner = "Gill - Git, Clone, Cleanliness.\nUsage: gill git://host/repository.git#category/sub-category/...\n\n"
72
98
 
73
99
  @opts.on('-l','--list','List all cloned repositories.') do |list|
74
100
  @options[:list] = list
75
101
  end
76
102
 
77
- @opts.on('-r ','--remove ','Remove a cloned repository. ie. -r ruby:somelib') do |remove|
103
+ @opts.on('-r ','--remove ','Remove a cloned repository. ie. -r category#folder') do |remove|
78
104
  @options[:remove] = remove
79
105
  end
80
106
 
@@ -83,7 +109,7 @@ module Gill
83
109
  end
84
110
 
85
111
  @opts.on('-v','--version','Version number') do |version|
86
- STDERR.puts "Gill - Version: #{Gill::VERSION}"
112
+ STDERR.puts "Version: #{Gill::VERSION}"
87
113
  exit -1
88
114
  end
89
115
 
data/lib/gill/config.rb CHANGED
@@ -5,12 +5,15 @@ module Gill
5
5
  attr_accessor :config
6
6
 
7
7
  def initialize
8
- @home ||= File.expand_path('~')
9
- @path ||= File.join(@home, '.gillrc')
10
- @cache ||= File.join(@home, '.gillcache')
8
+ @home = File.expand_path('~')
9
+ @path = File.join(@home, '.gillrc')
10
+ @cache = File.join(@home, '.gillcache')
11
11
  self.setup
12
12
  end
13
13
 
14
+ #
15
+ # Build the initial .gillrc configuration file.
16
+ #
14
17
  def build_config
15
18
  config = { :home => @home, :config => @path, :source => "#{@home}/source", :cache => @cache }
16
19
  File.open(@path, 'w') do |out|
@@ -18,12 +21,21 @@ module Gill
18
21
  end
19
22
  end
20
23
 
24
+ #
25
+ # Build the initial source directory configured in the .gillrc file.
26
+ #
27
+ # The initial source directory is only created if it does not exist.
28
+ #
21
29
  def build_source_folder
22
30
  unless File.directory?(self.config[:source])
31
+ STDERR.puts "Creating Source Directory: " + "#{self.config[:source]}"
23
32
  Dir.mkdir(self.config[:source])
24
33
  end
25
34
  end
26
35
 
36
+ #
37
+ # Build the inital .gillache file in the user home directory.
38
+ #
27
39
  def build_cache
28
40
  cache = { }
29
41
  File.open(@cache, 'w') do |out|
@@ -31,23 +43,36 @@ module Gill
31
43
  end
32
44
  end
33
45
 
46
+ #
47
+ # Rebuild cache writes updated entries to the .gillache file in the user home directory.
48
+ #
34
49
  def self.rebuild_cache(path, cache)
35
50
  File.open(path, 'w+') do |out|
36
51
  YAML.dump(cache, out)
37
52
  end
38
53
  end
39
54
 
55
+ #
56
+ # Setup - Determine if the current user has the proper gill configuration file in place
57
+ # or return the current configuration files.
58
+ #
40
59
  def setup
41
60
  if File.exists?("#{@path}")
42
61
  self.build_cache unless File.exists?("#{@cache}")
43
62
  self.config = YAML.load_file(@path)
63
+ self.build_source_folder
44
64
  else
45
65
  self.build_config
46
66
  self.build_cache unless File.exists?("#{@cache}")
47
67
  self.config = YAML.load_file(@path)
68
+ self.build_source_folder
48
69
  end
49
70
  end
50
71
 
72
+ #
73
+ # Yaml
74
+ # return the configuration file in yaml format.
75
+ #
51
76
  def yaml
52
77
  self.config
53
78
  end
@@ -0,0 +1,5 @@
1
+ module Gill
2
+ class ArgumentError < Error
3
+
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Gill
2
+ class DirectoryError < Error
3
+
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module Gill
2
+ class Error < RuntimeError
3
+ end
4
+ end
@@ -0,0 +1,5 @@
1
+ module Gill
2
+ class RepositoryError < Error
3
+
4
+ end
5
+ end
data/lib/gill/git.rb CHANGED
@@ -1,42 +1,50 @@
1
1
  module Gill
2
2
  class Git
3
3
 
4
- def initialize(type,folder,path)
5
- @path = path
6
- @type = type
7
- @folder = folder
8
- @cache = GILL_CONFIG[:cache]
9
- @source = GILL_CONFIG[:source]
10
- @type_path = File.join(@source, @type)
11
- @folder_path = File.join(@type_path, @folder)
4
+ def initialize(category,folder,repo)
5
+ @repo, @category, @folder = repo, category, folder
6
+ @cache, @source = GILL_CONFIG[:cache], GILL_CONFIG[:source]
7
+ @category_path = File.join(@source, @category)
8
+ if @folder
9
+ @folder_path = File.join(@category_path, @folder)
10
+ else
11
+ @folder_path = @category_path
12
+ end
12
13
  end
13
14
 
14
15
  def build_cache
15
16
  old_cache = YAML.load_file(@cache)
16
- if old_cache[:"#{@type}"]
17
- old_cache[:"#{@type}"] = old_cache[:"#{@type}"].merge!({:"#{@folder}" => @path})
17
+ if old_cache[:"#{@category}"]
18
+ old_cache[:"#{@category}"] = old_cache[:"#{@category}"].merge!({:"#{@folder}" => @repo})
18
19
  else
19
- old_cache = old_cache.merge!({:"#{@type}" => {:"#{@folder}" => @path}})
20
+ old_cache = old_cache.merge!({:"#{@category}" => {:"#{@folder}" => @repo}})
20
21
  end
21
22
  Gill::Config.rebuild_cache(@cache, old_cache)
22
23
  end
23
24
 
24
- def build_type_folder
25
- unless File.directory?(@type_path)
26
- Dir.mkdir(@type_path)
27
- unless File.directory?(@folder_path)
28
- Dir.mkdir(@folder_path)
25
+ def build_type_folder(make_folder=true)
26
+ unless File.directory?(@category_path)
27
+ FileUtils.mkdir_p(@category_path)
28
+ if make_folder
29
+ unless File.directory?(@folder_path)
30
+ FileUtils.mkdir_p(@folder_path)
31
+ end
29
32
  end
30
33
  end
31
34
  end
32
35
 
33
36
  def clone
34
- if File.directory?(@folder_path)
35
- STDERR.puts "Gill - Version: #{Gill::VERSION}\n"
36
- STDERR.puts "destination path '#{@folder_path}' already exists and is not an empty directory.\n"
37
+ if File.directory?(@folder_path) && @folder
38
+ raise(DirectoryError, "destination path '#{@folder_path}' already exists and is not an empty directory.")
37
39
  else
38
- build_type_folder
39
- build_cache if system('git', 'clone', @path, @folder_path)
40
+ if @folder
41
+ build_type_folder
42
+ build_cache if system('git', 'clone', @repo, @folder_path)
43
+ else
44
+ build_type_folder(false)
45
+ Dir.chdir(@folder_path)
46
+ build_cache if system('git', 'clone', @repo)
47
+ end
40
48
  end
41
49
  end
42
50
 
data/lib/gill/parse.rb CHANGED
@@ -1,34 +1,66 @@
1
1
  module Gill
2
-
2
+
3
3
  class Parse
4
-
4
+
5
+ attr_accessor :category, :folder, :repo
6
+
5
7
  def initialize(uri)
6
- @uri = uri.split(':', 3)
8
+ @uri = uri.split(/\#/)
9
+ self.start
7
10
  end
8
-
9
- def type
10
- @uri.first
11
+
12
+ def category=(category)
13
+ @category = category
11
14
  end
12
-
13
- def folder
14
- @uri[1]
15
+
16
+ def folder=(folder)
17
+ @folder = folder
15
18
  end
16
-
17
- def repo
18
- @uri.last
19
+
20
+ def repo=(repo)
21
+ @repo = repo
19
22
  end
20
-
21
- def valid?
22
- if type && folder && repo
23
- if repo[/^(http\:|https\:|git\:)+/i] && repo[/\.git/]
24
- return true
25
- else
26
- return false
27
- end
23
+
24
+ def start
25
+ self.category = @uri.first
26
+ if @uri.length == 3
27
+ self.repo = @uri.first if valid?(@uri.first)
28
+ self.category = @uri[1]
29
+ self.folder = @uri.last
30
+ elsif @uri.length == 2
31
+ self.category = @uri.last
32
+ self.repo = @uri.first if valid?(@uri.first)
33
+ self.folder = get_folder(self.repo)
34
+ elsif @uri.length < 2
35
+ raise(ArgumentError, "too few arguments.")
28
36
  else
29
- return false
37
+ raise(ArgumentError, "too many arguments.")
30
38
  end
31
39
  end
32
40
 
41
+ def get_folder(repo)
42
+ if repo =~ /\.git/i
43
+ repo_name = repo.match(/\S+[\/|\:](\S+)\.git/i)[1]
44
+ else
45
+ repo_name = repo.match(/\S+[\/|\:](\S+)\Z/i)[1]
46
+ end
47
+ repo_name
48
+ end
49
+
50
+ def valid?(repo)
51
+ case repo
52
+ when repo[/\A(http|https|git)\:\/\/\S+[\:|\/]\S+[\.git|\Z]\Z/i]
53
+ return repo
54
+ when repo[/http\:\/\/\S+\Z|https\:\/\/\S+\Z|git\:\/\/\S+\Z/i]
55
+ return repo
56
+ when repo[/\A(\S+\@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b\:\S+\S+[\.git|\Z])\Z/i]
57
+ return repo
58
+ when repo[/\A\S+\@\S+[\:|\/]\S+[\.git|\Z]\Z/i]
59
+ return repo
60
+ else
61
+ raise(RepositoryError, 'not a git repository.')
62
+ end
63
+ end
64
+
33
65
  end
34
- end
66
+ end
data/lib/gill/remove.rb CHANGED
@@ -2,24 +2,24 @@ module Gill
2
2
 
3
3
  class Remove
4
4
 
5
- def initialize(type,folder)
6
-
7
- @type = type
8
- @folder = folder
5
+ def initialize(args)
6
+ data = args.split('#')
7
+ raise(ArgumentError, 'Wrong number of arguments.') if data.length != 2
8
+ @category = data.first
9
+ @folder = data.last
9
10
  @cache = GILL_CONFIG[:cache]
10
11
  @source = GILL_CONFIG[:source]
11
-
12
12
  end
13
13
 
14
14
  def remove_cache
15
15
 
16
16
  old_cache = YAML.load_file(@cache)
17
17
 
18
- if old_cache[:"#{@type}"]
19
- old_cache[:"#{@type}"].delete(:"#{@folder}")
18
+ if old_cache[:"#{@category}"]
19
+ old_cache[:"#{@category}"].delete(:"#{@folder}")
20
20
 
21
- if old_cache[:"#{@type}"].empty?
22
- old_cache.delete(:"#{@type}")
21
+ if old_cache[:"#{@category}"].empty?
22
+ old_cache.delete(:"#{@category}")
23
23
  Gill::Config.rebuild_cache(@cache, old_cache)
24
24
  return true
25
25
 
@@ -35,31 +35,30 @@ module Gill
35
35
 
36
36
  def remove_repo
37
37
 
38
- type_folder = "#{@source}/#{@type}"
39
- folder = "#{@source}/#{@type}/#{@folder}"
38
+ type_folder = "#{@source}/#{@category}"
39
+ folder = "#{@source}/#{@category}/#{@folder}"
40
40
 
41
41
  if File.directory?(type_folder) && File.directory?(folder) && !YAML.load_file(@cache).empty?
42
42
 
43
- if YAML.load_file(@cache)[:"#{@type}"][:"#{@folder}"]
44
- STDERR.puts "Removing: #{@type} => " + "#{@folder}".foreground(:red)
43
+ if YAML.load_file(@cache)[:"#{@category}"][:"#{@folder}"]
44
+ STDERR.puts "Removing: #{@category} => " + "#{@folder}"
45
45
  FileUtils.rm_rf(folder)
46
46
  if remove_cache
47
- STDERR.puts "Reviewing folder #{@type}.".foreground(:green)
47
+ STDERR.puts "Reviewing folder #{@category}."
48
48
  if Dir.enum_for(:foreach, type_folder).any? {|n| /\A\.\.?\z/ !~ n}
49
- STDERR.puts "Skipping folder #{@type} - directory not empty.".foreground(:green)
49
+ STDERR.puts "Skipping folder #{@category} - directory not empty."
50
50
  else
51
- STDERR.puts "Removing folder #{@type} - directory empty.".foreground(:green)
51
+ STDERR.puts "Removing folder #{@category} - directory empty."
52
52
  FileUtils.rm_rf(type_folder)
53
53
  end
54
54
  end
55
- STDERR.puts "Repository Removed Successfully.".foreground(:green)
56
- STDERR.puts "Updating Gill Cache...".foreground(:green)
55
+ STDERR.puts "Repository Removed Successfully."
56
+ STDERR.puts "Updating Gill Cache..."
57
57
  end
58
58
 
59
59
  else
60
60
  remove_cache
61
- STDERR.puts "The directory #{@source}/#{@type}/#{@folder} does not exist or was not cloned with gill."
62
-
61
+ raise(DirectoryError, "The directory #{@source}/#{@category}/#{@folder} does not exist or was not cloned with gill.")
63
62
  end
64
63
  end
65
64
 
data/lib/gill/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Gill
2
2
  # Gill Version
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.7'
4
4
  end
data/spec/gill_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe "Gill" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
3
+ describe Gill do
4
+ it "should define a VERSION constant" do
5
+ Gill.should be_const_defined('VERSION')
6
6
  end
7
7
  end
@@ -0,0 +1,37 @@
1
+ require 'gill/parse'
2
+
3
+ describe Parse do
4
+
5
+ before(:all) do
6
+ @p = Parse.new("https://mephux@github.com/mephux/gill.git#ruby")
7
+ @p1 = Parse.new("http://mephux@github.com:gill.git#ruby#gill-dev")
8
+ @p2 = Parse.new("git://mephux@github.com/3/3/3/mephux/gill.git#dev")
9
+ @p3 = Parse.new("mephux@github.com/gill.git#test-123")
10
+ @p4 = Parse.new("mephux@127.0.0.1:gill.git#ruby/w0ot/w0ot/test#hello")
11
+ end
12
+
13
+ it "should grab the repository name correctly" do
14
+ @p.folder.should == 'gill'
15
+ @p1.folder.should == 'gill-dev'
16
+ @p2.folder.should == 'gill'
17
+ @p3.folder.should == 'gill'
18
+ @p4.folder.should == 'hello'
19
+ end
20
+
21
+ it "should grab the repository uri correctly" do
22
+ @p.repo.should == 'https://mephux@github.com/mephux/gill.git'
23
+ @p1.repo.should == 'http://mephux@github.com:gill.git'
24
+ @p2.repo.should == 'git://mephux@github.com/3/3/3/mephux/gill.git'
25
+ @p3.repo.should == 'mephux@github.com/gill.git'
26
+ @p4.repo.should == 'mephux@127.0.0.1:gill.git'
27
+ end
28
+
29
+ it "should grab the repository category name correctly" do
30
+ @p.category.should == 'ruby'
31
+ @p1.category.should == 'ruby'
32
+ @p2.category.should == 'dev'
33
+ @p3.category.should == 'test-123'
34
+ @p4.category.should == 'ruby/w0ot/w0ot/test'
35
+ end
36
+
37
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,7 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'gill'
1
+ require 'rubygems'
2
+ gem 'rspec', '>=1.3.0'
4
3
  require 'spec'
5
- require 'spec/autorun'
6
4
 
7
- Spec::Runner.configure do |config|
8
-
9
- end
5
+ require 'gill/version'
6
+
7
+ include Gill
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 5
9
- version: 0.0.5
8
+ - 7
9
+ version: 0.0.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dustin Willis Webber
@@ -14,64 +14,10 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-27 00:00:00 -04:00
17
+ date: 2010-07-01 00:00:00 -04:00
18
18
  default_executable: gill
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- requirement: &id001 !ruby/object:Gem::Requirement
22
- requirements:
23
- - - ~>
24
- - !ruby/object:Gem::Version
25
- segments:
26
- - 1
27
- - 1
28
- version: "1.1"
29
- prerelease: false
30
- type: :runtime
31
- name: rainbow
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- requirement: &id002 !ruby/object:Gem::Requirement
35
- requirements:
36
- - - ~>
37
- - !ruby/object:Gem::Version
38
- segments:
39
- - 0
40
- - 8
41
- - 7
42
- version: 0.8.7
43
- prerelease: false
44
- type: :development
45
- name: rake
46
- version_requirements: *id002
47
- - !ruby/object:Gem::Dependency
48
- requirement: &id003 !ruby/object:Gem::Requirement
49
- requirements:
50
- - - ~>
51
- - !ruby/object:Gem::Version
52
- segments:
53
- - 1
54
- - 4
55
- - 0
56
- version: 1.4.0
57
- prerelease: false
58
- type: :development
59
- name: jeweler
60
- version_requirements: *id003
61
- - !ruby/object:Gem::Dependency
62
- requirement: &id004 !ruby/object:Gem::Requirement
63
- requirements:
64
- - - ~>
65
- - !ruby/object:Gem::Version
66
- segments:
67
- - 1
68
- - 3
69
- - 0
70
- version: 1.3.0
71
- prerelease: false
72
- type: :development
73
- name: rspec
74
- version_requirements: *id004
19
+ dependencies: []
20
+
75
21
  description: Gill is a simple Ruby app to help keep your git clones clean and organized.
76
22
  email: dustin.webber@gmail.com
77
23
  executables:
@@ -82,8 +28,6 @@ extra_rdoc_files:
82
28
  - LICENSE
83
29
  - README.rdoc
84
30
  files:
85
- - .bundle/config
86
- - .document
87
31
  - .gitignore
88
32
  - .specopts
89
33
  - .yardopts
@@ -96,11 +40,16 @@ files:
96
40
  - lib/gill.rb
97
41
  - lib/gill/app.rb
98
42
  - lib/gill/config.rb
43
+ - lib/gill/exceptions/argument_error.rb
44
+ - lib/gill/exceptions/directory_error.rb
45
+ - lib/gill/exceptions/error.rb
46
+ - lib/gill/exceptions/repository_error.rb
99
47
  - lib/gill/git.rb
100
48
  - lib/gill/parse.rb
101
49
  - lib/gill/remove.rb
102
50
  - lib/gill/version.rb
103
51
  - spec/gill_spec.rb
52
+ - spec/parse_spec.rb
104
53
  - spec/spec.opts
105
54
  - spec/spec_helper.rb
106
55
  has_rdoc: yard
@@ -108,8 +57,8 @@ homepage: http://github.com/mephux/gill
108
57
  licenses:
109
58
  - MIT
110
59
  post_install_message:
111
- rdoc_options: []
112
-
60
+ rdoc_options:
61
+ - --charset=UTF-8
113
62
  require_paths:
114
63
  - lib
115
64
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -135,4 +84,5 @@ specification_version: 3
135
84
  summary: Gill- Git, Clone, Cleanliness.
136
85
  test_files:
137
86
  - spec/gill_spec.rb
87
+ - spec/parse_spec.rb
138
88
  - spec/spec_helper.rb
data/.bundle/config DELETED
@@ -1,2 +0,0 @@
1
- ---
2
- BUNDLE_WITHOUT: ""
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE