Class: Calagator::Source::Importer
- Inherits:
-
Struct
- Object
- Struct
- Calagator::Source::Importer
- Defined in:
- app/models/calagator/source/importer.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
Returns the value of attribute events.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #failure_message ⇒ Object
- #import ⇒ Object
-
#initialize(params) ⇒ Importer
constructor
A new instance of Importer.
Constructor Details
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events
5 6 7 |
# File 'app/models/calagator/source/importer.rb', line 5 def events @events end |
#source ⇒ Object
Returns the value of attribute source
5 6 7 |
# File 'app/models/calagator/source/importer.rb', line 5 def source @source end |
Instance Method Details
#failure_message ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/models/calagator/source/importer.rb', line 30 def if events.nil? "Unable to import: #{source.errors..to_sentence}" else 'Unable to find any upcoming events to import from this source' end end |
#import ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/calagator/source/importer.rb', line 10 def import return unless source.valid? self.events = source.create_events! events.present? rescue Source::Parser::NotFound add_error 'No events found at remote site. Is the event identifier in the URL correct?' rescue Source::Parser::HttpAuthenticationRequiredError add_error "Couldn't import events, remote site requires authentication." rescue OpenURI::HTTPError add_error "Couldn't download events, remote site may be experiencing connectivity problems." rescue Errno::EHOSTUNREACH add_error "Couldn't connect to remote site." rescue SocketError add_error "Couldn't find IP address for remote site. Is the URL correct?" rescue Exception => e add_error "Unknown error: #{e}" end |