Sha256: d1c632cd671e251f451393e3cbd2012babb0ce67a67a011d7aa48bf65fff6128
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
require "trello_flow/version" require "trello_flow/local_config" require "trello_flow/global_config" module TrelloFlow class Main def initialize(global_config = GlobalConfig.new, local_config = LocalConfig.new) Api::Base.configure(key: global_config.key, token: global_config.token) @local_config = local_config end def start(name) Cli.error "Your `trello_flow` version is out of date. Please run `gem update trello_flow`." unless Version.latest? card = create_or_pick_card(name) card.add_member(current_user) card.start Branch.from_card(user: current_user, card: card).checkout rescue Api::Error => error Cli.error(error.message) end def open Branch.current.open_trello(local_config) end def finish(options = {}) branch = Branch.current branch.push branch.open_pull_request(options) end def cleanup Cleanup.new(Branch.current.target).run end private attr_reader :local_config def board @_board ||= local_config.board end def create_or_pick_card(name) if name.to_s.start_with?("http") Api::Card.find_by_url(name) elsif name.present? create_new_card(name) else pick_existing_card end end def create_new_card(name) label = Table.pick board.labels, caption: "Add label:" card = board.lists.backlog.cards.create name: name card.add_label(label) if label card end def pick_existing_card Table.pick board.lists.backlog.cards end def current_user @_current_user ||= Api::Member.current end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trello_flow-3.8.0 | lib/trello_flow/main.rb |