gill 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## VIM
9
+ *.swp
10
+
11
+ ## PROJECT::GENERAL
12
+ coverage
13
+ rdoc
14
+ pkg
15
+
16
+ ## PROJECT::SPECIFIC
data/.specopts ADDED
@@ -0,0 +1 @@
1
+ --colour --format specdoc
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown --title 'Gill Documentation' --protected --files ChangeLog.md,LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group(:development) do
4
+ gem 'rake', '~> 0.8.7'
5
+ gem 'jeweler', '~> 1.4.0', :git => 'git://github.com/technicalpickles/jeweler.git'
6
+ end
7
+
8
+ group(:doc) do
9
+ gem 'yard', '~> 0.5.3'
10
+ end
11
+
12
+ gem 'rspec', '~> 1.3.0', :group => [:development]
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Gill - Git, Clone, Cleanliness..
2
+
3
+ Copyright (c) 2009-2010 Dustin Willis Webber
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,67 @@
1
+ = gill
2
+
3
+ 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
+
5
+ Files created by gill:
6
+ * ~/.gillrc #=> gill configurations
7
+ * ~/.gillcache #=> List of all gilled (installed) repos.
8
+
9
+ == Example
10
+
11
+ Gill Usage:
12
+
13
+ $ gill --help
14
+ Gill - Version: 0.0.1 - Git, Clone, Cleanliness.
15
+ Usage: gill [TYPE]:[FOLDER]:[URI]
16
+ Example: gill ruby:somelib:http://example.com/some_lib.git
17
+
18
+ -l, --list List Gilled Repos.
19
+ -r, --remove Remove a Gilled Repo. ie. -r ruby:somelib
20
+ -h, --help This help summary page.
21
+ -v, --version Version number
22
+
23
+ Cloning a git repo with gill:
24
+
25
+ $ gill rails:snorby:git@github.com:mephux/Snorby.git
26
+ Initialized empty Git repository in /Users/mephux/Source/rails/snorby/.git/
27
+ remote: Counting objects: 7958, done.
28
+ remote: Compressing objects: 100% (3367/3367), done.
29
+ remote: Total 7958 (delta 4199), reused 7946 (delta 4193)
30
+ Receiving objects: 100% (7958/7958), 8.59 MiB | 568 KiB/s, done.
31
+ Resolving deltas: 100% (4199/4199), done.
32
+
33
+ This will create a folder called 'rails' and clone the repo inside a folder called 'snorby'. ie: '/Users/mephux/Source/rails/snorby/'
34
+
35
+ gill jruby:jruby:http://github.com/jruby/jruby.git
36
+ gill security:ronin:http://github.com/postmodern/ronin.git
37
+ gill work:project:uri_to_work_proejct
38
+ etc...
39
+
40
+ Listing cloned repos:
41
+
42
+ $ gill --list
43
+ Listing Installed Repos:
44
+
45
+ rails:
46
+ snorby => git@github.com:mephux/Snorby.git
47
+
48
+ Removing a cloned repo:
49
+
50
+ $ gill -r rails:snorby
51
+ Removing: rails-test => snorby
52
+ Repo Removed Successfully.
53
+ Updating Cache...
54
+
55
+ == Note on Patches/Pull Requests
56
+
57
+ * Fork the project.
58
+ * Make your feature addition or bug fix.
59
+ * Add tests for it. This is important so I don't break it in a
60
+ future version unintentionally.
61
+ * Commit, do not mess with rakefile, version, or history.
62
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
63
+ * Send me a pull request. Bonus points for topic branches.
64
+
65
+ == Copyright
66
+
67
+ Copyright (c) 2010 Dustin Willis Webber. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'jeweler'
4
+ require './lib/gill/version.rb'
5
+ require 'bundler'
6
+
7
+ begin
8
+ Bundler.setup(:development, :doc)
9
+ rescue Bundler::BundlerError => e
10
+ STDERR.puts e.message
11
+ STDERR.puts "Run `bundle install` to install missing gems"
12
+ exit e.status_code
13
+ end
14
+
15
+ Jeweler::Tasks.new do |gem|
16
+ gem.name = 'gill'
17
+ gem.version = Gill::VERSION
18
+ gem.license = 'MIT'
19
+ gem.summary = %Q{Gill- Git, Clone, Cleanliness.}
20
+ gem.description = %Q{Gill is a simple Ruby app to help keep your git clones clean and organized.}
21
+ gem.email = 'dustin.webber@gmail.com'
22
+ gem.homepage = 'http://github.com/mephux/gill'
23
+ gem.authors = ['Dustin Willis Webber']
24
+ gem.has_rdoc = 'yard'
25
+ end
26
+
27
+ require 'spec/rake/spectask'
28
+ Spec::Rake::SpecTask.new(:spec) do |spec|
29
+ spec.libs += ['lib', 'spec']
30
+ spec.spec_files = FileList['spec/**/*_spec.rb']
31
+ spec.spec_opts = ['--options', '.specopts']
32
+ end
33
+
34
+ task :default => :spec
35
+
36
+ require 'yard'
37
+ YARD::Rake::YardocTask.new
data/bin/gill ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
4
+ unless $LOAD_PATH.include?(lib_dir)
5
+ $LOAD_PATH << lib_dir
6
+ end
7
+
8
+ require 'gill'
9
+ Gill.run
data/lib/gill/app.rb ADDED
@@ -0,0 +1,107 @@
1
+ require 'gill/config'
2
+ require 'gill/git'
3
+ require 'gill/remove'
4
+ require 'gill/version'
5
+ require 'yaml'
6
+ require 'optparse'
7
+
8
+ module Gill
9
+
10
+ # Load Gill Configuration
11
+ GILL_CONFIG = Gill::Config.new.yaml
12
+
13
+ def Gill.run
14
+ Gill.optparse(*ARGV)
15
+ begin
16
+ uri = @options[:uri].split(':', 3)
17
+ type = uri[0]
18
+ folder = uri[1]
19
+ path = uri[2]
20
+ if path =~ /\.git/
21
+ gillgit = Git.new(type, folder, path)
22
+ gillgit.clone
23
+ else
24
+ STDERR.puts "Gill - Version: #{Gill::VERSION}\n"
25
+ STDERR.puts "Error: Not a git repository."
26
+ end
27
+ rescue TypeError
28
+ STDERR.puts "Gill - Version: #{Gill::VERSION}\n"
29
+ STDERR.puts "Error: Please make sure to remove all whitespace from types and folder names."
30
+ rescue => e
31
+ STDERR.puts "Gill - Version: #{Gill::VERSION}\n"
32
+ STDERR.puts "Error: #{e}"
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def Gill.error
39
+ STDERR.puts "#{@opts}\n"
40
+ exit -1
41
+ end
42
+
43
+ def Gill.list
44
+ cache = YAML.load_file(GILL_CONFIG[:cache])
45
+ STDERR.puts "Listing Cloned Repositories:\n\n"
46
+ cache.each do |type,repos|
47
+ STDERR.puts "\t#{type}:"
48
+ repos.each do |repo|
49
+ STDERR.puts "\t\t#{repo[0]} => #{repo[1]}"
50
+ end
51
+ STDERR.puts "\n"
52
+ end
53
+ exit -1
54
+ end
55
+
56
+ def Gill.remove
57
+ remove = @options[:remove].split(':', 2)
58
+ removerepo = Remove.new(remove[0], remove[1]).remove_repo
59
+ STDERR.puts "\n"
60
+ exit -1
61
+ end
62
+
63
+ def Gill.optparse(*args)
64
+ @opts = OptionParser.new
65
+
66
+ @options = {}
67
+
68
+ @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"
69
+
70
+ @opts.on('-l','--list','List all cloned repositories.') do |list|
71
+ @options[:list] = list
72
+ end
73
+
74
+ @opts.on('-r ','--remove ','Remove a cloned repository. ie. -r ruby:somelib') do |remove|
75
+ @options[:remove] = remove
76
+ end
77
+
78
+ @opts.on('-h','--help','This help summary page.') do |help|
79
+ @options[:help] = help
80
+ end
81
+
82
+ @opts.on('-v','--version','Version number') do |version|
83
+ STDERR.puts "Gill - Version: #{Gill::VERSION}"
84
+ exit -1
85
+ end
86
+
87
+ begin
88
+ @args = @opts.parse!(args)
89
+ @options[:uri] = @args[0]
90
+ Gill.error if @options[:help]
91
+ Gill.list if @options[:list]
92
+ Gill.remove if @options[:remove]
93
+ Gill.error if @options.empty? or @options[:uri].nil?
94
+ rescue OptionParser::MissingArgument => e
95
+ STDERR.puts e.message
96
+ STDERR.puts @opts
97
+ STDERR.puts "\n"
98
+ exit -1
99
+ rescue OptionParser::InvalidOption => e
100
+ STDERR.puts e.message
101
+ STDERR.puts @opts
102
+ STDERR.puts "\n"
103
+ exit -1
104
+ end
105
+ end
106
+
107
+ end
@@ -0,0 +1,57 @@
1
+ module Gill
2
+
3
+ class Config
4
+
5
+ attr_accessor :config
6
+
7
+ def initialize
8
+ @home ||= File.expand_path('~')
9
+ @path ||= File.join(@home, '.gillrc')
10
+ @cache ||= File.join(@home, '.gillcache')
11
+ self.setup
12
+ end
13
+
14
+ def build_config
15
+ config = { :home => @home, :config => @path, :source => "#{@home}/source", :cache => @cache }
16
+ File.open(@path, 'w') do |out|
17
+ YAML.dump(config, out)
18
+ end
19
+ end
20
+
21
+ def build_source_folder
22
+ unless File.directory?(self.config[:source])
23
+ Dir.mkdir(self.config[:source])
24
+ end
25
+ end
26
+
27
+ def build_cache
28
+ cache = { }
29
+ File.open(@cache, 'w') do |out|
30
+ YAML.dump(cache, out)
31
+ end
32
+ end
33
+
34
+ def self.rebuild_cache(path, cache)
35
+ File.open(path, 'w+') do |out|
36
+ YAML.dump(cache, out)
37
+ end
38
+ end
39
+
40
+ def setup
41
+ if File.exists?("#{@path}")
42
+ self.build_cache unless File.exists?("#{@cache}")
43
+ self.config = YAML.load_file(@path)
44
+ else
45
+ self.build_config
46
+ self.build_cache unless File.exists?("#{@cache}")
47
+ self.config = YAML.load_file(@path)
48
+ end
49
+ end
50
+
51
+ def yaml
52
+ self.config
53
+ end
54
+
55
+ end
56
+
57
+ end
data/lib/gill/git.rb ADDED
@@ -0,0 +1,48 @@
1
+ module Gill
2
+ class Git
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)
12
+ end
13
+
14
+ def parse_path
15
+ end
16
+
17
+ def build_cache
18
+ old_cache = YAML.load_file(@cache)
19
+ if old_cache[:"#{@type}"]
20
+ old_cache[:"#{@type}"] = old_cache[:"#{@type}"].merge!({:"#{@folder}" => @path})
21
+ else
22
+ old_cache = old_cache.merge!({:"#{@type}" => {:"#{@folder}" => @path}})
23
+ end
24
+ Gill::Config.rebuild_cache(@cache, old_cache)
25
+ end
26
+
27
+ def build_type_folder
28
+ unless File.directory?(@type_path)
29
+ Dir.mkdir(@type_path)
30
+ unless File.directory?(@folder_path)
31
+ Dir.mkdir(@folder_path)
32
+ end
33
+ end
34
+ end
35
+
36
+ def clone
37
+ if File.directory?(@folder_path)
38
+ STDERR.puts "Gill - Version: #{Gill::VERSION}\n"
39
+ STDERR.puts "destination path '#{@folder_path}' already exists and is not an empty directory.\n"
40
+ else
41
+ build_type_folder
42
+ build_cache
43
+ system('git', 'clone', @path, @folder_path)
44
+ end
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,59 @@
1
+ module Gill
2
+
3
+ class Remove
4
+
5
+ def initialize(type,folder)
6
+
7
+ @type = type
8
+ @folder = folder
9
+ @cache = GILL_CONFIG[:cache]
10
+ @source = GILL_CONFIG[:source]
11
+
12
+ end
13
+
14
+ def remove_cache
15
+
16
+ old_cache = YAML.load_file(@cache)
17
+
18
+ if old_cache[:"#{@type}"]
19
+ old_cache[:"#{@type}"].delete(:"#{@folder}")
20
+
21
+ if old_cache[:"#{@type}"].empty?
22
+ old_cache.delete(:"#{@type}")
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
34
+ end
35
+
36
+ def remove_repo
37
+
38
+ type_folder = "#{@source}/#{@type}"
39
+ folder = "#{@source}/#{@type}/#{@folder}"
40
+
41
+ if File.directory?(type_folder) && File.directory?(folder) && !YAML.load_file(@cache).empty?
42
+
43
+ if YAML.load_file(@cache)[:"#{@type}"][:"#{@folder}"]
44
+ STDERR.puts "Removing: #{@type} => #{@folder}"
45
+ FileUtils.rm_rf(folder)
46
+ STDERR.puts "Repository Removed Successfully."
47
+ STDERR.puts "Updating Gill Cache..."
48
+ FileUtils.rm_rf(type_folder) if remove_cache
49
+ end
50
+
51
+ else
52
+
53
+ STDERR.puts "The directory #{@source}/#{@type}/#{@folder} does not exist or was not cloned with gill."
54
+
55
+ end
56
+ end
57
+
58
+ end
59
+ end
@@ -0,0 +1,4 @@
1
+ module Gill
2
+ # Gill Version
3
+ VERSION = '0.0.1'
4
+ end
data/lib/gill.rb ADDED
@@ -0,0 +1,20 @@
1
+ #
2
+ # Gill - Git, Clone, Cleanliness..
3
+ #
4
+ # Copyright (c) 20009-2010 Dustin Willis Webber (dustin.webber@gmail.com)
5
+ #
6
+ # This program is free software; you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation; either version 2 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with this program; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
+ #
20
+ require 'gill/app'
data/spec/gill_spec.rb ADDED
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Gill" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'gill'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gill
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Dustin Willis Webber
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-06-27 00:00:00 -04:00
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
+ - 0
27
+ - 8
28
+ - 7
29
+ version: 0.8.7
30
+ prerelease: false
31
+ type: :development
32
+ name: rake
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 1
41
+ - 4
42
+ - 0
43
+ version: 1.4.0
44
+ prerelease: false
45
+ type: :development
46
+ name: jeweler
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 1
55
+ - 3
56
+ - 0
57
+ version: 1.3.0
58
+ prerelease: false
59
+ type: :development
60
+ name: rspec
61
+ version_requirements: *id003
62
+ description: Gill is a simple Ruby app to help keep your git clones clean and organized.
63
+ email: dustin.webber@gmail.com
64
+ executables:
65
+ - gill
66
+ extensions: []
67
+
68
+ extra_rdoc_files:
69
+ - LICENSE
70
+ - README.rdoc
71
+ files:
72
+ - .document
73
+ - .gitignore
74
+ - .specopts
75
+ - .yardopts
76
+ - Gemfile
77
+ - LICENSE
78
+ - README.rdoc
79
+ - Rakefile
80
+ - bin/gill
81
+ - lib/gill.rb
82
+ - lib/gill/app.rb
83
+ - lib/gill/config.rb
84
+ - lib/gill/git.rb
85
+ - lib/gill/remove.rb
86
+ - lib/gill/version.rb
87
+ - spec/gill_spec.rb
88
+ - spec/spec.opts
89
+ - spec/spec_helper.rb
90
+ has_rdoc: yard
91
+ homepage: http://github.com/mephux/gill
92
+ licenses:
93
+ - MIT
94
+ post_install_message:
95
+ rdoc_options: []
96
+
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ segments:
111
+ - 0
112
+ version: "0"
113
+ requirements: []
114
+
115
+ rubyforge_project:
116
+ rubygems_version: 1.3.6
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: Gill- Git, Clone, Cleanliness.
120
+ test_files:
121
+ - spec/gill_spec.rb
122
+ - spec/spec_helper.rb