warp-dir 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34527a09e81e6828cdecf70a4c83c0e86d66458c
4
- data.tar.gz: ef320ca5a5098d7e0314323e3883e251915c3094
3
+ metadata.gz: 7b3d99ba5468db28b9ae37ea3af94548916e7f54
4
+ data.tar.gz: f5d4b48a203ee23353e0bca26a56f7af0bdce560
5
5
  SHA512:
6
- metadata.gz: 94c02934aead6a205dcdb9e75eb42d3ba6d104fc67c0bf64366f72267ffab9d0ccecf21a533966def3f45744e169510ea816a07a98b96c18a7473da0d2730b81
7
- data.tar.gz: 2f80dc1e9aa8102bb6daefb47664ad942e6fd73ffa90def0df93a36229717d04c10e54e3a20a15418abb9b06f428ec1d9077d0c2a71bd276d27d22ef824e58f2
6
+ metadata.gz: 9984d190b7e2d9d56d51cfd1d5ad5f6ecf05028500d6a50df6a34d2a1bbf6c17b1d5e613c33edcf149284ba0fa29c741739c83e39a816855eb9b7b2faab37d8d
7
+ data.tar.gz: 1ae6cc4f5bad3ad844cf35b205a8274abe49ea4f3c64f24b194f3c48039d8fc27898b72b1ffe4c7890204fd3408b2fecefcf4f44b7605b3823343049bde6c902
data/README.md CHANGED
@@ -43,7 +43,7 @@ Three steps:
43
43
  $ gem install warp-dir --no-ri --no-rdoc
44
44
  ```
45
45
 
46
- - [ ] The last step is to install the `wd` BASH function and auto-completion. This step appends the required shell function to your shell initialization file, that is specified with the `--dotfile` flag.
46
+ - The last step is to install the `wd` BASH function and auto-completion. This step appends the required shell function to your shell initialization file, that is specified with the `--dotfile` flag.
47
47
 
48
48
  ```bash
49
49
  $ warp-dir install --dotfile ~/.bash_profile
@@ -57,7 +57,7 @@ $ wd help
57
57
 
58
58
  If the above command returns a properly formatted help that looks like the image below, your setup is now complete!
59
59
 
60
- ![Image](doc/wd-help.png)
60
+ ![Image](doc/wd-help.png?refresh=1)
61
61
 
62
62
 
63
63
  ## Usage
@@ -0,0 +1,22 @@
1
+ require 'warp/dir/command'
2
+ require 'warp/dir/formatter'
3
+
4
+ class Warp::Dir::Command::Clean < Warp::Dir::Command
5
+ description %q(Removes any no-longer existing warp points)
6
+ aliases :x
7
+
8
+ def run(*)
9
+ removed = store.clean!
10
+ s = self.store
11
+ if removed.empty?
12
+ on :success do
13
+ message 'All entries are valid in your file ' + s.config.warprc.blue + ' are ' + 'valid.'.green
14
+ end
15
+ else
16
+ on :success do
17
+ message "The following no-longer existing points have been removed:\n\n".bold +
18
+ ::Warp::Dir::Formatter::StoreFormatter.new(removed).format.bold.red
19
+ end
20
+ end
21
+ end
22
+ end
@@ -23,7 +23,7 @@ module Warp
23
23
  print ? STDERR.printf(out) : out
24
24
  end
25
25
 
26
- def format_point(point, *args)
26
+ def self.format_point(point, *args)
27
27
  PointFormatter.new(point).format(*args)
28
28
  end
29
29
 
@@ -35,8 +35,6 @@ module Warp
35
35
  STDOUT.printf(message.blue.bold)
36
36
  end
37
37
 
38
- private
39
-
40
38
  class PointFormatter
41
39
  attr_accessor :point
42
40
 
@@ -55,18 +53,18 @@ module Warp
55
53
  end
56
54
 
57
55
  class StoreFormatter
58
- attr_accessor :store
56
+ attr_accessor :points
59
57
 
60
- def initialize(store)
61
- @store = store
58
+ def initialize(store_or_points)
59
+ self.points = store_or_points.is_a?(::Array) ? store_or_points : store_or_points.points
62
60
  end
63
61
 
64
62
  # find the widest warp point name, and indent them all based on that.
65
63
  # make it easy to extend to other types, and allow the caller to
66
64
  # sort by one of the fields.
67
65
  def format(type = DEFAULT_FORMAT, sort_field = :name)
68
- longest_key_length = store.points.map(&:name).map(&:length).sort.last
69
- Warp::Dir.sort_by(store.points, sort_field).map do |point|
66
+ longest_key_length = points.map(&:name).map(&:length).sort.last
67
+ Warp::Dir.sort_by(points, sort_field).map do |point|
70
68
  PointFormatter.new(point).format(type, longest_key_length)
71
69
  end.join("\n")
72
70
  end
@@ -50,6 +50,14 @@ module Warp
50
50
  @name = name.to_sym
51
51
  end
52
52
 
53
+ def exist?
54
+ ::Dir.exist?(full_path)
55
+ end
56
+
57
+ def missing?
58
+ !exist?
59
+ end
60
+
53
61
  def inspect
54
62
  sprintf("(#{object_id})[name: '%s', path: '%s']", name, relative_path)
55
63
  end
@@ -66,7 +74,7 @@ module Warp
66
74
  name <=> other.name
67
75
  end
68
76
 
69
- def eql?(another)
77
+ def ==(another)
70
78
  return false unless another.is_a?(Warp::Dir::Point)
71
79
  %i(name full_path).each do |attribute|
72
80
  return false unless send(attribute) == another.send(attribute)
@@ -74,6 +82,9 @@ module Warp
74
82
  true
75
83
  end
76
84
 
85
+ alias_method :eql?, :==
86
+
87
+
77
88
  def serialize
78
89
  "#{name}:#{full_path}"
79
90
  end
@@ -68,6 +68,13 @@ module Warp
68
68
  result
69
69
  end
70
70
 
71
+ def clean!
72
+ points_collection.select(&:missing?).tap do |p|
73
+ points_collection.reject!(&:missing?)
74
+ save!
75
+ end
76
+ end
77
+
71
78
  def save!
72
79
  serializer.persist!
73
80
  end
@@ -1,7 +1,7 @@
1
1
  require_relative '../../colored'
2
2
  module Warp
3
3
  module Dir
4
- VERSION = '1.5.0'
4
+ VERSION = '1.6.0'
5
5
 
6
6
  @install_notice = <<-EOF
7
7
 
@@ -25,8 +25,9 @@ Gem::Specification.new do |s|
25
25
 
26
26
  s.add_dependency('slop', '~> 4.2')
27
27
 
28
- s.add_development_dependency 'codeclimate-test-reporter', '~> 0.5'
29
- s.add_development_dependency 'bundler', '~> 1.11'
30
- s.add_development_dependency 'rake', '~> 10.0'
31
- s.add_development_dependency 'rspec', '~> 3.4'
28
+ s.add_development_dependency 'bundler'
29
+ s.add_development_dependency 'rake'
30
+ s.add_development_dependency 'rspec', '~> 3.6'
31
+ s.add_development_dependency 'rspec-its'
32
+ s.add_development_dependency 'codeclimate-test-reporter'
32
33
  end
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.5.0
4
+ version: 1.6.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-07-13 00:00:00.000000000 Z
11
+ date: 2017-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop
@@ -25,61 +25,75 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: codeclimate-test-reporter
28
+ name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0.5'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0.5'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: bundler
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.11'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.11'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '3.6'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '3.6'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec
70
+ name: rspec-its
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '3.4'
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: codeclimate-test-reporter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
- version: '3.4'
96
+ version: '0'
83
97
  description: Warp-Dir is compatible (and inspired by) the popular 'wd' tool available
84
98
  as a ZSH module. This one is written in ruby and so it should work in any shell.
85
99
  Credits for the original zsh-only tool go to (https://github.com/mfaerevaag/wd).
@@ -115,6 +129,7 @@ files:
115
129
  - lib/warp/dir/app/response.rb
116
130
  - lib/warp/dir/command.rb
117
131
  - lib/warp/dir/command/add.rb
132
+ - lib/warp/dir/command/clean.rb
118
133
  - lib/warp/dir/command/help.rb
119
134
  - lib/warp/dir/command/install.rb
120
135
  - lib/warp/dir/command/list.rb
@@ -161,10 +176,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
176
  version: 1.3.6
162
177
  requirements: []
163
178
  rubyforge_project:
164
- rubygems_version: 2.5.1
179
+ rubygems_version: 2.6.11
165
180
  signing_key:
166
181
  specification_version: 4
167
182
  summary: Warp-Dir (aka 'wd') replaces 'cd' and lets you instantly move between saved
168
183
  "warp points" and regular folders.
169
184
  test_files: []
170
- has_rdoc: