spath 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/README.md +22 -16
- data/bin/spath +30 -9
- data/lib/spath.rb +4 -0
- data/lib/spath/version.rb +1 -1
- data/spath.gemspec +1 -1
- metadata +3 -9
- data/bin/c +0 -5
- data/bin/l +0 -16
- data/bin/s +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7d49c015ba3a6ae33e809dbb66d615e4d1f8558
|
4
|
+
data.tar.gz: 600c48f74a64fac517fbafe1c74ff3690ac6db84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 463814c89a66055c57132f91e6c92744d21f6a9595b1e2794d0dcad3458a7c8db75ebdc634535e5645c90046d15ab1100269ff339751131cc299cd123c08e408
|
7
|
+
data.tar.gz: e93f5f63fe2fd71752cf9e482caff56d23f09a0ee2505a0319f1a4681a109d4b88fdb2ea44e89a1547d9949bf31119387abc1dcdb62007687f1b290e6dd45643
|
data/README.md
CHANGED
@@ -13,36 +13,42 @@ Install it as:
|
|
13
13
|
|
14
14
|
$ gem install spath
|
15
15
|
|
16
|
-
Add this to your .bashrc:
|
16
|
+
Add this to your .bashrc (suggested):
|
17
17
|
|
18
|
-
|
18
|
+
alias s='spath create'
|
19
|
+
alias l='spath list'
|
20
|
+
function c(){cd $(spath path $*||echo .)}
|
19
21
|
|
20
|
-
(
|
22
|
+
( c is required to be defined as a function because a Ruby script can not change the working directory of its parent process. )
|
21
23
|
|
22
24
|
## To do:
|
23
25
|
|
24
26
|
Add configuration options.
|
27
|
+
Add tests.
|
28
|
+
Add better error handling.
|
25
29
|
|
26
30
|
## Usage
|
27
31
|
|
28
|
-
Create shortcuts for common places with the command '
|
32
|
+
Create shortcuts for common places with the command 'spath create [nick] [path]'
|
29
33
|
|
30
|
-
|
34
|
+
$ spath create ltr /home/you/docs/letters
|
31
35
|
|
32
|
-
|
33
|
-
you@computer ~ $ s ok .
|
36
|
+
Non-absolute paths are acceptable.
|
34
37
|
|
35
|
-
|
38
|
+
$ cd /home/you/public/long/path/skynet/releases/v01-02-03/doc/
|
39
|
+
$ spath create snet ../
|
36
40
|
|
37
|
-
|
38
|
-
you@computer ~/files/something/lol/whatever/ok $
|
41
|
+
Visit them with the shortcut you made with the function 'c [nick]'.
|
39
42
|
|
40
|
-
|
43
|
+
you@computer $ c snet
|
44
|
+
you@computer $ pwd
|
45
|
+
/home/you/public/long/path/skynet/releases/v01-02-03/
|
41
46
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
List all available shortcuts with the command 'spath list'.
|
48
|
+
|
49
|
+
you@computer ~ $ spath list
|
50
|
+
snetdoc => /home/you/public/long/path/skynet/releases/v01-02-03/
|
51
|
+
ltr => /home/you/docs/letters
|
52
|
+
mu => /home/you
|
47
53
|
|
48
54
|
Shortcuts are stored at ~/.spath in YAML format.
|
data/bin/spath
CHANGED
@@ -1,29 +1,50 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# coding: utf-8
|
3
2
|
|
4
|
-
# spath: provide all functions, about message, configuration
|
5
|
-
|
6
|
-
$LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../lib")
|
7
3
|
require "spath"
|
8
4
|
|
9
5
|
def usage
|
10
|
-
abort
|
6
|
+
abort <<EOF
|
7
|
+
spath (v#{SPath::VERSION}): create shortcuts. Usage:
|
8
|
+
spath path [nick]
|
9
|
+
spath list
|
10
|
+
spath create [nick] [path]
|
11
|
+
EOF
|
11
12
|
end
|
12
13
|
|
13
|
-
|
14
|
+
mode, nickname, path = ARGV
|
15
|
+
usage unless mode
|
16
|
+
|
17
|
+
config_file = SPath::ConfigFile.load
|
14
18
|
|
15
19
|
case mode
|
16
|
-
when "
|
20
|
+
when "path"
|
17
21
|
|
18
|
-
usage unless
|
22
|
+
usage unless nickname
|
19
23
|
|
20
|
-
config_file = SPath::ConfigFile.load
|
21
24
|
begin
|
22
25
|
puts config_file.path_for(nickname)
|
23
26
|
rescue ArgumentError => msg
|
24
27
|
abort "spath: error: #{msg}"
|
25
28
|
end
|
26
29
|
|
30
|
+
when "list"
|
31
|
+
|
32
|
+
usage if nickname or path
|
33
|
+
|
34
|
+
shortcuts = config_file.shortcuts
|
35
|
+
shortcuts.each { |s| puts "#{s.nickname.to_s.rjust(8)} => #{s.path}" }
|
36
|
+
|
37
|
+
when "create"
|
38
|
+
|
39
|
+
usage unless nickname and path
|
40
|
+
|
41
|
+
path = File.expand_path(path)
|
42
|
+
abort "spath: error: #{path} is not a valid path. :(" \
|
43
|
+
unless File.exists?(path)
|
44
|
+
|
45
|
+
config_file << SPath::Shortcut.new(nickname, path)
|
46
|
+
config_file.write!
|
47
|
+
|
27
48
|
else
|
28
49
|
usage
|
29
50
|
end
|
data/lib/spath.rb
CHANGED
@@ -35,6 +35,10 @@ module SPath
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def self.load(path = DEFAULT_CONFIG_PATH)
|
38
|
+
path = File.expand_path(path)
|
39
|
+
|
40
|
+
return new unless File.exists?(File.expand_path(path))
|
41
|
+
|
38
42
|
data = YAML.load(File.read(path))
|
39
43
|
|
40
44
|
# If config file returns empty, use the default
|
data/lib/spath/version.rb
CHANGED
data/spath.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["jack@attac.us"]
|
11
11
|
spec.description = "spath creates shortcuts for paths"
|
12
12
|
spec.summary = "shortcuts for paths"
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "http://github.com/jackwillis/spath"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Willis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,9 +42,6 @@ description: spath creates shortcuts for paths
|
|
42
42
|
email:
|
43
43
|
- jack@attac.us
|
44
44
|
executables:
|
45
|
-
- c
|
46
|
-
- l
|
47
|
-
- s
|
48
45
|
- spath
|
49
46
|
extensions: []
|
50
47
|
extra_rdoc_files: []
|
@@ -53,14 +50,11 @@ files:
|
|
53
50
|
- LICENSE
|
54
51
|
- README.md
|
55
52
|
- Rakefile
|
56
|
-
- bin/c
|
57
|
-
- bin/l
|
58
|
-
- bin/s
|
59
53
|
- bin/spath
|
60
54
|
- lib/spath.rb
|
61
55
|
- lib/spath/version.rb
|
62
56
|
- spath.gemspec
|
63
|
-
homepage:
|
57
|
+
homepage: http://github.com/jackwillis/spath
|
64
58
|
licenses:
|
65
59
|
- MIT
|
66
60
|
metadata: {}
|
data/bin/c
DELETED
data/bin/l
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# coding: utf-8
|
3
|
-
|
4
|
-
# l: list shortcuts
|
5
|
-
|
6
|
-
$LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../lib")
|
7
|
-
require "spath"
|
8
|
-
|
9
|
-
abort unless ARGV.empty?
|
10
|
-
|
11
|
-
puts "l: list spath shortcuts."
|
12
|
-
|
13
|
-
config_file = SPath::ConfigFile.load
|
14
|
-
shortcuts = config_file.shortcuts
|
15
|
-
|
16
|
-
shortcuts.each { |s| puts "#{s.nickname.to_s.rjust(8)} => #{s.path}" }
|
data/bin/s
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# coding: utf-8
|
3
|
-
|
4
|
-
# s: create shortcut
|
5
|
-
|
6
|
-
$LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../lib")
|
7
|
-
require "spath"
|
8
|
-
|
9
|
-
nickname, path = ARGV
|
10
|
-
abort "s: create spath shortcut. Usage: s [nickname] [path]" \
|
11
|
-
unless nickname and path
|
12
|
-
|
13
|
-
path = File.expand_path(path)
|
14
|
-
abort "s: error: #{path} is not a valid path. :(" unless File.exists? path
|
15
|
-
|
16
|
-
config_file = SPath::ConfigFile.load
|
17
|
-
config_file << SPath::Shortcut.new(nickname, path)
|
18
|
-
config_file.write!
|