concat.rb 1.0.2 → 1.1.1
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/.rubocop.yml +37 -0
- data/AGENTS.md +55 -0
- data/CLAUDE.md +1 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +2 -2
- data/bin/rubocop +6 -0
- data/bin/test +10 -0
- data/concat2.gemspec +36 -0
- data/lib/concat/cli.rb +11 -1
- data/lib/concat/deconcat_cli.rb +2 -2
- data/lib/concat/version.rb +1 -1
- data/specs/README.md +31 -0
- metadata +9 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e9aceabd8b620aa2f44a70f4424ab0dc7cc4a1802663ff6dc3dfb0044ab55ca9
|
|
4
|
+
data.tar.gz: 5a3c6c7df2850ecfb8194ad5e1f63626b9245cd7e255d01f46058b09096fe26d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b6c44e3ea775ed9d9593c7267aeaa4551bc2fab30edfb96c4ffb857b5c128ab3b7072a9cd32ddcf65ca6b2355c15abaaa5b2575d11c45b37492d71d05dc2512e
|
|
7
|
+
data.tar.gz: dc234e54726c240b41996d46b0be48269f14b01d6de68c0c75bafeb46b25631a385e7ed466ef72007760f01a8b531f4f7b4023d12bd5d5d927091dba2f24d663
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
DisabledByDefault: true
|
|
3
|
+
|
|
4
|
+
RubyInterpreters:
|
|
5
|
+
- ruby
|
|
6
|
+
|
|
7
|
+
Include:
|
|
8
|
+
- '**/*.rb'
|
|
9
|
+
- '.pryrc'
|
|
10
|
+
|
|
11
|
+
Exclude:
|
|
12
|
+
<% Dir.glob("#{__dir__}/*").grep_v(%r{#{__dir__}\/(app|lib)}).each do |dir| %>
|
|
13
|
+
- <%= dir %>/**/*
|
|
14
|
+
<% end %>
|
|
15
|
+
- 'lib/templates/**/*'
|
|
16
|
+
|
|
17
|
+
Layout/IndentationConsistency:
|
|
18
|
+
Enabled: true
|
|
19
|
+
EnforcedStyle: indented_internal_methods
|
|
20
|
+
|
|
21
|
+
Layout/BlockEndNewline:
|
|
22
|
+
Enabled: true
|
|
23
|
+
|
|
24
|
+
Layout/BeginEndAlignment:
|
|
25
|
+
Enabled: true
|
|
26
|
+
EnforcedStyleAlignWith: start_of_line
|
|
27
|
+
|
|
28
|
+
Layout/ElseAlignment:
|
|
29
|
+
Enabled: true
|
|
30
|
+
|
|
31
|
+
Layout/DefEndAlignment:
|
|
32
|
+
Enabled: true
|
|
33
|
+
EnforcedStyleAlignWith: def
|
|
34
|
+
|
|
35
|
+
Layout/EmptyLinesAroundAccessModifier:
|
|
36
|
+
Enabled: true
|
|
37
|
+
EnforcedStyle: around
|
data/AGENTS.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
## Specifications
|
|
4
|
+
|
|
5
|
+
**IMPORTANT:** Before implementing any feature, consult the specifications in `specs/README.md`.
|
|
6
|
+
|
|
7
|
+
- **Assume NOT implemented.** Many specs describe planned features that may not yet exist in the codebase.
|
|
8
|
+
- **Check the codebase first.** Before concluding something is or isn't implemented, search the actual code. Specs describe intent; code describes reality.
|
|
9
|
+
- **Use specs as guidance.** When implementing a feature, follow the design patterns, types, and architecture defined in the relevant spec.
|
|
10
|
+
- **Spec index:** `specs/README.md` lists all specifications organized by category (core, LLM, security, etc.).
|
|
11
|
+
|
|
12
|
+
## Development Commands
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Setup
|
|
16
|
+
bin/setup
|
|
17
|
+
|
|
18
|
+
# Run all tests
|
|
19
|
+
bin/test
|
|
20
|
+
|
|
21
|
+
# Run a single test file
|
|
22
|
+
bin/test test/cli_test.rb
|
|
23
|
+
|
|
24
|
+
# Lint
|
|
25
|
+
bin/rubocop
|
|
26
|
+
|
|
27
|
+
# Interactive console
|
|
28
|
+
bin/console
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Architecture
|
|
32
|
+
|
|
33
|
+
concat.rb is a Ruby gem providing two CLI tools for file concatenation and restoration.
|
|
34
|
+
|
|
35
|
+
### Core Components
|
|
36
|
+
|
|
37
|
+
- **`Concat::CLI`** (`lib/concat/cli.rb`) - Recursively reads files from directories, outputs contents prefixed with `# File path: <path>` markers. Supports `--extensions` flag for filtering.
|
|
38
|
+
|
|
39
|
+
- **`Concat::DeconcatCLI`** (`lib/concat/deconcat_cli.rb`) - Parses concatenated output from STDIN, extracts file boundaries via `# File path:` markers, recreates directory structure and writes files.
|
|
40
|
+
|
|
41
|
+
### Entry Points
|
|
42
|
+
|
|
43
|
+
Executables in `exe/` instantiate the CLI classes and call `#call(ARGV)`, returning exit codes.
|
|
44
|
+
|
|
45
|
+
### File Format
|
|
46
|
+
|
|
47
|
+
The concatenation format uses `# File path: <relative_path>` as a delimiter:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
# File path: ./lib/foo.rb
|
|
51
|
+
<file contents>
|
|
52
|
+
|
|
53
|
+
# File path: ./lib/bar.rb
|
|
54
|
+
<file contents>
|
|
55
|
+
```
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
AGENTS.md
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
|
|
4
|
+
concat.rb (1.1.0)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
@@ -45,8 +45,8 @@ PLATFORMS
|
|
|
45
45
|
x86_64-linux
|
|
46
46
|
|
|
47
47
|
DEPENDENCIES
|
|
48
|
+
concat.rb!
|
|
48
49
|
minitest (~> 5.0)
|
|
49
|
-
mirrorfile!
|
|
50
50
|
rake (~> 13.0)
|
|
51
51
|
rubocop (~> 1.21)
|
|
52
52
|
yard (~> 0.9)
|
data/bin/rubocop
ADDED
data/bin/test
ADDED
data/concat2.gemspec
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/concat/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "concat"
|
|
7
|
+
spec.version = Concat::VERSION
|
|
8
|
+
spec.authors = ["Nathan Kidd"]
|
|
9
|
+
spec.email = ["nathankidd@hey.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "Concatenate files from directories with optional extension filtering"
|
|
12
|
+
|
|
13
|
+
spec.description = <<~DESC
|
|
14
|
+
A simple CLI tool that recursively reads files from directories and outputs
|
|
15
|
+
their contents with file path comments. Supports filtering by file extensions.
|
|
16
|
+
DESC
|
|
17
|
+
|
|
18
|
+
spec.homepage = "https://github.com/n-at-han-k/concat.rb"
|
|
19
|
+
spec.license = "MIT"
|
|
20
|
+
spec.required_ruby_version = ">= 3.2.0"
|
|
21
|
+
|
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
23
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
24
|
+
spec.metadata["documentation_uri"] = spec.homepage
|
|
25
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
26
|
+
|
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|data)/}) }
|
|
28
|
+
spec.bindir = "exe"
|
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
30
|
+
spec.require_paths = ["lib"]
|
|
31
|
+
|
|
32
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
|
33
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
34
|
+
spec.add_development_dependency "rubocop", "~> 1.21"
|
|
35
|
+
spec.add_development_dependency "yard", "~> 0.9"
|
|
36
|
+
end
|
data/lib/concat/cli.rb
CHANGED
|
@@ -26,7 +26,7 @@ module Concat
|
|
|
26
26
|
|
|
27
27
|
argv.each do |folder|
|
|
28
28
|
Dir.glob("#{folder}/**/*#{extensions}").each do |path|
|
|
29
|
-
if File.file?(path)
|
|
29
|
+
if File.file?(path) && !binary_file?(path)
|
|
30
30
|
puts "#{COMMENT} File path: #{path}"
|
|
31
31
|
puts File.read(path)
|
|
32
32
|
puts
|
|
@@ -36,6 +36,16 @@ module Concat
|
|
|
36
36
|
|
|
37
37
|
0
|
|
38
38
|
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def binary_file?(path)
|
|
43
|
+
File.open(path, "rb") do |file|
|
|
44
|
+
chunk = file.read(8192)
|
|
45
|
+
return false if chunk.nil?
|
|
46
|
+
chunk.include?("\x00")
|
|
47
|
+
end
|
|
48
|
+
end
|
|
39
49
|
end
|
|
40
50
|
end
|
|
41
51
|
|
data/lib/concat/deconcat_cli.rb
CHANGED
|
@@ -10,7 +10,7 @@ module Concat
|
|
|
10
10
|
|
|
11
11
|
ARGF.each_line do |line|
|
|
12
12
|
if line.start_with?("# File path: ")
|
|
13
|
-
File.write(current_path, content.join) if current_path && !content.empty?
|
|
13
|
+
File.write(current_path, content.join.chomp) if current_path && !content.empty?
|
|
14
14
|
current_path = line.sub("# File path: ", "").strip
|
|
15
15
|
content = []
|
|
16
16
|
FileUtils.mkdir_p(File.dirname(current_path))
|
|
@@ -19,7 +19,7 @@ module Concat
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
File.write(current_path, content.join) if current_path && !content.empty?
|
|
22
|
+
File.write(current_path, content.join.chomp) if current_path && !content.empty?
|
|
23
23
|
|
|
24
24
|
0
|
|
25
25
|
end
|
data/lib/concat/version.rb
CHANGED
data/specs/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Copyright (c) 2025 Nathan Kidd <nathankidd@hey.com>. All rights reserved.
|
|
3
|
+
SPDX-License-Identifier: Proprietary
|
|
4
|
+
-->
|
|
5
|
+
|
|
6
|
+
<!--
|
|
7
|
+
HOW TO MAINTAIN THIS FILE
|
|
8
|
+
|
|
9
|
+
This is the index of all design specifications for concat.rb.
|
|
10
|
+
Each row links a spec document to its implementation code and a short purpose summary.
|
|
11
|
+
|
|
12
|
+
When adding a new spec:
|
|
13
|
+
1. Create the markdown file in this directory (specs/)
|
|
14
|
+
2. Add a row to the appropriate table section below
|
|
15
|
+
3. Link the spec file, the code path it describes, and a brief purpose
|
|
16
|
+
|
|
17
|
+
Table format:
|
|
18
|
+
| [spec-name.md](./spec-name.md) | [path/to/code](../path/to/code) | Short description |
|
|
19
|
+
|
|
20
|
+
Use "—" in the Code column if the spec has no implementation yet.
|
|
21
|
+
Group specs under heading sections by domain area.
|
|
22
|
+
-->
|
|
23
|
+
|
|
24
|
+
# Project Specifications
|
|
25
|
+
|
|
26
|
+
concat.rb is a CLI tool for concatenating files from directories into a single output with file path markers, and reversing the process.
|
|
27
|
+
|
|
28
|
+
## Core
|
|
29
|
+
|
|
30
|
+
| Spec | Code | Purpose |
|
|
31
|
+
|------|------|---------|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: concat.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nathan Kidd
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-02-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|
|
@@ -78,20 +78,27 @@ extensions: []
|
|
|
78
78
|
extra_rdoc_files: []
|
|
79
79
|
files:
|
|
80
80
|
- ".github/workflows/gem-push.yml"
|
|
81
|
+
- ".rubocop.yml"
|
|
82
|
+
- AGENTS.md
|
|
83
|
+
- CLAUDE.md
|
|
81
84
|
- Gemfile
|
|
82
85
|
- Gemfile.lock
|
|
83
86
|
- LICENSE.txt
|
|
84
87
|
- README.md
|
|
85
88
|
- Rakefile
|
|
86
89
|
- bin/console
|
|
90
|
+
- bin/rubocop
|
|
87
91
|
- bin/setup
|
|
92
|
+
- bin/test
|
|
88
93
|
- concat.gemspec
|
|
94
|
+
- concat2.gemspec
|
|
89
95
|
- exe/concat
|
|
90
96
|
- exe/deconcat
|
|
91
97
|
- lib/concat.rb
|
|
92
98
|
- lib/concat/cli.rb
|
|
93
99
|
- lib/concat/deconcat_cli.rb
|
|
94
100
|
- lib/concat/version.rb
|
|
101
|
+
- specs/README.md
|
|
95
102
|
homepage: https://github.com/n-at-han-k/concat.rb
|
|
96
103
|
licenses:
|
|
97
104
|
- MIT
|