Class: Trellor::WebTrellor
- Inherits:
-
Object
- Object
- Trellor::WebTrellor
- Defined in:
- lib/web_trellor.rb
Instance Method Summary collapse
- #archive_card(board_name, list_name, name) ⇒ Object
-
#board_names ⇒ Object
trellor interface queries ###############.
- #card_names(board_name, list_name) ⇒ Object
- #create_card(board_name, list_name, name, descript = nil) ⇒ Object
- #ensure_webapp_is_running(fork = true) ⇒ Object
- #get_version ⇒ Object
- #list_names(board_name) ⇒ Object
- #run_webapp(fork) ⇒ Object
Instance Method Details
#archive_card(board_name, list_name, name) ⇒ Object
76 77 78 79 |
# File 'lib/web_trellor.rb', line 76 def archive_card(board_name, list_name, name) data = {archive: true, board_name: board_name, list_name: list_name, card_name: name} JSON.parse(post_http('/boards', data).body) end |
#board_names ⇒ Object
trellor interface queries ###############
57 58 59 60 |
# File 'lib/web_trellor.rb', line 57 def board_names verbose_log('getting boards') unless @boards @boards = JSON.parse(get_http('/boards').body) end |
#card_names(board_name, list_name) ⇒ Object
66 67 68 69 |
# File 'lib/web_trellor.rb', line 66 def card_names(board_name, list_name) body = get_http("/boards", {board_name: board_name, list_name: list_name}).body JSON.parse(body) end |
#create_card(board_name, list_name, name, descript = nil) ⇒ Object
71 72 73 74 |
# File 'lib/web_trellor.rb', line 71 def create_card(board_name, list_name, name, descript=nil) data = {board_name: board_name, list_name: list_name, card_name: name, descript: descript} JSON.parse(post_http('/boards', data).body) end |
#ensure_webapp_is_running(fork = true) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/web_trellor.rb', line 15 def ensure_webapp_is_running(fork=true) v = get_version $stderr.puts "Warning: this version is #{VERSION} but the webapp version is #{v}. You may want to kill the older webapp." unless (!v or (v==VERSION)) fail unless v rescue puts "The background webapp wasn't running. Will run it now." verbose_log "The background webapp wasn't running. Will run it now." run_webapp(fork) end |
#get_version ⇒ Object
47 48 49 50 51 52 |
# File 'lib/web_trellor.rb', line 47 def get_version response = get_http('/version', nil, nil, false) response.body rescue nil end |
#list_names(board_name) ⇒ Object
62 63 64 |
# File 'lib/web_trellor.rb', line 62 def list_names(board_name) JSON.parse(get_http("/boards", {board_name: board_name}).body) end |
#run_webapp(fork) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/web_trellor.rb', line 25 def run_webapp(fork) path = Pathname.new(__FILE__).parent.parent cmd = "cd '#{path}' && ruby lib/webapi.rb &> /dev/null" verbose_log cmd unless fork $stderr.puts 'running ...' exec cmd exit 0 end job = fork do exec cmd end # give webapp time to run before returning (1..30).each do |n| verbose_log '.' sleep 0.1 ver = get_version return if ver and ver!='' end Process.detach(job) end |