Class: Contentful::Exporter::Wordpress::Blog
- Inherits:
-
Object
- Object
- Contentful::Exporter::Wordpress::Blog
show all
- Defined in:
- lib/wordpress/blog.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(xml_document, settings) ⇒ Blog
Returns a new instance of Blog.
10
11
12
13
|
# File 'lib/wordpress/blog.rb', line 10
def initialize(xml_document, settings)
@xml = xml_document
@settings = settings
end
|
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
8
9
10
|
# File 'lib/wordpress/blog.rb', line 8
def settings
@settings
end
|
#xml ⇒ Object
Returns the value of attribute xml.
8
9
10
|
# File 'lib/wordpress/blog.rb', line 8
def xml
@xml
end
|
Instance Method Details
15
16
17
18
|
# File 'lib/wordpress/blog.rb', line 15
def
create_directory(settings.data_dir)
end
|
#create_directory(path) ⇒ Object
38
39
40
|
# File 'lib/wordpress/blog.rb', line 38
def create_directory(path)
FileUtils.mkdir_p(path) unless File.directory?(path)
end
|
#link_asset(asset) ⇒ Object
33
34
35
36
|
# File 'lib/wordpress/blog.rb', line 33
def link_asset(asset)
asset.keep_if { |key, _v| key if key == :id }
asset.merge!(type: 'File')
end
|
#link_entry(entry_or_entries) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/wordpress/blog.rb', line 20
def link_entry(entry_or_entries)
link = ->(entry) {
entry.keep_if { |key, _v| key if key == :id }
entry.merge!(type: 'Entry')
}
if entry_or_entries.is_a? Array
entry_or_entries.each(&link)
else
link.call(entry_or_entries)
end
end
|
#output_logger ⇒ Object
48
49
50
|
# File 'lib/wordpress/blog.rb', line 48
def output_logger
Logger.new(STDOUT)
end
|
#write_json_to_file(path, data) ⇒ Object
42
43
44
45
46
|
# File 'lib/wordpress/blog.rb', line 42
def write_json_to_file(path, data)
File.open(path, 'w') do |file|
file.write(JSON.pretty_generate(data))
end
end
|