ruby-edit 0.3.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ruby_edit/cli.rb +1 -18
- data/lib/ruby_edit/configuration.rb +6 -2
- data/lib/ruby_edit/grep.rb +2 -1
- data/lib/ruby_edit/version.rb +1 -1
- metadata +2 -3
- data/lib/ruby_edit/commands/grep.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e90b8a2ab82a34d5d474f65a5d482d7a48e93a9a3894bcc29847cafc79e48653
|
4
|
+
data.tar.gz: 35fa3805fceff2afe04669b13fb2c879c389e763b16192421e5c1c48ef7fec59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e67fef358e9144c692467bee50d66a187bb96ac6de7c4324f3dc8bfe6714c6324ec658490019b2d469b2ecbc1d7975742201ffa3e337edc80ec2657d3047b93
|
7
|
+
data.tar.gz: 27ada5b5739492de7fbe35c6c96bd1f0e36d077a779dfd7f9ed7860fb7b52e4679f46daeb4a3c6188c589ccb6de6f65e87ac48a948a35dad537ec6549b21e3ef
|
data/Gemfile.lock
CHANGED
data/lib/ruby_edit/cli.rb
CHANGED
@@ -18,21 +18,6 @@ module RubyEdit
|
|
18
18
|
end
|
19
19
|
map %w[--version -v] => :version
|
20
20
|
|
21
|
-
desc 'grep', 'search for an expression in your directory'
|
22
|
-
method_option :expression, aliases: %w[-e --expression], type: :string,
|
23
|
-
desc: 'the grep expression', required: true
|
24
|
-
method_option :path, aliases: %w[-p --path], type: :string, desc: 'the path you want to search'
|
25
|
-
def grep(*)
|
26
|
-
if options[:help]
|
27
|
-
invoke :help, ['grep']
|
28
|
-
else
|
29
|
-
require_relative 'commands/grep'
|
30
|
-
RubyEdit::Commands::Grep.new(options).execute
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
map %w[--grep -g] => :grep
|
35
|
-
|
36
21
|
desc 'configure', 'set and read your settings'
|
37
22
|
method_option :help, aliases: '-h', type: :boolean, desc: 'Display useage information'
|
38
23
|
method_option :editor, aliases: %w[-e --editor], type: :string,
|
@@ -50,7 +35,7 @@ module RubyEdit
|
|
50
35
|
|
51
36
|
map %w[--configure -c] => :configure
|
52
37
|
|
53
|
-
desc 'edit', '
|
38
|
+
desc 'edit', 'Perform a grep and edit the changes in one file'
|
54
39
|
method_option :expression, aliases: %w[-e --expression], type: :string,
|
55
40
|
desc: 'the grep expression', required: true
|
56
41
|
method_option :path, aliases: %w[-p --path], type: :string, desc: 'the path you want to search'
|
@@ -64,8 +49,6 @@ module RubyEdit
|
|
64
49
|
RubyEdit::Commands::Edit.new(options).execute
|
65
50
|
end
|
66
51
|
end
|
67
|
-
|
68
|
-
default_task :edit
|
69
52
|
end
|
70
53
|
end
|
71
54
|
|
@@ -19,11 +19,15 @@ module RubyEdit
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def grep_options
|
22
|
-
@config.fetch(:grep_options) || 'ir'
|
22
|
+
options = @config.fetch(:grep_options) || 'ir'
|
23
|
+
# The n option is needed for edited changes to be applied, so it needs to be added here
|
24
|
+
# automatically
|
25
|
+
"#{options}n"
|
23
26
|
end
|
24
27
|
|
25
28
|
def grep_options=(grep_options)
|
26
|
-
|
29
|
+
# All occurences of n are removed, as n is autamatically added when the options are fetched.
|
30
|
+
@config.set(:grep_options, value: grep_options.gsub('n', ''))
|
27
31
|
write
|
28
32
|
end
|
29
33
|
|
data/lib/ruby_edit/grep.rb
CHANGED
@@ -9,6 +9,7 @@ module RubyEdit
|
|
9
9
|
def initialize(options)
|
10
10
|
@path = options[:path] || '*'
|
11
11
|
@expression = options[:expression]
|
12
|
+
@config = RubyEdit.config
|
12
13
|
end
|
13
14
|
|
14
15
|
def search(output: $stdout, errors: $stderr)
|
@@ -16,7 +17,7 @@ module RubyEdit
|
|
16
17
|
output.puts 'No expression given'
|
17
18
|
return false
|
18
19
|
end
|
19
|
-
@result = run "grep
|
20
|
+
@result = run "grep -#{@config.grep_options} #{@path} -e '#{@expression}'" do |out, err|
|
20
21
|
errors << err if err
|
21
22
|
end
|
22
23
|
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: 1.0.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-09-
|
11
|
+
date: 2018-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pastel
|
@@ -376,7 +376,6 @@ files:
|
|
376
376
|
- lib/ruby_edit/commands/.gitkeep
|
377
377
|
- lib/ruby_edit/commands/configure.rb
|
378
378
|
- lib/ruby_edit/commands/edit.rb
|
379
|
-
- lib/ruby_edit/commands/grep.rb
|
380
379
|
- lib/ruby_edit/configuration.rb
|
381
380
|
- lib/ruby_edit/editor.rb
|
382
381
|
- lib/ruby_edit/grep.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'ruby_edit/grep'
|
4
|
-
|
5
|
-
module RubyEdit
|
6
|
-
module Commands
|
7
|
-
class Grep
|
8
|
-
def initialize(options)
|
9
|
-
@options = options
|
10
|
-
@grep = RubyEdit::Grep.new(@options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def execute(output: $stdout)
|
14
|
-
@result = @grep.search(output: output)
|
15
|
-
output.puts 'OK'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|