TrelloCycleTime 1.0.4 → 1.0.5

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzUwNTljMjk5Zjg3MzJjYWNmYzQ5NmM0ZTUwZTc0MzkzMzhlNzY0Mg==
4
+ ZWZkNTZmNjRmNWEwOTNjMDFjZDYxM2IwZjgxOWI5NGQ4OTkxMWJkNQ==
5
5
  data.tar.gz: !binary |-
6
- ZTc4YTgyYzhmZGQ2N2VmNWYyNTNhMDUxNDc5MjA4ODYxNGNiOTNkNw==
6
+ YzY2YjgyNzkzZjA1OWVhOGQ3ZDNmOTU2OWQyMDhmNDYyZTMwMjFjNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjNlYWI1M2E0MWMyNmY2ZGFhNWM3MzBhMjg3NmQxNmQ0ODA0ODA3Y2IyMmQ0
10
- ZmE5ZDMxMDgwYzUwYjc2YTA2NWM4ZDIzNWZhM2Y4MWQ4YTY0OTk1YzQwNGJi
11
- YTU0M2NmYzY5Njc2M2UwNDc3YjNiYTRhZTdlZjAwYzBiNjNlMGY=
9
+ NDA0ZWRiM2UyOTQ2OGEwNzZkNGI0YzQ3ZjVjNzEzYzc3ZTg5ZDgxMDcwYWE0
10
+ ZWFhNDI2NjkwNjEwMWZmNTQwYzUzY2VmZTdiNmZmYmU5YmZhZmYxYTg1ZDgy
11
+ ZGRkNDRlOGQ0NjU5ODZiN2ViMDhiZmE3NzFlMThlNWEyNmRhYWM=
12
12
  data.tar.gz: !binary |-
13
- NTIyNThjOGM5NzE1YzgzOGEwMzMyYTZiNjMzMDA2NWI3ZDM4NWMxYzQzMmMy
14
- YjJmZTJhYTg4MjJlYzk2Y2Y3ZmMzMmY3ODEwNGUyYTUzZjk2OGE0YjEyMWRk
15
- ODg5ZTExMmJkYjJiZWNhYTEzYmM1NzgyNmEwNWI3MzYyMDMyOTU=
13
+ YWQ2MTM2OTY4YmRkNTMyMjY4MTdhNjg2MDYyMjM1Mjc3NDZkNGExYTQyNzI5
14
+ ZTBkNjdhNjZmMDA1NGVjOWNhMGRmODc0Njk2MDA0MWRiMDk0ZmIxNjgyMjEx
15
+ YzNhMWQ0MWM1N2Q1ZjgxYWIxMDU4M2M3MTNmOTU4NjA1OTYxODg=
@@ -12,5 +12,37 @@ module AgileTrello
12
12
  return 0 if @cycle_times.length == 0
13
13
  (@cycle_times.reduce(:+) / @cycle_times.length).round(2)
14
14
  end
15
+
16
+ def standard_deviation
17
+ mean = self.average
18
+ return 0 if mean == 0
19
+ squared_deviations = @cycle_times.map do |cycle_time|
20
+ (cycle_time - mean) ** 2
21
+ end
22
+ variance = squared_deviations.reduce(:+) / squared_deviations.length
23
+ standard_deviation = Math.sqrt(variance).round(2)
24
+ end
25
+ end
26
+
27
+ class StandardDeviationCalculator
28
+ def initialize(average_cycle_time_calculator)
29
+ @average_cycle_time_calculator = average_cycle_time_calculator
30
+ @cycle_times = []
31
+ end
32
+
33
+ def add(cycle_time)
34
+ @average_cycle_time_calculator.add(cycle_time)
35
+ @cycle_times.push(cycle_time)
36
+ end
37
+
38
+ def standard_deviation
39
+ mean = @average_cycle_time_calculator.average
40
+ return 0 if mean == 0
41
+ squared_deviations = @cycle_times.map do |cycle_time|
42
+ (cycle_time - mean) ** 2
43
+ end
44
+ variance = squared_deviations.reduce(:+) / squared_deviations.length
45
+ standard_deviation = Math.sqrt(variance).round(2)
46
+ end
15
47
  end
16
48
  end
@@ -0,0 +1,23 @@
1
+ module AgileTrello
2
+ class StandardDeviationCalculator
3
+ def initialize(average_cycle_time_calculator)
4
+ @average_cycle_time_calculator = average_cycle_time_calculator
5
+ @cycle_times = []
6
+ end
7
+
8
+ def add(cycle_time)
9
+ @average_cycle_time_calculator.add(cycle_time)
10
+ @cycle_times.push(cycle_time)
11
+ end
12
+
13
+ def standard_deviation
14
+ mean = @average_cycle_time_calculator.average
15
+ return 0 if mean == 0
16
+ squared_deviations = @cycle_times.map do |cycle_time|
17
+ (cycle_time - mean) ** 2
18
+ end
19
+ variance = squared_deviations.reduce(:+) / squared_deviations.length
20
+ standard_deviation = Math.sqrt(variance).round(2)
21
+ end
22
+ end
23
+ end
@@ -1,6 +1,7 @@
1
1
  require_relative './TrelloFactory'
2
2
  require_relative './TrelloCredentials'
3
3
  require_relative './AverageCycleTimeCalculator'
4
+ require_relative './StandardDeviationCalculator'
4
5
  require_relative './CompletedCards'
5
6
  require_relative './TrelloListRepository'
6
7
 
@@ -11,20 +12,22 @@ module AgileTrello
11
12
  trello_factory = parameters[:trello_factory].nil? ? TrelloFactory.new : parameters[:trello_factory]
12
13
  trello = trello_factory.create(trello_credentials)
13
14
  @average_cycle_time_calculator = AverageCycleTimeCalculator.new
14
- @completed_cards = CompletedCards.new(trello, @average_cycle_time_calculator, TrelloListRepository.new(trello))
15
+ @standard_deviation_calculator = StandardDeviationCalculator.new(@average_cycle_time_calculator)
16
+ @completed_cards = CompletedCards.new(trello, @standard_deviation_calculator, TrelloListRepository.new(trello))
15
17
  end
16
18
 
17
19
  def get(parameters)
18
20
  @completed_cards.retrieve(parameters)
19
- return CycleTime.new(@average_cycle_time_calculator.average)
21
+ return CycleTime.new(@average_cycle_time_calculator.average, @standard_deviation_calculator.standard_deviation)
20
22
  end
21
23
  end
22
24
 
23
25
  class CycleTime
24
- attr_reader :mean
26
+ attr_reader :mean, :standard_deviation
25
27
 
26
- def initialize(mean)
28
+ def initialize(mean, standard_deviation)
27
29
  @mean = mean
30
+ @standard_deviation = standard_deviation
28
31
  end
29
32
  end
30
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: TrelloCycleTime
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - iainjmitchell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-24 00:00:00.000000000 Z
11
+ date: 2014-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-trello
@@ -51,6 +51,7 @@ files:
51
51
  - lib/CompletedCard.rb
52
52
  - lib/CompletedCardFactory.rb
53
53
  - lib/CompletedCards.rb
54
+ - lib/StandardDeviationCalculator.rb
54
55
  - lib/TrelloCredentials.rb
55
56
  - lib/TrelloCycleTime.rb
56
57
  - lib/TrelloFactory.rb