context_spook 0.0.0 → 0.1.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/README.md +1 -1
- data/bin/context_spook +4 -1
- data/context_spook.gemspec +3 -3
- data/contexts/project.rb +7 -1
- data/hello_world.json +3 -0
- data/lib/context_spook/generator.rb +33 -13
- data/lib/context_spook/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8061fffaf039f19b3b37a0df7ce5ce62624c04c303fd525a6b2a96b74bbf0fd4
|
4
|
+
data.tar.gz: 72b878f810bd5695aa0a09144fb3eb66475d7e12d73ba1cd1b17694e54a89c00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5f21ce7d81d9488732ebbe27e2b17096fa6c92afcd2e9dadf0427cad36a33eb48e4e114a7bd687a0fb60a37351297b8cbbcc035e4a6644c530a3007ee2aedc3
|
7
|
+
data.tar.gz: 38bc4a4e00193b70fce74115e8ba8d230dbb06d3c6179cebb1c889b83fb10310fe3d9699f8bbc26ef4d16fbd9c646c080274ea738e56d94fe08381250c7c1a96
|
data/README.md
CHANGED
data/bin/context_spook
CHANGED
@@ -4,5 +4,8 @@ require 'context_spook'
|
|
4
4
|
|
5
5
|
filename = ARGV.shift or fail 'require context definition file as first argument'
|
6
6
|
context_json = ContextSpook.generate_context(filename).to_json
|
7
|
-
|
7
|
+
context_json_size = Tins::Unit.format(
|
8
|
+
context_json.size, format: '%.2f %U', unit: ?b, prefix: 1024
|
9
|
+
)
|
10
|
+
STDERR.puts "Now outputting #{context_json_size} of JSON context in total."
|
8
11
|
puts context_json
|
data/context_spook.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: context_spook 0.
|
2
|
+
# stub: context_spook 0.1.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "context_spook".freeze
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.1.0".freeze
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.email = "flori@ping.de".freeze
|
14
14
|
s.executables = ["context_spook".freeze]
|
15
15
|
s.extra_rdoc_files = ["README.md".freeze, "lib/context_spook.rb".freeze, "lib/context_spook/generator.rb".freeze, "lib/context_spook/version.rb".freeze]
|
16
|
-
s.files = ["Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/context_spook".freeze, "context_spook.gemspec".freeze, "contexts/project.rb".freeze, "lib/context_spook.rb".freeze, "lib/context_spook/generator.rb".freeze, "lib/context_spook/version.rb".freeze, "spec/context_spook/generator_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
16
|
+
s.files = ["Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/context_spook".freeze, "context_spook.gemspec".freeze, "contexts/project.rb".freeze, "hello_world.json".freeze, "lib/context_spook.rb".freeze, "lib/context_spook/generator.rb".freeze, "lib/context_spook/version.rb".freeze, "spec/context_spook/generator_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
17
17
|
s.homepage = "https://github.com/flori/context_spook".freeze
|
18
18
|
s.licenses = ["MIT".freeze]
|
19
19
|
s.rdoc_options = ["--title".freeze, "ContextSpook - context_spook collects project context for AI".freeze, "--main".freeze, "README.md".freeze]
|
data/contexts/project.rb
CHANGED
@@ -25,6 +25,8 @@ context do
|
|
25
25
|
|
26
26
|
command 'false', tags: 'failure'
|
27
27
|
|
28
|
+
command 'echo hello world'
|
29
|
+
|
28
30
|
file 'nixda', tags: 'failure'
|
29
31
|
|
30
32
|
file 'Rakefile', tags: [ 'gem_hadar' ]
|
@@ -33,5 +35,9 @@ context do
|
|
33
35
|
|
34
36
|
meta ruby: RUBY_DESCRIPTION
|
35
37
|
|
36
|
-
meta
|
38
|
+
meta hello_world: json('hello_world.json')
|
39
|
+
|
40
|
+
meta nixda_json: json('nixda_json.json')
|
41
|
+
|
42
|
+
meta code_coverage: json('coverage/coverage_context.json')
|
37
43
|
end
|
data/hello_world.json
ADDED
@@ -117,6 +117,29 @@ module ContextSpook
|
|
117
117
|
nil
|
118
118
|
end
|
119
119
|
|
120
|
+
# The json method reads and parses a JSON file, returning the parsed data
|
121
|
+
# structure.
|
122
|
+
#
|
123
|
+
# This method attempts to load a JSON file from the specified path and
|
124
|
+
# returns the resulting Ruby data structure. It provides verbose output
|
125
|
+
# about the file size when successfully reading the file. In case of file
|
126
|
+
# not found errors, it outputs a colored warning message to standard
|
127
|
+
# error and returns nil.
|
128
|
+
#
|
129
|
+
# @param filename [ String ] the path to the JSON file to be read and parsed
|
130
|
+
#
|
131
|
+
# @return [ Object, nil ] the parsed JSON data structure or nil if the file cannot be read
|
132
|
+
def json(filename)
|
133
|
+
file_size = Tins::Unit.format(
|
134
|
+
File.size(filename), format: '%.2f %U', unit: ?b, prefix: 1024
|
135
|
+
)
|
136
|
+
STDERR.puts "Read #{filename.inspect} as JSON (%s) for context." % file_size
|
137
|
+
JSON.load_file(filename)
|
138
|
+
rescue Errno::ENOENT => e
|
139
|
+
STDERR.puts color(208) { "Reading #{filename.inspect} as JSON caused #{e.class}: #{e}" }
|
140
|
+
nil
|
141
|
+
end
|
142
|
+
|
120
143
|
# The files method sets up a DSL accessor for providing files.
|
121
144
|
#
|
122
145
|
# @param default [ Hash ] the default files hash
|
@@ -143,9 +166,13 @@ module ContextSpook
|
|
143
166
|
lines: content.lines.size,
|
144
167
|
tags: (Array(tags) if tags),
|
145
168
|
}.compact
|
169
|
+
file_size = Tins::Unit.format(
|
170
|
+
content.size, format: '%.2f %U', unit: ?b, prefix: 1024
|
171
|
+
)
|
172
|
+
STDERR.puts "Read #{filename.inspect} (%s) for context." % file_size
|
146
173
|
nil
|
147
174
|
rescue Errno::ENOENT => e
|
148
|
-
|
175
|
+
STDERR.puts color(208) { "Reading #{filename.inspect} caused #{e.class}: #{e}" }
|
149
176
|
end
|
150
177
|
|
151
178
|
# The commands method sets up a DSL accessor for provided command outputs.
|
@@ -168,7 +195,7 @@ module ContextSpook
|
|
168
195
|
output = `#{shell_command}`
|
169
196
|
exit_code = $?&.exitstatus.to_i
|
170
197
|
if exit_code != 0
|
171
|
-
|
198
|
+
STDERR.puts color(208) { "Executing #{shell_command.inspect} resulted in exit code #{exit_code}." }
|
172
199
|
end
|
173
200
|
commands[shell_command] = {
|
174
201
|
namespace: scope_top,
|
@@ -177,6 +204,10 @@ module ContextSpook
|
|
177
204
|
working_directory: Dir.pwd,
|
178
205
|
tags: (Array(tags) if tags),
|
179
206
|
}.compact
|
207
|
+
output_size = Tins::Unit.format(
|
208
|
+
output.size, format: '%.2f %U', unit: ?b, prefix: 1024
|
209
|
+
)
|
210
|
+
STDERR.puts "Executed #{shell_command.inspect} with output (%s) for context." % output_size
|
180
211
|
nil
|
181
212
|
end
|
182
213
|
|
@@ -199,17 +230,6 @@ module ContextSpook
|
|
199
230
|
variables:
|
200
231
|
}
|
201
232
|
end
|
202
|
-
|
203
|
-
private
|
204
|
-
|
205
|
-
# The warn method enhances warning messages by applying colored
|
206
|
-
# formatting before passing them to the superclass implementation.
|
207
|
-
#
|
208
|
-
# @param msgs [ Array ] an array of message objects to be formatted and warned
|
209
|
-
def warn(*msgs)
|
210
|
-
msgs.map! { |m| color(208) { m } }
|
211
|
-
super(*msgs, uplevel: 1)
|
212
|
-
end
|
213
233
|
end
|
214
234
|
|
215
235
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: context_spook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- bin/context_spook
|
142
142
|
- context_spook.gemspec
|
143
143
|
- contexts/project.rb
|
144
|
+
- hello_world.json
|
144
145
|
- lib/context_spook.rb
|
145
146
|
- lib/context_spook/generator.rb
|
146
147
|
- lib/context_spook/version.rb
|