tv_renamer 4.0.2 → 4.0.4
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 +4 -4
- data/lib/tv_renamer/renamer.rb +2 -157
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7196f271e558831bbc837c987d68fa24393cf70b
|
|
4
|
+
data.tar.gz: c61c41067e8f70762485bfe0e2953d4a76ed1c4c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ed9c50a4ef17a4196388f25844b20e11e6747fd0f95828fe1c74cc9158bb16bd94b9b3a2ae2aa5df946e5f1bc3c4842765174348eb1891e33606407e246f190c
|
|
7
|
+
data.tar.gz: 83a0462dfc98a575582307017a262858151395df957a10b699bfe4c20f12748861230d6bcd54a2aa15e132e411e864fe938e419c368524996275cffb2b5fcf60
|
data/lib/tv_renamer/renamer.rb
CHANGED
|
@@ -10,6 +10,8 @@ require 'cgi'
|
|
|
10
10
|
require 'fileutils'
|
|
11
11
|
require 'nokogiri'
|
|
12
12
|
|
|
13
|
+
require 'ini'
|
|
14
|
+
|
|
13
15
|
class VideoFile
|
|
14
16
|
SPLITS = [ ' ', '.' ]
|
|
15
17
|
|
|
@@ -487,160 +489,3 @@ def show_url(video)
|
|
|
487
489
|
end
|
|
488
490
|
|
|
489
491
|
end # class Renamer
|
|
490
|
-
|
|
491
|
-
# Ini class - read and write ini files
|
|
492
|
-
# Copyright (C) 2007 Jeena Paradies
|
|
493
|
-
# License: GPL
|
|
494
|
-
# Author: Jeena Paradies (info@jeenaparadies.net)
|
|
495
|
-
|
|
496
|
-
class Ini
|
|
497
|
-
|
|
498
|
-
# :inihash is a hash which holds all ini data
|
|
499
|
-
# :comment is a string which holds the comments on the top of the file
|
|
500
|
-
attr_accessor :inihash, :comment
|
|
501
|
-
|
|
502
|
-
# Creating a new Ini object
|
|
503
|
-
# +path+ is a path to the ini file
|
|
504
|
-
# +load+ if nil restores the data if possible
|
|
505
|
-
# if true restores the data, if not possible raises an error
|
|
506
|
-
# if false does not resotre the data
|
|
507
|
-
def initialize(path, load=nil)
|
|
508
|
-
@path = path
|
|
509
|
-
@inihash = {}
|
|
510
|
-
|
|
511
|
-
if load or ( load.nil? and FileTest.readable_real? @path )
|
|
512
|
-
restore()
|
|
513
|
-
end
|
|
514
|
-
end
|
|
515
|
-
|
|
516
|
-
# Retrive the ini data for the key +key+
|
|
517
|
-
def [](key)
|
|
518
|
-
@inihash[key]
|
|
519
|
-
end
|
|
520
|
-
|
|
521
|
-
# Set the ini data for the key +key+
|
|
522
|
-
def []=(key, value)
|
|
523
|
-
raise TypeError, "String expected" unless key.is_a? String
|
|
524
|
-
raise TypeError, "String or Hash expected" unless value.is_a? String or value.is_a? Hash
|
|
525
|
-
|
|
526
|
-
@inihash[key] = value
|
|
527
|
-
end
|
|
528
|
-
|
|
529
|
-
# Restores the data from file into the object
|
|
530
|
-
def restore()
|
|
531
|
-
@inihash = Ini.read_from_file(@path)
|
|
532
|
-
@comment = Ini.read_comment_from_file(@path)
|
|
533
|
-
end
|
|
534
|
-
|
|
535
|
-
# Store data from the object in the file
|
|
536
|
-
def update()
|
|
537
|
-
Ini.write_to_file(@path, @inihash, @comment)
|
|
538
|
-
end
|
|
539
|
-
|
|
540
|
-
# Reading data from file
|
|
541
|
-
# +path+ is a path to the ini file
|
|
542
|
-
# returns a hash which represents the data from the file
|
|
543
|
-
def Ini.read_from_file(path)
|
|
544
|
-
inihash = {}
|
|
545
|
-
headline = nil
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
IO.foreach(path) do |line|
|
|
549
|
-
|
|
550
|
-
line = line.strip.split(/#/)[0]
|
|
551
|
-
|
|
552
|
-
# if line is nil, just go to the next one
|
|
553
|
-
next if line.nil?
|
|
554
|
-
|
|
555
|
-
# read it only if the line doesn't begin with a "=" and is long enough
|
|
556
|
-
unless line.length < 2 and line[0,1] == "="
|
|
557
|
-
|
|
558
|
-
# it's a headline if the line begins with a "[" and ends with a "]"
|
|
559
|
-
if line[0,1] == "[" and line[line.length - 1, line.length] == "]"
|
|
560
|
-
|
|
561
|
-
# get rid of the [] and unnecessary spaces
|
|
562
|
-
headline = line[1, line.length - 2 ].strip
|
|
563
|
-
inihash[headline] = {}
|
|
564
|
-
else
|
|
565
|
-
|
|
566
|
-
key, value = line.split(/=/, 2)
|
|
567
|
-
|
|
568
|
-
key = key.strip unless key.nil?
|
|
569
|
-
value = value.strip unless value.nil?
|
|
570
|
-
|
|
571
|
-
unless headline.nil?
|
|
572
|
-
inihash[headline][key] = value
|
|
573
|
-
else
|
|
574
|
-
inihash[key] = value unless key.nil?
|
|
575
|
-
end
|
|
576
|
-
end
|
|
577
|
-
end
|
|
578
|
-
end
|
|
579
|
-
|
|
580
|
-
inihash
|
|
581
|
-
end
|
|
582
|
-
|
|
583
|
-
# Reading comments from file
|
|
584
|
-
# +path+ is a path to the ini file
|
|
585
|
-
# Returns a string with comments from the beginning of the
|
|
586
|
-
# ini file.
|
|
587
|
-
def Ini.read_comment_from_file(path)
|
|
588
|
-
comment = ""
|
|
589
|
-
|
|
590
|
-
IO.foreach(path) do |line|
|
|
591
|
-
line.strip!
|
|
592
|
-
next if line.nil?
|
|
593
|
-
|
|
594
|
-
next unless line[0,1] == "#"
|
|
595
|
-
|
|
596
|
-
comment << "#{line[1, line.length ].strip}\n"
|
|
597
|
-
end
|
|
598
|
-
|
|
599
|
-
comment
|
|
600
|
-
end
|
|
601
|
-
|
|
602
|
-
# Writing a ini hash into a file
|
|
603
|
-
# +path+ is a path to the ini file
|
|
604
|
-
# +inihash+ is a hash representing the ini File. Default is a empty hash.
|
|
605
|
-
# +comment+ is a string with comments which appear on the
|
|
606
|
-
# top of the file. Each line will get a "#" before.
|
|
607
|
-
# Default is no comment.
|
|
608
|
-
def Ini.write_to_file(path, inihash={}, comment=nil)
|
|
609
|
-
raise TypeError, "String expected" unless comment.is_a? String or comment.nil?
|
|
610
|
-
|
|
611
|
-
raise TypeError, "Hash expected" unless inihash.is_a? Hash
|
|
612
|
-
File.open(path, "w") { |file|
|
|
613
|
-
|
|
614
|
-
unless comment.nil?
|
|
615
|
-
comment.each do |line|
|
|
616
|
-
file << "# #{line}"
|
|
617
|
-
end
|
|
618
|
-
end
|
|
619
|
-
|
|
620
|
-
file << Ini.to_s(inihash)
|
|
621
|
-
}
|
|
622
|
-
end
|
|
623
|
-
|
|
624
|
-
# Turn a hash (up to 2 levels deepness) into a ini string
|
|
625
|
-
# +inihash+ is a hash representing the ini File. Default is a empty hash.
|
|
626
|
-
# Returns a string in the ini file format.
|
|
627
|
-
def Ini.to_s(inihash={})
|
|
628
|
-
str = ""
|
|
629
|
-
|
|
630
|
-
inihash.each do |key, value|
|
|
631
|
-
if value.is_a? Hash
|
|
632
|
-
str << "[#{key.to_s}]\n"
|
|
633
|
-
|
|
634
|
-
value.each do |under_key, under_value|
|
|
635
|
-
str << "#{under_key.to_s}=#{under_value.to_s unless under_value.nil?}\n"
|
|
636
|
-
end
|
|
637
|
-
|
|
638
|
-
else
|
|
639
|
-
str << "#{key.to_s}=#{value.to_s unless value2.nil?}\n"
|
|
640
|
-
end
|
|
641
|
-
end
|
|
642
|
-
|
|
643
|
-
str
|
|
644
|
-
end
|
|
645
|
-
|
|
646
|
-
end # end Ini
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tv_renamer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0.
|
|
4
|
+
version: 4.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kevin Adler
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-02-
|
|
11
|
+
date: 2015-02-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|
|
@@ -50,7 +50,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
50
50
|
requirements:
|
|
51
51
|
- - '>='
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '0'
|
|
53
|
+
version: '2.0'
|
|
54
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
55
|
requirements:
|
|
56
56
|
- - '>='
|