trello-pipes 1.0.0 → 1.0.1
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
|
-
|
4
|
+
MjhkMGQ3YWNmZDRkYjRlN2RmN2ZlZjFlZGZjZWQ3MjJhODhhMDBmMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmNkNTc2NDRkOTE2OWZhNWJlOTI3ZTM4NmM1NWNiYmNkZTA2N2I1OQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MThkN2I2OGU5MDk2ZTljZDFhMjQ3NDY2YTMwMDhiMzFiZDY5ZWRkNTk0YTc4
|
10
|
+
MTFhOWVkZTUwNDY0ODg1NmU0ODg3ZGU3OTNlZDU4M2NhNDU1OWE1ZGQwNTM0
|
11
|
+
M2ZlZTRmMjY3MTg1MTM1MjA5ZGM0YjkwYTE4NzRkNjQxODAxYjQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTEyMDdhOTllNDQ2MWNlZmIxZTVhNjIyNDBiYTYyZTRmNTU1ODgwMDk1MDhj
|
14
|
+
MjJmNzc5M2RkNDE0NmNhMTdkZTkwZDg5ZWZmYTYxMTZkMzhjNDcwOWM5OThj
|
15
|
+
OGUyNDQ1ZmE1YTFjZTVjYTQzNTAxOGNiMmI0YWJlY2UxNjBmZGQ=
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module TrelloPipes
|
2
|
+
class VelocityCalculatorAdapter
|
3
|
+
def initialize(successor)
|
4
|
+
@successor = successor
|
5
|
+
end
|
6
|
+
|
7
|
+
def push(cards)
|
8
|
+
complexity = 0
|
9
|
+
complexity = cards.inject(complexity) do |complexity, card|
|
10
|
+
complexity + CardComplexity.new(card).complexity
|
11
|
+
end
|
12
|
+
@successor.push(complexity)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class CardComplexity
|
17
|
+
attr_reader :complexity
|
18
|
+
|
19
|
+
COMPLEXITY_REGEX = /\(\d*\)/
|
20
|
+
|
21
|
+
def initialize(trello_card)
|
22
|
+
complexity_match = trello_card.name.match(COMPLEXITY_REGEX)
|
23
|
+
@complexity = (complexity_match.to_s.delete! '()').to_i
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module TrelloPipes
|
2
|
+
class CardContainsComplexityFilter
|
3
|
+
def initialize(successor)
|
4
|
+
@successor = successor
|
5
|
+
end
|
6
|
+
|
7
|
+
def push(cards)
|
8
|
+
complexity_cards = cards.select { | card | card.name.match(/\(\d*\)/)}
|
9
|
+
@successor.push(complexity_cards)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module TrelloPipes
|
4
|
+
class EnteredListAfterDateFilter
|
5
|
+
def initialize(successor, date, list_name, trello_board)
|
6
|
+
@successor = successor
|
7
|
+
@list_name = list_name
|
8
|
+
@date = Time.parse(date.to_s)
|
9
|
+
@subsequent_list_names =
|
10
|
+
SubsequentListNameRepository.new(trello_board, list_name).get
|
11
|
+
end
|
12
|
+
|
13
|
+
def push(cards)
|
14
|
+
matching_cards = cards.select do | card |
|
15
|
+
movement_action = find_movement_action(card.actions, @list_name, @subsequent_list_names)
|
16
|
+
movement_action.date > @date
|
17
|
+
end
|
18
|
+
@successor.push(matching_cards)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def find_movement_action(actions, list_name, subsequent_list_names)
|
23
|
+
specification = MovementIntoListSpecification.new(list_name)
|
24
|
+
movement_action = actions.find do | action |
|
25
|
+
specification.is_satisified_by(action)
|
26
|
+
end
|
27
|
+
return movement_action unless movement_action.nil?
|
28
|
+
return NullMovementAction.new if subsequent_list_names.empty?
|
29
|
+
head, *tail = subsequent_list_names
|
30
|
+
return find_movement_action(actions, head, tail)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class MovementIntoListSpecification
|
35
|
+
MOVE_INTO_LIST_ACTION = 'updateCard'
|
36
|
+
def initialize(list_name)
|
37
|
+
@list_name = list_name
|
38
|
+
end
|
39
|
+
|
40
|
+
def is_satisified_by(action)
|
41
|
+
(action.type == MOVE_INTO_LIST_ACTION &&
|
42
|
+
action.data && action.data['listAfter'] &&
|
43
|
+
action.data['listAfter']['name'].include?(@list_name))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class NullMovementAction
|
48
|
+
attr_reader :date
|
49
|
+
|
50
|
+
def initialize
|
51
|
+
date = Time.at(0)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class SubsequentListNameRepository
|
56
|
+
def initialize(trello_board, list_name)
|
57
|
+
list_names = trello_board.lists.map {|list| list.name}
|
58
|
+
list_index = list_names.index {|name| name.match(list_name)}
|
59
|
+
@subsequent_list_names = list_names.slice(list_index+1, list_names.size-1)
|
60
|
+
end
|
61
|
+
|
62
|
+
def get()
|
63
|
+
@subsequent_list_names
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module TrelloPipes
|
2
|
+
class CardsAfterAndIncludingListProducer
|
3
|
+
def initialize(successor, trello_board)
|
4
|
+
@successor = successor
|
5
|
+
@trello_board = trello_board
|
6
|
+
end
|
7
|
+
|
8
|
+
def produce(list_name)
|
9
|
+
lists = get_lists_after_and_including(list_name)
|
10
|
+
cards = all_cards_from(lists)
|
11
|
+
@successor.push(cards)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def get_lists_after_and_including(list_name)
|
16
|
+
list_index = @trello_board.lists.index { | list | list.name.match(list_name) }
|
17
|
+
return [] if list_index.nil?
|
18
|
+
@trello_board.lists.slice(list_index, @trello_board.lists.size)
|
19
|
+
end
|
20
|
+
|
21
|
+
def all_cards_from(lists)
|
22
|
+
return [] if lists.empty?
|
23
|
+
head, *tail = lists
|
24
|
+
return head.cards + all_cards_from(tail)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trello-pipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iainjmitchell
|
@@ -43,7 +43,11 @@ email: iainjmitchell@gmail.com
|
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
|
-
files:
|
46
|
+
files:
|
47
|
+
- lib/adapters/VelocityCalculatorAdapter.rb
|
48
|
+
- lib/filters/CardContainsComplexityFilter.rb
|
49
|
+
- lib/filters/EnteredListAfterDateFilter.rb
|
50
|
+
- lib/producers/CardsAfterAndIncludingListProducer.rb
|
47
51
|
homepage: https://github.com/iainjmitchell/trello-pipes
|
48
52
|
licenses:
|
49
53
|
- MIT
|