Class: Jekyll::Contentful::BaseDataExporter
- Inherits:
-
Object
- Object
- Jekyll::Contentful::BaseDataExporter
- Defined in:
- lib/jekyll-contentful-data-import/base_data_exporter.rb
Overview
Base Data Exporter Class
Generic Data Exporter Implementation
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #base_directory ⇒ Object
- #destination_directory ⇒ Object
-
#initialize(name, entries, config = {}) ⇒ BaseDataExporter
constructor
A new instance of BaseDataExporter.
- #run ⇒ Object
- #setup_directory(directory) ⇒ Object
Constructor Details
#initialize(name, entries, config = {}) ⇒ BaseDataExporter
Returns a new instance of BaseDataExporter.
11 12 13 14 15 |
# File 'lib/jekyll-contentful-data-import/base_data_exporter.rb', line 11 def initialize(name, entries, config = {}) @name = name @entries = entries @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/jekyll-contentful-data-import/base_data_exporter.rb', line 9 def config @config end |
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
9 10 11 |
# File 'lib/jekyll-contentful-data-import/base_data_exporter.rb', line 9 def entries @entries end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/jekyll-contentful-data-import/base_data_exporter.rb', line 9 def name @name end |
Instance Method Details
#base_directory ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jekyll-contentful-data-import/base_data_exporter.rb', line 21 def base_directory directory = File.(Dir.pwd) if config.key?('base_path') directory = File.join( directory, config['base_path'] ) end directory end |
#destination_directory ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/jekyll-contentful-data-import/base_data_exporter.rb', line 33 def destination_directory destination_dir = File.join( base_directory, data_folder, contentful_folder, spaces_folder ) if config.key?('destination') destination_dir = File.join( base_directory, data_folder, config['destination'] ) end destination_dir end |
#run ⇒ Object
17 18 19 |
# File 'lib/jekyll-contentful-data-import/base_data_exporter.rb', line 17 def run raise 'must implement' end |
#setup_directory(directory) ⇒ Object
47 48 49 |
# File 'lib/jekyll-contentful-data-import/base_data_exporter.rb', line 47 def setup_directory(directory) FileUtils.mkdir_p(directory) end |