jorm 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +22 -0
- data/README.md +18 -0
- data/bin/jorm +16 -0
- data/lib/jorm.rb +25 -0
- data/lib/jorm/folder.rb +21 -0
- data/lib/jorm/version.rb +3 -0
- data/test/mt_helper.rb +3 -0
- data/test/test_jorm.rb +33 -0
- metadata +127 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Whyme Lyu
|
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,18 @@
|
|
1
|
+
# Jorm
|
2
|
+
|
3
|
+
Normalizes JAV folder names.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install jorm
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Running
|
12
|
+
|
13
|
+
$ jorm javcrapsite-EBOD-277AVIC
|
14
|
+
|
15
|
+
Would rename the folder to `ebod277`, which should be easy to type in
|
16
|
+
terminal.
|
17
|
+
|
18
|
+
See `jorm -h` for more.
|
data/bin/jorm
ADDED
data/lib/jorm.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "jorm/version"
|
2
|
+
|
3
|
+
require "jorm/folder"
|
4
|
+
|
5
|
+
module Jorm
|
6
|
+
PATTERN = /([a-z]{2,5})-?([0-9]{3,5})/i
|
7
|
+
PATTERN_NORMALIZED = /\A[a-z]{2,5}[0-9]{3,5}\z/
|
8
|
+
|
9
|
+
def self.normalize_id input_jav_id
|
10
|
+
if m = input_jav_id.match(PATTERN)
|
11
|
+
_, category, num = *m
|
12
|
+
"#{category.downcase}#{num}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.normalized? input_jav_id
|
17
|
+
!!(input_jav_id =~ PATTERN_NORMALIZED)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.normalize_folder *folders
|
21
|
+
folders.each do |f|
|
22
|
+
Folder.new(f).normalize!
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/jorm/folder.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "pathname"
|
3
|
+
|
4
|
+
module Jorm
|
5
|
+
class Folder
|
6
|
+
attr_reader :path
|
7
|
+
|
8
|
+
def initialize path
|
9
|
+
@path = ::Pathname.new path
|
10
|
+
end
|
11
|
+
|
12
|
+
def normalized?
|
13
|
+
Jorm.normalized? path.to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
def normalize!
|
17
|
+
return if normalized?
|
18
|
+
FileUtils.mv path, Jorm.normalize_id(path.to_s)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/jorm/version.rb
ADDED
data/test/mt_helper.rb
ADDED
data/test/test_jorm.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "mt_helper"
|
2
|
+
|
3
|
+
require "jorm"
|
4
|
+
|
5
|
+
describe Jorm do
|
6
|
+
def assert_normalize_to input, expected
|
7
|
+
normalized = ::Jorm.normalize_id(input)
|
8
|
+
unless normalized == expected
|
9
|
+
fail "Expected #{expected}, got #{normalized}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def assert_normazlied input
|
14
|
+
fail "#{input} is not normalized" unless Jorm.normalized? input
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".normalize_id" do
|
18
|
+
it "normalize a dirty jav id to a clean one" do
|
19
|
+
assert_normalize_to '0222-star404avi', 'star404'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".normalized?" do
|
24
|
+
it "determines if a jav id is already normalized" do
|
25
|
+
assert_normazlied 'ebod096'
|
26
|
+
end
|
27
|
+
|
28
|
+
it "takes untrimmed jav id as unnormalized" do
|
29
|
+
refute Jorm.normalized?("pgd438\n")
|
30
|
+
refute Jorm.normalized?(" pgd438")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jorm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Whyme Lyu
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: main
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '5.2'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.2'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.3'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: minitest
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '5.0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '5.0'
|
78
|
+
description:
|
79
|
+
email:
|
80
|
+
- callme5long@gmail.com
|
81
|
+
executables:
|
82
|
+
- jorm
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files: []
|
85
|
+
files:
|
86
|
+
- README.md
|
87
|
+
- LICENSE.txt
|
88
|
+
- bin/jorm
|
89
|
+
- lib/jorm.rb
|
90
|
+
- lib/jorm/folder.rb
|
91
|
+
- lib/jorm/version.rb
|
92
|
+
- test/mt_helper.rb
|
93
|
+
- test/test_jorm.rb
|
94
|
+
homepage:
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ! '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
hash: 821699711764873484
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
hash: 821699711764873484
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 1.8.25
|
122
|
+
signing_key:
|
123
|
+
specification_version: 3
|
124
|
+
summary: Normalize JAV folder name
|
125
|
+
test_files:
|
126
|
+
- test/mt_helper.rb
|
127
|
+
- test/test_jorm.rb
|