-
-
Save stopthink/371522 to your computer and use it in GitHub Desktop.
| # Load format-specific drivers in the following order: | |
| $SourceParserImplementations = [] | |
| SourceParser::Upcoming | |
| SourceParser::Ical | |
| SourceParser::Hcal |
Nstamas you're incorrect about the signature of the class.
It needs to be defined as either:
class SourceParser::Upcoming
or
class SourceParser
class Upcoming
...
end
end
Or
module SourceParser
class Upcoming
...
end
end
Is SourceParser a class or a module? If it's a class and he's inheriting from SourceParser, he would use the "<" sig, if it's a module that the Upcoming, Ical, Hcal classes are included in, he'd use the "::" sig. Right?
for reference, I'm pulling code from http://github.com/calagator/calagator
I have cloned a copy of the Calagator project and am able to run it successfully on my machine. I've attempted to copy over just the components required for importing events, but clearly I've missed something, because it does not work in my project.
It appears that source_parser, and its siblings ical, upcoming, etc are classes.
source_parser.rb: http://github.com/calagator/calagator/blob/master/app/models/source_parser.rb
upcoming.rb: http://github.com/calagator/calagator/blob/master/app/models/source_parser/upcoming.rb
Try just moving source_parser.rb and the source_parser folder into the lib folder. The classes should then be included automatically by Rails.
Does SourceParser inherit from ActiveRecord::Base? I like to keep non-ActiveRecord objects out of app/models and put them in the lib folder. Rails will include all class files in this directory by default.
Assuming SourceParser does not inherit from ActiveRecord::Base, I would put all your class files in lib and llose the folder hierarchy. So you'd have lib/source_parser.rb, lib/upcoming.rb, etc. If Upcoming, Ical and Hcal are subclasses of SourceParser, their class signature needs to look like "class Upcoming < SourceParser".
Does that help?