Class: Middleman::Cli::Contentful
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Middleman::Cli::Contentful
- Includes:
- Thor::Actions
- Defined in:
- lib/contentful_middleman/commands/contentful.rb
Overview
This class provides an “contentful” command for the middleman CLI.
Class Method Summary collapse
-
.exit_on_failure? ⇒ Boolean
Tell Thor to exit with a nonzero exit code on failure.
- .source_root ⇒ Object
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
Tell Thor to exit with a nonzero exit code on failure
29 30 31 |
# File 'lib/contentful_middleman/commands/contentful.rb', line 29 def self.exit_on_failure? true end |
.source_root ⇒ Object
24 25 26 |
# File 'lib/contentful_middleman/commands/contentful.rb', line 24 def self.source_root ENV['MM_ROOT'] end |
Instance Method Details
#contentful ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/contentful_middleman/commands/contentful.rb', line 33 def contentful raise Thor::Error.new "You need to activate the contentful extension in config.rb before you can import data from Contentful" if contentful_instances.empty? ContentfulMiddleman::VersionHash.source_root = self.class.source_root ContentfulMiddleman::LocalData::File.thor = self hash_local_data_changed = contentful_instances.reduce(false) do |changes, instance| ContentfulMiddleman::LocalData::Store.base_path = File.join( instance..base_path, instance..destination ) import_task = create_import_task(instance) import_task.run changes || import_task.changed_local_data? end Middleman::Cli::Build.new.build if hash_local_data_changed && [:rebuild] logger.info 'Contentful Import: Done!' end |