ruby-edit 0.2.0 → 0.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 +5 -5
- data/.gitignore +1 -0
- data/Gemfile.lock +8 -6
- data/README.md +3 -2
- data/configuration.yml +1 -0
- data/lib/ruby_edit.rb +1 -0
- data/lib/ruby_edit/cli.rb +4 -5
- data/lib/ruby_edit/commands/configure.rb +11 -8
- data/lib/ruby_edit/commands/edit.rb +1 -1
- data/lib/ruby_edit/configuration.rb +12 -2
- data/lib/ruby_edit/grep.rb +1 -2
- data/lib/ruby_edit/version.rb +1 -1
- data/lib/ruby_extensions/string.rb +8 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c2db2191f5accfe438db15cc17bddbbe511142d0a8c9cc92e4455f1de826c45b
|
4
|
+
data.tar.gz: 3eb45b01ca1b2f90e2ca386b4a42c5bcb364d97f49f88587da531ea561afb145
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e413e5fb3451650e97e22710d00be4dd0d6933df1286e8dfa4e7dce3af29ba1bc32a945025206a6f871050bab6aa96c4c60b5290d4fc2c3ee105618bc43cfeb3
|
7
|
+
data.tar.gz: cfa48842fab46ae7cde378a79c0803d654222e47b8e81009995a9cc49e377f66958e4ec6120ddc89c165ea26b4b574c3ebd1f894c31810b6d540549481fa5f6a
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ruby-edit (0.
|
4
|
+
ruby-edit (0.3.0)
|
5
5
|
pastel (~> 0.7.2)
|
6
6
|
thor (~> 0.20.0)
|
7
7
|
tty-color (~> 0.4.2)
|
@@ -66,14 +66,16 @@ GEM
|
|
66
66
|
simplecov-html (~> 0.10.0)
|
67
67
|
simplecov-html (0.10.2)
|
68
68
|
slop (3.6.0)
|
69
|
-
strings (0.1.
|
70
|
-
|
69
|
+
strings (0.1.4)
|
70
|
+
strings-ansi (~> 0.1.0)
|
71
|
+
unicode-display_width (~> 1.4.0)
|
71
72
|
unicode_utils (~> 1.4.0)
|
73
|
+
strings-ansi (0.1.0)
|
72
74
|
thor (0.20.0)
|
73
75
|
timers (4.1.2)
|
74
76
|
hitimes
|
75
77
|
tty-color (0.4.3)
|
76
|
-
tty-command (0.8.
|
78
|
+
tty-command (0.8.2)
|
77
79
|
pastel (~> 0.7.0)
|
78
80
|
tty-config (0.2.0)
|
79
81
|
tty-cursor (0.5.0)
|
@@ -97,7 +99,7 @@ GEM
|
|
97
99
|
tty-screen (~> 0.6.4)
|
98
100
|
tty-which (~> 0.3.0)
|
99
101
|
tty-platform (0.1.0)
|
100
|
-
tty-progressbar (0.15.
|
102
|
+
tty-progressbar (0.15.1)
|
101
103
|
tty-cursor (~> 0.5.0)
|
102
104
|
tty-screen (~> 0.6.4)
|
103
105
|
unicode-display_width (~> 1.3)
|
@@ -122,7 +124,7 @@ GEM
|
|
122
124
|
tty-screen (~> 0.6.4)
|
123
125
|
tty-tree (0.1.0)
|
124
126
|
tty-which (0.3.0)
|
125
|
-
unicode-display_width (1.
|
127
|
+
unicode-display_width (1.4.0)
|
126
128
|
unicode_utils (1.4.0)
|
127
129
|
wisper (2.0.0)
|
128
130
|
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
|
1
|
+
[](https://badge.fury.io/rb/ruby-edit)
|
2
|
+
[](https://travis-ci.org/finn-francis/ruby-edit)
|
2
3
|
|
3
|
-
|
4
|
+
# RubyEdit
|
4
5
|
|
5
6
|
RubyEdit is a simple commandline app that allows you to edit grep results in one file.
|
6
7
|
|
data/configuration.yml
CHANGED
data/lib/ruby_edit.rb
CHANGED
data/lib/ruby_edit/cli.rb
CHANGED
@@ -19,9 +19,8 @@ module RubyEdit
|
|
19
19
|
map %w[--version -v] => :version
|
20
20
|
|
21
21
|
desc 'grep', 'search for an expression in your directory'
|
22
|
-
method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
|
23
22
|
method_option :expression, aliases: %w[-e --expression], type: :string,
|
24
|
-
desc: 'the grep expression'
|
23
|
+
desc: 'the grep expression', required: true
|
25
24
|
method_option :path, aliases: %w[-p --path], type: :string, desc: 'the path you want to search'
|
26
25
|
def grep(*)
|
27
26
|
if options[:help]
|
@@ -38,6 +37,8 @@ module RubyEdit
|
|
38
37
|
method_option :help, aliases: '-h', type: :boolean, desc: 'Display useage information'
|
39
38
|
method_option :editor, aliases: %w[-e --editor], type: :string,
|
40
39
|
desc: 'Set or view your default text editor'
|
40
|
+
method_option :grep_options, aliases: %w[-o --grep-options], type: :string,
|
41
|
+
description: 'default grep options to refine your searches'
|
41
42
|
def configure(*)
|
42
43
|
if options[:help]
|
43
44
|
invoke :help, ['configure']
|
@@ -50,11 +51,9 @@ module RubyEdit
|
|
50
51
|
map %w[--configure -c] => :configure
|
51
52
|
|
52
53
|
desc 'edit', '[Default] Perform a grep and edit the changes in one file'
|
53
|
-
method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
|
54
54
|
method_option :expression, aliases: %w[-e --expression], type: :string,
|
55
|
-
desc: 'the grep expression'
|
55
|
+
desc: 'the grep expression', required: true
|
56
56
|
method_option :path, aliases: %w[-p --path], type: :string, desc: 'the path you want to search'
|
57
|
-
|
58
57
|
def edit(*)
|
59
58
|
if options[:help]
|
60
59
|
invoke :help, ['edit']
|
@@ -5,24 +5,27 @@ require 'ruby_edit'
|
|
5
5
|
module RubyEdit
|
6
6
|
module Commands
|
7
7
|
class Configure
|
8
|
+
CONFIGURATIONS = %i[editor grep_options].freeze
|
9
|
+
|
8
10
|
def initialize(options)
|
9
11
|
@options = options
|
10
12
|
end
|
11
13
|
|
12
14
|
def execute(output: $stdout)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
options.each do |key, val|
|
16
|
+
if val == key.to_s
|
17
|
+
output.puts RubyEdit.config.send(key)
|
18
|
+
else
|
19
|
+
RubyEdit.config.send("#{key}=", val)
|
20
|
+
output.puts "#{key.to_s.titleize} changed to #{val}"
|
21
|
+
end
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
22
25
|
private
|
23
26
|
|
24
|
-
def
|
25
|
-
@options
|
27
|
+
def options
|
28
|
+
@options = @options.select { |key, _val| CONFIGURATIONS.include?(key.to_sym) }
|
26
29
|
end
|
27
30
|
end
|
28
31
|
end
|
@@ -10,16 +10,26 @@ module RubyEdit
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def editor
|
13
|
-
@config.fetch(:editor)
|
13
|
+
@config.fetch(:editor) || 'vim'
|
14
14
|
end
|
15
15
|
|
16
16
|
def editor=(editor)
|
17
|
-
@config.set(:editor, value: editor
|
17
|
+
@config.set(:editor, value: editor)
|
18
|
+
write
|
19
|
+
end
|
20
|
+
|
21
|
+
def grep_options
|
22
|
+
@config.fetch(:grep_options) || 'ir'
|
23
|
+
end
|
24
|
+
|
25
|
+
def grep_options=(grep_options)
|
26
|
+
@config.set(:grep_options, value: grep_options)
|
18
27
|
write
|
19
28
|
end
|
20
29
|
|
21
30
|
def reset_defaults
|
22
31
|
@config.set(:editor, value: 'vim')
|
32
|
+
@config.set(:grep_options, value: 'ir')
|
23
33
|
write
|
24
34
|
end
|
25
35
|
|
data/lib/ruby_edit/grep.rb
CHANGED
@@ -7,7 +7,7 @@ module RubyEdit
|
|
7
7
|
attr_reader :result
|
8
8
|
|
9
9
|
def initialize(options)
|
10
|
-
@path = options[:path] || '
|
10
|
+
@path = options[:path] || '*'
|
11
11
|
@expression = options[:expression]
|
12
12
|
end
|
13
13
|
|
@@ -17,7 +17,6 @@ module RubyEdit
|
|
17
17
|
return false
|
18
18
|
end
|
19
19
|
@result = run "grep -irn #{@path} -e '#{@expression}'" do |out, err|
|
20
|
-
output << out if out
|
21
20
|
errors << err if err
|
22
21
|
end
|
23
22
|
rescue TTY::Command::ExitError => error
|
data/lib/ruby_edit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-edit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- finn-francis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pastel
|
@@ -384,6 +384,7 @@ files:
|
|
384
384
|
- lib/ruby_edit/templates/.gitkeep
|
385
385
|
- lib/ruby_edit/version.rb
|
386
386
|
- lib/ruby_edit/writer.rb
|
387
|
+
- lib/ruby_extensions/string.rb
|
387
388
|
- ruby-edit.gemspec
|
388
389
|
homepage: https://github.com/finn-francis/ruby-edit
|
389
390
|
licenses:
|
@@ -405,7 +406,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
405
406
|
version: '0'
|
406
407
|
requirements: []
|
407
408
|
rubyforge_project:
|
408
|
-
rubygems_version: 2.
|
409
|
+
rubygems_version: 2.7.6
|
409
410
|
signing_key:
|
410
411
|
specification_version: 4
|
411
412
|
summary: Edit grep results in one file
|