Commit febfda55 authored by Florent Didier's avatar Florent Didier
Browse files

[dev] wiki_generator.rb: add update_files method

parent cf4077f8
......@@ -28,6 +28,13 @@ module MediawikiApi
res = get_conn.send(:get, '', params)
res.body
end
def update_file(filename, path, content_type, comment, ignorewarnings, text = nil)
file = Faraday::UploadIO.new(path, content_type)
action(:upload,
filename: filename, file: file, comment: comment, text: text,
ignorewarnings: ignorewarnings)
end
end
end
......
......@@ -47,6 +47,12 @@ class WikiGenerator
return content.gsub(/''<small>Generated from the Grid5000 APIs on .+<\/small>''/, '')
end
def update_files
@files.each { |file|
@mw_client.update_file(file['filename'], file['path'], file['content_type'], file['comment'], true)
}
end
#print generator content to stdout
def print()
puts @generated_content
......@@ -117,7 +123,8 @@ class WikiGenerator
generator.print
end
if (options[:update])
generator.update_page
generator.update_page if generator.instance_variable_get('@generated_content')
generator.update_files if generator.instance_variable_get('@files')
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment