scene-toolkit 0.1.0 → 0.1.1
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.
- data/README.rdoc +16 -0
- data/VERSION +1 -1
- data/lib/scene_toolkit/cache/releases.rb +2 -2
- data/lib/scene_toolkit/release.rb +14 -11
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -1,7 +1,23 @@
|
|
1
1
|
= Scene-Toolkit
|
2
2
|
|
3
|
+
== Description
|
4
|
+
|
3
5
|
Tool to assist scene MP3 library maintenance
|
4
6
|
|
7
|
+
== Summary
|
8
|
+
|
9
|
+
$ scene-toolkit
|
10
|
+
Commands
|
11
|
+
|
12
|
+
verify [directory] # Verify library or release. Executes all validations if none specified
|
13
|
+
-n/--name # Validate release name
|
14
|
+
-r/--required-files # Validate inclusion of required files
|
15
|
+
-c/--checksum # Validate release CRC-32 checksum
|
16
|
+
-d/--display-valid # Display valid releases too
|
17
|
+
-f/--flush-cache # Flush file modification cache
|
18
|
+
-m/--move-invalid-to=[STRING] # Move INVALID releases to specified folder
|
19
|
+
-M/--move-valid-to=[STRING] # Move VALID releases to specified folder
|
20
|
+
|
5
21
|
== Note on Patches/Pull Requests
|
6
22
|
|
7
23
|
* Fork the project.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -24,10 +24,10 @@ class SceneToolkit::Cache::Releases
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def errors(release)
|
27
|
+
def errors(release, validations = SceneToolkit::Release::VALIDATIONS)
|
28
28
|
@cache.transaction(true) do
|
29
29
|
if @cache[@cache_key].has_key?(release.path)
|
30
|
-
@cache[@cache_key][release.path][:errors]
|
30
|
+
@cache[@cache_key][release.path][:errors].reject{ |validation, errors| not validations.include?(validation) }
|
31
31
|
else
|
32
32
|
raise RuntimeError.new("Release not catched")
|
33
33
|
end
|
@@ -24,18 +24,21 @@ class SceneToolkit::Release
|
|
24
24
|
@path = path
|
25
25
|
@name = File.basename(path)
|
26
26
|
@uid = Digest::MD5.hexdigest(@name.downcase.gsub(/[^A-Z0-9]/i, ' ').gsub(/\s+/, ' '))
|
27
|
-
@errors =
|
27
|
+
@errors = {}
|
28
|
+
VALIDATIONS.each do |validation|
|
29
|
+
@errors[validation] = []
|
30
|
+
end
|
28
31
|
end
|
29
32
|
|
30
|
-
def valid?(
|
33
|
+
def valid?(validations = VALIDATIONS)
|
31
34
|
if @cache.releases.modified?(self)
|
32
35
|
@errors = []
|
33
|
-
|
36
|
+
validations.each do |validation|
|
34
37
|
send("valid_#{validation}?")
|
35
38
|
end
|
36
39
|
@cache.releases.store(self)
|
37
40
|
else
|
38
|
-
@errors = @cache.releases.errors(self)
|
41
|
+
@errors = @cache.releases.errors(self, validations)
|
39
42
|
end
|
40
43
|
@errors.none?
|
41
44
|
end
|
@@ -43,8 +46,8 @@ class SceneToolkit::Release
|
|
43
46
|
def valid_required_files?
|
44
47
|
REQUIRED_FILES.each do |ext|
|
45
48
|
file_count = send("#{ext}_files")
|
46
|
-
@errors << "No #{ext} found." if file_count.none?
|
47
|
-
@errors << "Multiple #{ext} found." if file_count.size > 1
|
49
|
+
@errors[:required_files] << "No #{ext} found." if file_count.none?
|
50
|
+
@errors[:required_files] << "Multiple #{ext} found." if file_count.size > 1
|
48
51
|
end
|
49
52
|
end
|
50
53
|
|
@@ -74,10 +77,10 @@ class SceneToolkit::Release
|
|
74
77
|
filename, checksum = match.captures
|
75
78
|
if files_to_check.has_key?(filename.downcase)
|
76
79
|
unless Zlib.crc32(File.read(files_to_check[filename.downcase])).eql?(checksum.hex)
|
77
|
-
@errors << "#{filename} is corrupted"
|
80
|
+
@errors[:checksum] << "#{filename} is corrupted"
|
78
81
|
end
|
79
82
|
else
|
80
|
-
@errors << "File #{filename} not found"
|
83
|
+
@errors[:checksum] << "File #{filename} not found"
|
81
84
|
end
|
82
85
|
matched_something = true
|
83
86
|
end
|
@@ -85,9 +88,9 @@ class SceneToolkit::Release
|
|
85
88
|
end
|
86
89
|
|
87
90
|
def valid_name?
|
88
|
-
@errors << "Release name is not a valid scene release name" unless @name =~ /^([A-Z0-9\-_.()&]+)\-(\d{4}|\d{3}x|\d{2}xx)\-([A-Z0-9_]+)$/i
|
89
|
-
@errors << "Release name is lowercased" if @name.eql?(@name.downcase)
|
90
|
-
@errors << "Release name is uppercased" if @name.eql?(@name.upcase)
|
91
|
+
@errors[:name] << "Release name is not a valid scene release name" unless @name =~ /^([A-Z0-9\-_.()&]+)\-(\d{4}|\d{3}x|\d{2}xx)\-([A-Z0-9_]+)$/i
|
92
|
+
@errors[:name] << "Release name is lowercased" if @name.eql?(@name.downcase)
|
93
|
+
@errors[:name] << "Release name is uppercased" if @name.eql?(@name.upcase)
|
91
94
|
end
|
92
95
|
end
|
93
96
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scene-toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "V\xC3\xADctor Mart\xC3\xADnez"
|