warp-dir 1.2.0 → 1.3.0
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/.gitignore +1 -22
- data/.rspec +0 -2
- data/.travis.yml +2 -2
- data/README.md +94 -48
- data/Rakefile +2 -2
- data/bin/warp-dir.bash +7 -2
- data/lib/warp/dir.rb +10 -3
- data/lib/warp/dir/command/install.rb +27 -5
- data/lib/warp/dir/point.rb +52 -12
- data/lib/warp/dir/serializer/dotfile.rb +5 -8
- data/lib/warp/dir/version.rb +1 -1
- metadata +2 -3
- data/.idea/misc.xml +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 61b42bdc5b12481249402bc4d6dacdf721c9fc5e
|
|
4
|
+
data.tar.gz: 83d013305b5d9ce4aded23b90484ea09f90c15d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 101ddf5bada2103da584e85553ed6c60971a1771a322f722f22c8db71a8f38ac1264a6c0ef5380e064144a713d9335304b49b3283011850fc776d8e3d278d100
|
|
7
|
+
data.tar.gz: cd1d0d4d60306349b06e16407b30a5477dbaa45a2e66ddcfdc6685d30d49ee10394f860a6c1625a7808e5373392eba1981c3419c99a97ebd34f106785ded7100
|
data/.gitignore
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
.idea/
|
|
1
2
|
*.gem
|
|
2
3
|
*.rbc
|
|
3
4
|
.bundle
|
|
@@ -17,25 +18,3 @@ test/version_tmp
|
|
|
17
18
|
tmp
|
|
18
19
|
vendor/
|
|
19
20
|
**/.DS_Store
|
|
20
|
-
|
|
21
|
-
.idea/.rakeTasks
|
|
22
|
-
.idea/*.iml
|
|
23
|
-
# User-specific stuff:
|
|
24
|
-
.idea/workspace.xml
|
|
25
|
-
.idea/tasks.xml
|
|
26
|
-
.idea/dictionaries
|
|
27
|
-
|
|
28
|
-
# Sensitive or high-churn files:
|
|
29
|
-
.idea/dataSources.ids
|
|
30
|
-
.idea/dataSources.xml
|
|
31
|
-
.idea/sqlDataSources.xml
|
|
32
|
-
.idea/dynamic.xml
|
|
33
|
-
.idea/uiDesigner.xml
|
|
34
|
-
|
|
35
|
-
# Gradle:
|
|
36
|
-
.idea/gradle.xml
|
|
37
|
-
.idea/libraries
|
|
38
|
-
|
|
39
|
-
# Mongo Explorer plugin:
|
|
40
|
-
.idea/mongoSettings.xml
|
|
41
|
-
|
data/.rspec
CHANGED
data/.travis.yml
CHANGED
|
@@ -3,11 +3,11 @@ env:
|
|
|
3
3
|
- CODECLIMATE_REPO_TOKEN=5306e7c3069bd3fef06f717d679f41e969e13bb05efef5bbe1fd781043b0c117
|
|
4
4
|
rvm:
|
|
5
5
|
- 2.2.3
|
|
6
|
-
- 2.3.
|
|
6
|
+
- 2.3.1
|
|
7
7
|
script: "gem install bundler rake --no-ri --no-rdoc; rake"
|
|
8
8
|
notifications:
|
|
9
9
|
email:
|
|
10
10
|
recipients:
|
|
11
11
|
- kigster@gmail.com
|
|
12
|
-
on_success:
|
|
12
|
+
on_success: change
|
|
13
13
|
on_failure: always
|
data/README.md
CHANGED
|
@@ -10,81 +10,102 @@
|
|
|
10
10
|
[](https://gitter.im/kigster/warp-dir)
|
|
11
11
|
<hr/>
|
|
12
12
|
|
|
13
|
-
This is a ruby implementation of the tool
|
|
14
|
-
[originally written as a
|
|
13
|
+
This is a ruby implementation of the tool `wd` (warp directory),
|
|
14
|
+
[originally written as a `ZSH` module](https://github.com/mfaerevaag/wd)
|
|
15
15
|
by [Markus Færevaag](https://github.com/mfaerevaag).
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
compatible tool that is well tested, and can be extended to do some more interesting things.
|
|
17
|
+
I personaly went back to `bash` after trying out `ZSH`, but it was the `wd` plugin that I really missed.
|
|
19
18
|
|
|
20
|
-
Markus kindly offered a ruby version in a [separate branch of this module](https://github.com/mfaerevaag/wd/tree/ruby),
|
|
21
|
-
|
|
19
|
+
While Markus kindly offered a ruby version in a [separate branch of this module](https://github.com/mfaerevaag/wd/tree/ruby),
|
|
20
|
+
it wasn't quite as extensible as I wanted to (or well tested), so it ended up being an inspiration for this gem.
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
## Warp This
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
* it would be nice to quickly switch between these folders (which we call __warp points__).
|
|
27
|
-
* it should be easy to add, remove, list, and validate warp points
|
|
28
|
-
* everything should require as few characters as possible :)
|
|
24
|
+
WarpDir is a UNIX command line tool that works somewhat similar to the standard built-in command `cd` — "change directory".
|
|
29
25
|
|
|
30
|
-
|
|
26
|
+
The main difference is that `wd` is able to add/remove/list folder "shortcuts", and allows you to jump to these shortcuts from anywhere on the filesystem.
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
* eventually we might want to do things across all projects, such as perform group `git pull`,
|
|
34
|
-
or even `git push` etc.
|
|
28
|
+
This of this as a folder-navigation super-charge tool that you'd use on a most frequently-used set of folders. This becomes __really useful__ if you are often finding youself going into a small number of deeply nested folders with a long path prefix.
|
|
35
29
|
|
|
36
|
-
##
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
__NOTE:__ in the below examples, the characters `~ ❯ ` denote the current shell prompt, showing the current folder you are in. The command to type is on the right hand side of the "❯".
|
|
33
|
+
|
|
34
|
+
Let's first bookmark a long directory:
|
|
37
35
|
|
|
38
|
-
|
|
36
|
+
```bash
|
|
37
|
+
~ ❯ cd ~/workspace/arduino/robots/command-bridge/src
|
|
38
|
+
~/workspace/arduino/robots/command-bridge/src ❯ wd add cbsrc
|
|
39
|
+
Warp point saved!
|
|
40
|
+
|
|
41
|
+
~/workspace/arduino/robots/command-bridge/src ❯ cd ~/workspace/c++/foo/src
|
|
42
|
+
~/workspace/c++/foo/src ❯ wd add foosrc
|
|
43
|
+
Warp point saved!
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
~/workspace/c++/foo/src ❯ cd /usr/local/Cellar
|
|
46
|
+
/usr/local/Cellar ❯ wd add brew
|
|
47
|
+
Warp point saved!
|
|
42
48
|
```
|
|
43
|
-
And then execute:
|
|
44
49
|
|
|
45
|
-
|
|
50
|
+
Now we can list/inspect current set of warp points:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
/usr/local/Cellar ❯ wd l
|
|
54
|
+
cbsrc -> ~/workspace/arduino/robots/command-bridge/src
|
|
55
|
+
foosrc -> ~/workspace/c++/foo/src
|
|
56
|
+
brew -> /usr/local/Cellar
|
|
57
|
+
```
|
|
46
58
|
|
|
47
|
-
|
|
59
|
+
Now we can jump around these warp points, as well as run 'ls' inside (even passing arbitrary arguments to the `ls` itself):
|
|
48
60
|
|
|
49
|
-
|
|
61
|
+
```bash
|
|
62
|
+
/usr/local/Cellar ❯ wd cbsrc
|
|
63
|
+
~/workspace/arduino/robots/command-bridge/src ❯ wd foosrc
|
|
64
|
+
~/workspace/c++/foo/src ❯ 1 wd ls brew -- -alF | head -4 # run ls -alF inside /usr/local/Cellar
|
|
65
|
+
total 0
|
|
66
|
+
drwxrwx--- 73 kig staff 2482 May 7 15:29 ./
|
|
67
|
+
drwxrwx--- 21 kig staff 714 Apr 28 11:40 ../
|
|
68
|
+
drwxrwx--- 3 kig staff 102 Dec 24 03:14 ack/
|
|
69
|
+
```
|
|
50
70
|
|
|
51
|
-
|
|
52
|
-
Choose
|
|
53
|
-
$ warp-dir install [ --dotfile <file> ]
|
|
71
|
+
### Command Completion
|
|
54
72
|
|
|
55
|
-
|
|
56
|
-
"help" message by typing:
|
|
73
|
+
If you installed `wd` properly, it should register it's own command completion for BASH and be ready for your tabs :)
|
|
57
74
|
|
|
58
|
-
|
|
75
|
+
Note that you can use `wd` to change directory by giving an absolute or relative directory name, just like `cd` (so not just using warp-points), so when you type `wd [TAB]` you will see all saved warp points as well as the local directories you can `cd` into.
|
|
59
76
|
|
|
60
|
-
|
|
61
|
-
is now complete!
|
|
77
|
+
That's basically it!
|
|
62
78
|
|
|
63
|
-
|
|
79
|
+
### Config File (aka. Warp Points Database)
|
|
64
80
|
|
|
65
|
-
|
|
66
|
-
I like how `wd` can be used with very short warp points, so it's so much less typing. I often name
|
|
67
|
-
my points `pu` so that I can jump there with `wd pu`.
|
|
81
|
+
All of the mappings are stored in the `~/.warprc` file, where the warp point name is followed by a colon, and the path it maps to. So it's trivial to do a global search/replace on that file in your favorite editor, if, for example, a commond top level folder had changed.
|
|
68
82
|
|
|
69
|
-
|
|
70
|
-
you can (if you want to) use flags to achieve the same effect with more
|
|
71
|
-
characters to type, for example all below commands do the same thing.
|
|
83
|
+
The format of the file was left identical to that of the `ZSH` version of `wd` so that one could switch back and force between the two versions of `wd` and still be able to use their collection of warp points.
|
|
72
84
|
|
|
73
|
-
|
|
74
|
-
wd pu
|
|
75
|
-
wd --warp --point pu
|
|
76
|
-
wd -m warp -p pu
|
|
77
|
-
```
|
|
85
|
+
See? I think we thought of everything :)
|
|
78
86
|
|
|
79
|
-
|
|
80
|
-
`wd ls pu`, but in this implementation you can also pass arguments to `ls` after
|
|
81
|
-
the `--` in argument list, for example, to run `ls -1` I would do `wd ls pu -- -1`.
|
|
87
|
+
Happy warping!
|
|
82
88
|
|
|
83
|
-
|
|
89
|
+
### Detailed Usage
|
|
84
90
|
|
|
85
91
|

|
|
86
92
|
|
|
87
|
-
|
|
93
|
+
## `wd` Concept
|
|
94
|
+
|
|
95
|
+
The overall concept comes from the realization that when we work on the command line, we often do things that `wd` tool provides straight out of the box, such as:
|
|
96
|
+
|
|
97
|
+
* we often have to deal with a limited number of folders at any given time
|
|
98
|
+
* on occastion have to jump between these folders (which we call __warp points__), which may require mult-level `cd` command, for example: `cd ~/workspace/foo/src/include/; ....; cd ~/Documents/Microsoft\ Word/; ...`
|
|
99
|
+
* seems like it should be easy to add, remove and list warp points
|
|
100
|
+
* everything should require typing few characters as possible :)
|
|
101
|
+
* it would be great to have full BASH completion support
|
|
102
|
+
|
|
103
|
+
Some future extensions could be based on some additional realizations:
|
|
104
|
+
|
|
105
|
+
* perhaps you might want to inspect a bookmarked folder without leaving your current place.
|
|
106
|
+
* maybe by inspecting we mean — running a `find`, or `ls` or any other command for that matter
|
|
107
|
+
|
|
108
|
+
### Notable Differences with original `wd`
|
|
88
109
|
|
|
89
110
|
* instead of `wd add!` use `wd add -f <point>` (or --force)
|
|
90
111
|
|
|
@@ -94,6 +115,31 @@ These features will be added shortly:
|
|
|
94
115
|
* for now history is not supported
|
|
95
116
|
* for now '-' is not supported
|
|
96
117
|
|
|
118
|
+
## Installation
|
|
119
|
+
|
|
120
|
+
Three steps:
|
|
121
|
+
|
|
122
|
+
1. This `wd` requires version 2+ of ruby interpreter. Check your default ruby with `ruby --version`. You should see something like "ruby 2.3.0p0....". If you see version 1.9 or earlier, upgrade your ruby with `brew update; brew install ruby`.
|
|
123
|
+
2. Install warp-dir gem:
|
|
124
|
+
```bash
|
|
125
|
+
~ ❯ gem install warp-dir --no-ri --no-rdoc
|
|
126
|
+
```
|
|
127
|
+
3. The last step is to install the `wd` BASH function and auto-completion:
|
|
128
|
+
```bash
|
|
129
|
+
~ ❯ warp-dir install --dotfile ~/.bash_profile
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
This last step appends the required shell function to the shell initialization file specified with the `--dotfile` flag. If you are unsure what that means, please run the command above as is.
|
|
133
|
+
|
|
134
|
+
And step 3 you will need to restart your shell, so reopen your Terminal or [iTerm2](https://www.iterm2.com/) (please use iTerm over Terminal — it's soooo much better!), and then type:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
~ ❯ wd help
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
If the above command returns a properly formatted help like the image below, your setup
|
|
141
|
+
is now complete!
|
|
142
|
+
|
|
97
143
|
## Future Development
|
|
98
144
|
|
|
99
145
|
I have so many cool ideas about where this can go, that I created a
|
data/Rakefile
CHANGED
|
@@ -27,8 +27,8 @@ namespace :development do
|
|
|
27
27
|
task :setup do
|
|
28
28
|
sh %q{
|
|
29
29
|
echo "source 'https://rubygems.org'; gemspec" > Gemfile
|
|
30
|
-
[[ -n $(which bundle) ]] || gem install bundler --no-ri --no-rdoc
|
|
31
|
-
bundle install
|
|
30
|
+
[[ -n $(which bundle) ]] || gem install bundler --no-ri --no-rdoc --quiet
|
|
31
|
+
bundle install --quiet
|
|
32
32
|
}.gsub(%r{^\s+}m, '')
|
|
33
33
|
end
|
|
34
34
|
|
data/bin/warp-dir.bash
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
#
|
|
2
|
+
#
|
|
3
|
+
# %WARP-DIR% shell wrapper, installed by a gem 'warp-dir'
|
|
4
|
+
#
|
|
5
|
+
# © 2015-2016, Konstantin Gredeskoul
|
|
6
|
+
# https://github.com/kigster/warp-dir
|
|
7
|
+
#
|
|
8
|
+
#
|
|
4
9
|
wd() {
|
|
5
10
|
if [ -z "${warp_dir_exec_installed}" -o "${warp_dir_exec_installed}" == "1" ]; then
|
|
6
11
|
$(which 'warp-dir') 2>&1 > /dev/null
|
data/lib/warp/dir.rb
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
require_relative 'dir/version'
|
|
1
2
|
module Warp
|
|
2
3
|
PROJECT_LIBS = File.dirname(File.absolute_path(__FILE__))
|
|
3
4
|
PROJECT_HOME = PROJECT_LIBS + '/../..'
|
|
4
5
|
|
|
5
6
|
module Dir
|
|
6
7
|
# tried in order.
|
|
8
|
+
INSTALL_TIME = Time.now
|
|
7
9
|
DOTFILES = %w(.bash_profile .bashrc .profile .bash_login).map{|f| "~/#{f}" }
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
SHELL_WRAPPER_FILE = "#{PROJECT_HOME}/bin/warp-dir.bash"
|
|
11
|
+
SHELL_WRAPPER_DEST = ENV['HOME'] + '/.bash_wd'
|
|
12
|
+
SHELL_WRAPPER_REGX = %r[WarpDir \(v(\d+\.\d+\.\d+)]
|
|
13
|
+
SHELL_WRAPPER_SRCE = <<-eof
|
|
14
|
+
# WarpDir (v#{Warp::Dir::VERSION}, appended on #{INSTALL_TIME}) BEGIN
|
|
15
|
+
[[ -f ~/.bash_wd ]] && source ~/.bash_wd
|
|
16
|
+
# WarpDir (v#{Warp::Dir::VERSION}, appended on #{INSTALL_TIME}) END
|
|
17
|
+
eof
|
|
11
18
|
class << self
|
|
12
19
|
def require_all_from(folder)
|
|
13
20
|
::Dir.glob(Warp::PROJECT_LIBS + folder + '/*.rb') { |file| Kernel.require file }
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
require 'warp/dir/command'
|
|
2
1
|
require 'warp/dir'
|
|
2
|
+
require 'warp/dir/command'
|
|
3
|
+
require 'fileutils'
|
|
3
4
|
class Warp::Dir::Command::Install < Warp::Dir::Command
|
|
4
5
|
description %q(Installs warp-dir shell wrapper in your ~/.bashrc)
|
|
5
6
|
needs_a_point? false
|
|
6
7
|
|
|
7
8
|
attr_accessor :installed, :existing, :wrapper, :shell_init_files
|
|
8
9
|
|
|
10
|
+
# SHELL_WRAPPER_FILE
|
|
11
|
+
# SHELL_WRAPPER_DEST
|
|
12
|
+
# SHELL_WRAPPER_REGX
|
|
13
|
+
# SHELL_WRAPPER_SRCE
|
|
14
|
+
|
|
9
15
|
class << self
|
|
10
16
|
def wrapper_installed?
|
|
11
17
|
::Warp::Dir::DOTFILES.any?{ |file| already_installed?(file) }
|
|
@@ -15,7 +21,7 @@ class Warp::Dir::Command::Install < Warp::Dir::Command
|
|
|
15
21
|
path = ::Warp::Dir.absolute(file_path)
|
|
16
22
|
matches = if File.exists?(path)
|
|
17
23
|
File.open path do |file|
|
|
18
|
-
file.find { |line| line =~
|
|
24
|
+
file.find { |line| line =~ ::Warp::Dir::SHELL_WRAPPER_REGX }
|
|
19
25
|
end
|
|
20
26
|
end
|
|
21
27
|
matches
|
|
@@ -25,7 +31,7 @@ class Warp::Dir::Command::Install < Warp::Dir::Command
|
|
|
25
31
|
def initialize(*args)
|
|
26
32
|
self.installed = []
|
|
27
33
|
self.existing = []
|
|
28
|
-
self.wrapper =
|
|
34
|
+
self.wrapper = ::Warp::Dir::SHELL_WRAPPER_SRCE
|
|
29
35
|
self.shell_init_files = ::Warp::Dir::DOTFILES
|
|
30
36
|
super(*args)
|
|
31
37
|
end
|
|
@@ -33,9 +39,14 @@ class Warp::Dir::Command::Install < Warp::Dir::Command
|
|
|
33
39
|
def run(*args)
|
|
34
40
|
self.shell_init_files = config[:dotfile].split(',') if config[:dotfile]
|
|
35
41
|
self.shell_init_files.any? { |dotfile| append_wrapper_to(dotfile) }
|
|
42
|
+
|
|
43
|
+
# Overwrites if already there
|
|
44
|
+
install_bash_wd
|
|
45
|
+
|
|
36
46
|
local_existing = self.existing
|
|
37
47
|
local_installed = self.installed
|
|
38
48
|
local_shell_files = self.shell_init_files
|
|
49
|
+
|
|
39
50
|
if installed.empty?
|
|
40
51
|
if existing.empty?
|
|
41
52
|
on :error do
|
|
@@ -61,14 +72,25 @@ class Warp::Dir::Command::Install < Warp::Dir::Command
|
|
|
61
72
|
|
|
62
73
|
private
|
|
63
74
|
|
|
75
|
+
def install_bash_wd
|
|
76
|
+
source = File.read(::Warp::Dir::SHELL_WRAPPER_FILE)
|
|
77
|
+
source.gsub!(/%WARP-DIR%/, "WarpDir (v#{::Warp::Dir::VERSION})")
|
|
78
|
+
File.open(::Warp::Dir::SHELL_WRAPPER_DEST, 'w') do |file|
|
|
79
|
+
file.puts source
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
64
83
|
def append_wrapper_to(shell_init_file)
|
|
65
84
|
file = ::Warp::Dir.absolute(shell_init_file)
|
|
66
85
|
pre_installed = self.class.already_installed?(file)
|
|
67
86
|
self.existing << file if pre_installed
|
|
68
87
|
if File.exists?(file)
|
|
69
88
|
if !pre_installed || config[:force]
|
|
70
|
-
File.
|
|
71
|
-
|
|
89
|
+
source = File.read(file)
|
|
90
|
+
source.gsub!(/# WarpDir.*BEGIN\n.*\n# WarpDir.*END/, '')
|
|
91
|
+
File.open(file, 'w') do |f|
|
|
92
|
+
f.write source
|
|
93
|
+
f.write wrapper
|
|
72
94
|
end
|
|
73
95
|
self.installed << shell_init_file
|
|
74
96
|
end
|
data/lib/warp/dir/point.rb
CHANGED
|
@@ -2,7 +2,45 @@ require 'forwardable'
|
|
|
2
2
|
require 'digest'
|
|
3
3
|
module Warp
|
|
4
4
|
module Dir
|
|
5
|
+
# This class encapsulates the tuple: name + path.
|
|
6
|
+
# It provides convenience accessors to retrieve absolute or
|
|
7
|
+
# realtive path of a point, optionally via a set of predefined
|
|
8
|
+
# filters.
|
|
9
|
+
#
|
|
10
|
+
# In addition, this class is responsible for serializing and
|
|
11
|
+
# deserializing itself properly.
|
|
5
12
|
class Point
|
|
13
|
+
|
|
14
|
+
# This method creates/defines methods used to
|
|
15
|
+
# access the #full_path component of the Point instance, but
|
|
16
|
+
# enclosing it in a chain of provided filters.
|
|
17
|
+
def self.filtered_paths(path_hash)
|
|
18
|
+
path_hash.each_pair do |method, filters|
|
|
19
|
+
define_method method.to_sym do |*args|
|
|
20
|
+
filters.inject(self.full_path) do |memo, filter|
|
|
21
|
+
self.send(filter, memo)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.deserialize(line)
|
|
28
|
+
name, path = line.split(/:/)
|
|
29
|
+
if name.nil? || path.nil?
|
|
30
|
+
raise Warp::Dir::Errors::StoreFormatError.new(
|
|
31
|
+
'warprc file may be corrupt, offending line is: ' +
|
|
32
|
+
line, line)
|
|
33
|
+
end
|
|
34
|
+
self.new(name, path)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
filtered_paths absolute_path: %i(quote_spaces),
|
|
38
|
+
path: %i(quote_spaces),
|
|
39
|
+
relative_path: %i(make_relative quote_spaces)
|
|
40
|
+
|
|
41
|
+
#
|
|
42
|
+
# Instance Methods
|
|
43
|
+
#
|
|
6
44
|
attr_accessor :full_path, :name
|
|
7
45
|
|
|
8
46
|
def initialize(name, full_path)
|
|
@@ -12,18 +50,6 @@ module Warp
|
|
|
12
50
|
@name = name.to_sym
|
|
13
51
|
end
|
|
14
52
|
|
|
15
|
-
def absolute_path
|
|
16
|
-
full_path
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def relative_path
|
|
20
|
-
Warp::Dir.relative full_path
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def path
|
|
24
|
-
absolute_path
|
|
25
|
-
end
|
|
26
|
-
|
|
27
53
|
def inspect
|
|
28
54
|
sprintf("(#{object_id})[name: '%s', path: '%s']", name, relative_path)
|
|
29
55
|
end
|
|
@@ -48,6 +74,20 @@ module Warp
|
|
|
48
74
|
true
|
|
49
75
|
end
|
|
50
76
|
|
|
77
|
+
def serialize
|
|
78
|
+
"#{name}:#{full_path}"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
|
|
83
|
+
# Filters that receive a path, and return a possibly decorated path back
|
|
84
|
+
def make_relative(path)
|
|
85
|
+
Warp::Dir.relative(path)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def quote_spaces(path)
|
|
89
|
+
path =~ /\s+/ ? %Q("#{path}") : path
|
|
90
|
+
end
|
|
51
91
|
end
|
|
52
92
|
end
|
|
53
93
|
end
|
|
@@ -4,6 +4,8 @@ require_relative 'base'
|
|
|
4
4
|
module Warp
|
|
5
5
|
module Dir
|
|
6
6
|
module Serializer
|
|
7
|
+
# Serializer only assumes that Points can serialize themselves
|
|
8
|
+
# or deserialize themselves to/from a one-line text format.
|
|
7
9
|
class Dotfile < Base
|
|
8
10
|
|
|
9
11
|
def warprc_file_path
|
|
@@ -19,11 +21,8 @@ module Warp
|
|
|
19
21
|
f.each_line do |line|
|
|
20
22
|
line = line.chomp
|
|
21
23
|
next if line.blank?
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
raise Warp::Dir::Errors::StoreFormatError.new("File may be corrupt - #{config.warprc}:#{line}", line)
|
|
25
|
-
end
|
|
26
|
-
store.add point_name: name, point_path: path
|
|
24
|
+
line.gsub!(/["']/,'') # remove any quotes that may have been inserted
|
|
25
|
+
store.add(point: Warp::Dir::Point.deserialize(line))
|
|
27
26
|
end
|
|
28
27
|
end
|
|
29
28
|
end
|
|
@@ -32,7 +31,7 @@ module Warp
|
|
|
32
31
|
File.open(warprc_file_path, 'wt') do |file|
|
|
33
32
|
buffer = ''
|
|
34
33
|
store.points.each do |point|
|
|
35
|
-
buffer << "#{point.
|
|
34
|
+
buffer << "#{point.serialize}\n"
|
|
36
35
|
end
|
|
37
36
|
file.write(buffer)
|
|
38
37
|
end
|
|
@@ -41,5 +40,3 @@ module Warp
|
|
|
41
40
|
end
|
|
42
41
|
end
|
|
43
42
|
end
|
|
44
|
-
|
|
45
|
-
|
data/lib/warp/dir/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: warp-dir
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Konstantin Gredeskoul
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-06-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: slop
|
|
@@ -94,7 +94,6 @@ files:
|
|
|
94
94
|
- ".codeclimate.yml"
|
|
95
95
|
- ".gitignore"
|
|
96
96
|
- ".idea/encodings.xml"
|
|
97
|
-
- ".idea/misc.xml"
|
|
98
97
|
- ".idea/modules.xml"
|
|
99
98
|
- ".idea/runConfigurations/All_Specs.xml"
|
|
100
99
|
- ".idea/vcs.xml"
|
data/.idea/misc.xml
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
|
4
|
-
<OptionsSetting value="true" id="Add" />
|
|
5
|
-
<OptionsSetting value="true" id="Remove" />
|
|
6
|
-
<OptionsSetting value="true" id="Checkout" />
|
|
7
|
-
<OptionsSetting value="true" id="Update" />
|
|
8
|
-
<OptionsSetting value="true" id="Status" />
|
|
9
|
-
<OptionsSetting value="true" id="Edit" />
|
|
10
|
-
<ConfirmationsSetting value="0" id="Add" />
|
|
11
|
-
<ConfirmationsSetting value="0" id="Remove" />
|
|
12
|
-
</component>
|
|
13
|
-
<component name="ProjectRootManager" version="2" project-jdk-name="ruby-2.2.3-p173" project-jdk-type="RUBY_SDK" />
|
|
14
|
-
</project>
|