clean_filenames 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +108 -0
- data/Guardfile +15 -0
- data/LICENSE.txt +7 -0
- data/README.md +50 -0
- data/README.rdoc +31 -0
- data/Rakefile +66 -0
- data/bin/clean_filenames +55 -0
- data/clean_filenames.gemspec +37 -0
- data/features/clean_filenames.feature +30 -0
- data/features/step_definitions/clean_filenames_steps.rb +1 -0
- data/features/support/env.rb +16 -0
- data/lib/clean_filenames.rb +41 -0
- data/lib/clean_filenames/version.rb +3 -0
- data/spec/lib/clean_filenames_spec.rb +23 -0
- data/spec/spec_helper.rb +22 -0
- metadata +264 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d725349f02fb070e945a51086831c3319bc6c834
|
4
|
+
data.tar.gz: d94dcfb66f062b15e685af522f4483f12e9b03a9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eb75f3bd903af3caddc1474cb3d6674d74f8dae71238492b630985d9bb019c813adf75d513f8f287a5788d8b197fe32f000cbef288ae14d2c20e2d45506322d6
|
7
|
+
data.tar.gz: 5fa38ca34cec5056e4d775099fc68303883fea91e4825bb78dfa2300a23ffdf1d39ca4d1380f2a9f17f976945779d0e562097b4ff5ec0177ba6a16c357c2eaf6
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
clean_filenames (1.0.1)
|
5
|
+
methadone (~> 1.3.2)
|
6
|
+
stringex
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
aruba (0.5.4)
|
12
|
+
childprocess (>= 0.3.6)
|
13
|
+
cucumber (>= 1.1.1)
|
14
|
+
rspec-expectations (>= 2.7.0)
|
15
|
+
awesome_print (1.2.0)
|
16
|
+
binding_of_caller (0.7.2)
|
17
|
+
debug_inspector (>= 0.0.1)
|
18
|
+
builder (3.2.2)
|
19
|
+
celluloid (0.15.2)
|
20
|
+
timers (~> 1.1.0)
|
21
|
+
celluloid-io (0.15.0)
|
22
|
+
celluloid (>= 0.15.0)
|
23
|
+
nio4r (>= 0.5.0)
|
24
|
+
childprocess (0.5.1)
|
25
|
+
ffi (~> 1.0, >= 1.0.11)
|
26
|
+
coderay (1.1.0)
|
27
|
+
cucumber (1.3.11)
|
28
|
+
builder (>= 2.1.2)
|
29
|
+
diff-lcs (>= 1.1.3)
|
30
|
+
gherkin (~> 2.12)
|
31
|
+
multi_json (>= 1.7.5, < 2.0)
|
32
|
+
multi_test (>= 0.0.2)
|
33
|
+
debug_inspector (0.0.2)
|
34
|
+
diff-lcs (1.2.5)
|
35
|
+
ffi (1.9.3)
|
36
|
+
formatador (0.2.4)
|
37
|
+
gherkin (2.12.2)
|
38
|
+
multi_json (~> 1.3)
|
39
|
+
guard (2.5.1)
|
40
|
+
formatador (>= 0.2.4)
|
41
|
+
listen (~> 2.6)
|
42
|
+
lumberjack (~> 1.0)
|
43
|
+
pry (>= 0.9.12)
|
44
|
+
thor (>= 0.18.1)
|
45
|
+
guard-cucumber (1.4.0)
|
46
|
+
cucumber (>= 1.2.0)
|
47
|
+
guard (>= 1.1.0)
|
48
|
+
guard-rspec (4.2.8)
|
49
|
+
guard (~> 2.1)
|
50
|
+
rspec (>= 2.14, < 4.0)
|
51
|
+
json (1.8.1)
|
52
|
+
listen (2.7.1)
|
53
|
+
celluloid (>= 0.15.2)
|
54
|
+
celluloid-io (>= 0.15.0)
|
55
|
+
rb-fsevent (>= 0.9.3)
|
56
|
+
rb-inotify (>= 0.9)
|
57
|
+
lumberjack (1.0.4)
|
58
|
+
methadone (1.3.2)
|
59
|
+
bundler
|
60
|
+
method_source (0.8.2)
|
61
|
+
multi_json (1.9.0)
|
62
|
+
multi_test (0.0.3)
|
63
|
+
nio4r (1.0.0)
|
64
|
+
pry (0.9.12.6)
|
65
|
+
coderay (~> 1.0)
|
66
|
+
method_source (~> 0.8)
|
67
|
+
slop (~> 3.4)
|
68
|
+
pry-nav (0.2.3)
|
69
|
+
pry (~> 0.9.10)
|
70
|
+
pry-stack_explorer (0.4.9.1)
|
71
|
+
binding_of_caller (>= 0.7)
|
72
|
+
pry (>= 0.9.11)
|
73
|
+
rake (10.1.1)
|
74
|
+
rb-fsevent (0.9.4)
|
75
|
+
rb-inotify (0.9.3)
|
76
|
+
ffi (>= 0.5.0)
|
77
|
+
rdoc (4.1.1)
|
78
|
+
json (~> 1.4)
|
79
|
+
rspec (2.14.1)
|
80
|
+
rspec-core (~> 2.14.0)
|
81
|
+
rspec-expectations (~> 2.14.0)
|
82
|
+
rspec-mocks (~> 2.14.0)
|
83
|
+
rspec-core (2.14.8)
|
84
|
+
rspec-expectations (2.14.5)
|
85
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
86
|
+
rspec-mocks (2.14.6)
|
87
|
+
slop (3.5.0)
|
88
|
+
stringex (2.3.0)
|
89
|
+
thor (0.18.1)
|
90
|
+
timers (1.1.0)
|
91
|
+
|
92
|
+
PLATFORMS
|
93
|
+
ruby
|
94
|
+
|
95
|
+
DEPENDENCIES
|
96
|
+
aruba
|
97
|
+
awesome_print
|
98
|
+
bundler (~> 1.5)
|
99
|
+
clean_filenames!
|
100
|
+
guard
|
101
|
+
guard-cucumber
|
102
|
+
guard-rspec
|
103
|
+
pry
|
104
|
+
pry-nav
|
105
|
+
pry-stack_explorer
|
106
|
+
rake
|
107
|
+
rdoc
|
108
|
+
rspec
|
data/Guardfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
guard :rspec,
|
2
|
+
:cmd => "bundle exec rspec -c -f d",
|
3
|
+
:all_after_pass => true,
|
4
|
+
:all_on_start => true do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
end
|
9
|
+
|
10
|
+
guard 'cucumber' do
|
11
|
+
watch("bin/clean_filenames") { 'features' }
|
12
|
+
watch(%r{^features/.+\.feature$})
|
13
|
+
watch(%r{^features/support/.+$}) { 'features' }
|
14
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
|
15
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2014 YOUR NAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# CleanFilenames
|
2
|
+
|
3
|
+
Convert file name paths to clean paths by converting high-byte and double-byte characters, spaces, capitals, non-alpha-nums, etc, to lowercase alphanums and hyphens.
|
4
|
+
|
5
|
+
Example:
|
6
|
+
|
7
|
+
Mary\ Jane\ Lamond/Làn\ Dùil/01\ A\ Mhàiri\ Bhòidheach.mp3
|
8
|
+
|
9
|
+
would be converted to:
|
10
|
+
|
11
|
+
mary-jane-lamond/lan-duil/01-a-mhairi-bhoidheach.mp3
|
12
|
+
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
gem 'clean_filenames'
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install clean_filenames
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
clean_filenames --ignore-levels=n PATH_NAME
|
31
|
+
|
32
|
+
where:
|
33
|
+
|
34
|
+
* *ignore-levels* is the number of directories in the beginning of PATH_NAME to ignore in conversion.
|
35
|
+
|
36
|
+
For example:
|
37
|
+
|
38
|
+
clean_filenames --ignore-levels=3 /media/MyAndroidPhone/Music/Mary\ Jane\ Lamond/Làn\ Dùil/01\ A\ Mhàiri\ Bhòidheach.mp3
|
39
|
+
|
40
|
+
would produce:
|
41
|
+
|
42
|
+
/media/MyAndroidPhone/Music/mary-jane-lamond/lan-duil/01-a-mhairi-bhoidheach.mp3
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it ( http://github.com/tamouse/clean_filenames/fork )
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create new Pull Request
|
data/README.rdoc
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
= clean_filenames - Give file name paths clean names
|
2
|
+
|
3
|
+
Author:: Tamara Temple <tamouse@gmail.com>
|
4
|
+
Copyright:: Copyright (c) 2014 Tamara Temple
|
5
|
+
|
6
|
+
|
7
|
+
License:: mit, see LICENSE.txt
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
Clean Filenames converts file name paths to clean names with only lower-case alphanumerics and hyphens.
|
12
|
+
|
13
|
+
For example, the following path:
|
14
|
+
|
15
|
+
Mary\ Jane\ Lamond/Làn\ Dùil/01\ A\ Mhàiri\ Bhòidheach.mp3
|
16
|
+
|
17
|
+
would be converted to:
|
18
|
+
|
19
|
+
mary-jane-lamond/lan-duil/01-a-mhairi-bhoidheach.mp3
|
20
|
+
|
21
|
+
== Links
|
22
|
+
|
23
|
+
* {Source on Github}[https://github.com/tamouse/clean_filenames]
|
24
|
+
* RDoc[LINK TO RDOC.INFO]
|
25
|
+
|
26
|
+
== Install
|
27
|
+
|
28
|
+
== Examples
|
29
|
+
|
30
|
+
== Contributing
|
31
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
def dump_load_path
|
2
|
+
puts $LOAD_PATH.join("\n")
|
3
|
+
found = nil
|
4
|
+
$LOAD_PATH.each do |path|
|
5
|
+
if File.exists?(File.join(path,"rspec"))
|
6
|
+
puts "Found rspec in #{path}"
|
7
|
+
if File.exists?(File.join(path,"rspec","core"))
|
8
|
+
puts "Found core"
|
9
|
+
if File.exists?(File.join(path,"rspec","core","rake_task"))
|
10
|
+
puts "Found rake_task"
|
11
|
+
found = path
|
12
|
+
else
|
13
|
+
puts "!! no rake_task"
|
14
|
+
end
|
15
|
+
else
|
16
|
+
puts "!!! no core"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
if found.nil?
|
21
|
+
puts "Didn't find rspec/core/rake_task anywhere"
|
22
|
+
else
|
23
|
+
puts "Found in #{path}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
require 'bundler'
|
27
|
+
require 'rake/clean'
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
rescue LoadError
|
32
|
+
dump_load_path
|
33
|
+
raise
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'cucumber'
|
37
|
+
require 'cucumber/rake/task'
|
38
|
+
gem 'rdoc' # we need the installed RDoc gem, not the system one
|
39
|
+
require 'rdoc/task'
|
40
|
+
|
41
|
+
include Rake::DSL
|
42
|
+
|
43
|
+
Bundler::GemHelper.install_tasks
|
44
|
+
|
45
|
+
|
46
|
+
RSpec::Core::RakeTask.new do |t|
|
47
|
+
# Put spec opts in a file named .rspec in root
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
CUKE_RESULTS = 'results.html'
|
52
|
+
CLEAN << CUKE_RESULTS
|
53
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
54
|
+
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
|
55
|
+
t.fork = false
|
56
|
+
end
|
57
|
+
|
58
|
+
Rake::RDocTask.new do |rd|
|
59
|
+
|
60
|
+
rd.main = "README.rdoc"
|
61
|
+
|
62
|
+
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
63
|
+
end
|
64
|
+
|
65
|
+
task :default => [:spec,:features]
|
66
|
+
|
data/bin/clean_filenames
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'methadone'
|
5
|
+
require 'clean_filenames.rb'
|
6
|
+
|
7
|
+
class App
|
8
|
+
include Methadone::Main
|
9
|
+
include Methadone::CLILogging
|
10
|
+
|
11
|
+
main do |path_name| # Add args you want: |like,so|
|
12
|
+
# your program code here
|
13
|
+
# You can access CLI options via
|
14
|
+
# the options Hash
|
15
|
+
|
16
|
+
debug path_name.inspect
|
17
|
+
debug options.inspect
|
18
|
+
|
19
|
+
puts CleanFilenames.run(path_name, options)
|
20
|
+
end
|
21
|
+
|
22
|
+
# supplemental methods here
|
23
|
+
|
24
|
+
# Declare command-line interface here
|
25
|
+
|
26
|
+
# description "one line description of your app"
|
27
|
+
description "Convert path names to clean path names"
|
28
|
+
|
29
|
+
#
|
30
|
+
# Accept flags via:
|
31
|
+
# on("--flag VAL","Some flag")
|
32
|
+
# options[flag] will contain VAL
|
33
|
+
options["ignore-levels"] == 0
|
34
|
+
on("--ignore-levels IGNORE_LEVEL", "Number of levels in beginning of PATH_NAME to ignore")
|
35
|
+
#
|
36
|
+
# Specify switches via:
|
37
|
+
# on("--[no-]switch","Some switch")
|
38
|
+
#
|
39
|
+
# Or, just call OptionParser methods on opts
|
40
|
+
#
|
41
|
+
# Require an argument
|
42
|
+
# arg :some_arg
|
43
|
+
arg :path_name, "Path name to convert"
|
44
|
+
|
45
|
+
|
46
|
+
#
|
47
|
+
# # Make an argument optional
|
48
|
+
# arg :optional_arg, :optional
|
49
|
+
|
50
|
+
version CleanFilenames::VERSION
|
51
|
+
|
52
|
+
use_log_level_option
|
53
|
+
|
54
|
+
go!
|
55
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'clean_filenames/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "clean_filenames"
|
8
|
+
spec.version = CleanFilenames::VERSION
|
9
|
+
spec.authors = ["Tamara Temple"]
|
10
|
+
spec.email = ["tamouse@gmail.com"]
|
11
|
+
spec.summary = %q{Give file name paths clean names}
|
12
|
+
spec.description = %q{Give file name paths clean names}
|
13
|
+
spec.homepage = "https://github.com/tamouse/clean_filenames"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency('methadone', '~> 1.3.2')
|
22
|
+
spec.add_dependency 'stringex'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency('rdoc')
|
27
|
+
spec.add_development_dependency('aruba')
|
28
|
+
spec.add_development_dependency('rspec')
|
29
|
+
spec.add_development_dependency "pry"
|
30
|
+
spec.add_development_dependency "pry-nav"
|
31
|
+
spec.add_development_dependency "pry-stack_explorer"
|
32
|
+
spec.add_development_dependency "awesome_print"
|
33
|
+
spec.add_development_dependency "guard"
|
34
|
+
spec.add_development_dependency "guard-rspec"
|
35
|
+
spec.add_development_dependency "guard-cucumber"
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Feature: My bootstrapped app kinda works
|
2
|
+
In order to get going on coding my awesome app
|
3
|
+
I want to have aruba and cucumber setup
|
4
|
+
So I don't have to do it myself
|
5
|
+
|
6
|
+
Scenario: App just runs
|
7
|
+
When I get help for "clean_filenames"
|
8
|
+
Then the exit status should be 0
|
9
|
+
And the banner should be present
|
10
|
+
And the banner should document that this app takes options
|
11
|
+
And the following options should be documented:
|
12
|
+
|--version|
|
13
|
+
|--ignore-levels|
|
14
|
+
And the banner should document that this app's arguments are:
|
15
|
+
|path_name|
|
16
|
+
|
17
|
+
Scenario Outline: Clean file path names
|
18
|
+
When I run `clean_filenames --log-level=debug --ignore-levels=<level> '<path>'`
|
19
|
+
Then the exit status should be 0
|
20
|
+
And the output should contain "<clean>"
|
21
|
+
|
22
|
+
Examples:
|
23
|
+
| level | path | clean |
|
24
|
+
| 0 | A Path/And Another/path.tom | a-path/and-another/path.tom |
|
25
|
+
| 1 | A Path/And Another/path.tom | A Path/and-another/path.tom |
|
26
|
+
| 2 | A Path/And Another/path.tom | A Path/And Another/path.tom |
|
27
|
+
| 0 | /A Path/And Another/path.tom | /a-path/and-another/path.tom |
|
28
|
+
| 1 | /A Path/And Another/path.tom | /A Path/and-another/path.tom |
|
29
|
+
| 2 | /A Path/And Another/path.tom | /A Path/And Another/path.tom |
|
30
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
# Put your step definitions here
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
require 'methadone/cucumber'
|
3
|
+
|
4
|
+
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
5
|
+
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
|
6
|
+
|
7
|
+
Before do
|
8
|
+
# Using "announce" causes massive warnings on 1.9.2
|
9
|
+
@puts = true
|
10
|
+
@original_rubylib = ENV['RUBYLIB']
|
11
|
+
ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
After do
|
15
|
+
ENV['RUBYLIB'] = @original_rubylib
|
16
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "clean_filenames/version"
|
2
|
+
require "stringex_lite"
|
3
|
+
require "methadone"
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
module CleanFilenames
|
7
|
+
|
8
|
+
extend Methadone::CLILogging
|
9
|
+
|
10
|
+
DEFAULT_OPTIONS = {}
|
11
|
+
|
12
|
+
def self.run(*args)
|
13
|
+
options = DEFAULT_OPTIONS.merge(args.pop) if args.last.is_a?(Hash)
|
14
|
+
ignore_levels = options.fetch("ignore-levels", "0").to_i
|
15
|
+
name = args.shift if args.first.is_a?(String)
|
16
|
+
self.convert_name(name,ignore_levels)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.convert_name(name=nil, ignore_levels=0)
|
20
|
+
# When performing the split below, if there is a leading file
|
21
|
+
# separator on the file name, an empty string will be in the
|
22
|
+
# leading resulting array, just as needed. However, the number of
|
23
|
+
# levels expected needs to be increased to accomodate this fact.
|
24
|
+
ignore_levels += 1 if name[0] == File::SEPARATOR
|
25
|
+
|
26
|
+
parts = name.dup.to_s.split(File::SEPARATOR)
|
27
|
+
leading_parts = []
|
28
|
+
(0...ignore_levels).each {|l| leading_parts.push parts.shift}
|
29
|
+
|
30
|
+
converted_parts = parts.map do |p|
|
31
|
+
extension = File.extname(p)
|
32
|
+
basename = File.basename(p,extension)
|
33
|
+
basename = basename.to_url
|
34
|
+
"#{basename}#{extension}"
|
35
|
+
end
|
36
|
+
|
37
|
+
File.join(leading_parts + converted_parts)
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'clean_filenames'
|
3
|
+
|
4
|
+
describe CleanFilenames do
|
5
|
+
|
6
|
+
it "knows how to run" do
|
7
|
+
expect(CleanFilenames).to respond_to(:run)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "knows how to convert" do
|
11
|
+
expect(CleanFilenames).to respond_to(:convert_name)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "converts a full path file name" do
|
15
|
+
expect(CleanFilenames.convert_name('/A Dir/Another Dir/A String',2)).to eq "/A Dir/Another Dir/a-string"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "converts a relative path file name" do
|
19
|
+
expect(CleanFilenames.convert_name('A Dir/Another Dir/A String',2)).to eq "A Dir/Another Dir/a-string"
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
18
|
+
|
19
|
+
require "methadone"
|
20
|
+
include Methadone::CLILogging
|
21
|
+
logger.level=Logger::DEBUG
|
22
|
+
debug "Logging with Methadone"
|
metadata
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: clean_filenames
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tamara Temple
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: methadone
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.3.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.3.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: stringex
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rdoc
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: aruba
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-nav
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry-stack_explorer
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: awesome_print
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: guard
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: guard-rspec
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - '>='
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: guard-cucumber
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - '>='
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - '>='
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
description: Give file name paths clean names
|
210
|
+
email:
|
211
|
+
- tamouse@gmail.com
|
212
|
+
executables:
|
213
|
+
- clean_filenames
|
214
|
+
extensions: []
|
215
|
+
extra_rdoc_files: []
|
216
|
+
files:
|
217
|
+
- .gitignore
|
218
|
+
- .rspec
|
219
|
+
- Gemfile
|
220
|
+
- Gemfile.lock
|
221
|
+
- Guardfile
|
222
|
+
- LICENSE.txt
|
223
|
+
- README.md
|
224
|
+
- README.rdoc
|
225
|
+
- Rakefile
|
226
|
+
- bin/clean_filenames
|
227
|
+
- clean_filenames.gemspec
|
228
|
+
- features/clean_filenames.feature
|
229
|
+
- features/step_definitions/clean_filenames_steps.rb
|
230
|
+
- features/support/env.rb
|
231
|
+
- lib/clean_filenames.rb
|
232
|
+
- lib/clean_filenames/version.rb
|
233
|
+
- spec/lib/clean_filenames_spec.rb
|
234
|
+
- spec/spec_helper.rb
|
235
|
+
homepage: https://github.com/tamouse/clean_filenames
|
236
|
+
licenses:
|
237
|
+
- MIT
|
238
|
+
metadata: {}
|
239
|
+
post_install_message:
|
240
|
+
rdoc_options: []
|
241
|
+
require_paths:
|
242
|
+
- lib
|
243
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
244
|
+
requirements:
|
245
|
+
- - '>='
|
246
|
+
- !ruby/object:Gem::Version
|
247
|
+
version: '0'
|
248
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
249
|
+
requirements:
|
250
|
+
- - '>='
|
251
|
+
- !ruby/object:Gem::Version
|
252
|
+
version: '0'
|
253
|
+
requirements: []
|
254
|
+
rubyforge_project:
|
255
|
+
rubygems_version: 2.0.14
|
256
|
+
signing_key:
|
257
|
+
specification_version: 4
|
258
|
+
summary: Give file name paths clean names
|
259
|
+
test_files:
|
260
|
+
- features/clean_filenames.feature
|
261
|
+
- features/step_definitions/clean_filenames_steps.rb
|
262
|
+
- features/support/env.rb
|
263
|
+
- spec/lib/clean_filenames_spec.rb
|
264
|
+
- spec/spec_helper.rb
|