pdfsplit 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: 88ab14a47b95bfccc2da78ae1225171ec58d24cc4e184929e0fdbb47bf35c8b1
4
- data.tar.gz: ee799c83c1c7f5b1c8741b60f6434ae9c7c5f9e4c10c5bc05b87a36f4efa0d65
3
+ metadata.gz: 278a98b0809b3c7758edad4cd272e03ddd916fac0ce39cc72618033faf6ec27b
4
+ data.tar.gz: f012717920b8110ad70dac344e1074b4840174f2930b535148461c759735fdbe
5
5
  SHA512:
6
- metadata.gz: d397ef0239901506a6cb8bb7ce275b6289fdd851dc73ce894635c7aacdf52c1c7c5c351102689a203fe42dd875f9854bc4c376cfd5b679a8f1065455b65d0cf5
7
- data.tar.gz: b9d0b912fc487c98e13c19a029d0887adafcf4757fb3fad7d365c101cc5b0867f576e91c4303e9a7610b5679895dc2716359f71ba5384faca0a06ea6c5915296
6
+ metadata.gz: 42ea6f40991e2a537de41cad2eee64ba0e238c3666993c140fff2977665ad105dffe660e021d949fc769a17885d14a8398f61b3f684cfa9a650157d3c74ba899
7
+ data.tar.gz: d68ebf56786df8cdbb88cd49a3658824872944af15f2568bee39e000812730ccb549846713a26da17a642486add836364b5f40de32d07f583f28fa2b58cc7942
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.1] - 2026-01-05
4
+
5
+ - Now, if you don't specify an output folder, the files after cutting will not be saved next to each other, but a folder will be automatically created for them.
6
+
3
7
  ## [0.1.0] - 2026-01-03
4
8
 
5
9
  - Initial release
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  `pdfsplit` is a Ruby CLI tool that splits a multi-page PDF into smaller PDF files with a fixed number of pages per part.
4
4
 
5
- - Cross-platform: Linux / Windows (with Ruby installed)
5
+ - Cross-platform: Linux / macOS / Windows
6
6
  - No external PDF utilities required (no `pdftk`, `qpdf`, etc.)
7
7
  - Uses the **HexaPDF** gem to handle PDF files
8
8
 
@@ -20,14 +20,31 @@
20
20
 
21
21
  ## Requirements
22
22
 
23
- - Ruby (3.1+ recommended)
24
- - Bundler
23
+ - Ruby **3.1+** (recommended)
25
24
 
26
- > On Linux you may need system development packages (headers/libs) to build native extensions if Bundler fails while installing dependencies.
25
+ > Bundler is only needed for development / running from the repository.
26
+ > After installing the gem, you can run the `pdfsplit` command directly.
27
27
 
28
28
  ---
29
29
 
30
- ## Installation (from the repository)
30
+ ## Installation
31
+
32
+ ### Option A: Install from RubyGems (recommended)
33
+
34
+ ```bash
35
+ gem install pdfsplit
36
+ ```
37
+
38
+ After installation the executable becomes available:
39
+
40
+ ```bash
41
+ pdfsplit --help
42
+ ```
43
+
44
+ > On Windows, if the `pdfsplit` command is not found, ensure RubyGems' **bin** directory is in your `PATH`
45
+ > (RubyInstaller usually sets this up automatically).
46
+
47
+ ### Option B: Install from the repository (for development)
31
48
 
32
49
  Clone the repository and install dependencies:
33
50
 
@@ -35,10 +52,20 @@ Clone the repository and install dependencies:
35
52
  bundle install
36
53
  ```
37
54
 
55
+ ---
56
+
38
57
  ## Usage
39
58
 
40
59
  ### Split a PDF into parts of N pages
41
60
 
61
+ **Installed gem (recommended):**
62
+
63
+ ```bash
64
+ pdfsplit input.pdf --pages 10
65
+ ```
66
+
67
+ **From repository:**
68
+
42
69
  ```bash
43
70
  bundle exec pdfsplit input.pdf --pages 10
44
71
  ```
@@ -52,7 +79,7 @@ Outputs will be created in the current directory:
52
79
  ### Specify an output directory
53
80
 
54
81
  ```bash
55
- bundle exec pdfsplit input.pdf --pages 10 --out out
82
+ pdfsplit INPUT.pdf --pages 10 --out out
56
83
  ```
57
84
 
58
85
  Files will be created in `out/`.
@@ -60,13 +87,13 @@ Files will be created in `out/`.
60
87
  ### Help
61
88
 
62
89
  ```bash
63
- bundle exec pdfsplit --help
90
+ pdfsplit --help
64
91
  ```
65
92
 
66
93
  ### Version
67
94
 
68
95
  ```bash
69
- bundle exec pdfsplit --version
96
+ pdfsplit --version
70
97
  ```
71
98
 
72
99
  ---
@@ -85,11 +112,11 @@ Given an input file `input.pdf`, the tool writes:
85
112
  ## Errors & behavior
86
113
 
87
114
  - Missing input file → exit 1 + Usage
88
- - Missing --pages / --pages <= 0 → exit 1 + Usage
115
+ - Missing `--pages` / `--pages <= 0` → exit 1 + Usage
89
116
  - More than one input file provided → exit 1 + Usage
90
117
  - Input file does not exist → exit 1 + OS error message
91
118
  - Input is not a valid PDF → exit 1 + Error: invalid PDF
92
- - --out points to an existing file → exit 1 + Error: --out must be a directory
119
+ - `--out` points to an existing file → exit 1 + Error: `--out` must be a directory
93
120
  - Output directory is not writable → exit 1 + OS error message
94
121
 
95
122
  ---
@@ -119,4 +146,3 @@ bin/console
119
146
  ## License
120
147
 
121
148
  MIT License
122
-
data/lib/pdfsplit/cli.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "optparse"
4
+ require "fileutils"
4
5
 
5
6
  module Pdfsplit
6
7
  class CLI
@@ -9,7 +10,7 @@ module Pdfsplit
9
10
  out_dir = nil
10
11
 
11
12
  parser = OptionParser.new do |opts|
12
- opts.banner = "Usage: pdfsplit .pdf --pages N [--out DIR]"
13
+ opts.banner = "Usage: pdfsplit INPUT.pdf --pages N [--out DIR]"
13
14
 
14
15
  opts.on("-h", "--help", "Show help") do
15
16
  puts opts
@@ -58,7 +59,12 @@ module Pdfsplit
58
59
 
59
60
 
60
61
  input_path = argv.first
61
- out_dir ||="."
62
+
63
+ if out_dir.nil?
64
+ base_dir = File.dirname(input_path)
65
+ base_name = File.basename(input_path, File.extname(input_path))
66
+ out_dir = File.join(base_dir, base_name)
67
+ end
62
68
 
63
69
  if File.exist?(out_dir) && !File.directory?(out_dir)
64
70
  warn "Error: --out must be a directory"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pdfsplit
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdfsplit
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
  - Shiyano