trello-weekly-velocity 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OWQ4ODRjYTRlOWIzNGRhMmJmNTI2Y2MzYmVjNTgyMjVmNmM1ZjhiYg==
5
+ data.tar.gz: !binary |-
6
+ ZGNhMjc0Mjc5MTM2ZmQ4NzIwYThmZTU4ZDBhZjhlZmRkYjZhYjk0YQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ N2JiMjliNjAxYzQ1M2ViYWE5Nzc3YzhjOTQ5ODNiNWMzYWI2MDVmMTU5Njhh
10
+ Y2NmZjdhNWQxMmUxZWZkYWE1NWQ5OTZkZjEzN2Y0ODJhYjg0MmM0NTQzOTVk
11
+ MDQ5M2FkZTdmNzkxOTA5MWEwNzM2OTE4MjMzMjczYmRiZDc3ODY=
12
+ data.tar.gz: !binary |-
13
+ NDQ1MzlmM2E1OTYxZDhjNDZmZjE5NzEyODEyNmQ4OGJkZGM3YWNmZjAzY2Jj
14
+ NzRlMTkwYmIwMTEyYjc5OTA3ODQ2NDUwMGZkNTgxMjVkNjBkMGFmYjI2M2Yy
15
+ YmU2N2U4MDcyN2Q5OWJlODQzZTk5OGI2YjhhNWI3M2MzZmNmMjc=
@@ -0,0 +1,12 @@
1
+ module AgileTrello
2
+ class CardContainsComplexityFilter
3
+ def initialize(next_filter)
4
+ @next_filter = next_filter
5
+ end
6
+
7
+ def match(card)
8
+ return false unless card.name.match(/\(\d*\)/)
9
+ return @next_filter.match(card)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,31 @@
1
+ module AgileTrello
2
+ ONE_DAY = 86400
3
+
4
+ class CardsCompletedInLastSevenDaysFilter
5
+ SEVEN_DAYS_AGO = Time.now - (ONE_DAY * 7)
6
+ MOVE_INTO_LIST_ACTION = 'updateCard'
7
+
8
+ def initialize(end_list, lists_after_end_list)
9
+ @end_list = end_list
10
+ @lists_after_end_list = lists_after_end_list
11
+ end
12
+
13
+ def match(card)
14
+ moved_into_end_list_action = find_movement_action(@end_list, card)
15
+ count = 0
16
+ until (moved_into_end_list_action || count == @lists_after_end_list.length) do
17
+ list_name = @lists_after_end_list[count]
18
+ moved_into_end_list_action = find_movement_action(list_name, card)
19
+ count = count+1
20
+ end
21
+ moved_into_end_list_action && moved_into_end_list_action.date > SEVEN_DAYS_AGO
22
+ end
23
+
24
+ private
25
+ def find_movement_action(list_name, card)
26
+ card.actions.find do | action |
27
+ action.type == MOVE_INTO_LIST_ACTION && action.data && action.data['listAfter'] && action.data['listAfter']['name'].include?(list_name)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,11 @@
1
+ module AgileTrello
2
+ class CompletedCard
3
+ attr_reader :complexity
4
+
5
+ COMPLEXITY_REGEX = /\(\d*\)/
6
+
7
+ def initialize(name)
8
+ @complexity = (name.match(COMPLEXITY_REGEX).to_s.delete! '()').to_i
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ module AgileTrello
2
+ class CompletedCardRepository
3
+ def initialize(card_repository)
4
+ @card_repository = card_repository
5
+ end
6
+
7
+ def find(parameters)
8
+ cards = @card_repository.find(parameters)
9
+ return cards.map { | card | CompletedCard.new(card.name) }
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ require_relative './CardsCompletedInLastSevenDaysFilter'
2
+ require_relative './CardContainsComplexityFilter'
3
+
4
+ module AgileTrello
5
+ class FilterFactory
6
+ def initialize(trello_boards)
7
+ @trello_boards = trello_boards
8
+ end
9
+
10
+ def create(board_id, end_list_name)
11
+ trello_board = @trello_boards.get(board_id)
12
+ lists_after = trello_board.get_list_names_after(end_list_name)
13
+ seven_day_filter = CardsCompletedInLastSevenDaysFilter.new(end_list_name, lists_after)
14
+ CardContainsComplexityFilter.new(seven_day_filter)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ module AgileTrello
2
+ class FilteredCardRepostitory
3
+ def initialize(trello_boards)
4
+ @trello_boards = trello_boards
5
+ end
6
+
7
+ def find(parameters)
8
+ filter = parameters[:filter]
9
+ @trello_boards
10
+ .get(parameters[:board_id])
11
+ .get_cards_after_list(parameters[:end_list])
12
+ .find_all {|card| filter.match(card)}
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,28 @@
1
+ module AgileTrello
2
+ class TrelloBoard
3
+ def initialize(board)
4
+ @board = board
5
+ end
6
+
7
+ def get_cards_after_list(end_list_name)
8
+ found_end = false
9
+ cards = []
10
+ @board.lists.each do | list |
11
+ found_end = true if !found_end && (list.name.include? end_list_name)
12
+ if (found_end)
13
+ list.cards.each do | card |
14
+ cards.push(card)
15
+ end
16
+ end
17
+ end
18
+ return cards
19
+ end
20
+
21
+ def get_list_names_after(end_list_name)
22
+ list_names = @board.lists.map { | list | list.name }
23
+ end_list_position = list_names.index{ |list_name | list_name.include? end_list_name }
24
+ return [] unless end_list_position
25
+ return list_names.slice(end_list_position+1, list_names.length)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,14 @@
1
+ require_relative './TrelloBoard'
2
+
3
+ module AgileTrello
4
+ class TrelloBoards
5
+ def initialize(trello)
6
+ @trello = trello
7
+ end
8
+
9
+ def get(board_id)
10
+ board = @trello.get_board(board_id)
11
+ return TrelloBoard.new(board)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,39 @@
1
+ require 'TrelloCredentials'
2
+ require 'TrelloFactory'
3
+ require_relative '../lib/CompletedCard'
4
+ require_relative '../lib/VelocityCalculator'
5
+ require_relative '../lib/CompletedCardRepository'
6
+ require_relative '../lib/TrelloBoards'
7
+ require_relative '../lib/FilteredCardRepository'
8
+ require_relative '../lib/FilterFactory'
9
+
10
+ module AgileTrello
11
+ class TrelloWeeklyVelocity
12
+ def initialize(parameters = {})
13
+ trello_credentials = TrelloCredentials.new(parameters[:public_key], parameters[:access_token])
14
+ trello_factory = parameters[:trello_factory].nil? ? TrelloFactory.new : parameters[:trello_factory]
15
+ trello = trello_factory.create(trello_credentials)
16
+ trello_boards = TrelloBoards.new(trello)
17
+ last_seven_days_cards = FilteredCardRepostitory.new(trello_boards)
18
+ @completed_cards = CompletedCardRepository.new(last_seven_days_cards)
19
+ @filter_factory = FilterFactory.new(trello_boards)
20
+ end
21
+
22
+ def get(parameters = {})
23
+ filter = @filter_factory.create(parameters[:board_id], parameters[:end_list])
24
+ velocity_calculator = VelocityCalculator.new
25
+ @completed_cards
26
+ .find(board_id: parameters[:board_id], end_list: parameters[:end_list], filter: filter)
27
+ .each { | card | velocity_calculator.add(card.complexity) }
28
+ return WeeklyVelocity.new(velocity_calculator.total);
29
+ end
30
+ end
31
+
32
+ class WeeklyVelocity
33
+ attr_reader :amount
34
+
35
+ def initialize(amount)
36
+ @amount = amount
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,15 @@
1
+ module AgileTrello
2
+ class VelocityCalculator
3
+ def initialize
4
+ @total = 0
5
+ end
6
+
7
+ def add(complexity)
8
+ @total += complexity
9
+ end
10
+
11
+ def total
12
+ @total
13
+ end
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trello-weekly-velocity
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - iainjmitchell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby-trello
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: trello-factory
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email: iainjmitchell@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/CardContainsComplexityFilter.rb
48
+ - lib/CardsCompletedInLastSevenDaysFilter.rb
49
+ - lib/CompletedCard.rb
50
+ - lib/CompletedCardRepository.rb
51
+ - lib/FilterFactory.rb
52
+ - lib/FilteredCardRepository.rb
53
+ - lib/TrelloBoard.rb
54
+ - lib/TrelloBoards.rb
55
+ - lib/TrelloWeeklyVelocity.rb
56
+ - lib/VelocityCalculator.rb
57
+ homepage: https://github.com/code-computerlove/trello-weekly-velocity
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.2.2
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Calculates weekly velocity from trello boards
81
+ test_files: []