filter_rename 1.1.0 → 1.2.0

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: '0772829a453b3d53a307e213ea42d969c6f5f6598a47ca8c19236b2eae7d46fb'
4
- data.tar.gz: ac03f34f6eca2f5650bc283f7c139e4f8032cf87a25134b810eda5716a9577de
3
+ metadata.gz: 7b45ed1cf9b2044a3613d698125dc699c005154bc3c859623be546f748efebdf
4
+ data.tar.gz: 7b2407fbe28d667e3d298f9b90a11b12704bd30a2152c062484ba267f9fcd2a9
5
5
  SHA512:
6
- metadata.gz: 4a33e3231cdc186f63cacb21ef752ca78b136a76f64c138ec02cf58470d2ebb02afc35dc5e0a22dbce2a712a93e184faf1a962cce66ab2ef948771fe2f546789
7
- data.tar.gz: d08e371afb6cea91b7cef9a228b8e8f4f49bcf3c618b6d1ae0b32664539b744d41a9f02d97fc5537bcc60fa00348f3da54cb10679ba23571beda6c1cf18a5293
6
+ metadata.gz: 8054cf53f69b2c0aa28fa41d8b9343c6caee5b2ea14b3c829bd09ea2348b0c86e33022eedc7a788ca5b1dc406692a9590bcf810b183cfcf33ed9fd5cfa464658
7
+ data.tar.gz: 00334ee6bff0e4436e3922340bae92d02df5af45d3b176d2769725ca0063ebc8cfb3ceaae5c35d7707db77e017c9e0e4de6e87e2c026a36331356c2ca94f14e1
data/.github/FUNDING.yml CHANGED
@@ -1,14 +1,16 @@
1
+ ---
1
2
  # These are supported funding model platforms
2
3
 
3
4
  github: [fabiomux]
4
5
  #patreon: # Replace with a single Patreon username
5
6
  #open_collective: # Replace with a single Open Collective username
6
- #ko_fi: # Replace with a single Ko-fi username
7
+ ko_fi: freeaptitude
7
8
  #tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
9
  #community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
10
  #liberapay: # Replace with a single Liberapay username
10
11
  #issuehunt: # Replace with a single IssueHunt username
11
12
  #otechie: # Replace with a single Otechie username
12
13
  #custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13
- custom: ['https://www.buymeacoffee.com/DCkNYFg']
14
-
14
+ custom:
15
+ - 'https://paypal.me/fabiomux'
16
+ - 'https://www.buymeacoffee.com/DCkNYFg'
@@ -0,0 +1,46 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ tags:
8
+ - 'v*'
9
+
10
+ jobs:
11
+ build:
12
+ name: Build + Publish
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ contents: read
16
+ packages: write
17
+
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+ - name: Set up Ruby 2.6
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: 2.6.10
24
+
25
+ - name: Publish to GPR
26
+ run: |
27
+ mkdir -p $HOME/.gem
28
+ touch $HOME/.gem/credentials
29
+ chmod 0600 $HOME/.gem/credentials
30
+ printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
31
+ gem build *.gemspec
32
+ gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
33
+ env:
34
+ GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
35
+ OWNER: ${{ github.repository_owner }}
36
+
37
+ # - name: Publish to RubyGems
38
+ # run: |
39
+ # mkdir -p $HOME/.gem
40
+ # touch $HOME/.gem/credentials
41
+ # chmod 0600 $HOME/.gem/credentials
42
+ # printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
43
+ # gem build *.gemspec
44
+ # gem push *.gem
45
+ # env:
46
+ # GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
@@ -0,0 +1,32 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ pull_request:
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ name: Ruby ${{ matrix.ruby }}
14
+ strategy:
15
+ matrix:
16
+ ruby:
17
+ - '2.7.8'
18
+
19
+ steps:
20
+ - uses: actions/checkout@v3
21
+ - name: Install exiv2
22
+ run: sudo apt-get install -y libexiv2-dev
23
+ - name: Install taglib
24
+ run: sudo apt-get install -y libtag1-dev
25
+ - name: Set up Ruby
26
+ uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: ${{ matrix.ruby }}
29
+ bundler-cache: true
30
+
31
+ - name: Run the default task
32
+ run: bundle exec rake
data/.rubocop.yml ADDED
@@ -0,0 +1,84 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+ NewCops: enable
4
+ SuggestExtensions: false
5
+
6
+ Style/ClassVars:
7
+ Enabled: false
8
+
9
+ Style/StringLiterals:
10
+ Enabled: true
11
+ EnforcedStyle: double_quotes
12
+
13
+ Style/StringLiteralsInInterpolation:
14
+ Enabled: true
15
+ EnforcedStyle: double_quotes
16
+
17
+ Layout/LineLength:
18
+ Max: 120
19
+
20
+ Naming/FileName:
21
+ Enabled: false
22
+
23
+ Metrics/MethodLength:
24
+ Enabled: false
25
+
26
+ Metrics/AbcSize:
27
+ Enabled: false
28
+
29
+ Lint/DuplicateBranch:
30
+ Enabled: false
31
+
32
+ Metrics/ClassLength:
33
+ Enabled: true
34
+ Exclude:
35
+ - './lib/**/cli.rb'
36
+ - './lib/**/config.rb'
37
+ - './lib/**/filename.rb'
38
+ - './lib/**/filter_rename.rb'
39
+ - './lib/**/utils.rb'
40
+
41
+ Metrics/BlockLength:
42
+ Enabled: true
43
+ Exclude:
44
+ - '*.gemspec'
45
+ - './lib/**/cli.rb'
46
+ - './spec/**/*'
47
+
48
+ Metrics/PerceivedComplexity:
49
+ Enabled: true
50
+ Exclude:
51
+ - './lib/**/filter_rename.rb'
52
+ - './lib/**/cli.rb'
53
+ - './lib/**/config.rb'
54
+ - './lib/**/filename_factory.rb'
55
+ - './lib/**/filter_base.rb'
56
+ - './lib/**/utils.rb'
57
+ - './lib/**/audio_filename.rb'
58
+
59
+ Metrics/CyclomaticComplexity:
60
+ Enabled: true
61
+ Exclude:
62
+ - './lib/**/filter_rename.rb'
63
+ - './lib/**/cli.rb'
64
+ - './lib/**/config.rb'
65
+ - './lib/**/filename_factory.rb'
66
+ - './lib/**/filter_base.rb'
67
+ - './lib/**/utils.rb'
68
+ - './lib/**/audio_filename.rb'
69
+
70
+ Style/MixinUsage:
71
+ Enabled: true
72
+ Exclude:
73
+ - './spec/**/*'
74
+
75
+ Style/FrozenStringLiteralComment:
76
+ Enabled: true
77
+ Exclude:
78
+ - './bin/*'
79
+ - './exe/*'
80
+
81
+ Style/Documentation:
82
+ Enabled: true
83
+ Exclude:
84
+ - './lib/**/filters.rb'
data/Gemfile CHANGED
@@ -1,4 +1,18 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
2
4
 
3
5
  # Specify your gem's dependencies in filter_rename.gemspec
4
6
  gemspec
7
+
8
+ gem "bundler", "~> 2.0"
9
+
10
+ gem "rake", "~> 13.0"
11
+
12
+ gem "rspec", "~> 3.0"
13
+
14
+ gem "rubocop", "~> 1.21"
15
+
16
+ gem "rubocop-rake", "~> 0.7.0"
17
+
18
+ gem "rubocop-rspec", "~> 3.0"
data/README.md CHANGED
@@ -1,82 +1,126 @@
1
1
  # FilterRename
2
2
 
3
- FilterRename is a CLI tool created to rename a bunch of files at once applying a cascade of
4
- self-explainatory options called _filters_, in order to substitute all the other shell commands
5
- (like _sed_, _awk_, _trim_, ... ) and personal shell script to achieve that goal safely and
6
- in comfortable manner.
3
+ FilterRename is a CLI tool created for bulk file renaming that work appending a set of micro
4
+ operations here called *filters*, which aim to replace most, if not all, the shell commands
5
+ usually involved in that kind of operations (*sed*, *awk*, *trim*, ...) in a more safe and
6
+ comfortable manner.
7
+
8
+ [![Ruby](https://github.com/fabiomux/filter_rename/actions/workflows/main.yml/badge.svg)][wf_main]
9
+ [![Gem Version](https://badge.fury.io/rb/filter_rename.svg)][gem_version]
10
+
11
+ ## Installation
12
+
13
+ ### Requirements
14
+
15
+ These two libraries must be installed:
16
+ - **exiv2**
17
+ - **taglib**
18
+
19
+ With *openSUSE*:
20
+ ```shell
21
+ $ sudo zypper install libexiv2-devel libtag-devel
22
+ ```
23
+
24
+ With *Debian*/*Ubuntu*:
25
+ ```shell
26
+ $ sudo apt-get install libexiv2-dev libtag1-dev
27
+ ```
28
+
29
+ ### Rubygem
30
+
31
+ Install it as a regular Ruby gem with:
32
+ ```shell
33
+ $ gem install filter_rename
34
+ ```
35
+
36
+ ## Usage
7
37
 
8
38
  To simplify the whole process through a command line, the full filename is logically organized
9
- in _targets_ like:
39
+ in *targets*:
10
40
 
11
41
  <path>/<folder>/<name><ext>
12
42
 
13
- Considering the file `/home/fabio/Documents/Ruby/filter_rename/Gemfile.lock` we have:
43
+ For example, considering the file `/home/fabio/Documents/Ruby/filter_rename/Gemfile.lock` we have:
14
44
 
15
45
  - path: */home/fabio/Documents/Ruby*
16
46
  - folder: *filter_rename*
17
47
  - name: *Gemfile*
18
48
  - ext: *.lock*
19
49
 
20
- The chain of filters will be applied to the current _target_ which can be selected using the *--select*
21
- option, the default target is _name_.
22
-
23
- ## Installation
24
-
25
- Install it yourself as:
26
-
27
- $ gem install filter_rename
50
+ The chain of *filters* will be applied to the current *target*, which is *name* by default, but can
51
+ be changed using the *--select* option on the same command line without running the command twice.
28
52
 
29
- ## Usage
53
+ For example, to capitalize the *ext* and upper case the *name* at the same time we can use:
54
+ ```shell
55
+ filter_rename Gemfile.lock --uppercase --select ext --capitalize
56
+ ```
30
57
 
31
- The main concept about FilterRename is the _target_ manipulation with a chain of _filters_
32
- executed one by one as they appear in the argument's list.
58
+ So the file *Gemfile.lock* becomes *GEMFILE.Lock*.
33
59
 
34
- There are three main operations:
35
- * _preview_: show the results without make any change (default);
36
- * _dry-run_: executes a simulation warning when a conflict is raised;
37
- * _apply_: confirm the changes and rename the files unless the destination file exists.
60
+ To make things easier we can use a special class of *filters* that target a string as a list of *words*
61
+ or *numbers* with their position used as index.
38
62
 
39
- Having the files:
63
+ For example, having the files:
40
64
 
41
65
  home
42
66
  fabio
43
67
  Documents
44
68
  Photos
45
69
  Vacations
46
- image_portofino_1.jpg
47
- image_portofino_2.jpg
48
- image_portofino_3.jpg
70
+ image_from_portofino_0.jpg
71
+ image_from_portofino_1.jpg
72
+ image_from_portofino_2.jpg
49
73
  ...
50
74
 
51
- to replace _underscores_ with _spaces_ and _capitalize_ each word let's execute:
75
+ We want:
76
+ - space-separated words in place of the underscore;
77
+ - the first and third word capitalized;
78
+ - the final number must start from 1;
79
+ - the final number must be 2 digits wide.
52
80
 
53
- filter_rename /home/fabio/Documents/Photos/Vacations/*.jpg --spacify '_' --capitalize --apply
81
+ Using:
82
+ ```shell
83
+ $ filter_rename /home/fabio/Documents/Photos/Vacations/*.jpg \
84
+ --spacify '_' \
85
+ --capitalize-word 1:3 \
86
+ --add-number 1,1 \
87
+ --format-number 1,2
88
+ ```
54
89
 
55
- and the result will be:
90
+ The result is:
56
91
 
57
92
  home
58
93
  fabio
59
94
  Documents
60
95
  Photos
61
96
  Vacations
62
- Image Portofino 1.jpg
63
- Image Portofino 2.jpg
64
- Image Portofino 3.jpg
97
+ Image from Portofino 01.jpg
98
+ Image from Portofino 02.jpg
99
+ Image from Portofino 03.jpg
65
100
  ...
66
101
 
102
+ If you are wondering why all the commands above didn't affected the files physically on the disk,
103
+ then must be aware of the three main operations contemplated:
104
+ - *diff*: shows the results verbosly without making any change (default);
105
+ - *dry-run*: executes a simulation warning also for renaming conflicts;
106
+ - *apply*: confirm the changes and rename the files unless the destination file exists.
107
+
108
+ Last but not least filter_rename also supports *macros* and *regular expressions*, and the ability to
109
+ setup configurations params on the fly (*config* and *global*).
67
110
 
68
111
  ## Get help
69
112
 
70
113
  Where to start
114
+ ```shell
115
+ $ filter_rename --help
116
+ ```
71
117
 
72
- $ filter_rename --help
73
-
74
- More help
75
-
76
- - The wiki page: https://github.com/fabiomux/filter_rename/wiki
77
-
118
+ ## More help
78
119
 
79
- ## Contributing
120
+ More info is available at:
121
+ - the [FilterRename GitHub wiki][filter_rename_wiki].
80
122
 
81
- Bug reports and pull requests are welcome on GitHub at https://github.com/fabio_mux/filter_rename. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
82
123
 
124
+ [filter_rename_wiki]: https://github.com/fabiomux/filter_rename/wiki "FilterRename wiki page on GitHub"
125
+ [wf_main]: https://github.com/fabiomux/filter_rename/actions/workflows/main.yml
126
+ [gem_version]: https://badge.fury.io/rb/filter_rename
data/Rakefile CHANGED
@@ -1,6 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/exe/filter_rename CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'filter_rename/cli'
3
+ require "filter_rename/cli"
4
4
 
5
5
  FilterRename::CLI.start
@@ -1,7 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'filter_rename/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/filter_rename/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = "filter_rename"
@@ -9,36 +8,35 @@ Gem::Specification.new do |spec|
9
8
  spec.authors = ["Fabio Mucciante"]
10
9
  spec.email = ["fabio.mucciante@gmail.com"]
11
10
 
12
- spec.summary = %q{File renaming tool which make use of a chain of actions called filters.}
13
- spec.description = %q{FilterRename is a bulk renaming tool, based on the concept of filters as small operations to perform over sections of the full filename logically represented in targets.}
11
+ spec.summary = "File renaming tool which make use of a chain of actions called filters."
12
+ spec.description = "FilterRename is a bulk renaming tool, based on the concept of filters as small operations " \
13
+ "to perform over sections of the full filename logically represented in targets."
14
14
  spec.homepage = "https://github.com/fabiomux/filter_rename"
15
15
  spec.license = "GPL-3.0"
16
+ spec.required_ruby_version = ">= 2.5.0"
16
17
 
17
- spec.metadata = {
18
- "bug_tracker_uri" => "https://github.com/fabiomux/filter_rename/issues",
19
- "changelog_uri" => "https://freeaptitude.altervista.org/projects/filter-rename.htm#changelog",
20
- "documentation_uri" => "https://www.rubydoc.info/gems/filter_rename/#{spec.version}",
21
- "homepage_uri" => "https://freeaptitude.altervista.org/projects/filter-rename.html",
22
- #"mailing_list_uri" => "",
23
- "source_code_uri" => "https://github.com/fabiomux/filter_rename",
24
- "wiki_uri" => "https://github.com/fabiomux/filter_rename/wiki"
18
+ spec.metadata = {
19
+ "bug_tracker_uri" => "https://github.com/fabiomux/filter_rename/issues",
20
+ "homepage_uri" => "https://freeaptitude.altervista.org/projects/filter-rename.html",
21
+ "source_code_uri" => "https://github.com/fabiomux/filter_rename",
22
+ "changelog_uri" => "https://freeaptitude.altervista.org/projects/filter-rename.html#changelog",
23
+ "wiki_uri" => "https://github.com/fabiomux/filter_rename/wiki",
24
+ "rubygems_mfa_required" => "true"
25
25
  }
26
26
 
27
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
28
  f.match(%r{^(test|spec|features)/})
29
29
  end
30
30
  spec.bindir = "exe"
31
31
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
32
  spec.require_paths = ["lib"]
33
33
 
34
- spec.add_development_dependency "bundler", "~> 2.0"
35
- spec.add_development_dependency "rake", "~> 13.0"
36
- spec.add_development_dependency "rspec", "~> 3.0"
37
-
38
- spec.add_runtime_dependency "mp3info"
39
- spec.add_runtime_dependency "mimemagic"
40
- spec.add_runtime_dependency "differ"
41
- spec.add_runtime_dependency "exiv2"
42
- spec.add_runtime_dependency "fastimage"
43
- spec.add_runtime_dependency "pdf-reader"
34
+ spec.add_dependency "differ"
35
+ spec.add_dependency "exiv2"
36
+ spec.add_dependency "fastimage"
37
+ spec.add_dependency "keisan"
38
+ spec.add_dependency "mimemagic"
39
+ spec.add_dependency "mp3info"
40
+ spec.add_dependency "pdf-reader"
41
+ spec.add_dependency "taglib-ruby" #, "~> 1.0"
44
42
  end