ripgrep 0.1.1 → 0.1.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 +10 -8
- data/bin/console +6 -5
- data/lib/ripgrep.rb +1 -0
- data/lib/ripgrep/match.rb +19 -0
- data/lib/ripgrep/result.rb +2 -2
- data/lib/ripgrep/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3778f790aa4fe46bd2573b5e5fefa8429cfda234928d56c89b4b5485c8e681d4
|
4
|
+
data.tar.gz: 5e15af07a7008e772666d35a0c38e0e5d2ad8824a4ae4a42b77c2073d4252645
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53c17879617f7a49629ffda4099cd231ae1b2746c3b1c456a7a613b453dbb55466996b560cf8e3db7e46dfda098fe5d59c4cd09f06f6edea1cd28de4e66f29b7
|
7
|
+
data.tar.gz: f87295bc407b1b46bc916110c34a74230691d6e3af81cfeaa7c0ebd407456a09477daf8049c7ce1f54a7ccb25462bf08224bc0c97154f0aaaac0feb8eb30ae4c
|
data/README.md
CHANGED
@@ -40,17 +40,19 @@ puts result
|
|
40
40
|
# lib/ripgrep.rb:require 'ripgrep/core'
|
41
41
|
# lib/ripgrep.rb:require 'ripgrep/client'
|
42
42
|
# lib/ripgrep.rb:require 'ripgrep/result'
|
43
|
-
# lib/ripgrep
|
43
|
+
# lib/ripgrep.rb:require 'ripgrep/match'
|
44
44
|
# lib/ripgrep/core.rb:require 'open3'
|
45
|
+
# lib/ripgrep/client.rb:require 'forwardable'
|
45
46
|
|
46
|
-
puts result.matches
|
47
|
+
puts result.matches.map(&:to_json)
|
47
48
|
# =>
|
48
|
-
# {
|
49
|
-
# {
|
50
|
-
# {
|
51
|
-
# {
|
52
|
-
# {
|
53
|
-
# {
|
49
|
+
# {"file":"lib/ripgrep.rb","body":"require 'ripgrep/version'","raw_line":"lib/ripgrep.rb:require 'ripgrep/version'"}
|
50
|
+
# {"file":"lib/ripgrep.rb","body":"require 'ripgrep/core'","raw_line":"lib/ripgrep.rb:require 'ripgrep/core'"}
|
51
|
+
# {"file":"lib/ripgrep.rb","body":"require 'ripgrep/client'","raw_line":"lib/ripgrep.rb:require 'ripgrep/client'"}
|
52
|
+
# {"file":"lib/ripgrep.rb","body":"require 'ripgrep/result'","raw_line":"lib/ripgrep.rb:require 'ripgrep/result'"}
|
53
|
+
# {"file":"lib/ripgrep.rb","body":"require 'ripgrep/match'","raw_line":"lib/ripgrep.rb:require 'ripgrep/match'"}
|
54
|
+
# {"file":"lib/ripgrep/core.rb","body":"require 'open3'","raw_line":"lib/ripgrep/core.rb:require 'open3'"}
|
55
|
+
# {"file":"lib/ripgrep/client.rb","body":"require 'forwardable'","raw_line":"lib/ripgrep/client.rb:require 'forwardable'"}
|
54
56
|
|
55
57
|
### Search like `rg --ignore-case ruby ripgrep.gemspec`
|
56
58
|
result = rg.exec 'ruby', path: 'ripgrep.gemspec', options: { ignore_case: true }
|
data/bin/console
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'pry'
|
5
|
+
require 'ripgrep'
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
def rg
|
8
|
+
@rg ||= Ripgrep::Client.new
|
9
|
+
end
|
8
10
|
|
9
|
-
require "pry"
|
10
11
|
Pry.start
|
data/lib/ripgrep.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Ripgrep
|
2
|
+
class Match
|
3
|
+
attr_reader :file, :body, :raw_line
|
4
|
+
|
5
|
+
def initialize(file:, body:, raw_line:)
|
6
|
+
@file = file
|
7
|
+
@body = body
|
8
|
+
@raw_line = raw_line
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
raw_line
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_json
|
16
|
+
{ file: file, body: body, raw_line: raw_line }.to_json
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/ripgrep/result.rb
CHANGED
@@ -14,10 +14,10 @@ module Ripgrep
|
|
14
14
|
@exit_status = exit_status
|
15
15
|
|
16
16
|
# TODO: skip when not matching result. like a help or version.
|
17
|
+
# $ rg --files で対象ファイルが取れるので、これと比較してmatch結果かどうか見るのがいいかも
|
17
18
|
@matches = result.split("\n").map do |line|
|
18
|
-
# TODO: implement Match class. make more rich and useful interface.
|
19
19
|
file, *body = line.split(':')
|
20
|
-
|
20
|
+
Match.new file: file, body: body.join(':'), raw_line: line
|
21
21
|
end
|
22
22
|
|
23
23
|
case exit_status
|
data/lib/ripgrep/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ripgrep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- motoki-shun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/ripgrep.rb
|
86
86
|
- lib/ripgrep/client.rb
|
87
87
|
- lib/ripgrep/core.rb
|
88
|
+
- lib/ripgrep/match.rb
|
88
89
|
- lib/ripgrep/result.rb
|
89
90
|
- lib/ripgrep/version.rb
|
90
91
|
- ripgrep.gemspec
|