tisba/gst-kitchen

More GST-workflow specific stuff?

nerdinand opened this issue · 6 comments

episode.rb:8 looks like this:

/#{podcast.handle}(?<number>\d{3})/ =~ data["data"]["metadata"]["title"]

I don't quite understand what ?<number> means, I have never seen that kind of regex magic before. It seems that this should save the number-string to the number variable, however on my system this does not seem to work. I get an error on line 14 telling me that number is not defined. Could you please clarify?

Also, episode.rb:27 reads:

episode = self.new

But I think it should be

episode = self.new(podcast)

because I'm getting an error on line 66, saying podcast is nil.

This is a feature of ruby 1.9's regex engine[0].

When this fails for you, then maybe you are not running Ruby 1.9. I could rewrite it to be 1.8.7 compatible, but since Ruby 1.8.7 is going to reach its end of life and won't be supported by the ruby core team any longer[1] I don't think this is a good idea.

[0] http://www.ruby-doc.org/core-1.9.3/doc/re_rdoc.html (under Capturing)
[1] http://www.ruby-lang.org/en/news/2011/10/06/plans-for-1-8-7/

I just released 0.6.1 which should have fixed the issue with episode creation from auphonic (see a74f398). I also specified the required ruby version in the gemspec to be at least 1.9.3.

That regex still does not yield the right result. Yes, I am using Ruby 1.9.3. Consider the documentation for the Regexp class [0]:

A regexp interpolation, #{}, also disables the assignment.

Here is some code I tried in irb that illustrates the problem:

% irb
irb(main):001:0> title = "GC001 Casual Friday"
=> "GC001 Casual Friday"
irb(main):002:0> handle = "GC"
=> "GC"
irb(main):003:0> /#{handle}(?<number>\d{3})/ =~ title
=> 0
irb(main):004:0> number
NameError: undefined local variable or method number' for main:Object from (irb):4 from /Users/ferdi/.rbenv/versions/1.9.3-p362/bin/irb:12:in

'
irb(main):005:0> /GC(?<number>\d{3})/ =~ title
=> 0
irb(main):006:0> number
=> "001"

Can you confirm this?
I couldn't explain it if the code actually worked the way it is now.

[0] http://www.ruby-doc.org/core-1.9.3/Regexp.html#method-i-3D-7E

Uh shit, you are absolutely right! I assume I changed this stuff after we did our last episode, because this is obviously broken :)

@nerdinand it should be fixed (see https://github.com/tisba/gst-kitchen/blob/d8286a4b4858292e9e27a03d4c783ddcb1eda814/lib/gst-kitchen/episode.rb). I also started to add some tests, but since the coverage is still quite poor, I want to test the process manually myself.

Yes, that fixed it. Thank you!