TrelloCycleTime 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Y2RhOTdkNGY4M2E0YTQ0MTAyMWZiZDMzZjRlNTFiZTQxN2Y1ZmI5Mw==
5
+ data.tar.gz: !binary |-
6
+ NGMwMzFiZGViYjViYzRmMzY3OWU4MzMxNTM4YTMxYmY3OTFhNmZhMw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NzA3ODVlYzFjYTM4NzljZjVlMmI5NjIxYjkyY2FmYjVmOTQ3MTI1M2MwYmZm
10
+ YWE1NTczODRjZTQyN2FkZGQwMmVkOGI0YWE1MTBkMDY5OWQzNmNlMDY3ZmEy
11
+ ZTFlNmM4OWMxNmUwYTE3MDkzZjg1ZTRjZDUwY2RhYjQwZTM4MTI=
12
+ data.tar.gz: !binary |-
13
+ MTdiZGFiYWQ3NzZiNjk5YmFlY2QyZWE2NWMyMDMzM2JjZTRmN2NkMTFhMDky
14
+ ZDFjYTU3YzE3ODY0OWM3OGI2OGJhNzRlNjUyOWJhYjkwNDFjOTMzMjg5NDQy
15
+ ZjhmMjFlNjk0MWRlMDliNzMwYjAzOGI1YWVmYTk5MDQ2ZTVhZTc=
@@ -0,0 +1,16 @@
1
+ module AgileTrello
2
+ class AverageCycleTimeCalculator
3
+ def initialize
4
+ @cycle_times = []
5
+ end
6
+
7
+ def add(cycle_time)
8
+ @cycle_times.push(cycle_time)
9
+ end
10
+
11
+ def average
12
+ return 0 if @cycle_times.length == 0
13
+ (@cycle_times.reduce(:+) / @cycle_times.length).round(2)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ module AgileTrello
2
+ class CardHistory
3
+ MOVEMENT_ACTION_TYPE = 'updateCard'
4
+ MOVEMENT_DATA_ATTRIBUTE = 'listAfter'
5
+ MOVEMENT_DATA_LIST_NAME = 'name'
6
+
7
+ def initialize(trello_card, all_lists_on_board)
8
+ @card_movements = trello_card.actions.select do | action |
9
+ action.type == MOVEMENT_ACTION_TYPE && !action.data[MOVEMENT_DATA_ATTRIBUTE].nil?
10
+ end
11
+ @all_lists_on_board = all_lists_on_board
12
+ end
13
+
14
+ def find_date_entered_list(list_name)
15
+ @card_movements.each do |movement|
16
+ return movement.date if movement.data[MOVEMENT_DATA_ATTRIBUTE][MOVEMENT_DATA_LIST_NAME].include?(list_name)
17
+ end
18
+ current_index = @all_lists_on_board.index { |board_list_name| board_list_name.include? list_name }
19
+ next_list_name = @all_lists_on_board[current_index + 1]
20
+ find_date_entered_list(next_list_name)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ module AgileTrello
2
+ class CardRepository
3
+ def initialize(trello, parameters)
4
+ @trello_board = trello.get_board(parameters[:board_id])
5
+ @end_list = parameters[:end_list]
6
+ end
7
+
8
+ def get_cards_after
9
+ cards_after = []
10
+ ignore = true
11
+ @trello_board.lists.each do | list |
12
+ ignore = !list.name.include?(@end_list) if ignore
13
+ if !ignore
14
+ list.cards.each do | card |
15
+ cards_after.push(card)
16
+ end
17
+ end
18
+ end
19
+ return cards_after
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ module AgileTrello
2
+ class CompletedCard
3
+ SECONDS_IN_24HRS = (24 * 60 * 60)
4
+
5
+ attr_reader :cycle_time
6
+
7
+ def initialize(start_date, end_date)
8
+ @cycle_time = ((end_date - start_date) / SECONDS_IN_24HRS).round(2)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ require_relative 'CompletedCard'
2
+ require_relative 'CardHistory'
3
+
4
+ module AgileTrello
5
+ class CompletedCardFactory
6
+ MOVEMENT_ACTION_TYPE = 'updateCard'
7
+ MOVEMENT_DATA_ATTRIBUTE = 'listAfter'
8
+ MOVEMENT_DATA_LIST_NAME = 'name'
9
+
10
+ def initialize(parameters)
11
+ @start_list = parameters[:start_list]
12
+ @end_list = parameters[:end_list]
13
+ @all_lists = parameters[:all_lists]
14
+ end
15
+
16
+ def create(trello_card)
17
+ card_history = CardHistory.new(trello_card, @all_lists)
18
+ start_date = card_history.find_date_entered_list(@start_list)
19
+ end_date = card_history.find_date_entered_list(@end_list)
20
+ CompletedCard.new(start_date, end_date)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,26 @@
1
+ require_relative './CompletedCardFactory'
2
+ require_relative './CardRepository'
3
+
4
+ module AgileTrello
5
+ class CompletedCardRepository
6
+ def initialize(trello, parameters)
7
+ trello_board = trello.get_board(parameters[:board_id])
8
+ all_lists_on_board = trello_board.lists.map do |list|
9
+ list.name
10
+ end
11
+ @card_repository = CardRepository.new(trello, parameters)
12
+ @completed_card_factory = CompletedCardFactory.new(
13
+ start_list: parameters[:start_list],
14
+ end_list: parameters[:end_list],
15
+ all_lists: all_lists_on_board
16
+ )
17
+ end
18
+
19
+ def get
20
+ completed_cards = @card_repository.get_cards_after
21
+ completed_cards.map do |card|
22
+ @completed_card_factory.create(card)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,10 @@
1
+ module AgileTrello
2
+ class TrelloCredentials
3
+ attr_reader :public_key, :access_token
4
+
5
+ def initialize(public_key, access_token)
6
+ @public_key = public_key
7
+ @access_token = access_token
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,25 @@
1
+ require 'peach'
2
+ require_relative './TrelloFactory'
3
+ require_relative './TrelloCredentials'
4
+ require_relative './AverageCycleTimeCalculator'
5
+ require_relative './CompletedCardRepository'
6
+
7
+ module AgileTrello
8
+ class TrelloCycleTime
9
+ def initialize(parameters = {})
10
+ trello_credentials = TrelloCredentials.new(parameters[:public_key], parameters[:access_token])
11
+ trello_factory = parameters[:trello_factory].nil? ? TrelloFactory.new : parameters[:trello_factory]
12
+ @trello = trello_factory.create(trello_credentials)
13
+ @average_cycle_time_calculator = AverageCycleTimeCalculator.new
14
+ end
15
+
16
+ def get(parameters)
17
+ completed_card_repository = CompletedCardRepository.new(@trello, parameters)
18
+ finished_cards = completed_card_repository.get
19
+ finished_cards.peach do | card |
20
+ @average_cycle_time_calculator.add(card.cycle_time)
21
+ end
22
+ return @average_cycle_time_calculator.average
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ require 'trello'
2
+
3
+ module AgileTrello
4
+ class TrelloFactory
5
+ include Trello
6
+ include Trello::Authorization
7
+
8
+ def create(trello_credentials)
9
+ Trello::Authorization.const_set :AuthPolicy, OAuthPolicy
10
+ OAuthPolicy.consumer_credential = OAuthCredential.new trello_credentials.public_key, 'SECRET'
11
+ OAuthPolicy.token = OAuthCredential.new trello_credentials.access_token, nil
12
+ TrelloRepository.new
13
+ end
14
+ end
15
+
16
+ class TrelloRepository
17
+ include Trello
18
+
19
+ def get_board(board_id)
20
+ Board.find board_id
21
+ end
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: TrelloCycleTime
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - iainjmitchell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-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: peach
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/AverageCycleTimeCalculator.rb
48
+ - lib/CardHistory.rb
49
+ - lib/CardRepository.rb
50
+ - lib/CompletedCard.rb
51
+ - lib/CompletedCardFactory.rb
52
+ - lib/CompletedCardRepository.rb
53
+ - lib/TrelloCredentials.rb
54
+ - lib/TrelloCycleTime.rb
55
+ - lib/TrelloFactory.rb
56
+ homepage: https://github.com/code-computerlove/trello-cycletime
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.2.2
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Calculates cycle time from cards on a trello board
80
+ test_files: []