spltty 0.1.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3bf97f1aff65eb471face732214bed57413de422a2e1bbae72d562931849db79
4
- data.tar.gz: aaaf79b631b2972234bf56dbec3a9a2db7c37448addba068fdb84026cc04aa3c
3
+ metadata.gz: cda46c6bf3b96b0fc361678123afa2b6a99ee9499925c1c9218f5d2cdc1bdad2
4
+ data.tar.gz: c53c93595eb48159d85dd8179a69e5e81c6e9ffde392c57474f68496111bbea6
5
5
  SHA512:
6
- metadata.gz: f5d18872e7428a31860edc70d027e4e922ea71c29eb0a008890986cbe1f24cc1ba6449fb47f48683c0b56af1a71157bb92b27a1d11aac4544b26c64df765135c
7
- data.tar.gz: 3000707668e2ca9604cd5f411ed973dbcac99067192b172783d1a32a19ba2c4ae29afc76ae7f0488c57019376954ccc5e780c99c253a8576739eab8a0b11c892
6
+ metadata.gz: 15887da426206c6d5449cd6ea1d849cdff176cc2df67bb0a56473a97d4a077e178f526adea6010f0f846b8ddaf46696e6745c3bc7d1d165e7ba2833489c72812
7
+ data.tar.gz: f343cfb690de8f8adadbf66b8763e5521f2b6e29e93dec9817d383f5f0387c596a16b9645f48c5c20eabbf9937b20198e287c1d0d8dda4b9760f35a6fabd8c3d
@@ -66,7 +66,7 @@ module SplttyCLI
66
66
  path = Ledger.target_path(@config, name, entry, date)
67
67
  ensure_file(name, entry, path, date)
68
68
 
69
- text = File.read(path)
69
+ text = File.read(path, encoding: "UTF-8")
70
70
  parsed = Table.parse(text)
71
71
  row = Table.format_row(parsed, values)
72
72
 
@@ -292,7 +292,7 @@ module SplttyCLI
292
292
  return if File.exist?(path)
293
293
 
294
294
  FileUtils.mkdir_p(File.dirname(path))
295
- File.write(path, File.read(File.join(SplttyCLI::TEMPLATES_DIR, "sources-INDEX.md")))
295
+ File.write(path, read_template("sources-INDEX.md"))
296
296
  end
297
297
 
298
298
  # Render the workspace guide. An existing CLAUDE.md is never clobbered —
@@ -316,7 +316,7 @@ module SplttyCLI
316
316
  skill = File.join(@root, ".claude", "skills", "ingest", "SKILL.md")
317
317
  unless File.exist?(skill)
318
318
  FileUtils.mkdir_p(File.dirname(skill))
319
- File.write(skill, File.read(File.join(SplttyCLI::TEMPLATES_DIR, "skills", "ingest", "SKILL.md")))
319
+ File.write(skill, read_template("skills", "ingest", "SKILL.md"))
320
320
  end
321
321
  path
322
322
  end
@@ -340,7 +340,7 @@ module SplttyCLI
340
340
 
341
341
  gitignore = File.join(@root, ".gitignore")
342
342
  unless File.exist?(gitignore)
343
- File.write(gitignore, File.read(File.join(SplttyCLI::TEMPLATES_DIR, "gitignore")))
343
+ File.write(gitignore, read_template("gitignore"))
344
344
  end
345
345
  system("git", "init", "--quiet", @root) || warn("spltty install: git init failed — skipping")
346
346
  end
@@ -372,9 +372,16 @@ module SplttyCLI
372
372
  # --- helpers ------------------------------------------------------------
373
373
 
374
374
  def render(template, **vars)
375
- src = File.read(File.join(SplttyCLI::TEMPLATES_DIR, template))
376
375
  scope = TemplateScope.new(vars)
377
- ERB.new(src, trim_mode: "-").result(scope.binding_for)
376
+ ERB.new(read_template(template), trim_mode: "-").result(scope.binding_for)
377
+ end
378
+
379
+ # Templates ship as UTF-8. Read them explicitly rather than through the
380
+ # locale's default_external: under LC_ALL=C (Docker, cron, CI, `brew test`)
381
+ # Ruby would tag them US-ASCII and ERB would refuse to compile the em dashes
382
+ # with "invalid multibyte character".
383
+ def read_template(*parts)
384
+ File.read(File.join(SplttyCLI::TEMPLATES_DIR, *parts), encoding: "UTF-8")
378
385
  end
379
386
 
380
387
  def split_list(str)
@@ -36,7 +36,7 @@ module SplttyCLI
36
36
  data =
37
37
  if File.exist?(path)
38
38
  begin
39
- JSON.parse(File.read(path))
39
+ JSON.parse(File.read(path, encoding: "UTF-8"))
40
40
  rescue JSON::ParserError => e
41
41
  raise Error, "malformed config at #{path}: #{e.message}"
42
42
  end
@@ -52,7 +52,7 @@ module SplttyCLI
52
52
  def detect_schema(file)
53
53
  return "standard" unless file && File.exist?(file)
54
54
 
55
- File.foreach(file) do |line|
55
+ File.foreach(file, encoding: "UTF-8") do |line|
56
56
  next unless line.strip.start_with?("|")
57
57
 
58
58
  return line.include?("Orig. Value") ? "montreal" : "standard"
@@ -20,7 +20,7 @@ module SplttyCLI
20
20
  def parse(path)
21
21
  return { frontmatter: {}, body: "", mtime: nil } unless File.exist?(path)
22
22
 
23
- raw = File.read(path)
23
+ raw = File.read(path, encoding: "UTF-8")
24
24
  mtime = File.mtime(path)
25
25
  fm, body = split(raw)
26
26
  { frontmatter: fm, body: body, mtime: mtime }
@@ -109,7 +109,7 @@ module SplttyCLI
109
109
  new_fm["spltty"] = new_spltty
110
110
  end
111
111
 
112
- old_raw = File.read(path)
112
+ old_raw = File.read(path, encoding: "UTF-8")
113
113
  new_raw = render(new_fm, body)
114
114
  return false if new_raw == old_raw
115
115
 
@@ -58,7 +58,7 @@ module SplttyCLI
58
58
  rows = []
59
59
  header = nil
60
60
  vi = pi = ri = nil
61
- File.foreach(path) do |line|
61
+ File.foreach(path, encoding: "UTF-8") do |line|
62
62
  next unless line.strip.start_with?("|")
63
63
 
64
64
  cells = Table.row_cells(line)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SplttyCLI
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/spltty_cli.rb CHANGED
@@ -37,6 +37,12 @@ module SplttyCLI
37
37
  # --paid-responsible option, supporting both `-pr X` and `-pr=X`.
38
38
  def self.run(argv = ARGV)
39
39
  $PROGRAM_NAME = "spltty"
40
+
41
+ # Ledgers, notes and templates are UTF-8 whatever the caller's locale is. Under
42
+ # LC_ALL=C (Docker, cron, CI) default_external is US-ASCII, so every File.read
43
+ # comes back mistagged and an em dash or accented name derails the command.
44
+ Encoding.default_external = Encoding::UTF_8
45
+
40
46
  normalized = argv.map do |arg|
41
47
  if arg == "-pr"
42
48
  "--paid-responsible"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spltty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thiago Diniz