Class: Gromit::Uploader
- Inherits:
-
Object
- Object
- Gromit::Uploader
- Defined in:
- lib/gromit/uploader.rb
Defined Under Namespace
Classes: Partay
Class Method Summary collapse
Class Method Details
.invoke ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/gromit/uploader.rb', line 12 def invoke = {} OptionParser.new do |opts| opts. = "Usage: uploader.rb [options]" opts.on('-s', '--source SOURCE_DIR', 'Source directory') do |source_dir| [:source_dir] = source_dir end end.parse! path = Pathname.new(.fetch(:source_dir, '')) unless path.exist? puts "Error: The source directory (-s or --source) doesn't exist or is not specified." exit 1 end sections = Gromit::MarkdownParser.process(path.to_s) sections.each do |section| puts "uploading: #{section[:file]} section: #{section[:section_title]}" Partay.post('/upsert', { headers: {"Content-Type" => "application/json"}, body: section.to_json }) end end |