context_grep 0.1.0 → 0.2.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/context_grep.gemspec +1 -1
- data/lib/context_grep.rb +12 -5
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f0da5e25812952e719c642974b5a7cdec355f50ce0e0d1acc954fd38cf10e93c
|
|
4
|
+
data.tar.gz: 451808e55032fbd2f64fd138de7427c365cd140055324260e60887e687034526
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 50675d9cd5800cf45270d7458493739b94a074df3b6fa76014d1d4fe8086f4d846161f32af14576130f53905d816617c2278dcdc3b8362c8a47b3659cfe9bc2d
|
|
7
|
+
data.tar.gz: 979ced1ef8bdfb26c1fc7c5d094d549d3cd5c688aabb6b4499a2127980e30915e9af6aab12ceab1b29a0a743bcca23f63941680cac91de147b7fd3fb4cf4aa5f
|
data/context_grep.gemspec
CHANGED
data/lib/context_grep.rb
CHANGED
|
@@ -34,24 +34,31 @@ def ContextGrep pattern
|
|
|
34
34
|
require "zip"
|
|
35
35
|
::FileUtils.mkdir_p ::TreeStand.config.parser_path
|
|
36
36
|
zip_filename = ::File.join ::TreeStand.config.parser_path, "temp.zip"
|
|
37
|
+
lambda do
|
|
37
38
|
"https://github.com/Faveod/tree-sitter-parsers/releases/download/v5.0/tree-sitter-parsers-5.0-#{
|
|
38
39
|
"Darwin" == ::Etc.uname[:sysname] ? "macos" : "linux"
|
|
39
40
|
}-#{
|
|
40
41
|
::RbConfig::CONFIG["host_cpu"] =~ /x86_64|amd64/ ? "x64" : "arm64"
|
|
41
42
|
}.zip".tap do |url|
|
|
42
|
-
|
|
43
|
+
::STDERR.puts "downloading #{url} to #{::TreeStand.config.parser_path}"
|
|
43
44
|
::File.binwrite zip_filename, ::URI.open(url, &:read)
|
|
44
45
|
end
|
|
45
46
|
::Zip::File.open(zip_filename) do |zip|
|
|
46
47
|
for entry in zip
|
|
47
48
|
next if entry.directory?
|
|
48
49
|
target_path = ::File.join ::TreeStand.config.parser_path, ::File.basename(entry.name)
|
|
49
|
-
|
|
50
|
+
next if ::File.exists? target_path
|
|
50
51
|
entry.extract target_path
|
|
52
|
+
begin
|
|
53
|
+
return ::TreeStand::Parser.new ts_name
|
|
54
|
+
rescue ::TreeSitter::ParserNotFoundError
|
|
55
|
+
::FileUtils.rm_f target_path
|
|
56
|
+
end
|
|
51
57
|
end
|
|
52
58
|
end
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
ensure
|
|
60
|
+
::FileUtils.rm_f zip_filename
|
|
61
|
+
end.call
|
|
55
62
|
end.parse_string(src).root_node
|
|
56
63
|
]
|
|
57
64
|
nodes = {}
|
|
@@ -69,7 +76,7 @@ def ContextGrep pattern
|
|
|
69
76
|
if ::ENV["COGREP_DEBUGTYPES"]
|
|
70
77
|
s = node.ts_node.start_point.row + 1
|
|
71
78
|
e = node.ts_node.end_point.row + 1
|
|
72
|
-
puts "#{::File.basename file} #{node.type.inspect} #{s}-#{e}: #{src.lines[s - 1]}"
|
|
79
|
+
::STDERR.puts "#{::File.basename file} #{node.type.inspect} #{s}-#{e}: #{src.lines[s - 1]}"
|
|
73
80
|
end
|
|
74
81
|
lines.push node.ts_node.start_point.row unless %i{ program body_statement translation_unit }.include? node.type
|
|
75
82
|
end while node = nodes[node]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: context_grep
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Victor Maslov aka Nakilon
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir:
|
|
10
10
|
- exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2026-
|
|
12
|
+
date: 2026-04-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: github-linguist
|