Class: TrelloTool::TrelloClient
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- TrelloTool::TrelloClient
- Includes:
- Util
- Defined in:
- lib/trello_tool/trello_client.rb
Overview
Wrapped client for trello adapting it to things we need it to do
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
- #archive_board ⇒ Object
-
#archiveable_list_names_with_index ⇒ Array
Of list names with left index, ordered from right.
- #authorized(&block) ⇒ Object
-
#initialize(configuration) ⇒ TrelloClient
constructor
A new instance of TrelloClient.
- #main_board ⇒ Object
- #next_version_list ⇒ Object
Constructor Details
#initialize(configuration) ⇒ TrelloClient
Returns a new instance of TrelloClient.
13 14 15 16 17 18 19 20 |
# File 'lib/trello_tool/trello_client.rb', line 13 def initialize(configuration) @configuration = configuration @client = Trello::Client.new( developer_public_key: ENV["TRELLO_DEVELOPER_PUBLIC_KEY"], member_token: ENV["TRELLO_MEMBER_TOKEN"] ) super(@client) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/trello_tool/trello_client.rb', line 10 def client @client end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
10 11 12 |
# File 'lib/trello_tool/trello_client.rb', line 10 def configuration @configuration end |
Instance Method Details
#archive_board ⇒ Object
38 39 40 |
# File 'lib/trello_tool/trello_client.rb', line 38 def archive_board @archive_board ||= client.find(:boards, extract_id_from_url(configuration.archive_board_url)) end |
#archiveable_list_names_with_index ⇒ Array
Returns of list names with left index, ordered from right.
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/trello_tool/trello_client.rb', line 43 def archiveable_list_names_with_index @archiveable_list_names_with_index ||= [].tap do |lists| all_lists = main_board.lists all_lists.reverse.each_with_index do |list, right_index| if (divider_list?(list) && right_index.zero?) || version_list?(list) # rubocop:disable Style/GuardClause left_index = all_lists.length - right_index - 1 lists << [list.name, left_index] else break end end end end |
#authorized(&block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/trello_tool/trello_client.rb', line 22 def (&block) Trello.configure do |config| config.developer_public_key = ENV["TRELLO_DEVELOPER_PUBLIC_KEY"] config.member_token = ENV["TRELLO_MEMBER_TOKEN"] end block.call Trello.configure do |config| config.developer_public_key = nil config.member_token = nil end end |
#main_board ⇒ Object
34 35 36 |
# File 'lib/trello_tool/trello_client.rb', line 34 def main_board @main_board ||= client.find(:boards, extract_id_from_url(configuration.main_board_url)) end |
#next_version_list ⇒ Object
57 58 59 |
# File 'lib/trello_tool/trello_client.rb', line 57 def next_version_list @next_version_list ||= find_list_by_list_name(main_board, configuration.next_version_list_name) end |