sindex 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +2 -1
- data/Rakefile +10 -0
- data/lib/sindex/errors.rb +10 -0
- data/lib/sindex/series.rb +56 -0
- data/lib/sindex/series_index.rb +268 -0
- data/lib/sindex/version.rb +1 -1
- data/lib/sindex.rb +3 -0
- data/res/seriesindex.dtd +14 -0
- data/sindex.gemspec +3 -0
- data/test/seriesindex_example.xml +76 -0
- data/test/test_helper.rb +8 -0
- data/test/test_series_index.rb +101 -0
- metadata +53 -5
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# Sindex
|
1
|
+
# Sindex [![Build Status](https://secure.travis-ci.org/pboehm/sindex.png)](http://travis-ci.org/pboehm/sindex)
|
2
|
+
|
2
3
|
|
3
4
|
Sindex is a tool and library that manages an index file, which contains the tv
|
4
5
|
series and episodes you have been watched. This index can be used by other
|
data/Rakefile
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
module Sindex
|
2
|
+
|
3
|
+
class Series
|
4
|
+
|
5
|
+
attr_accessor :episodes, :receive_updates
|
6
|
+
|
7
|
+
def initialize(receive_updates=true)
|
8
|
+
@episodes = {}
|
9
|
+
@receive_updates=receive_updates
|
10
|
+
end
|
11
|
+
|
12
|
+
# Public: determines if thos series contains episode in the
|
13
|
+
# supplied language
|
14
|
+
#
|
15
|
+
# :language - language-symbol :de/:en/...
|
16
|
+
def has_episodes_in_language?(language)
|
17
|
+
! @episodes[language].nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
# Public: Adds an existing episode to the list of episodes
|
21
|
+
#
|
22
|
+
# :filename - the filename to the episode
|
23
|
+
# :language - language in which the episode was watched :de/:en
|
24
|
+
#
|
25
|
+
def add_episode(filename, language=:de)
|
26
|
+
if id = SeriesIndex.extract_episode_identifier(filename)
|
27
|
+
|
28
|
+
if @episodes[language].nil?
|
29
|
+
@episodes[language] = {}
|
30
|
+
end
|
31
|
+
|
32
|
+
@episodes[language][id] = filename
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Public: Is Episode already watched
|
37
|
+
#
|
38
|
+
# :episode_data - data that hoölds the episode identifier
|
39
|
+
# :language - the language in which the episode is available :de/:en
|
40
|
+
def is_episode_existing?(episode_data, language=:de)
|
41
|
+
|
42
|
+
# if we are not interested in updates this method responds
|
43
|
+
# always with true
|
44
|
+
return true unless @receive_updates
|
45
|
+
|
46
|
+
if id = SeriesIndex.extract_episode_identifier(episode_data)
|
47
|
+
if not @episodes[language].nil?
|
48
|
+
return @episodes[language].has_key? id
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
false
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,268 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Sindex
|
4
|
+
|
5
|
+
class SeriesIndex
|
6
|
+
|
7
|
+
attr_reader :options, :series_data, :index_file
|
8
|
+
|
9
|
+
# Public: instantiate a new series_index
|
10
|
+
#
|
11
|
+
# options - Options (default: {})
|
12
|
+
# :index_file - Path to the index file, should be supplied
|
13
|
+
#
|
14
|
+
def initialize(options = {})
|
15
|
+
@options = {index_file: nil, }.merge(options)
|
16
|
+
|
17
|
+
@index_file = @options[:index_file]
|
18
|
+
@series_data = {}
|
19
|
+
@series_aliases = {}
|
20
|
+
|
21
|
+
if @index_file and File.file? @index_file
|
22
|
+
parse_file(@index_file)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
# Public: checks if there are entries in the index
|
28
|
+
#
|
29
|
+
# Returns true if there no entries loaded
|
30
|
+
def empty?
|
31
|
+
@series_data.length == 0
|
32
|
+
end
|
33
|
+
|
34
|
+
# Public: Check if a supplied episode is in the index
|
35
|
+
#
|
36
|
+
# series_name - Name of the series in the index
|
37
|
+
# episode_text - episode data
|
38
|
+
#
|
39
|
+
# Returns true if the episode is existing, false otherwise
|
40
|
+
def episode_existing?(series_name, episode_text, language=:de)
|
41
|
+
|
42
|
+
series_name = series_name_in_index(series_name)
|
43
|
+
|
44
|
+
if series_name and series = @series_data[series_name]
|
45
|
+
return series.is_episode_existing?(episode_text, language)
|
46
|
+
end
|
47
|
+
|
48
|
+
false
|
49
|
+
end
|
50
|
+
|
51
|
+
# Public: Check if the series is watched in this specified language
|
52
|
+
#
|
53
|
+
# series_name - Name of the series in the index
|
54
|
+
# language - either :de or :en
|
55
|
+
#
|
56
|
+
# Returns true if the series is watched in the supplied language
|
57
|
+
def is_series_in_this_language?(series_name, language=:de)
|
58
|
+
|
59
|
+
series_name = series_name_in_index(series_name)
|
60
|
+
|
61
|
+
if series_name and series = @series_data[series_name]
|
62
|
+
return series.has_episodes_in_language?(language)
|
63
|
+
end
|
64
|
+
|
65
|
+
false
|
66
|
+
end
|
67
|
+
|
68
|
+
# Public: Dumps the in-memory version of the index back to a xml file
|
69
|
+
#
|
70
|
+
# :filename - path to file in which the index should be dumped
|
71
|
+
def dump_index_to_file(filename)
|
72
|
+
|
73
|
+
tree = build_up_xml_tree_from_index
|
74
|
+
|
75
|
+
File.open(filename, "w") do |f|
|
76
|
+
f.write(tree);
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# Public: checks if the seriesname in the supplied data is in the
|
81
|
+
# index or an alias to a series
|
82
|
+
#
|
83
|
+
# episode_text - data that contains the episode information
|
84
|
+
# clean - does the episode_data contains already the series name
|
85
|
+
#
|
86
|
+
# Returns true if the series is in the index, false otherwise
|
87
|
+
def is_series_in_index?(episode_text, clean=false)
|
88
|
+
|
89
|
+
if not clean and series_name = SeriesIndex.extract_seriesname(episode_text)
|
90
|
+
episode_text = series_name
|
91
|
+
end
|
92
|
+
|
93
|
+
! series_name_in_index(episode_text).nil?
|
94
|
+
end
|
95
|
+
|
96
|
+
# Public: Adds episode to index
|
97
|
+
#
|
98
|
+
# :series_name
|
99
|
+
# :episode
|
100
|
+
# :language
|
101
|
+
def add_episode_to_index(series_name, episode, language=:de)
|
102
|
+
|
103
|
+
series_name = series_name_in_index(series_name)
|
104
|
+
|
105
|
+
if series_name and series = @series_data[series_name]
|
106
|
+
series.add_episode(episode, language)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
class << self
|
111
|
+
|
112
|
+
# Public: tries to extract the seriesname from supplied data
|
113
|
+
#
|
114
|
+
# data - data that holds the episode information
|
115
|
+
#
|
116
|
+
# Returns the seriesname or nil if there is no seriesname
|
117
|
+
def extract_seriesname(data)
|
118
|
+
if md = data.match(/(.+?)S\d+E\d+/)
|
119
|
+
return md[1].gsub(/\./, " ").strip
|
120
|
+
end
|
121
|
+
nil
|
122
|
+
end
|
123
|
+
|
124
|
+
# Public: tries to extract the episode identifier from the episode data
|
125
|
+
#
|
126
|
+
# data - data that holds the episode information
|
127
|
+
#
|
128
|
+
# Returns the identifier xx_xx or nil if there is no identifier
|
129
|
+
def extract_episode_identifier(data)
|
130
|
+
if md = data.match(/S(\d+)E(\d+)/i)
|
131
|
+
return "%s_%s" % [md[1].to_i, md[2].to_i]
|
132
|
+
end
|
133
|
+
nil
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
private
|
139
|
+
|
140
|
+
# Private: this methode places the information from index into a
|
141
|
+
# new XML tree
|
142
|
+
#
|
143
|
+
# Returns XML tree
|
144
|
+
def build_up_xml_tree_from_index
|
145
|
+
|
146
|
+
dtd_path = File.expand_path(
|
147
|
+
File.join(File.dirname(__FILE__), '../../res/seriesindex.dtd'))
|
148
|
+
|
149
|
+
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
150
|
+
xml.doc.create_internal_subset("seriesindex", nil, dtd_path)
|
151
|
+
|
152
|
+
xml.seriesindex {
|
153
|
+
@series_data.sort.map do |seriesname, data|
|
154
|
+
attrs = {:name => seriesname}
|
155
|
+
attrs[:receive_updates] = false unless data.receive_updates
|
156
|
+
|
157
|
+
xml.series(attrs) {
|
158
|
+
|
159
|
+
# write alias definition if there are any
|
160
|
+
@series_aliases.select { |al,re| re == seriesname }.each do |_alias,real|
|
161
|
+
xml.alias(:to => _alias)
|
162
|
+
end
|
163
|
+
|
164
|
+
# write the different episodes
|
165
|
+
data.episodes.each do |language, episodes|
|
166
|
+
xml.episodes(:lang => language) {
|
167
|
+
episodes.each do |episode_id, filename|
|
168
|
+
xml.episode(:name => filename)
|
169
|
+
end
|
170
|
+
}
|
171
|
+
end
|
172
|
+
}
|
173
|
+
end
|
174
|
+
}
|
175
|
+
end
|
176
|
+
|
177
|
+
builder.to_xml
|
178
|
+
end
|
179
|
+
|
180
|
+
# Internal: finds the seriesname for the supplied name in index
|
181
|
+
#
|
182
|
+
# It is used to apply an alias for series and finds the real series name
|
183
|
+
#
|
184
|
+
# Returns the seriesname in index or nil if it does not exist
|
185
|
+
def series_name_in_index(name)
|
186
|
+
|
187
|
+
@series_data.each do |key, val|
|
188
|
+
if key.match(/#{name}/i)
|
189
|
+
return key
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
@series_aliases.each do |key, val|
|
194
|
+
if key.match(/#{name}/i)
|
195
|
+
return val
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
nil
|
200
|
+
end
|
201
|
+
|
202
|
+
# Internal: parse this file to a hash indexed by seriesname
|
203
|
+
#
|
204
|
+
# file - path to the xml file
|
205
|
+
#
|
206
|
+
def parse_file(file)
|
207
|
+
|
208
|
+
doc = open_xml_file(file)
|
209
|
+
|
210
|
+
doc.css("seriesindex > series").each do |series|
|
211
|
+
|
212
|
+
series_name = series[:name]
|
213
|
+
next unless series_name and series_name.match(/\w+/)
|
214
|
+
|
215
|
+
s = Series.new()
|
216
|
+
|
217
|
+
s.receive_updates = false if series[:receive_updates].match(/false/i)
|
218
|
+
|
219
|
+
series.css('episodes').each do |episodes|
|
220
|
+
language = episodes['lang'].match(/de/) ? :de : :en
|
221
|
+
|
222
|
+
episodes.css('episode').each do |episode|
|
223
|
+
episode['name'] || next
|
224
|
+
|
225
|
+
s.add_episode(episode['name'], language)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
@series_data[series_name] = s
|
230
|
+
|
231
|
+
# apply aliases
|
232
|
+
series.css("alias").each do |series_alias|
|
233
|
+
if series_alias['to'] and series_alias['to'].match(/\w+/)
|
234
|
+
alias_name = series_alias['to']
|
235
|
+
@series_aliases[alias_name] = series_name
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
# Internal: wrapper around opening a xml file in Nokogiri with
|
243
|
+
# external DTD definition
|
244
|
+
#
|
245
|
+
# file - path to xml file
|
246
|
+
#
|
247
|
+
# returns Nokogiri XML Document
|
248
|
+
def open_xml_file(file)
|
249
|
+
options = Nokogiri::XML::ParseOptions::DEFAULT_XML |
|
250
|
+
Nokogiri::XML::ParseOptions::DTDLOAD
|
251
|
+
|
252
|
+
doc = Nokogiri::XML::Document.parse(File.read(file), nil, nil, options)
|
253
|
+
doc.external_subset || raise(XmlDTDError, "DTD could not be processed")
|
254
|
+
|
255
|
+
errors = doc.external_subset.validate(doc)
|
256
|
+
|
257
|
+
if not errors.empty?
|
258
|
+
error = XmlMalformedError.new
|
259
|
+
error.errors = errors
|
260
|
+
raise error
|
261
|
+
end
|
262
|
+
|
263
|
+
doc
|
264
|
+
end
|
265
|
+
|
266
|
+
end
|
267
|
+
|
268
|
+
end
|
data/lib/sindex/version.rb
CHANGED
data/lib/sindex.rb
CHANGED
data/res/seriesindex.dtd
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
<!ELEMENT seriesindex (series+)>
|
2
|
+
|
3
|
+
<!ELEMENT series(episodes|alias)*>
|
4
|
+
<!ATTLIST series name CDATA #REQUIRED>
|
5
|
+
<!ATTLIST series receive_updates (true|false) "true">
|
6
|
+
|
7
|
+
<!ELEMENT episodes(episode*)>
|
8
|
+
<!ATTLIST episodes lang (de|en|fr) "de">
|
9
|
+
|
10
|
+
<!ELEMENT episode EMPTY>
|
11
|
+
<!ATTLIST episode name CDATA #REQUIRED>
|
12
|
+
|
13
|
+
<!ELEMENT alias EMPTY>
|
14
|
+
<!ATTLIST alias to CDATA #REQUIRED>
|
data/sindex.gemspec
CHANGED
@@ -16,4 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_runtime_dependency(%q<nokogiri>, [">= 1.5"])
|
21
|
+
gem.add_runtime_dependency(%q<hashconfig>, [">= 0.0.1"])
|
19
22
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE seriesindex SYSTEM "res/seriesindex.dtd">
|
3
|
+
|
4
|
+
<seriesindex>
|
5
|
+
<series name="Community">
|
6
|
+
<alias to="Comm" />
|
7
|
+
<alias to="unity" />
|
8
|
+
<episodes>
|
9
|
+
<episode name="S01E01 - Zurück aufs College.avi" />
|
10
|
+
<episode name="S01E02 - Grundkurs Spanisch.avi" />
|
11
|
+
<episode name="S01E03 - Carpe Diem.avi" />
|
12
|
+
<episode name="S01E04 - Bitte warten.avi" />
|
13
|
+
<episode name="S01E05 - Prozess im Schwimmbad.avi" />
|
14
|
+
<episode name="S01E06 - Toiletten Talk.avi" />
|
15
|
+
<episode name="S01E07 - Mexanisches Halloween.avi" />
|
16
|
+
<episode name="S01E08 - Picknick unter Sternen.avi" />
|
17
|
+
<episode name="S01E09 - Der Mensch ist gut.avi" />
|
18
|
+
<episode name="S01E10 - Green Day für Arme.avi" />
|
19
|
+
<episode name="S01E11 - Das P Wort.avi" />
|
20
|
+
<episode name="S01E12 - Die Weihnachtsschlacht.avi" />
|
21
|
+
<episode name="S01E13 - Zweite Wahl.avi" />
|
22
|
+
<episode name="S01E14 - Echte Männer tanzen nicht.avi" />
|
23
|
+
<episode name="S01E15 - Jeder mit jedem.avi" />
|
24
|
+
<episode name="S01E16 - Trunken am Telefon.avi" />
|
25
|
+
<episode name="S01E17 - Billard ohne.mkv" />
|
26
|
+
<episode name="S01E18 - Familientag.mkv" />
|
27
|
+
<episode name="S01E19 - Die Parkplatzsegler.mkv" />
|
28
|
+
<episode name="S01E20 - Die Spassbremse.mkv" />
|
29
|
+
</episodes>
|
30
|
+
</series>
|
31
|
+
<series name="Shameless US">
|
32
|
+
<episodes lang="de">
|
33
|
+
<episode name="S01E01 - Pilot.avi" />
|
34
|
+
<episode name="S01E02 - Frank The Plank.avi" />
|
35
|
+
<episode name="S01E03 - Der Scheck heiligt die Mittel.avi" />
|
36
|
+
<episode name="S01E04 - Nur mal Spielen.avi" />
|
37
|
+
<episode name="S01E05 - Drei Freunde.avi" />
|
38
|
+
<episode name="S01E06 - Killer Carl.avi" />
|
39
|
+
<episode name="S01E07 - Frank Gallagher Loving Husband Devoted Father.avi" />
|
40
|
+
<episode name="S01E08 - Katerstimmung.avi" />
|
41
|
+
</episodes>
|
42
|
+
<episodes lang="en">
|
43
|
+
<episode name="S01E01 - Pilot.avi" />
|
44
|
+
<episode name="S01E02 - Frank The Plank.avi" />
|
45
|
+
<episode name="S01E03 - Der Scheck heiligt die Mittel.avi" />
|
46
|
+
<episode name="S01E04 - Nur mal Spielen.avi" />
|
47
|
+
<episode name="S01E05 - Drei Freunde.avi" />
|
48
|
+
<episode name="S01E06 - Killer Carl.avi" />
|
49
|
+
<episode name="S01E07 - Frank Gallagher Loving Husband Devoted Father.avi" />
|
50
|
+
<episode name="S01E08 - Katerstimmung.avi" />
|
51
|
+
<episode name="S01E09 - But At Last Came A Knock.avi" />
|
52
|
+
<episode name="S01E10 - Auf Oma ist verlass.avi" />
|
53
|
+
<episode name="S01E11 - Daddys Girl.avi" />
|
54
|
+
<episode name="S01E12 - Vater Frank voller Gnade.avi" />
|
55
|
+
<episode name="S02E01 - Summertime.avi" />
|
56
|
+
<episode name="S02E02 - Summer Loving.avi" />
|
57
|
+
<episode name="S02E03 - Ill Light A Candle For You Every Day.avi" />
|
58
|
+
<episode name="S02E04 - A Beautiful Mess.avi" />
|
59
|
+
<episode name="S02E05 - Fathers Day.avi" />
|
60
|
+
<episode name="S02E06 - Can I Have A Mother.avi" />
|
61
|
+
<episode name="S02E07 - A Bottle of Jean Nate.avi" />
|
62
|
+
<episode name="S02E08 - Parenthood.avi" />
|
63
|
+
<episode name="S02E09 - Hurricane Monica.avi" />
|
64
|
+
<episode name="S02E10 - A Great Cause.mkv" />
|
65
|
+
<episode name="S02E11 - Just Like The Pilgrims Intended.mkv" />
|
66
|
+
</episodes>
|
67
|
+
</series>
|
68
|
+
<series name="Prison Break" receive_updates="false">
|
69
|
+
<episodes>
|
70
|
+
<episode name="S01E01 - Zurück aufs College.avi" />
|
71
|
+
<episode name="S01E02 - Grundkurs Spanisch.avi" />
|
72
|
+
<episode name="S01E03 - Carpe Diem.avi" />
|
73
|
+
<episode name="S01E04 - Bitte warten.avi" />
|
74
|
+
</episodes>
|
75
|
+
</series>
|
76
|
+
</seriesindex>
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
class TestIndex < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
index_file = File.dirname(__FILE__) + '/seriesindex_example.xml'
|
9
|
+
|
10
|
+
@tmp_directory = '/tmp/'
|
11
|
+
|
12
|
+
@series_index = Sindex::SeriesIndex.new(index_file: index_file)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_instantiating
|
16
|
+
index = Sindex::SeriesIndex.new()
|
17
|
+
|
18
|
+
assert_instance_of Sindex::SeriesIndex, index
|
19
|
+
assert_instance_of Hash, index.series_data
|
20
|
+
assert_equal index.empty?, true
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_parsing_a_valid_series_index
|
24
|
+
assert_not_nil @series_index.series_data['Community']
|
25
|
+
|
26
|
+
series = @series_index.series_data['Community']
|
27
|
+
assert_equal series.has_episodes_in_language?(:de), true
|
28
|
+
assert_not_nil series.episodes[:de]['1_1']
|
29
|
+
assert_nil series.episodes[:de]['11_11']
|
30
|
+
|
31
|
+
series = @series_index.series_data['Shameless US']
|
32
|
+
assert_equal series.has_episodes_in_language?(:de), true
|
33
|
+
assert_equal series.has_episodes_in_language?(:en), true
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_that_series_aliases_take_place
|
37
|
+
assert_equal @series_index.is_series_in_index?("Comm", true), true
|
38
|
+
assert_equal @series_index.is_series_in_index?("unity", true), true
|
39
|
+
assert_equal @series_index.is_series_in_index?("NoCommunity", true), false
|
40
|
+
|
41
|
+
assert_equal @series_index.is_series_in_index?("shameless uS", true), true
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_series_is_watched_in_a_specific_language
|
45
|
+
assert_equal @series_index.is_series_in_this_language?("Community", :de), true
|
46
|
+
assert_equal @series_index.is_series_in_this_language?("Community", :en), false
|
47
|
+
|
48
|
+
assert_equal @series_index.is_series_in_this_language?("Shameless US", :de), true
|
49
|
+
assert_equal @series_index.is_series_in_this_language?("Shameless US", :en), true
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_check_for_episode_existance
|
53
|
+
assert_equal true, @series_index.episode_existing?("Shameless US",
|
54
|
+
"Shameless.US.S01E01.Just.Like.The.Pilgrims.Intended.German")
|
55
|
+
|
56
|
+
assert_equal false, @series_index.episode_existing?("Shameless US",
|
57
|
+
"Shameless.US.S01E09.Just.Like.The.Pilgrims.Intended.German")
|
58
|
+
|
59
|
+
assert_equal true, @series_index.episode_existing?("Shameless US",
|
60
|
+
"Shameless.US.S01E09.Just.Like.The.Pilgrims.Intended.German", :en)
|
61
|
+
|
62
|
+
assert_equal true, @series_index.episode_existing?("Community",
|
63
|
+
"Community.S01E01.Bankgeheimnis.DL.German.HDTV.XviD-GDR")
|
64
|
+
|
65
|
+
assert_equal false, @series_index.episode_existing?("Community",
|
66
|
+
"Community.S01E31.Bankgeheimnis.DL.German.HDTV.XviD-GDR")
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_that_an_index_can_be_dumped_right
|
70
|
+
filename = @tmp_directory + 'dumped_index.xml'
|
71
|
+
@series_index.dump_index_to_file(filename)
|
72
|
+
|
73
|
+
index = Sindex::SeriesIndex.new(index_file: filename)
|
74
|
+
assert_equal index.is_series_in_index?("Community", true), true
|
75
|
+
|
76
|
+
assert_equal false, index.episode_existing?("Shameless US",
|
77
|
+
"Shameless.US.S01E09.Just.Like.The.Pilgrims.Intended.German")
|
78
|
+
|
79
|
+
assert_equal true, index.episode_existing?("Shameless US",
|
80
|
+
"Shameless.US.S01E09.Just.Like.The.Pilgrims.Intended.German", :en)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_that_the_receive_updates_flag_is_used
|
84
|
+
assert_equal @series_index.series_data["Prison Break"].receive_updates, false
|
85
|
+
|
86
|
+
# when the receive_updates flag is set to false
|
87
|
+
# :episode_existing? returns always true
|
88
|
+
assert_equal true, @series_index.episode_existing?("Prison Break",
|
89
|
+
"Prison.Break.S01E31.Bankgeheimnis.DL.German.HDTV.XviD-GDR")
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_that_you_can_add_new_episodes_to_the_index
|
93
|
+
assert_equal @series_index.episode_existing?("Shameless US",
|
94
|
+
"Shameless.US.S01E09.German"), false
|
95
|
+
|
96
|
+
@series_index.add_episode_to_index("Shameless US", "S01E09 - Episode.mkv")
|
97
|
+
|
98
|
+
assert_equal @series_index.episode_existing?("Shameless US",
|
99
|
+
"Shameless.US.S01E09.German"), true
|
100
|
+
end
|
101
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sindex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
13
|
-
dependencies:
|
12
|
+
date: 2012-10-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.5'
|
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: '1.5'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: hashconfig
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.0.1
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.0.1
|
14
46
|
description: Tool and library that manages the episodes you have seen in different
|
15
47
|
tv series
|
16
48
|
email:
|
@@ -20,13 +52,21 @@ extensions: []
|
|
20
52
|
extra_rdoc_files: []
|
21
53
|
files:
|
22
54
|
- .gitignore
|
55
|
+
- .travis.yml
|
23
56
|
- Gemfile
|
24
57
|
- LICENSE.txt
|
25
58
|
- README.md
|
26
59
|
- Rakefile
|
27
60
|
- lib/sindex.rb
|
61
|
+
- lib/sindex/errors.rb
|
62
|
+
- lib/sindex/series.rb
|
63
|
+
- lib/sindex/series_index.rb
|
28
64
|
- lib/sindex/version.rb
|
65
|
+
- res/seriesindex.dtd
|
29
66
|
- sindex.gemspec
|
67
|
+
- test/seriesindex_example.xml
|
68
|
+
- test/test_helper.rb
|
69
|
+
- test/test_series_index.rb
|
30
70
|
homepage: https://github.com/pboehm/sindex
|
31
71
|
licenses: []
|
32
72
|
post_install_message:
|
@@ -39,17 +79,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
39
79
|
- - ! '>='
|
40
80
|
- !ruby/object:Gem::Version
|
41
81
|
version: '0'
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
hash: 2420045716595700599
|
42
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
86
|
none: false
|
44
87
|
requirements:
|
45
88
|
- - ! '>='
|
46
89
|
- !ruby/object:Gem::Version
|
47
90
|
version: '0'
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
hash: 2420045716595700599
|
48
94
|
requirements: []
|
49
95
|
rubyforge_project:
|
50
96
|
rubygems_version: 1.8.24
|
51
97
|
signing_key:
|
52
98
|
specification_version: 3
|
53
99
|
summary: Series-Index that manages your watched episodes
|
54
|
-
test_files:
|
55
|
-
|
100
|
+
test_files:
|
101
|
+
- test/seriesindex_example.xml
|
102
|
+
- test/test_helper.rb
|
103
|
+
- test/test_series_index.rb
|