pro 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +68 -0
- data/Rakefile +1 -0
- data/bin/pro +44 -0
- data/lib/pro.rb +83 -0
- data/lib/pro/version.rb +3 -0
- data/pro.gemspec +26 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b15ba0cff13982167359dbb415e2b949e9dc1956
|
4
|
+
data.tar.gz: 5f48d6b702d9b045ca05ffeb77df36d2273a0b6a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9403e2d5237705f2daa8a30c0368e65487d2d9ee9d8765896bcaee2313cf44a5cea22d6b4b6320e277ee922eebc78f80f613415c87a575f9862e78b0e7bd18b4
|
7
|
+
data.tar.gz: 96a90289037146c2125abfd7b07eefe7251e3fab049693c035680b2b439a478f090dae6ffba4a20fa2d8c6a11a20a227eee67ab952748e72d1d215b8df78a817
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Tristan Hume
|
2
|
+
|
3
|
+
MIT License
|
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.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Pro
|
2
|
+
|
3
|
+
`pro` is a little utility to wrangle your git repositories.
|
4
|
+
At the moment all it does is provide the very useful function of letting
|
5
|
+
you instantly cd to git repositories based on fuzzy matching.
|
6
|
+
|
7
|
+
## Pro CD
|
8
|
+
|
9
|
+
Use the `pro install` command and follow the prompts to install the pro cd command.
|
10
|
+
As part of the install process you can name it whatever you want but it
|
11
|
+
defaults to `pd`.
|
12
|
+
|
13
|
+
### Examples
|
14
|
+
|
15
|
+
```bash
|
16
|
+
~/randomFolder/ $ pd pro
|
17
|
+
pro/ $ pwd
|
18
|
+
/Users/tristan/Box/Dev/Projects/pro
|
19
|
+
pro/ $ pd eye
|
20
|
+
eyeLike/ $ pwd
|
21
|
+
/Users/tristan/Box/Dev/Projects/eyeLike
|
22
|
+
eyeLike/ $ pd web
|
23
|
+
Website/ $ pwd
|
24
|
+
/Users/tristan/Box/Dev/Website/
|
25
|
+
```
|
26
|
+
|
27
|
+
## Installation
|
28
|
+
|
29
|
+
Pro is bundled as a Ruby gem. To install run:
|
30
|
+
|
31
|
+
$ gem install pro
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
$ pro help
|
36
|
+
pro is a command to help you manage your git repositories.
|
37
|
+
|
38
|
+
base directory ==========
|
39
|
+
pro works from a base directory for efficiency.
|
40
|
+
this is the folder that contains all your other git repositories;
|
41
|
+
they don't have to be at the base level, just somewhere down the tree.
|
42
|
+
|
43
|
+
to set the base directory set the pro_base environment variable or make
|
44
|
+
a ~/.probase file containing the path.
|
45
|
+
|
46
|
+
commands ===============
|
47
|
+
pro search <query> - prints path of git repo that matches query.
|
48
|
+
pro install - install the pro cd command. cd to a directory by fuzzy git repo matching.
|
49
|
+
pro help - display help
|
50
|
+
|
51
|
+
cd command ============
|
52
|
+
you can use the 'pro install' command to install a wrapper function that allows
|
53
|
+
you to cd to git repositories in your pro base wherever you are based on fuzzy matching.
|
54
|
+
|
55
|
+
example:
|
56
|
+
|
57
|
+
~/randomfolder/ $ pd pro
|
58
|
+
pro/ $ pwd
|
59
|
+
/users/tristan/box/dev/projects/pro
|
60
|
+
|
61
|
+
|
62
|
+
## Contributing
|
63
|
+
|
64
|
+
1. Fork it
|
65
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
66
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
67
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
68
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/pro
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# vi: set filetype=ruby fileencoding=UTF-8 shiftwidth=2 tabstop=2 expandtab
|
3
|
+
|
4
|
+
require "pro"
|
5
|
+
|
6
|
+
HELP = <<END
|
7
|
+
pro is a command to help you manage your git repositories.
|
8
|
+
|
9
|
+
Base Directory ==========
|
10
|
+
Pro works from a base directory for efficiency.
|
11
|
+
This is the folder that contains all your other git repositories;
|
12
|
+
they don't have to be at the base level, just somewhere down the tree.
|
13
|
+
|
14
|
+
To set the base directory set the PRO_BASE environment variable or make
|
15
|
+
a ~/.proBase file containing the path.
|
16
|
+
|
17
|
+
Commands ===============
|
18
|
+
pro search <query> - prints path of git repo that matches query.
|
19
|
+
pro install - Install the pro cd command. cd to a directory by fuzzy git repo matching.
|
20
|
+
pro help - display help
|
21
|
+
|
22
|
+
CD Command ============
|
23
|
+
You can use the 'pro install' command to install a wrapper function that allows
|
24
|
+
you to cd to git repositories in your Pro Base wherever you are based on fuzzy matching.
|
25
|
+
|
26
|
+
Example:
|
27
|
+
|
28
|
+
~/randomFolder/ $ pd pro
|
29
|
+
pro/ $ pwd
|
30
|
+
/Users/tristan/Box/Dev/Projects/pro
|
31
|
+
|
32
|
+
END
|
33
|
+
|
34
|
+
command = ARGV.shift || 'help'
|
35
|
+
|
36
|
+
case command
|
37
|
+
when 'search'
|
38
|
+
puts Pro.find_repo(ARGV.first)
|
39
|
+
when 'install'
|
40
|
+
Pro.install_cd
|
41
|
+
when 'help'
|
42
|
+
puts HELP
|
43
|
+
end
|
44
|
+
|
data/lib/pro.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require "pro/version"
|
2
|
+
require "find"
|
3
|
+
require "fuzzy_match"
|
4
|
+
|
5
|
+
SHELL_FUNCTION = <<END
|
6
|
+
# pro cd function
|
7
|
+
{{name}}() {
|
8
|
+
projDir=$(pro search $1)
|
9
|
+
cd ${projDir}
|
10
|
+
}
|
11
|
+
END
|
12
|
+
|
13
|
+
CD_INFO = <<END
|
14
|
+
This installs a command to allow you to cd to a git repo
|
15
|
+
arbitrarily deep in your PRO_BASE based on fuzzy matching.
|
16
|
+
|
17
|
+
Example:
|
18
|
+
|
19
|
+
~/randomFolder/ $ pd pro
|
20
|
+
pro/ $ pwd
|
21
|
+
/Users/tristan/Box/Dev/Projects/pro
|
22
|
+
|
23
|
+
========
|
24
|
+
END
|
25
|
+
|
26
|
+
|
27
|
+
module Pro
|
28
|
+
# Finds the base directory where repos are kept
|
29
|
+
# Checks the environment variable PRO_BASE and the
|
30
|
+
# file .proBase
|
31
|
+
def self.base_dir()
|
32
|
+
# check environment first
|
33
|
+
base = ENV['PRO_BASE']
|
34
|
+
return base if base
|
35
|
+
# next check proBase file
|
36
|
+
path = ENV['HOME'] + "/.proBase"
|
37
|
+
base = ENV['HOME'] # default to home
|
38
|
+
if File.exists?(path)
|
39
|
+
base = IO.read(path).chomp
|
40
|
+
base = File.expand_path(base)
|
41
|
+
end
|
42
|
+
base
|
43
|
+
end
|
44
|
+
def self.find_repo(name)
|
45
|
+
repos = []
|
46
|
+
Find.find(Pro.base_dir) do |path|
|
47
|
+
if FileTest.directory?(path)
|
48
|
+
# is this folder a git repo
|
49
|
+
if File.exists?(path+"/.git")
|
50
|
+
base_name = File.basename(path)
|
51
|
+
repos << [base_name,path]
|
52
|
+
Find.prune
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
match = FuzzyMatch.new(repos, :read => :first).find(name)
|
57
|
+
match[1] unless match.nil?
|
58
|
+
end
|
59
|
+
def self.install_cd
|
60
|
+
puts CD_INFO
|
61
|
+
print "Continue with installation (yN)? "
|
62
|
+
return unless gets.chomp == "y"
|
63
|
+
# get name
|
64
|
+
print "Name of pro cd command (default 'pd'): "
|
65
|
+
name = gets.strip
|
66
|
+
name = 'pd' if name.empty?
|
67
|
+
# sub into function
|
68
|
+
func = SHELL_FUNCTION.sub("{{name}}",name)
|
69
|
+
['~/.bashrc','~/.zshrc'].each do |rel_path|
|
70
|
+
# check if file exists
|
71
|
+
path = File.expand_path(rel_path)
|
72
|
+
next unless File.exists?(path)
|
73
|
+
# ask the user if they want to add it
|
74
|
+
print "Install #{name} function to #{rel_path} (yN): "
|
75
|
+
next unless gets.chomp == "y"
|
76
|
+
# add it on to the end of the file
|
77
|
+
File.open(path,'a') do |file|
|
78
|
+
file.puts func
|
79
|
+
end
|
80
|
+
end
|
81
|
+
puts "Done! #{name} will be available in new shells."
|
82
|
+
end
|
83
|
+
end
|
data/lib/pro/version.rb
ADDED
data/pro.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pro/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pro"
|
8
|
+
spec.version = Pro::VERSION
|
9
|
+
spec.authors = ["Tristan Hume"]
|
10
|
+
spec.email = ["tris.hume@gmail.com"]
|
11
|
+
spec.description = %q{Lightweight git project tool.}
|
12
|
+
spec.summary = %q{Command line tool that allows you to quickly cd to git projects.}
|
13
|
+
spec.homepage = "http://github.com/trishume/pro"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
#spec.add_runtime_dependency 'commander','~> 4.1.2'
|
17
|
+
spec.add_runtime_dependency 'fuzzy_match'
|
18
|
+
|
19
|
+
spec.files = `git ls-files`.split($/)
|
20
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pro
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tristan Hume
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fuzzy_match
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Lightweight git project tool.
|
56
|
+
email:
|
57
|
+
- tris.hume@gmail.com
|
58
|
+
executables:
|
59
|
+
- pro
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/pro
|
69
|
+
- lib/pro.rb
|
70
|
+
- lib/pro/version.rb
|
71
|
+
- pro.gemspec
|
72
|
+
homepage: http://github.com/trishume/pro
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.0.3
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Command line tool that allows you to quickly cd to git projects.
|
96
|
+
test_files: []
|