class Ribose::CLI::Commands::Note

Public Instance Methods

add() click to toggle source
# File lib/ribose/cli/commands/note.rb, line 28
def add
  note = create_note(options)
  say("Note has been posted added! Id: " + note.id.to_s)
end
list() click to toggle source
# File lib/ribose/cli/commands/note.rb, line 9
def list
  say(build_output(list_notes(options), options))
end
remove() click to toggle source
# File lib/ribose/cli/commands/note.rb, line 50
def remove
  remove_note(options)
  say("The note has been removed!")
rescue
  say("Could not remove the specified note")
end
show() click to toggle source
# File lib/ribose/cli/commands/note.rb, line 18
def show
  note = Ribose::Wiki.fetch(options[:space_id], options[:note_id])
  say(build_resource_output(note, options))
end
update() click to toggle source
# File lib/ribose/cli/commands/note.rb, line 39
def update
  update_note(options)
  say("Your space note has been updated!")
rescue Ribose::UnprocessableEntity
  say("Something went wrong!, please check required attributes")
end

Private Instance Methods

create_note(attributes) click to toggle source
# File lib/ribose/cli/commands/note.rb, line 63
def create_note(attributes)
  Ribose::Wiki.create(
    attributes[:space_id],
    name: attributes[:title],
    tag_list: attributes[:tag_list] || "",
  )
end
list_notes(attributes) click to toggle source
# File lib/ribose/cli/commands/note.rb, line 59
def list_notes(attributes)
  @notes ||= Ribose::Wiki.all(attributes[:space_id])
end
remove_note(attributes) click to toggle source
# File lib/ribose/cli/commands/note.rb, line 80
def remove_note(attributes)
  Ribose::Wiki.delete(attributes[:space_id], attributes[:note_id])
end
table_field_names() click to toggle source
# File lib/ribose/cli/commands/note.rb, line 88
def table_field_names
  %w(id space_id name address version revision tag_list)
end
table_headers() click to toggle source
# File lib/ribose/cli/commands/note.rb, line 84
def table_headers
  ["ID", "Name", "Revisions"]
end
table_rows(notes) click to toggle source
# File lib/ribose/cli/commands/note.rb, line 92
def table_rows(notes)
  notes.map { |note| [note.id, note.name, note.revision] }
end
update_note(attributes) click to toggle source
# File lib/ribose/cli/commands/note.rb, line 71
def update_note(attributes)
  Ribose::Wiki.update(
    attributes[:space_id],
    attributes[:note_id],
    name: attributes[:title] || "",
    tag_list: attributes[:tag_list] || "",
  )
end