sakusei 0.5.8 → 0.5.9

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: 1845947d6ebe2f9b6c5732093eff5bbd90aa7bc2a60ad79a568033bd8c674e57
4
- data.tar.gz: 595a6804e797c8b0c58804b7df122b5a738e5592b786f4a0c29454801c864ed9
3
+ metadata.gz: f8f86cb0ba1fda1a5536579ffc06db171359b7d839537bef66a7622dabed68be
4
+ data.tar.gz: 1eeb757166832e05c87fa8ae7d8a654a4cf2c5abab097b82e4466245d99830d1
5
5
  SHA512:
6
- metadata.gz: 0c2d9f30c83d0f1de7c73f8c23dcfe590208c057e95cfae0a261a64a36f7a386f3e0e34d9ba1849b46407ce4e19bd86e6dc3544db861fa8ab2f92cf0ac868d6d
7
- data.tar.gz: 29428e2b7e9dbbe86753c58a537b6596f55a7ff7c075efe9bf40c1b0a2ada7d6f9921273400cc8226cf5acb12613a8caffed8ce9efc55576fe9a7d9b7790ca71
6
+ metadata.gz: e6d8145acd491414bdaea711ba249557aa887a049b0d7c59788825d1b8946cb93f33a4f5e87be5b3843f2ef8703577fe34dd7c0ec7681f9b55216c897e3aad17
7
+ data.tar.gz: 07ead103bda8c9d269501f6384f2d42d37efaf718f66237b006a0dc2430974535696d3eb1e1fb1b46b82683afa0eed437dd6a0a590692c01b6fd53f42f0daafa
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sakusei (0.5.8)
4
+ sakusei (0.5.9)
5
5
  erb (~> 4.0)
6
6
  listen (~> 3.8)
7
7
  thor (~> 1.2)
data/bin/sakusei-preview CHANGED
@@ -24,9 +24,9 @@ if args.empty?
24
24
  exit 1
25
25
  end
26
26
 
27
- source_file = args.first
27
+ source_file = Sakusei.resolve_file_extension(args.first)
28
28
  unless File.exist?(source_file)
29
- warn "File not found: #{source_file}"
29
+ warn "File not found: #{args.first}"
30
30
  exit 1
31
31
  end
32
32
 
data/lib/sakusei/cli.rb CHANGED
@@ -242,26 +242,14 @@ module Sakusei
242
242
  return false if arg.nil? || arg.empty?
243
243
  return false if File.extname(arg).length > 0 # Already has an extension
244
244
 
245
- %w[.md .text .markdown].any? { |ext| File.exist?(arg + ext) }
245
+ Sakusei::MARKDOWN_EXTENSIONS.any? { |ext| File.exist?(arg + ext) }
246
246
  end
247
247
 
248
248
  private
249
249
 
250
250
  # Resolve file by trying markdown extensions if no extension provided
251
251
  def resolve_file_extension(file)
252
- return file if File.exist?(file)
253
- return file if File.directory?(file)
254
- return file if file.include?('*') # Glob pattern
255
- return file if File.extname(file).length > 0 # Already has extension
256
-
257
- # Try markdown extensions
258
- %w[.md .text .markdown].each do |ext|
259
- path_with_ext = file + ext
260
- return path_with_ext if File.exist?(path_with_ext)
261
- end
262
-
263
- # Return original if no extension found
264
- file
252
+ Sakusei.resolve_file_extension(file)
265
253
  end
266
254
 
267
255
  def open_pdf(path)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sakusei
4
- VERSION = '0.5.8'
4
+ VERSION = '0.5.9'
5
5
  end
data/lib/sakusei.rb CHANGED
@@ -21,6 +21,28 @@ require_relative 'sakusei/page_chrome_translator'
21
21
  module Sakusei
22
22
  class Error < StandardError; end
23
23
 
24
+ # Markdown extensions to auto-discover when a CLI is given a file argument
25
+ # without an extension (e.g. `sakusei-preview ai_workflow_assessment`).
26
+ MARKDOWN_EXTENSIONS = %w[.md .text .markdown].freeze
27
+
28
+ # Resolve a file argument by trying known markdown extensions if no extension
29
+ # was given. Returns the input unchanged if the file already exists, is a
30
+ # directory, looks like a glob, or already has an extension.
31
+ def self.resolve_file_extension(file)
32
+ return file if file.nil? || file.empty?
33
+ return file if File.exist?(file)
34
+ return file if File.directory?(file)
35
+ return file if file.include?('*')
36
+ return file if File.extname(file).length.positive?
37
+
38
+ MARKDOWN_EXTENSIONS.each do |ext|
39
+ candidate = file + ext
40
+ return candidate if File.exist?(candidate)
41
+ end
42
+
43
+ file
44
+ end
45
+
24
46
  # Main entry point for building PDFs
25
47
  def self.build(source_file, options = {})
26
48
  Builder.new(source_file, options).build
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sakusei
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Rowell