pello 0.1.0 → 0.3
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 +4 -4
- data/lib/pello/actions/add_pomodori_to_card.rb +62 -0
- data/lib/pello/actions/move_card.rb +45 -0
- data/lib/pello/card.rb +8 -19
- data/lib/pello/config.rb +19 -14
- data/lib/pello/inputs.rb +2 -2
- data/lib/pello/list.rb +1 -1
- data/lib/pello/runner.rb +12 -39
- data/lib/pello/version.rb +1 -1
- data/lib/pello.rb +2 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c85bd4f1d9080e27d0b8738141d556464c690f10b3cca2685aaaf79fa8d4511
|
4
|
+
data.tar.gz: 6fee889e4547385203fe90833fc959cab8fdf0cdf8bc084535ef7cba974a61cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a9d6a69228c7d7d3d1a05e9a2706d4e8692158345a603d32251ce283a7af0d2bbfd453a539ae0056edab0aa51dcbab0cf282dde939a77d00ec502211e3875b4
|
7
|
+
data.tar.gz: bd0c992649f399d3bdd95572859eb5a6c04d1805056d46a62866887f946e2d1bc96766a36398b58402c549b85aef3adb1cadf7cdef9b24d7d10c25b24566d180
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pello
|
4
|
+
module Actions
|
5
|
+
class AddPomodoriToCard
|
6
|
+
attr_reader :prompt
|
7
|
+
|
8
|
+
def initialize(prompt)
|
9
|
+
@prompt = prompt
|
10
|
+
end
|
11
|
+
|
12
|
+
def run(user, board_url, list_name)
|
13
|
+
board = Pello::Inputs.choose_board user, board_url
|
14
|
+
return unless board
|
15
|
+
|
16
|
+
puts board.as_table
|
17
|
+
continue = true
|
18
|
+
while continue
|
19
|
+
list = Pello::Inputs.choose_list board, list_name
|
20
|
+
return unless list
|
21
|
+
|
22
|
+
card = Pello::Inputs.choose_card list
|
23
|
+
next unless card
|
24
|
+
|
25
|
+
pomodori_before = card.extract_pomodori
|
26
|
+
pomodori_to_add = prompt.ask('Pomodori', default: 1)
|
27
|
+
|
28
|
+
new_name = name_with_added_pomodori(card, pomodori_to_add.to_i)
|
29
|
+
|
30
|
+
puts "Updating card #{card.name}"
|
31
|
+
puts "New title: #{new_name}"
|
32
|
+
|
33
|
+
if prompt.yes?('Confirm?')
|
34
|
+
card.name = new_name
|
35
|
+
card.save
|
36
|
+
card.log "[#{Time.now}] #{card.extract_name} (#{pomodori_before} -> #{card.extract_pomodori})", user
|
37
|
+
puts('Done!')
|
38
|
+
else
|
39
|
+
puts 'Ok, bye!'
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
|
43
|
+
continue = prompt.yes?('Another one?')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def name_with_added_pomodori(card, pomodori_to_add)
|
50
|
+
current_pomodori = card.extract_pomodori
|
51
|
+
current_points = card.extract_points
|
52
|
+
current_name = card.extract_name
|
53
|
+
|
54
|
+
result = []
|
55
|
+
result << "(#{current_points})" unless current_points.zero?
|
56
|
+
result << "#{current_pomodori + pomodori_to_add} 🍅"
|
57
|
+
result << current_name
|
58
|
+
result.join(' ')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pello
|
4
|
+
module Actions
|
5
|
+
class MoveCard
|
6
|
+
attr_reader :prompt
|
7
|
+
|
8
|
+
def initialize(prompt)
|
9
|
+
@prompt = prompt
|
10
|
+
end
|
11
|
+
|
12
|
+
def run(user, board_url, list_name)
|
13
|
+
board = Pello::Inputs.choose_board user, board_url
|
14
|
+
return unless board
|
15
|
+
|
16
|
+
puts board.as_table
|
17
|
+
continue = true
|
18
|
+
while continue
|
19
|
+
source_list = Pello::Inputs.choose_list board, list_name, 'Choose source list'
|
20
|
+
return unless source_list
|
21
|
+
|
22
|
+
card = Pello::Inputs.choose_card source_list
|
23
|
+
next unless card
|
24
|
+
|
25
|
+
target_list = Pello::Inputs.choose_list board, list_name, 'Choose target list'
|
26
|
+
return unless target_list && target_list != source_list
|
27
|
+
|
28
|
+
puts "Moving card #{card.name} from \"#{source_list.name}\" to \"#{target_list.name}\""
|
29
|
+
|
30
|
+
if prompt.yes?('Confirm?')
|
31
|
+
card.list_id = target_list.id
|
32
|
+
card.save
|
33
|
+
card.log "[#{Time.now}] #{card.extract_name} (#{source_list.name} -> #{target_list.name})", user
|
34
|
+
puts('Done!')
|
35
|
+
else
|
36
|
+
puts 'Ok, bye!'
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
continue = prompt.yes?('Another one?')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/pello/card.rb
CHANGED
@@ -5,43 +5,32 @@ module Pello
|
|
5
5
|
class Card
|
6
6
|
extend Forwardable
|
7
7
|
|
8
|
-
|
8
|
+
NAME_REGEX = /(\(([0-9.]*)\))*\s*([0-9.]*)\s*🍅*\s*(.*)/.freeze
|
9
9
|
attr_accessor :trello_card
|
10
|
-
def_delegators :@trello_card, :name, :name=, :comments, :add_comment, :save, :id
|
10
|
+
def_delegators :@trello_card, :name, :name=, :comments, :add_comment, :save, :id, :list_id, :list_id=
|
11
11
|
|
12
12
|
def initialize(trello_card)
|
13
13
|
@trello_card = trello_card
|
14
14
|
end
|
15
15
|
|
16
16
|
def extract_pomodori
|
17
|
-
pomos = name.match(
|
17
|
+
pomos = name.match(NAME_REGEX)[3]
|
18
18
|
pomos ||= 0
|
19
19
|
pomos.to_i
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
23
|
-
name.match(
|
22
|
+
def extract_name
|
23
|
+
name.match(NAME_REGEX)[-1]
|
24
24
|
end
|
25
25
|
|
26
26
|
def extract_points
|
27
|
-
points = name.match(
|
27
|
+
points = name.match(NAME_REGEX)[2]
|
28
28
|
points ||= 0
|
29
29
|
points.to_f
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
33
|
-
|
34
|
-
current_points = extract_points
|
35
|
-
current_title = extract_title
|
36
|
-
result = []
|
37
|
-
result << "(#{current_points})" unless current_points.zero?
|
38
|
-
result << "#{current_pomodori + how_many} 🍅"
|
39
|
-
result << current_title
|
40
|
-
result.join(' ')
|
41
|
-
end
|
42
|
-
|
43
|
-
def log(event)
|
44
|
-
comment = comments.select { |c| c.data['text'] =~ /PELLO LOG/ }.first
|
32
|
+
def log(event, user)
|
33
|
+
comment = comments.select { |c| c.creator_id == user.id && c.data['text'] =~ /PELLO LOG/ }.first
|
45
34
|
if comment
|
46
35
|
new_text = [comment.data['text'], event].join("\n")
|
47
36
|
comment.delete
|
data/lib/pello/config.rb
CHANGED
@@ -1,25 +1,31 @@
|
|
1
1
|
module Pello
|
2
2
|
class Config
|
3
3
|
CONFIG_FILE_PATH = "#{ENV['HOME']}/.config/pello/pello.yaml".freeze
|
4
|
-
attr_accessor :board_url, :developer_public_key, :list_name, :
|
4
|
+
attr_accessor :board_url, :developer_public_key, :list_name, :member_token, :username, :error
|
5
5
|
|
6
6
|
def initialize
|
7
|
-
|
7
|
+
if File.exist?(CONFIG_FILE_PATH)
|
8
|
+
config = YAML.safe_load File.open(CONFIG_FILE_PATH).read
|
8
9
|
|
9
|
-
|
10
|
+
auth_config = config['auth']
|
11
|
+
@developer_public_key = auth_config['developer_public_key']
|
12
|
+
@member_token = auth_config['member_token']
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
@log_file = pello_config['log_file']
|
14
|
+
pello_config = config['config']
|
15
|
+
@username = pello_config['username']
|
16
|
+
@board_url = pello_config['board_url']
|
17
|
+
@list_name = pello_config['list_name']
|
18
|
+
@error = false
|
19
|
+
else
|
20
|
+
@error = true
|
21
|
+
end
|
20
22
|
rescue => e
|
23
|
+
@error = true
|
21
24
|
puts "Error loading config: #{e.message}"
|
22
|
-
|
25
|
+
end
|
26
|
+
|
27
|
+
def valid?
|
28
|
+
!error
|
23
29
|
end
|
24
30
|
|
25
31
|
def self.write_empty_config
|
@@ -32,7 +38,6 @@ module Pello
|
|
32
38
|
file.puts ' board_url: ""'
|
33
39
|
file.puts ' username: ""'
|
34
40
|
file.puts ' list_name: "In progress"'
|
35
|
-
file.puts ' log_file: "/Users/your_name/.pello_log"'
|
36
41
|
end
|
37
42
|
end
|
38
43
|
end
|
data/lib/pello/inputs.rb
CHANGED
@@ -15,12 +15,12 @@ module Pello
|
|
15
15
|
Pello::Board.new(user.boards.detect { |b| b.name == input })
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.choose_list(board, list_name)
|
18
|
+
def self.choose_list(board, list_name, prompt_text = 'Choose list')
|
19
19
|
prompt = TTY::Prompt.new
|
20
20
|
list_names = board.lists.map(&:name)
|
21
21
|
list_names << BACK_OPTION
|
22
22
|
default_list = board.lists.select { |l| l.name == list_name }.first.try(:name)
|
23
|
-
input = prompt.select(
|
23
|
+
input = prompt.select(prompt_text, list_names, per_page: 15, default: default_list)
|
24
24
|
return nil if input == BACK_OPTION
|
25
25
|
|
26
26
|
Pello::List.new(board.lists.detect { |l| l.name == input })
|
data/lib/pello/list.rb
CHANGED
data/lib/pello/runner.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'yaml'
|
2
4
|
require 'trello'
|
3
5
|
require 'tty-prompt'
|
@@ -21,14 +23,18 @@ module Pello
|
|
21
23
|
while continue
|
22
24
|
case prompt.select('Choose task') do |menu|
|
23
25
|
menu.choice name: 'Add pomodori', value: :add_pomodori
|
26
|
+
menu.choice name: 'Move card', value: :move_card
|
24
27
|
menu.choice name: 'Edit config', value: :edit_config
|
25
28
|
menu.choice name: 'quit', value: :quit
|
26
29
|
end
|
27
30
|
when :add_pomodori
|
28
31
|
add_pomodori_to_card
|
32
|
+
when :move_card
|
33
|
+
move_card
|
29
34
|
when :edit_config
|
35
|
+
editor = ENV['EDITOR'] || 'vim'
|
30
36
|
system 'mkdir -p ~/.config/pello'
|
31
|
-
system "#{
|
37
|
+
system "#{editor} ~/.config/pello/pello.yaml"
|
32
38
|
when :quit
|
33
39
|
puts 'Ok, bye!'
|
34
40
|
exit
|
@@ -38,49 +44,17 @@ module Pello
|
|
38
44
|
|
39
45
|
private
|
40
46
|
|
41
|
-
def file_log(text)
|
42
|
-
File.open(@log_file_path, 'a+') do |file|
|
43
|
-
file.puts(text)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
47
|
def add_pomodori_to_card
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
puts board.as_table
|
52
|
-
continue = true
|
53
|
-
while continue
|
54
|
-
list = Pello::Inputs.choose_list board, @list_name
|
55
|
-
return unless list
|
56
|
-
|
57
|
-
card = Pello::Inputs.choose_card list
|
58
|
-
next unless card
|
59
|
-
|
60
|
-
pomodori_before = card.extract_pomodori
|
61
|
-
pomodori_to_add = prompt.ask('Pomodori', default: 1)
|
62
|
-
|
63
|
-
puts "Updating card #{card.name}"
|
64
|
-
puts "New title: #{card.title_with_added_pomodori(pomodori_to_add.to_i)}"
|
65
|
-
|
66
|
-
if prompt.yes?('Confirm?')
|
67
|
-
card.name = card.title_with_added_pomodori(pomodori_to_add.to_i)
|
68
|
-
card.save
|
69
|
-
file_log "[#{Time.now} - #{@user.full_name}] #{card.extract_title} (#{pomodori_before} -> #{card.extract_pomodori})"
|
70
|
-
card.log "[#{Time.now} - #{@user.full_name}] #{card.extract_title} (#{pomodori_before} -> #{card.extract_pomodori})"
|
71
|
-
puts('Done!')
|
72
|
-
else
|
73
|
-
puts 'Ok, bye!'
|
74
|
-
nil
|
75
|
-
end
|
48
|
+
Pello::Actions::AddPomodoriToCard.new(prompt).run(@user, board_url, list_name)
|
49
|
+
end
|
76
50
|
|
77
|
-
|
78
|
-
|
51
|
+
def move_card
|
52
|
+
Pello::Actions::MoveCard.new(prompt).run(@user, board_url, list_name)
|
79
53
|
end
|
80
54
|
|
81
55
|
def configure_pello
|
82
56
|
config = Pello::Config.new
|
83
|
-
if config
|
57
|
+
if config.valid?
|
84
58
|
Trello.configure do |trello_config|
|
85
59
|
trello_config.developer_public_key = config.developer_public_key
|
86
60
|
trello_config.member_token = config.member_token
|
@@ -89,7 +63,6 @@ module Pello
|
|
89
63
|
@user = Trello::Member.find config.username
|
90
64
|
@board_url = config.board_url
|
91
65
|
@list_name = config.list_name
|
92
|
-
@log_file_path = config.log_file
|
93
66
|
else
|
94
67
|
puts 'No config found, opening config file...'
|
95
68
|
Pello::Config.write_empty_config
|
data/lib/pello/version.rb
CHANGED
data/lib/pello.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pello
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrea Schiavini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-trello
|
@@ -52,7 +52,8 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description: Perform Trello operations like adding pomodori to a card
|
55
|
+
description: Perform Trello operations like adding pomodori to a card name and moving
|
56
|
+
cards across lists
|
56
57
|
email:
|
57
58
|
- metalelf0@gmail.com
|
58
59
|
executables:
|
@@ -62,6 +63,8 @@ extra_rdoc_files: []
|
|
62
63
|
files:
|
63
64
|
- bin/pello
|
64
65
|
- lib/pello.rb
|
66
|
+
- lib/pello/actions/add_pomodori_to_card.rb
|
67
|
+
- lib/pello/actions/move_card.rb
|
65
68
|
- lib/pello/board.rb
|
66
69
|
- lib/pello/card.rb
|
67
70
|
- lib/pello/config.rb
|