lib/plugin/serienjunkies_feed.rb in serienrenamer-0.0.1 vs lib/plugin/serienjunkies_feed.rb in serienrenamer-0.0.2

- old
+ new

@@ -20,11 +20,11 @@ # # if this is the first call to this method, it builds up # a hash with all series and existing episodes, which can # be used by all future method calls # - def self.generate_episode_information(episode) + def self.generate_episode_information(episode, debug=false) raise ArgumentError, "Serienrenamer::Episode instance needed" unless episode.is_a?(Serienrenamer::Episode) unless defined? @feed_data @@ -64,10 +64,11 @@ matched_episodes = [] name_words = episode.series.split(/ /) word_splitted = false while ! name_words.empty? + p name_words if debug pattern = name_words.join('.*') matched_episodes = matched_definitions.grep(/#{pattern}.*S\d+E\d+/i) break if ! matched_episodes.empty? @@ -75,9 +76,13 @@ if name_words.length == 1 && ! word_splitted name_words = pattern.split(//) word_splitted = true next end + + # if last word was splitted and does not match than break + # and return empty resultset + break if word_splitted name_words.delete_at(0) end return matched_episodes