lib/wcc/contentful.rb in wcc-contentful-1.2.0 vs lib/wcc/contentful.rb in wcc-contentful-1.2.1

- old
+ new

@@ -46,11 +46,11 @@ end def logger return Rails.logger if defined?(Rails) - @logger ||= Logger.new(STDERR) + @logger ||= Logger.new($stderr) end end # Configures the WCC::Contentful gem to talk to a Contentful space. # This must be called first in your initializer, before #init! or accessing the @@ -80,11 +80,11 @@ raise InitializationError, 'Please first call WCC:Contentful.configure' if configuration.nil? raise InitializationError, 'Already Initialized' if @initialized if configuration.update_schema_file == :always || (configuration.update_schema_file == :if_possible && Services.instance.management_client) || - configuration.update_schema_file == :if_missing && !File.exist?(configuration.schema_file) + (configuration.update_schema_file == :if_missing && !File.exist?(configuration.schema_file)) begin downloader = WCC::Contentful::DownloadsSchema.new downloader.update! if configuration.update_schema_file == :always || downloader.needs_update? rescue WCC::Contentful::SimpleClient::ApiError => e @@ -94,13 +94,11 @@ end end content_types = begin - if File.exist?(configuration.schema_file) - JSON.parse(File.read(configuration.schema_file))['contentTypes'] - end + JSON.parse(File.read(configuration.schema_file))['contentTypes'] if File.exist?(configuration.schema_file) rescue JSON::ParserError WCC::Contentful.logger.warn("Schema file invalid, ignoring it: #{configuration.schema_file}") nil end @@ -117,11 +115,11 @@ WCC::Contentful.logger.warn("Unable to load content types from API - #{e.message}") end end unless content_types - raise InitializationError, 'Unable to load content types from schema file or API!' \ - ' Check your access token and space ID.' + raise InitializationError, 'Unable to load content types from schema file or API! ' \ + 'Check your access token and space ID.' end # Set the schema on the default WCC::Contentful::Model WCC::Contentful::Model.configure( configuration,