mvr 2.0.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 +7 -0
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +8 -0
- data/bin/mvr +183 -0
- data/lib/mvr.rb +1 -0
- data/lib/mvr/plugin.rb +121 -0
- data/lib/mvr/plugin/extension.plugin.rb +11 -0
- data/lib/mvr/version.rb +3 -0
- data/mvr.gemspec +28 -0
- data/spec/extension_spec.rb +64 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4e65d9869db5d352159a8c6e182d8b574215d9e8
|
4
|
+
data.tar.gz: 0f14152e9f0d2fb1400bfa24fa8eb7da43227f4a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1a62d2a175fa468699b34140e72db3bdf1de30dc8b794cb86b4c84d49a0cfc60e910bc0e6a5462df630be12f3da0f529fbf999ccbcb23f4648c2955204e3bc65
|
7
|
+
data.tar.gz: 6ef8f06d84209296892bbee29529d61adda26f7b48d8403807456fd23b31f575c05e8cf44cbd819091affc1b159d6fe5ce1652c0701c8652446427f221f0db12
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Eric Henderson
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Mvr
|
2
|
+
|
3
|
+
a Ruby script that allows you to rename a group of files via regular expression
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install it yourself as:
|
8
|
+
|
9
|
+
$ gem install mvr
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
###required parameters:
|
14
|
+
* match pattern
|
15
|
+
* replacement pattern (use `\1` for first match, `\2` for second match, and so on)
|
16
|
+
* filenames
|
17
|
+
|
18
|
+
###optional parameters:
|
19
|
+
* `-e` or `--exclude-extension` to exclude the extension of the file from the pattern matching/replacement
|
20
|
+
* `-v` or `--override-colors` to override the colors with the ones configured by the [colorconfig][colorconfig] script
|
21
|
+
|
22
|
+
###displays:
|
23
|
+
prints a color-coded list of file names and their replacement names; also asks for confirmation
|
24
|
+
|
25
|
+
#####Color Coding:
|
26
|
+
grey background for no change, red background for conflict
|
27
|
+
|
28
|
+
###action:
|
29
|
+
if you type `y` or `yes` (case insensitive), it will rename the files; anything else will cause it to cancel the operation
|
data/Rakefile
ADDED
data/bin/mvr
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'yaml'
|
5
|
+
require 'rubygems'
|
6
|
+
require 'everyday-cli-utils'
|
7
|
+
include EverydayCliUtils
|
8
|
+
import :format, :option
|
9
|
+
|
10
|
+
#noinspection RubyResolve
|
11
|
+
require 'mvr/plugin'
|
12
|
+
|
13
|
+
require 'everyday-plugins'
|
14
|
+
include EverydayPlugins
|
15
|
+
|
16
|
+
Plugins.load_plugins 'mvr'
|
17
|
+
|
18
|
+
def help_str
|
19
|
+
str = <<eos
|
20
|
+
{NAME}(bd)
|
21
|
+
{mvr}(bdfpu) -- Renames a group of files and/or folders using a regular expression
|
22
|
+
|
23
|
+
{SYNOPSIS}(bd)
|
24
|
+
{mvr}(bdfpu) [options] <{find}(ulfcy)> <{replace}(ulfcy)> {file ...}(fcy)
|
25
|
+
|
26
|
+
{DESCRIPTION}(bd)
|
27
|
+
{mvr}(bdfpu) is a Ruby script that allows you to rename a group of files and/or folders using a regular expression.
|
28
|
+
The {find}(ulfcy) parameter uses normal regular expression syntax (there might be Ruby-specific things, but I doubt it).
|
29
|
+
The {replace}(ulfcy) parameter is plain text, using {\\#}(fgr) to insert capture group {#}(fgr) (so {\\1}(fgr) to insert the first capture group).
|
30
|
+
The list of files can be as many items as you want, and you can use typical wildcard expressions.
|
31
|
+
Any parameter after {replace}(ulfcy) will be interpreted as a file/folder name that should be included in the list of what to rename.
|
32
|
+
|
33
|
+
Parameters:
|
34
|
+
<{find}(ulfcy)> The regular expression for the renaming
|
35
|
+
<{replace}(ulfcy)> The text to replace what the regular expression matches (use {\\#}(fgr) to insert capture group {#}(fgr) (so {\\1}(fgr) to insert the first capture group))
|
36
|
+
{file ...}(fcy) The list of files and/or folders to rename
|
37
|
+
|
38
|
+
Options:
|
39
|
+
#{MyOptions.opts.summarize.join}
|
40
|
+
eos
|
41
|
+
str.format_all
|
42
|
+
end
|
43
|
+
|
44
|
+
class MyOptions
|
45
|
+
extend OptionUtil
|
46
|
+
|
47
|
+
help_option %w(-h --help), desc: 'print out this help'
|
48
|
+
|
49
|
+
#option :exclude_extension, %w(-e --exclude-extension), desc: 'remove the file extension before doing the rename operation. the extension will be added back on after renaming.'
|
50
|
+
option :override_colors, %w(-v --override-colors), desc: 'override the colors with the ones configured by the colorconfig script'
|
51
|
+
end
|
52
|
+
|
53
|
+
Plugins.get :option, MyOptions
|
54
|
+
Plugins.get :option_with_param, MyOptions
|
55
|
+
|
56
|
+
MyOptions.help_str = help_str
|
57
|
+
|
58
|
+
MyOptions.parse!
|
59
|
+
|
60
|
+
options = MyOptions.options
|
61
|
+
|
62
|
+
Plugins.set_var :options, options
|
63
|
+
|
64
|
+
#color_opts = {
|
65
|
+
# normal: {
|
66
|
+
# fg: :none,
|
67
|
+
# bg: :none,
|
68
|
+
# },
|
69
|
+
# same: {
|
70
|
+
# fg: :black,
|
71
|
+
# bg: :white,
|
72
|
+
# },
|
73
|
+
# conflict: {
|
74
|
+
# fg: :white,
|
75
|
+
# bg: :red,
|
76
|
+
# },
|
77
|
+
#}
|
78
|
+
#
|
79
|
+
#config_file = File.expand_path('~/mvr-colors.yaml')
|
80
|
+
#
|
81
|
+
#if options[:override_colors] && File.exist?(config_file)
|
82
|
+
# color_opts = YAML::load_file(config_file)
|
83
|
+
#end
|
84
|
+
#
|
85
|
+
#color_opts.each { |opt| Format.color_profile opt[0], fgcolor: opt[1][:fg], bgcolor: opt[1][:bg] }
|
86
|
+
|
87
|
+
Plugins.get :color_override
|
88
|
+
|
89
|
+
pattern = ARGV.shift
|
90
|
+
|
91
|
+
if pattern == 'help' || pattern == '--help' || pattern == '-h'
|
92
|
+
puts help_str
|
93
|
+
exit
|
94
|
+
end
|
95
|
+
if ARGV.length < 2
|
96
|
+
puts "\n{Usage}(bdul): {mvr}(bdfpu) <{find}(ulfcy)> <{replace}(ulfcy)> {file ...}(fcy)\n\n".format_all
|
97
|
+
puts "Run {mvr}(bdfpu) {help}(bdfcy) for command information.\n\n".format_all
|
98
|
+
exit
|
99
|
+
end
|
100
|
+
replacement = ARGV.shift
|
101
|
+
regex = /#{pattern}/o
|
102
|
+
mappings = Hash.new
|
103
|
+
encountered = Array.new
|
104
|
+
duplicated = Array.new
|
105
|
+
ARGV.each do |filename|
|
106
|
+
file_basename = File.basename(filename)
|
107
|
+
directory = filename[0, (filename.length - file_basename.length)]
|
108
|
+
#file_ext = File.extname(file_basename)
|
109
|
+
#if options[:exclude_extension] && file_ext.length > 0
|
110
|
+
# file_basename2 = file_basename[0...-file_ext.length]
|
111
|
+
# replacement_basename = file_basename2.gsub(regex, replacement)
|
112
|
+
# replacement_name = "#{directory}#{replacement_basename}#{file_ext}"
|
113
|
+
#else
|
114
|
+
# replacement_basename = file_basename.gsub(regex, replacement)
|
115
|
+
# replacement_name = "#{directory}#{replacement_basename}"
|
116
|
+
#end
|
117
|
+
basename = Plugins.get :name_change_before, file_basename
|
118
|
+
replacement_basename = Plugins.get :name_change_after, basename.gsub(regex, replacement)
|
119
|
+
replacement_name = "#{directory}#{replacement_basename}"
|
120
|
+
mappings[filename] = replacement_name
|
121
|
+
if encountered.include?(replacement_name)
|
122
|
+
unless duplicated.include?(replacement_name)
|
123
|
+
duplicated << replacement_name
|
124
|
+
end
|
125
|
+
else
|
126
|
+
encountered << replacement_name
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
ARGV.clear
|
131
|
+
|
132
|
+
len1 = mappings.keys.max do |a, b|
|
133
|
+
a.length <=> b.length
|
134
|
+
end
|
135
|
+
|
136
|
+
len2 = mappings.values.max do |a, b|
|
137
|
+
a.length <=> b.length
|
138
|
+
end
|
139
|
+
|
140
|
+
len1 = len1.length
|
141
|
+
len2 = len2.length
|
142
|
+
|
143
|
+
if len1 < 3
|
144
|
+
len1 = 3
|
145
|
+
end
|
146
|
+
|
147
|
+
if len2 < 3
|
148
|
+
len2 = 3
|
149
|
+
end
|
150
|
+
|
151
|
+
border = "+#{'-' * (len1+2)}+#{'-' * (len2+2)}+"
|
152
|
+
|
153
|
+
puts border
|
154
|
+
puts "| #{'Old'.mycenter(len1)} | #{'New'.mycenter(len2)} |"
|
155
|
+
puts border
|
156
|
+
|
157
|
+
mappings.each do |from, to|
|
158
|
+
from2 = from.mycenter(len1)
|
159
|
+
to2 = to.mycenter(len2)
|
160
|
+
if from == to
|
161
|
+
from2 = "{#{from2}}(:same)"
|
162
|
+
to2 = "{#{to2}}(:same)"
|
163
|
+
elsif duplicated.include?(to)
|
164
|
+
from2 = "{#{from2}}(:conflict)"
|
165
|
+
to2 = "{#{to2}}(:conflict)"
|
166
|
+
else
|
167
|
+
from2 = "{#{from2}}(:normal)"
|
168
|
+
to2 = "{#{to2}}(:normal)"
|
169
|
+
end
|
170
|
+
puts "| #{from2} | #{to2} |".format_all
|
171
|
+
end
|
172
|
+
|
173
|
+
puts border
|
174
|
+
|
175
|
+
print "\nAre you sure you want to rename these files (yes/no or y/n)? "
|
176
|
+
response = gets.chomp
|
177
|
+
if response.downcase == 'yes' || response.downcase == 'y'
|
178
|
+
mappings.each do |from, to|
|
179
|
+
if from != to
|
180
|
+
File.rename(from, to)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
data/lib/mvr.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'mvr/version'
|
data/lib/mvr/plugin.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'everyday-plugins'
|
2
|
+
include EverydayPlugins
|
3
|
+
|
4
|
+
module Mvr
|
5
|
+
class OptionTypes
|
6
|
+
extend PluginType
|
7
|
+
|
8
|
+
def self.register_option(list, options)
|
9
|
+
list.sort_by { |v| v[:options][:sym].to_s }.each { |option|
|
10
|
+
id = option[:options].delete(:sym)
|
11
|
+
names = option[:options].delete(:names)
|
12
|
+
default = option[:options].delete(:default) || nil
|
13
|
+
yield(id, names, option)
|
14
|
+
options.default_options id => default unless default.nil?
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.def_options
|
19
|
+
register_type(:option) { |list, options| register_option(list, options) { |id, names, option| options.option id, names, option[:options] } }
|
20
|
+
register_type(:option_with_param) { |list, options| register_option(list, options) { |id, names, option| options.option_with_param id, names, option[:options] } }
|
21
|
+
end
|
22
|
+
|
23
|
+
def_options
|
24
|
+
end
|
25
|
+
class ColorTypes
|
26
|
+
extend PluginType
|
27
|
+
|
28
|
+
DEFAULT_COLOR_OPTS = {
|
29
|
+
normal: {
|
30
|
+
fg: :none,
|
31
|
+
bg: :none,
|
32
|
+
},
|
33
|
+
same: {
|
34
|
+
fg: :black,
|
35
|
+
bg: :white,
|
36
|
+
},
|
37
|
+
conflict: {
|
38
|
+
fg: :white,
|
39
|
+
bg: :red,
|
40
|
+
},
|
41
|
+
}
|
42
|
+
|
43
|
+
def self.def_color
|
44
|
+
register_type(:color_override) { |list|
|
45
|
+
options = Plugins.get_var :options
|
46
|
+
opts = DEFAULT_COLOR_OPTS
|
47
|
+
list.sort_by { |v| -v[:options][:priority] }.each { |item|
|
48
|
+
rval = item[:block].call(options)
|
49
|
+
unless rval.nil? || !rval
|
50
|
+
opts = rval
|
51
|
+
break
|
52
|
+
end
|
53
|
+
}
|
54
|
+
opts.each { |opt| Format.color_profile opt[0], fgcolor: opt[1][:fg], bgcolor: opt[1][:bg] }
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def_color
|
59
|
+
end
|
60
|
+
class NameChangeTypes
|
61
|
+
extend PluginType
|
62
|
+
|
63
|
+
register_type(:name_change_before) { |list, name|
|
64
|
+
options = Plugins.get_var :options
|
65
|
+
list.sort_by { |v| v[:options][:order] }.each { |item|
|
66
|
+
if item[:block].nil?
|
67
|
+
if !item[:options].has_key?(:option) || options[item[:options][:option]] == (item[:options].has_key?(:value) ? item[:options][:value] : true)
|
68
|
+
if item[:options].has_key?(:regex)
|
69
|
+
if item[:options].has_key?(:vars)
|
70
|
+
item[:options][:vars].each { |var|
|
71
|
+
v = name.gsub(item[:options][:regex], var[1])
|
72
|
+
Plugins.set_var var[0], v == name ? nil : v
|
73
|
+
}
|
74
|
+
end
|
75
|
+
name = name.gsub(item[:options][:regex], item[:options][:replace]) if item[:options].has_key?(:replace)
|
76
|
+
end
|
77
|
+
if item[:options].has_key?(:override)
|
78
|
+
name = item[:options][:override].gsub(/\{:name\}/, name).gsub(/\{:(.+?)\}/) { |_|
|
79
|
+
val = Plugins.get_var $1.to_sym
|
80
|
+
val.nil? ? '' : val.to_s
|
81
|
+
}
|
82
|
+
end
|
83
|
+
end
|
84
|
+
else
|
85
|
+
rval = item[:block].call(options, name)
|
86
|
+
name = rval unless rval.nil? || !rval
|
87
|
+
end
|
88
|
+
}
|
89
|
+
name
|
90
|
+
}
|
91
|
+
|
92
|
+
register_type(:name_change_after) { |list, name|
|
93
|
+
options = Plugins.get_var :options
|
94
|
+
list.sort_by { |v| v[:options][:order] }.each { |item|
|
95
|
+
if item[:block].nil?
|
96
|
+
if !item[:options].has_key?(:option) || options[item[:options][:option]] == (item[:options].has_key?(:value) ? item[:options][:value] : true)
|
97
|
+
if item[:options].has_key?(:regex)
|
98
|
+
if item[:options].has_key?(:vars)
|
99
|
+
item[:options][:vars].each { |var|
|
100
|
+
v = name.gsub(item[:options][:regex], var[1])
|
101
|
+
Plugins.set_var var[0], v == name ? nil : v
|
102
|
+
}
|
103
|
+
end
|
104
|
+
name = name.gsub(item[:options][:regex], item[:options][:replace]) if item[:options].has_key?(:replace)
|
105
|
+
end
|
106
|
+
if item[:options].has_key?(:override)
|
107
|
+
name = item[:options][:override].gsub(/\{:name\}/, name).gsub(/\{:(.+?)\}/) { |_|
|
108
|
+
val = Plugins.get_var $1.to_sym
|
109
|
+
val.nil? ? '' : val.to_s
|
110
|
+
}
|
111
|
+
end
|
112
|
+
end
|
113
|
+
else
|
114
|
+
rval = item[:block].call(options, name)
|
115
|
+
name = rval unless rval.nil? || !rval
|
116
|
+
end
|
117
|
+
}
|
118
|
+
name
|
119
|
+
}
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'everyday-plugins'
|
2
|
+
include EverydayPlugins
|
3
|
+
|
4
|
+
class ExtensionPlugin
|
5
|
+
extend Plugin
|
6
|
+
|
7
|
+
register :option, sym: :exclude_extension, names: %w(-e --exclude-extension), desc: 'remove the file extension before doing the rename operation. the extension will be added back on after renaming.'
|
8
|
+
|
9
|
+
register :name_change_before, order: 10, option: :exclude_extension, regex: /^(.+)(\..+?)$/, replace: '\1', vars: { ext: '\2' }
|
10
|
+
register :name_change_after, order: 10, option: :exclude_extension, override: '{:name}{:ext}'
|
11
|
+
end
|
data/lib/mvr/version.rb
ADDED
data/mvr.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
#noinspection RubyResolve
|
5
|
+
require 'mvr/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'mvr'
|
9
|
+
spec.version = Mvr::VERSION
|
10
|
+
spec.authors = ['Eric Henderson']
|
11
|
+
spec.email = ['henderea@gmail.com']
|
12
|
+
spec.summary = %q{regex rename}
|
13
|
+
spec.description = %q{a Ruby script that allows you to rename a group of files via regular expression}
|
14
|
+
spec.homepage = 'https://github.com/henderea/mvr'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec'
|
25
|
+
|
26
|
+
spec.add_dependency 'everyday-cli-utils', '>= 1.4.0'
|
27
|
+
spec.add_dependency 'everyday-plugins', '>= 1.0.0'
|
28
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'everyday-plugins'
|
2
|
+
include EverydayPlugins
|
3
|
+
require_relative '../lib/mvr/plugin'
|
4
|
+
require_relative '../lib/mvr/plugin/extension.plugin'
|
5
|
+
|
6
|
+
describe ExtensionPlugin do
|
7
|
+
it 'removes and adds back the extension' do
|
8
|
+
Plugins.set_var :options, { exclude_extension: true }
|
9
|
+
Plugins.set_var :ext, nil
|
10
|
+
name = 'filename.txt'
|
11
|
+
edit1 = Plugins.get :name_change_before, name
|
12
|
+
edit1.should eq 'filename'
|
13
|
+
ext = Plugins.get_var :ext
|
14
|
+
ext.should eq '.txt'
|
15
|
+
edit2 = Plugins.get :name_change_after, edit1
|
16
|
+
edit2.should eq name
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'does not mess up with no extension' do
|
20
|
+
Plugins.set_var :options, { exclude_extension: true }
|
21
|
+
Plugins.set_var :ext, nil
|
22
|
+
name = 'filename'
|
23
|
+
edit1 = Plugins.get :name_change_before, name
|
24
|
+
edit1.should eq name
|
25
|
+
ext = Plugins.get_var :ext
|
26
|
+
ext.should be_nil
|
27
|
+
edit2 = Plugins.get :name_change_after, edit1
|
28
|
+
edit2.should eq name
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'handles multiple extensions fine' do
|
32
|
+
Plugins.set_var :options, { exclude_extension: true }
|
33
|
+
Plugins.set_var :ext, nil
|
34
|
+
name = 'filename.a.b.c.txt'
|
35
|
+
edit1 = Plugins.get :name_change_before, name
|
36
|
+
edit1.should eq 'filename.a.b.c'
|
37
|
+
ext = Plugins.get_var :ext
|
38
|
+
ext.should eq '.txt'
|
39
|
+
edit2 = Plugins.get :name_change_after, edit1
|
40
|
+
edit2.should eq name
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'does not mess up with no filename' do
|
44
|
+
Plugins.set_var :options, { exclude_extension: true }
|
45
|
+
Plugins.set_var :ext, nil
|
46
|
+
name = '.filename'
|
47
|
+
edit1 = Plugins.get :name_change_before, name
|
48
|
+
edit1.should eq name
|
49
|
+
ext = Plugins.get_var :ext
|
50
|
+
ext.should be_nil
|
51
|
+
edit2 = Plugins.get :name_change_after, edit1
|
52
|
+
edit2.should eq name
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'does not remove and add back extension if option disabled' do
|
56
|
+
Plugins.set_var :options, { exclude_extension: false }
|
57
|
+
Plugins.set_var :ext, nil
|
58
|
+
name = 'filename.txt'
|
59
|
+
edit1 = Plugins.get :name_change_before, name
|
60
|
+
edit1.should eq name
|
61
|
+
edit2 = Plugins.get :name_change_after, edit1
|
62
|
+
edit2.should eq name
|
63
|
+
end
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mvr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eric Henderson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: everyday-cli-utils
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.4.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.4.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: everyday-plugins
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.0.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.0.0
|
83
|
+
description: a Ruby script that allows you to rename a group of files via regular
|
84
|
+
expression
|
85
|
+
email:
|
86
|
+
- henderea@gmail.com
|
87
|
+
executables:
|
88
|
+
- mvr
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/mvr
|
98
|
+
- lib/mvr.rb
|
99
|
+
- lib/mvr/plugin.rb
|
100
|
+
- lib/mvr/plugin/extension.plugin.rb
|
101
|
+
- lib/mvr/version.rb
|
102
|
+
- mvr.gemspec
|
103
|
+
- spec/extension_spec.rb
|
104
|
+
homepage: https://github.com/henderea/mvr
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.2.0
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: regex rename
|
128
|
+
test_files:
|
129
|
+
- spec/extension_spec.rb
|
130
|
+
has_rdoc:
|