renamr 1.0.12 → 1.0.14

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: add99e5c3b4e5c30b276654fa07d22a7df3337962cc199f27e1a899d55e6822e
4
- data.tar.gz: 132462b67ee327945c622025fb8cad50fe04590d0dc6b5a9a9259e93f193ce2a
3
+ metadata.gz: 941d7c1306c7ee0e0bbeaa02d39d31bc3a3fde4930edb344ffb62604d9ab4fa5
4
+ data.tar.gz: a309506a3b659b16ca9c371b6c070a4fe51dfc9b18f54c53d34e9f21dbe96677
5
5
  SHA512:
6
- metadata.gz: 9668905ce583125aa3e6a16ef081d09db89a236a030cc724072c17a3183faeee30a315ea4915190aea7e58c448f0eefa22c88f799588364c4609dc1b1bbea844
7
- data.tar.gz: 31f30b1cefbf25ded7cd04815456aa08c7e36065b3cb37639d4f90ae9da43a949a92b16ee13891814998cdb976fba697ad06a3e030e660729aa0f8980feeaf31
6
+ metadata.gz: f3094a67d116ecdce1c6edfb0ab31d41d68f14e0adf3ef8528e74ad0efee715f04cf5c7786140239869d76be379d75e5247e5ad87423f21e08bf0059c2869401
7
+ data.tar.gz: f70e4d552a8e09f1c4d5b34857325a5c0cac625ad88d7253ccf779b831737573bfb3f40c316bd4b370aeecd581baf715e8f635c7e6e88781e3ac7456650773e3
@@ -0,0 +1,13 @@
1
+ # SPDX-FileCopyrightText: 2023-2025 David Rabkin
2
+ # SPDX-License-Identifier: 0BSD
3
+ ---
4
+ version: 2
5
+ updates:
6
+ - package-ecosystem: github-actions
7
+ directory: /
8
+ schedule:
9
+ interval: daily
10
+ - package-ecosystem: bundler
11
+ directory: /
12
+ schedule:
13
+ interval: daily
@@ -0,0 +1,34 @@
1
+ # SPDX-FileCopyrightText: 2023-2025 David Rabkin
2
+ # SPDX-License-Identifier: 0BSD
3
+ ---
4
+ name: rubocop
5
+ 'on':
6
+ pull_request:
7
+ branches: [master]
8
+ jobs:
9
+ rubocop:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ fail-fast: false
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: ruby/setup-ruby@472790540115ce5bd69d399a020189a8c87d641f
16
+ with:
17
+ ruby-version: 3.2
18
+ - name: Install Code Scanning integration
19
+ run: bundle add code-scanning-rubocop --version 0.6.1 --skip-install
20
+ - name: Install dependencies
21
+ run: bundle install
22
+ - name: Rubocop run
23
+ run: |
24
+ bash -c "
25
+ bundle exec rubocop \
26
+ --require code_scanning \
27
+ --format CodeScanning::SarifFormatter \
28
+ -o rubocop.sarif
29
+ [[ $? -ne 2 ]]
30
+ "
31
+ - name: Upload Sarif output
32
+ uses: github/codeql-action/upload-sarif@v3
33
+ with:
34
+ sarif_file: rubocop.sarif
@@ -0,0 +1,20 @@
1
+ # SPDX-FileCopyrightText: 2023-2025 David Rabkin
2
+ # SPDX-License-Identifier: 0BSD
3
+ ---
4
+ name: test
5
+ 'on': push
6
+ jobs:
7
+ lint:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v4
11
+ - uses: docker://github/super-linter:v2.1.1
12
+ env:
13
+ VALIDATE_ALL_CODEBASE: true
14
+ VALIDATE_ANSIBLE: false
15
+ - uses: fsfe/reuse-action@v5
16
+ - uses: crate-ci/typos@master
17
+ - uses: ibiqlik/action-yamllint@v3
18
+ with:
19
+ file_or_dir: .github/*.yml .github/workflows/*.yml
20
+ strict: true
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ coverage/
2
+ Gemfile.lock
3
+ .idea/
4
+ *.gem
5
+ .bundle/
6
+ .DS_Store
7
+ rdoc/
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ # SPDX-FileCopyrightText: 2023-2025 David Rabkin
2
+ # SPDX-License-Identifier: 0BSD
3
+ ---
4
+ language: ruby
5
+ rvm:
6
+ - ~>3.2
7
+ branches:
8
+ only:
9
+ - master
10
+ install:
11
+ - bundle install
12
+ script:
13
+ - set -e
14
+ - bundle exec rake
data/Gemfile CHANGED
@@ -1,16 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2020-2023 David Rabkin
5
- source 'https://rubygems.org'
6
- ruby '>2.6'
7
- gem 'date', '~>3.3'
8
- gem 'fileutils', '~>1.7'
9
- gem 'i18n', '~>1.12'
10
- gem 'minitest', '~>5.8'
11
- gem 'pidfile', '~>0.3'
12
- gem 'rake', '~>13.0'
13
- gem 'rubocop', '~>1.50'
14
- gem 'terminal-table', '~>3.0'
4
+ # SPDX-FileCopyrightText: 2020-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
15
6
 
16
- gem "code-scanning-rubocop", "= 0.6.1"
7
+ source 'https://rubygems.org'
8
+ gem 'date'
9
+ gem 'ellipsized'
10
+ gem 'fileutils'
11
+ gem 'i18n'
12
+ gem 'minitest'
13
+ gem 'pidfile'
14
+ gem 'rake'
15
+ gem 'rubocop'
16
+ gem 'terminal-table'
data/LICENSE CHANGED
@@ -1,12 +1,5 @@
1
- Copyright 2020-2023 David Rabkin
1
+ Copyright 2020-2025 David Rabkin
2
2
 
3
- Permission to use, copy, modify, and/or distribute this software for any
4
- purpose with or without fee is hereby granted.
3
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
5
4
 
6
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
7
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
8
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
9
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
10
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
11
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
12
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
5
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
data/LICENSES/0BSD.txt ADDED
@@ -0,0 +1,5 @@
1
+ Copyright 2020-2025 David Rabkin
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
4
+
5
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
data/README.adoc ADDED
@@ -0,0 +1,94 @@
1
+ // Settings:
2
+ :toc: macro
3
+ :!toc-title:
4
+ // URLs:
5
+ :img-gem: https://badge.fury.io/rb/renamr.svg
6
+ :img-hoc: https://hitsofcode.com/github/rdavid/renamr?branch=master&label=hits%20of%20code
7
+ :img-license: https://img.shields.io/github/license/rdavid/renamr?color=blue&labelColor=gray&logo=freebsd&logoColor=lightgray&style=flat
8
+ :img-maintainability: https://api.codeclimate.com/v1/badges/406f1433b0b9e0509a6e/maintainability
9
+ :img-rubocop: https://github.com/rdavid/renamr/actions/workflows/rubocop.yml/badge.svg
10
+ :img-style: https://img.shields.io/badge/code_style-rubocop-brightgreen.svg
11
+ :img-test: https://github.com/rdavid/renamr/actions/workflows/test.yml/badge.svg
12
+ :url-cv: http://cv.rabkin.co.il
13
+ :url-gem: https://badge.fury.io/rb/renamr
14
+ :url-hoc: https://hitsofcode.com/view/github/rdavid/renamr?branch=master
15
+ :url-license: https://github.com/rdavid/renamr/blob/master/LICENSES/0BSD.txt
16
+ :url-maintainability: https://codeclimate.com/github/rdavid/renamr/maintainability
17
+ :url-reuse: https://github.com/fsfe/reuse-action
18
+ :url-rubocop: https://github.com/rdavid/renamr/actions/workflows/rubocop.yml
19
+ :url-ruby: https://www.ruby-lang.org/en/documentation/installation
20
+ :url-style: https://github.com/rubocop/rubocop
21
+ :url-test: https://github.com/rdavid/renamr/actions/workflows/test.yml
22
+ :url-vale: https://vale.sh
23
+ :url-yamllint: https://github.com/adrienverge/yamllint
24
+
25
+ = Renamr
26
+
27
+ image:{img-rubocop}[rubocop,link={url-rubocop}]
28
+ image:{img-gem}[gem version,link={url-gem}]
29
+ // image:{img-maintainability}[maintainability,link={url-maintainability}]
30
+ image:{img-style}[code style,link={url-style}]
31
+ image:{img-test}[test,link={url-test}]
32
+ image:{img-hoc}[hits of code,link={url-hoc}]
33
+ image:{img-license}[license,link={url-license}]
34
+
35
+ toc::[]
36
+
37
+ == About
38
+
39
+ `renamr` organizes file and directory names.
40
+
41
+ == Installation
42
+ The tool is designed to operate on macOS, GNU/Linux, Windows, and Unix-like
43
+ operating systems.
44
+ It is packaged as a Gem and requires Ruby version 3.2 or later.
45
+ If you do not have the appropriate version on your platform, refer to
46
+ {url-ruby}[Installing Ruby].
47
+
48
+ Utilize this command for installing the package:
49
+
50
+ [,sh]
51
+ ----
52
+ gem install renamr
53
+ ----
54
+
55
+ == Updating
56
+
57
+ Utilize this command for updating the package:
58
+
59
+ [,sh]
60
+ ----
61
+ gem update renamr
62
+ ----
63
+
64
+ == Usage
65
+
66
+ [,sh]
67
+ ----
68
+ renamr [options]
69
+ -a, --act Real renaming.
70
+ -r, --rec Passes recursively.
71
+ -l, --lim Limits name length.
72
+ -m, --mod Prepends modification time.
73
+ -d, --dir dir Directory to rename.
74
+ -s, --src src A string to substitute.
75
+ -t, --dst dst A string to replace to.
76
+ -w, --wid wid Width of the table.
77
+ -p, --pre str,beg A string to prepend to started from beg.
78
+ -c, --cut pos,len Removes len symbols from pos.
79
+ -v, --version Shows version.
80
+ ----
81
+
82
+ == Example
83
+
84
+ [,sh]
85
+ ----
86
+ renamr -d <source>
87
+ ----
88
+
89
+ It renames all files in `source` by default pattern: 26 English letters, 10 numbers, minus for spaces and other symbols.
90
+
91
+ == License
92
+
93
+ `renamr` is copyright {url-cv}[David Rabkin] and available under a
94
+ {url-license}[Zero-Clause BSD license].
data/REUSE.toml ADDED
@@ -0,0 +1,11 @@
1
+ # SPDX-FileCopyrightText: 2025 David Rabkin
2
+ # SPDX-License-Identifier: 0BSD
3
+ version = 1
4
+ [[annotations]]
5
+ path = [
6
+ ".gitignore",
7
+ "README.adoc",
8
+ ]
9
+ precedence = "override"
10
+ SPDX-FileCopyrightText = "2025 David Rabkin"
11
+ SPDX-License-Identifier = "0BSD"
data/Rakefile CHANGED
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2020-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2020-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  task default: %w[test]
7
8
 
data/bin/renamr CHANGED
@@ -2,11 +2,11 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # vi:ts=2 sw=2 tw=79 et lbr wrap
5
- # Copyright 2018-2023 David Rabkin
5
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
6
+ # SPDX-License-Identifier: 0BSD
7
+ #
6
8
  # This script renames files in given directory by specific rules.
7
9
 
8
- require 'pidfile'
9
10
  require_relative '../lib/renamr'
10
11
 
11
- PidFile.new
12
12
  Renamr::Renamer.new.do
data/lib/renamr/action.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  module Renamr
7
8
  # An interface for actions implementation.
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require_relative 'action'
7
8
 
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require 'i18n'
7
8
  require_relative 'action'
@@ -10,6 +11,7 @@ module Renamr
10
11
  # Automatic localization.
11
12
  class AutoLocalizationAction < Action
12
13
  def initialize
14
+ super
13
15
  I18n.config.available_locales = :en
14
16
  end
15
17
 
data/lib/renamr/char.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
- require 'set'
7
7
  require_relative 'action'
8
8
 
9
9
  module Renamr
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require 'optparse'
7
8
 
@@ -64,7 +65,7 @@ module Renamr
64
65
 
65
66
  @options[:dir] = File.expand_path(dir)
66
67
  end
67
- raise "Width of the table should exeeds 14 symbols: #{wid}." if wid < 15
68
+ raise "Width of the table should exceeds 14 symbols: #{wid}." if wid < 15
68
69
  end
69
70
 
70
71
  def act?
data/lib/renamr/date.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2020-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require 'date'
7
8
  require_relative 'action'
@@ -9,7 +10,7 @@ require_relative 'action'
9
10
  module Renamr
10
11
  # Replaces any valid date, e.g. 2020-11-02 or 02-11-2020 with 20201102.
11
12
  class DateAction < Action
12
- REG = /(\d+)-(\d+)-(\d+)/.freeze
13
+ REG = /(\d+)-(\d+)-(\d+)/
13
14
  PAT = ['%m-%d-%Y', '%d-%m-%Y', '%Y-%m-%d', '%Y-%d-%m'].freeze
14
15
 
15
16
  def validate(dat)
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require_relative 'action'
7
8
 
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require_relative 'ascii_validator'
7
8
  require_relative 'auto_localization'
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require_relative 'action'
7
8
 
data/lib/renamr/omit.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require_relative 'action'
7
8
 
@@ -9,6 +10,7 @@ module Renamr
9
10
  # Omits file names shorter than limit.
10
11
  class OmitAction < Action
11
12
  def initialize(lim)
13
+ super
12
14
  raise 'lim cannot be nil.' if lim.nil?
13
15
 
14
16
  @lim = lim
data/lib/renamr/point.rb CHANGED
@@ -1,14 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require_relative 'action'
7
8
 
8
9
  module Renamr
9
- # All points besides extention are replaced by minus.
10
+ # All points besides extension are replaced by minus.
10
11
  class PointAction < Action
11
12
  def initialize(dir)
13
+ super()
12
14
  raise 'dir cannot be nil.' if dir.nil?
13
15
 
14
16
  @dir = dir
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require_relative 'action'
7
8
 
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require_relative 'action'
7
8
 
@@ -9,6 +10,7 @@ module Renamr
9
10
  # Prepends file modification datestamp.
10
11
  class PrependDateAction < Action
11
12
  def initialize(dir)
13
+ super
12
14
  @dir = dir
13
15
  end
14
16
 
data/lib/renamr/remove.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require_relative 'action'
7
8
 
@@ -9,6 +10,7 @@ module Renamr
9
10
  # Removes symbols between left and right positions.
10
11
  class RemoveAction < Action
11
12
  def initialize(pos, len)
13
+ super
12
14
  raise 'len cannot bi nil.' if len.nil?
13
15
  raise 'pos cannot be nil.' if pos.nil?
14
16
  raise 'pos has to be positive.' unless pos.to_i.positive?
@@ -18,9 +20,9 @@ module Renamr
18
20
  end
19
21
 
20
22
  def do(src)
21
- return src[@len..-1] if @pos == 1
23
+ return src[@len..] if @pos == 1
22
24
 
23
- src[0..@pos - 1] + src[@pos + @len..-1]
25
+ src[0..@pos - 1] + src[@pos + @len..]
24
26
  end
25
27
  end
26
28
  end
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require 'fileutils'
7
8
  require_relative 'configurator'
@@ -37,7 +38,7 @@ module Renamr
37
38
 
38
39
  def unique(dat, nme)
39
40
  dst = []
40
- dat.each { |_, d| dst << File.basename(d) }
41
+ dat.each { |_, d| dst << File.basename(d) } # rubocop:disable Style/HashEachMethods
41
42
  return nme unless dst.include?(nme)
42
43
 
43
44
  ext = File.extname(nme)
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require 'terminal-table'
7
8
  require_relative 'action'
@@ -9,6 +10,7 @@ require_relative 'utils'
9
10
 
10
11
  module Renamr
11
12
  # Formats and prints output data.
13
+ # rubocop:disable Style/ClassVars
12
14
  class Reporter
13
15
  @@tim = Timer.new
14
16
  @@sta = { moved: 0, unaltered: 0, failed: 0 }
@@ -53,7 +55,7 @@ module Renamr
53
55
  def self.stat_out
54
56
  out = ''
55
57
  @@sta.each do |k, v|
56
- out += ' ' + v.to_s + ' ' + k.to_s + ',' if v.positive?
58
+ out += " #{v} #{k}," if v.positive?
57
59
  end
58
60
  out.chop
59
61
  end
@@ -64,4 +66,5 @@ module Renamr
64
66
  puts "| #{msg}#{' ' * (@@ttl - msg.length)} |\n+-#{'-' * @@ttl}-+"
65
67
  end
66
68
  end
69
+ # rubocop:enable Style/ClassVars
67
70
  end
data/lib/renamr/rutoen.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require_relative 'action'
7
8
 
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require_relative 'action'
7
8
 
@@ -9,6 +10,7 @@ module Renamr
9
10
  # Substitutes a string with a string.
10
11
  class SubstituteAction < Action
11
12
  def initialize(src, dst)
13
+ super
12
14
  raise 'src cannot be nil.' if src.nil?
13
15
 
14
16
  # The action works after PointAction. All points are replaces with minus.
data/lib/renamr/trim.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require_relative 'action'
7
8
 
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require_relative 'action'
7
8
 
@@ -9,6 +10,7 @@ module Renamr
9
10
  # Limits file length.
10
11
  class TruncateAction < Action
11
12
  def initialize(lim)
13
+ super()
12
14
  raise 'lim cannot be nil.' if lim.nil?
13
15
 
14
16
  @lim = lim
data/lib/renamr/utils.rb CHANGED
@@ -1,18 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
6
+
7
+ require 'ellipsized'
5
8
 
6
9
  # All methods are static.
7
10
  class Utils
8
11
  class << self
9
- SEP = '~'
10
12
  def trim(src, lim)
11
- return src if src.length <= lim
12
-
13
- beg = fin = (lim - SEP.length) / 2
14
- beg -= 1 if lim.odd?
15
- src[0..beg] + SEP + src[-fin..-1]
13
+ src.ellipsized(lim, '~', :center)
16
14
  end
17
15
  end
18
16
  end
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2020-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2020-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  module Renamr
7
- VERSION = '1.0.12'
8
- DATE = '2023-04-22'
8
+ VERSION = '1.0.14'
9
+ DATE = '2025-07-21'
9
10
  end
data/lib/renamr.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # vi:ts=2 sw=2 tw=79 et lbr wrap
4
- # Copyright 2018-2023 David Rabkin
4
+ # SPDX-FileCopyrightText: 2018-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
5
6
 
6
7
  require_relative 'renamr/renamer'
7
8
  require_relative 'renamr/version'
data/renamr.gemspec CHANGED
@@ -1,15 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/lib')
3
+ # SPDX-FileCopyrightText: 2023-2025 David Rabkin
4
+ # SPDX-License-Identifier: 0BSD
5
+
6
+ $LOAD_PATH.unshift File.expand_path('lib', __dir__)
4
7
 
5
8
  require 'renamr'
6
9
 
7
10
  Gem::Specification.new do |s|
11
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
12
+ s.required_ruby_version = '>=3.2'
8
13
  s.name = 'renamr'
9
14
  s.version = Renamr::VERSION
10
15
  s.date = Renamr::DATE
11
- s.required_ruby_version = '>2.6'
12
- s.summary = 'File and directory names organiser.'
16
+ s.summary = 'File and directory names organiser'
13
17
  s.description = <<-HERE
14
18
  Renamr organises multiple files and directories.
15
19
  HERE
@@ -17,16 +21,8 @@ Gem::Specification.new do |s|
17
21
  s.author = 'David Rabkin'
18
22
  s.email = 'david@rabkin.co.il'
19
23
  s.homepage = 'https://github.com/rdavid/renamr'
20
- s.files = Dir['{bin,lib}/**/*'] + Dir['[A-Z]*'] + ['renamr.gemspec']
21
- s.executables = ['renamr']
22
- s.extra_rdoc_files = ['LICENSE', 'README.md']
23
- s.require_paths = ['lib']
24
- s.add_runtime_dependency 'date', '~>3.3'
25
- s.add_runtime_dependency 'fileutils', '~>1.7'
26
- s.add_runtime_dependency 'i18n', '~>1.12'
27
- s.add_runtime_dependency 'pidfile', '~>0.3'
28
- s.add_runtime_dependency 'terminal-table', '~>3.0'
29
- s.add_development_dependency 'minitest', '~>5.8'
30
- s.add_development_dependency 'rake', '~>13.0'
31
- s.add_development_dependency 'rubocop', '~>1.50'
24
+ s.files = `git ls-files`.split($RS)
25
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
26
+ s.extra_rdoc_files = ['LICENSE', 'README.adoc']
27
+ s.metadata['rubygems_mfa_required'] = 'true'
32
28
  end
data/test/test_char.rb ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # vi:ts=2 sw=2 tw=79 et lbr wrap
4
+ # SPDX-FileCopyrightText: 2020-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
6
+
7
+ require 'minitest/autorun'
8
+ require_relative '../lib/renamr/char'
9
+
10
+ class TestChar < Minitest::Test
11
+ def setup
12
+ @act = Renamr::CharAction.new
13
+ end
14
+
15
+ def test_act
16
+ assert_equal('-' * 32,
17
+ @act.do(' (){},~–\'![]_#@=„“”"`—+‘’;·‡«»%…'.dup))
18
+ end
19
+ end
data/test/test_date.rb ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ # vi:ts=2 sw=2 tw=79 et lbr wrap
4
+ # SPDX-FileCopyrightText: 2020-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
6
+
7
+ require 'minitest/autorun'
8
+ require_relative '../lib/renamr/date'
9
+
10
+ # Test DateAction class.
11
+ class TestChar < Minitest::Test
12
+ def setup
13
+ @act = Renamr::DateAction.new
14
+ end
15
+
16
+ def good
17
+ assert_equal('1 20201031 bar', @act.do('1 31-10-2020 bar'.dup))
18
+ assert_equal('2 20201031 bar', @act.do('2 10-31-2020 bar'.dup))
19
+ assert_equal('3 20201031 bar', @act.do('3 2020-10-31 bar'.dup))
20
+ assert_equal('4 20201031 bar', @act.do('4 2020-31-10 bar'.dup))
21
+ end
22
+
23
+ def bad
24
+ assert_equal('5 2nd Nov 2020 bar', @act.do('5 2nd Nov 2020 bar'.dup))
25
+ assert_equal('6 1-1-1-1 bar', @act.do('6 1-1-1-1 bar'.dup))
26
+ end
27
+
28
+ def test_act
29
+ good
30
+ bad
31
+ end
32
+ end
data/test/test_trim.rb ADDED
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # vi:ts=2 sw=2 tw=79 et lbr wrap
4
+ # SPDX-FileCopyrightText: 2020-2025 David Rabkin
5
+ # SPDX-License-Identifier: 0BSD
6
+
7
+ require 'minitest/autorun'
8
+ require_relative '../lib/renamr/trim'
9
+
10
+ class TestTrim < Minitest::Test
11
+ def setup
12
+ @act = Renamr::TrimAction.new
13
+ end
14
+
15
+ def test_act
16
+ assert_equal('-', @act.do('-'.dup))
17
+ assert_equal('-', @act.do('--'.dup))
18
+ assert_equal('1', @act.do('1-'.dup))
19
+ assert_equal('1', @act.do('-1'.dup))
20
+ assert_equal('1-1', @act.do('-1--1-'.dup))
21
+ end
22
+ end
metadata CHANGED
@@ -1,127 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renamr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rabkin
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-04-22 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: date
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '3.3'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '3.3'
27
- - !ruby/object:Gem::Dependency
28
- name: fileutils
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.7'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.7'
41
- - !ruby/object:Gem::Dependency
42
- name: i18n
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.12'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.12'
55
- - !ruby/object:Gem::Dependency
56
- name: pidfile
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.3'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.3'
69
- - !ruby/object:Gem::Dependency
70
- name: terminal-table
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3.0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '3.0'
83
- - !ruby/object:Gem::Dependency
84
- name: minitest
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '5.8'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '5.8'
97
- - !ruby/object:Gem::Dependency
98
- name: rake
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '13.0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '13.0'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '1.50'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '1.50'
10
+ date: 2025-07-21 00:00:00.000000000 Z
11
+ dependencies: []
125
12
  description: " Renamr organises multiple files and directories.\n"
126
13
  email: david@rabkin.co.il
127
14
  executables:
@@ -129,14 +16,19 @@ executables:
129
16
  extensions: []
130
17
  extra_rdoc_files:
131
18
  - LICENSE
132
- - README.md
19
+ - README.adoc
133
20
  files:
21
+ - ".github/dependabot.yml"
22
+ - ".github/workflows/rubocop.yml"
23
+ - ".github/workflows/test.yml"
24
+ - ".gitignore"
25
+ - ".travis.yml"
134
26
  - Gemfile
135
- - Gemfile.lock
136
27
  - LICENSE
137
- - README.md
28
+ - LICENSES/0BSD.txt
29
+ - README.adoc
30
+ - REUSE.toml
138
31
  - Rakefile
139
- - appveyor.yml
140
32
  - bin/renamr
141
33
  - lib/renamr.rb
142
34
  - lib/renamr/action.rb
@@ -162,27 +54,29 @@ files:
162
54
  - lib/renamr/utils.rb
163
55
  - lib/renamr/version.rb
164
56
  - renamr.gemspec
57
+ - test/test_char.rb
58
+ - test/test_date.rb
59
+ - test/test_trim.rb
165
60
  homepage: https://github.com/rdavid/renamr
166
61
  licenses:
167
62
  - 0BSD
168
- metadata: {}
169
- post_install_message:
63
+ metadata:
64
+ rubygems_mfa_required: 'true'
170
65
  rdoc_options: []
171
66
  require_paths:
172
67
  - lib
173
68
  required_ruby_version: !ruby/object:Gem::Requirement
174
69
  requirements:
175
- - - ">"
70
+ - - ">="
176
71
  - !ruby/object:Gem::Version
177
- version: '2.6'
72
+ version: '3.2'
178
73
  required_rubygems_version: !ruby/object:Gem::Requirement
179
74
  requirements:
180
75
  - - ">="
181
76
  - !ruby/object:Gem::Version
182
77
  version: '0'
183
78
  requirements: []
184
- rubygems_version: 3.4.8
185
- signing_key:
79
+ rubygems_version: 3.6.9
186
80
  specification_version: 4
187
- summary: File and directory names organiser.
81
+ summary: File and directory names organiser
188
82
  test_files: []
data/Gemfile.lock DELETED
@@ -1,57 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- ast (2.4.2)
5
- code-scanning-rubocop (0.6.1)
6
- rubocop (~> 1.0)
7
- concurrent-ruby (1.2.2)
8
- date (3.3.3)
9
- fileutils (1.7.1)
10
- i18n (1.12.0)
11
- concurrent-ruby (~> 1.0)
12
- json (2.6.3)
13
- minitest (5.18.0)
14
- parallel (1.22.1)
15
- parser (3.2.2.0)
16
- ast (~> 2.4.1)
17
- pidfile (0.3.0)
18
- rainbow (3.1.1)
19
- rake (13.0.6)
20
- regexp_parser (2.7.0)
21
- rexml (3.2.5)
22
- rubocop (1.50.0)
23
- json (~> 2.3)
24
- parallel (~> 1.10)
25
- parser (>= 3.2.0.0)
26
- rainbow (>= 2.2.2, < 4.0)
27
- regexp_parser (>= 1.8, < 3.0)
28
- rexml (>= 3.2.5, < 4.0)
29
- rubocop-ast (>= 1.28.0, < 2.0)
30
- ruby-progressbar (~> 1.7)
31
- unicode-display_width (>= 2.4.0, < 3.0)
32
- rubocop-ast (1.28.0)
33
- parser (>= 3.2.1.0)
34
- ruby-progressbar (1.13.0)
35
- terminal-table (3.0.2)
36
- unicode-display_width (>= 1.1.1, < 3)
37
- unicode-display_width (2.4.2)
38
-
39
- PLATFORMS
40
- x86_64-darwin-21
41
-
42
- DEPENDENCIES
43
- code-scanning-rubocop (= 0.6.1)
44
- date (~> 3.3)
45
- fileutils (~> 1.7)
46
- i18n (~> 1.12)
47
- minitest (~> 5.8)
48
- pidfile (~> 0.3)
49
- rake (~> 13.0)
50
- rubocop (~> 1.50)
51
- terminal-table (~> 3.0)
52
-
53
- RUBY VERSION
54
- ruby 3.2.2p53
55
-
56
- BUNDLED WITH
57
- 2.4.8
data/README.md DELETED
@@ -1,75 +0,0 @@
1
- # Renamr
2
-
3
- [![build](https://ci.appveyor.com/api/projects/status/cca9iog230smu3k2?svg=true)](https://ci.appveyor.com/project/rdavid/renamr)
4
- [![rubocop](https://github.com/rdavid/renamr/actions/workflows/rubocop.yml/badge.svg)](https://github.com/rdavid/renamr/actions/workflows/rubocop.yml)
5
- [![gem](https://badge.fury.io/rb/renamr.svg)](https://badge.fury.io/rb/renamr)
6
- [![maintainability](https://api.codeclimate.com/v1/badges/406f1433b0b9e0509a6e/maintainability)](https://codeclimate.com/github/rdavid/renamr/maintainability)
7
- [![hits of code](https://hitsofcode.com/github/rdavid/renamr?branch=master&label=hits%20of%20code)](https://hitsofcode.com/view/github/rdavid/renamr)
8
- [![ruby style](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
9
- [![license](https://img.shields.io/github/license/rdavid/renamr?color=blue&labelColor=gray&logo=freebsd&logoColor=lightgray&style=flat)](https://github.com/rdavid/renamr/blob/master/LICENSE)
10
-
11
- * [About](#about)
12
- * [Installation](#installation)
13
- * [Usage](#usage)
14
- * [License](#license)
15
-
16
- ## About
17
-
18
- `renamr` organizes file and directory names.
19
-
20
- ## Installation
21
-
22
- The tool is designed to work on macOS, GNU/Linux, Windows, Unix-like OS. It is
23
- packaged as a Gem and require Ruby version 2.6 or later. See “[Installing
24
- Ruby](https://www.ruby-lang.org/en/documentation/installation/)” if you don't
25
- have the proper version on your platform.
26
-
27
- Use this command to install:
28
-
29
- ```sh
30
- gem install renamr
31
- ```
32
-
33
- ### Updating
34
-
35
- Use this command to update the package:
36
-
37
- ```sh
38
- gem update renamr
39
-
40
- ```
41
-
42
- ### Requirements
43
-
44
- There are no requirements.
45
-
46
- ## Usage
47
-
48
- ```sh
49
- renamr [options]
50
- -a, --act Real renaming.
51
- -r, --rec Passes recursively.
52
- -l, --lim Limits name length.
53
- -m, --mod Prepends modification time.
54
- -d, --dir dir Directory to rename.
55
- -s, --src src A string to substitute.
56
- -t, --dst dst A string to replace to.
57
- -w, --wid wid Width of the table.
58
- -p, --pre str,beg A string to prepend to started from beg.
59
- -c, --cut pos,len Removes len symbols from pos.
60
- -v, --version Shows version.
61
- ```
62
-
63
- ### Example
64
-
65
- ```sh
66
- renamr -d <source>
67
- ```
68
-
69
- It renames all files in `source` by default pattern: 26 English letters,
70
- 10 numbers, minus for spaces and other symbols.
71
-
72
- ## License
73
-
74
- `renamr` is copyright [David Rabkin](http://cv.rabkin.co.il) and
75
- available under a [Zero-Clause BSD license](https://github.com/rdavid/renamr/blob/master/LICENSE).
data/appveyor.yml DELETED
@@ -1,26 +0,0 @@
1
- ---
2
- version: '{build}'
3
- skip_tags: true
4
- clone_depth: 10
5
- branches:
6
- only:
7
- - master
8
- except:
9
- - gh-pages
10
- os: Windows Server 2012
11
- environment:
12
- matrix:
13
- - ruby_version: 26-x64
14
- install:
15
- - ps: |
16
- $Env:PATH = "C:\Ruby${Env:ruby_version}\bin;${Env:PATH}"
17
- - bundle config --local path vendor/bundle
18
- - ruby -v
19
- - bundle -v
20
- build_script:
21
- - bundle update
22
- - bundle install
23
- test_script:
24
- - bundle exec rake --quiet
25
- cache:
26
- - vendor/bundle