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.
Constant Summary collapse
- MIDDLEMAN_LOCAL_DATA_FOLDER =
Path where Middleman expects the local data to be stored
'data'
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
32 33 34 |
# File 'lib/contentful_middleman/commands/contentful.rb', line 32 def self.exit_on_failure? true end |
.source_root ⇒ Object
27 28 29 |
# File 'lib/contentful_middleman/commands/contentful.rb', line 27 def self.source_root ENV['MM_ROOT'] end |
Instance Method Details
#contentful ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/contentful_middleman/commands/contentful.rb', line 36 def contentful if contentful_instances.size > 0 ContentfulMiddleman::VersionHash.source_root = self.class.source_root ContentfulMiddleman::LocalData::Store.base_path = MIDDLEMAN_LOCAL_DATA_FOLDER ContentfulMiddleman::LocalData::File.thor = self hash_local_data_changed = contentful_instances.reduce(false) do |changes, instance| 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!' else raise Thor::Error.new "You need to activate the contentful extension in config.rb before you can import data from Contentful" end end |