trellor 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a75332839fc3f9a73606e8bc3edbe10a0df2e72
4
- data.tar.gz: 99ea0ab3625ef2894cbdb20ec27368072de0b4ce
3
+ metadata.gz: 85d97d017e9e202db49b8a9a4ec8ff05472fc3e0
4
+ data.tar.gz: 7de26825b22aa66f3086d983802cf4186301048d
5
5
  SHA512:
6
- metadata.gz: e49e48215f237b10f0e6c9a2f2410d72dabccd96b656139c864694365009a4337b825818090c736243738b2a6def32c12f81d0959abd00bccdf2977facce1dce
7
- data.tar.gz: 5344faf45db12a13166d019b51b2ec72f29fbd0e3fc82325d18991a0724a59f6d0f2bf7e71bdf5e9bf1e52d0ab39df730b94c4128b85fb52a4d37817c526851e
6
+ metadata.gz: 737f9fc421e8d2af416001014b368d2288a6583f644177c2fbf7e71fa5b4d2e3fb326f39e294f98e2fbf1a8e8c0765f511ccd3860c8da8f3daf7c9dfeb724330
7
+ data.tar.gz: 1ffb79c6a4f311dd524ebb1b8b30842d67927eb7fe59be2be436762704a437073a30fe201039e03c19b9da97cd3e14d7edfa13ee4b1ed484fc940228dd8ca6d8
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Trellor
2
2
 
3
- Gem to read and write to Trello, plus a terminal interface.
3
+ Terminal interface to Trello.
4
4
 
5
5
  ## Installation
6
6
 
data/lib/cli.rb CHANGED
@@ -15,11 +15,11 @@ module Trellor
15
15
  end
16
16
 
17
17
  if webapi?
18
- puts 'webapi'
19
- require_relative 'webapi'
20
- run TrellorWebapi
21
- puts 'done?'
22
- sleep 10
18
+ require_relative 'web_trellor'
19
+ web = WebTrellor.new
20
+ web.be_verbose = true if @opts[:verbose]
21
+ web.ensure_webapp_is_running
22
+ exit 0
23
23
  end
24
24
 
25
25
  if cache?
@@ -42,6 +42,7 @@ module Trellor
42
42
  verbose_log('using webapi')
43
43
  require_relative 'web_trellor'
44
44
  web = WebTrellor.new
45
+ web.be_verbose = true if @opts[:verbose]
45
46
  web.ensure_webapp_is_running
46
47
  web
47
48
  end
data/lib/trellor.rb CHANGED
@@ -52,7 +52,6 @@ module Trellor
52
52
  card.name = name
53
53
  card.desc = descript if descript
54
54
  card.save
55
- # card_names(board_name, list_name)
56
55
  end
57
56
  def archive_card(board_name, list_name, name)
58
57
  card = find_card(board_name, list_name, name)
@@ -74,17 +73,15 @@ module Trellor
74
73
  def board(name)
75
74
  boards # to get verbose log ordering correct
76
75
  verbose_log('getting board', name)
77
- name = name.downcase
78
- boards.detect{ |board| board.name.downcase.start_with?(name) }
76
+ name = Regexp.new(name, Regexp::IGNORECASE)
77
+ boards.detect{ |board| name.match(board.name) }
79
78
  end
80
79
 
81
80
  def list(board_name, list_name)
82
81
  this_board = board(board_name)
83
82
  verbose_log(' getting list', board_name, list_name)
84
- list_name = list_name.downcase
85
- this_board.lists.detect do |list|
86
- list.name.downcase.start_with?(list_name)
87
- end
83
+ name = Regexp.new(list_name, Regexp::IGNORECASE)
84
+ this_board.lists.detect{ |list| name.match(list.name) }
88
85
  end
89
86
 
90
87
  def cards(board_name, list_name)
@@ -1,3 +1,3 @@
1
1
  module Trellor
2
- VERSION = "2.0.2"
2
+ VERSION = "2.0.3"
3
3
  end
data/lib/web_trellor.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'trello'
4
4
  require 'net/http'
5
5
  require 'pathname'
6
+ require 'addressable/uri'
6
7
  require_relative "trellor/version"
7
8
 
8
9
  module Trellor
@@ -15,38 +16,45 @@ module Trellor
15
16
  fail unless v
16
17
  rescue
17
18
  puts "The background webapp wasn't running. Will run it now."
19
+ verbose_log "The background webapp wasn't running. Will run it now."
18
20
  run_webapp
19
21
  end
20
22
 
21
23
  def run_webapp
22
24
  path = Pathname.new(__FILE__).parent.parent
23
25
  cmd = "cd '#{path}' && ruby lib/webapi.rb &> /dev/null"
26
+ verbose_log cmd
24
27
  job = fork do
25
28
  exec cmd
26
29
  end
27
30
  # give webapp time to run before returning
28
- (1..15).each do |n|
31
+ (1..30).each do |n|
32
+ verbose_log '.'
29
33
  sleep 0.1
30
- return if get_version
34
+ ver = get_version
35
+ return if ver and ver!=''
31
36
  end
32
37
  Process.detach(job)
33
38
  end
34
39
 
35
40
  def get_version
36
- response = get_http('/version', nil, false)
41
+ response = get_http('/version', nil, nil, false)
37
42
  response.body
38
43
  rescue
39
44
  nil
40
45
  end
41
46
 
42
- def get_http(url, timeout=nil, show_error=true)
43
- uri = URI("#{site}#{url}")
47
+ def get_http(url, data=nil, timeout=nil, show_error=true)
48
+ uri = Addressable::URI.parse("#{site}#{url}")
44
49
  http = Net::HTTP.new uri.host, uri.port
45
50
  http.open_timeout = default_open_timeout
46
51
  http.read_timeout = timeout || default_read_timeout
47
52
  request = Net::HTTP::Get.new(uri.request_uri)
48
53
  # request.basic_auth 'trellor', password if password
49
- http.request(request)
54
+ request.set_form_data data if data
55
+ response = http.request(request)
56
+ verbose_log response.code, response.body
57
+ response
50
58
  rescue Exception => e
51
59
  $stderr.puts "ERROR in get_http(#{url})" if show_error
52
60
  raise e
@@ -65,7 +73,9 @@ module Trellor
65
73
  # request.basic_auth 'trellor', password if password
66
74
 
67
75
  request.set_form_data data
68
- http.request(request)
76
+ response = http.request(request)
77
+ verbose_log response.code, response.body
78
+ response
69
79
  rescue Exception => e
70
80
  $stderr.puts "ERROR in post_http(#{url})"
71
81
  raise e
@@ -102,11 +112,11 @@ module Trellor
102
112
  end
103
113
 
104
114
  def list_names(board_name)
105
- JSON.parse(get_http("/boards/#{board_name}/lists").body)
115
+ JSON.parse(get_http("/boards", {board_name: board_name}).body)
106
116
  end
107
117
 
108
118
  def card_names(board_name, list_name)
109
- JSON.parse(get_http("/boards/#{board_name}/lists/#{list_name}/cards").body)
119
+ JSON.parse(get_http("/boards", {board_name: board_name, list_name: list_name}).body)
110
120
  end
111
121
 
112
122
  def create_card(board_name, list_name, name, descript=nil)
data/lib/webapi.rb CHANGED
@@ -41,23 +41,16 @@ get '/version' do
41
41
  end
42
42
 
43
43
  get '/boards' do
44
- boards = trellor.board_names
45
- boards.to_json
46
- end
47
-
48
- get '/boards/:board_name/lists' do |board_name|
49
- lists = trellor.list_names(board_name)
50
- lists.to_json
51
- end
52
-
53
- get '/boards/:board_name/lists/:list_name/cards' do |board_name, list_name|
54
- cards = trellor.list(board_name,list_name).cards.collect{ |card| card.name }
55
- cards.to_json
56
- end
57
-
58
- get '/bbboards/:board_name/lists/:list_name/cards/:card_name' do
59
- card = trellor.list(params['board_name'],params['list_name'],params['card_name'])
60
- card.to_json
44
+ if params[:list_name]
45
+ cards = trellor.list(params[:board_name],params[:list_name]).cards.collect{ |card| card.name }
46
+ cards.to_json
47
+ elsif params[:board_name]
48
+ lists = trellor.list_names(params[:board_name])
49
+ lists.to_json
50
+ else
51
+ boards = trellor.board_names
52
+ boards.to_json
53
+ end
61
54
  end
62
55
 
63
56
  post '/boards/:board_name/lists/:list_name/cards' do |board_name, list_name|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trellor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Murphy-Dye
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-03 00:00:00.000000000 Z
11
+ date: 2015-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-trello