evados-tracker 0.2.1 → 0.2.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 +4 -4
- data/bin/et +47 -9
- data/lib/evados_tracker.rb +5 -5
- data/lib/evados_tracker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8768cfaf56bb541d670cd67ff0c58330a6128a59
|
4
|
+
data.tar.gz: 2cbc29a89f420153a95137b05232b0aa2e4f1153
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfda633fb6f0591ee9bcd4653efdc51d215ffbde467cb04b0a4f75918963b4f8de20991344d2bd8600486fd50dde99bfe838adf29e561eeacd8c636ced20e550
|
7
|
+
data.tar.gz: cc1e13ca59a4781f4453a7e31cb9025c5e6cb7db878e5ba5f10dfed93335819dd5449588f499dd64844f68d76bff7615fe9c119e8b19aaf693792b3bcf4d2ada
|
data/bin/et
CHANGED
@@ -4,8 +4,10 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
4
4
|
|
5
5
|
require 'thor'
|
6
6
|
require 'evados_tracker'
|
7
|
+
require 'json'
|
7
8
|
|
8
9
|
PATH_TO_KEY = Dir.home + "/.evados-tracker/.key"
|
10
|
+
PATH_TO_PREV_ISSUE = Dir.home + "/.evados-tracker/prev_issue.json"
|
9
11
|
|
10
12
|
class CLI < Thor
|
11
13
|
def initialize(a, b, c)
|
@@ -25,17 +27,35 @@ class CLI < Thor
|
|
25
27
|
method_options :a => :boolean
|
26
28
|
def start(task_num)
|
27
29
|
check_rescue do
|
30
|
+
@tracker.current_issue_id = @tracker.numerated_list["#{task_num}"]['id']
|
31
|
+
@prev_issue = { @tracker.current_issue_id => @tracker.numerated_list[task_num.to_s]['title'] }
|
32
|
+
hash_to_json
|
28
33
|
begin
|
29
|
-
@tracker.
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
+
do_pomodoro(@tracker.numerated_list[task_num.to_s]['title'])
|
35
|
+
end while options[:a]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "resume", "resume to previous task, with key -a start autocontinue"
|
40
|
+
method_options :a => :boolean
|
41
|
+
def resume
|
42
|
+
check_rescue do
|
43
|
+
@prev_issue = json_to_hash
|
44
|
+
@tracker.current_issue_id = @prev_issue.keys.first
|
45
|
+
begin
|
46
|
+
do_pomodoro(@prev_issue[@prev_issue.keys.first])
|
34
47
|
end while options[:a]
|
35
48
|
end
|
36
49
|
end
|
37
50
|
|
38
51
|
private ##############
|
52
|
+
def do_pomodoro(issue_title)
|
53
|
+
pomodoro = @tracker.create_pomodoro
|
54
|
+
@tracker.pomodoro_id = pomodoro["id"]
|
55
|
+
puts "You started doing #{issue_title}"
|
56
|
+
one_pomodoro_iteration
|
57
|
+
end
|
58
|
+
|
39
59
|
def check_for_response_error(response)
|
40
60
|
if response.is_a? Hash
|
41
61
|
case response["error"]
|
@@ -65,14 +85,18 @@ private ##############
|
|
65
85
|
progressbar = ProgressBar.create( :format => '%a %bᗧ%i %p%% %t',
|
66
86
|
:progress_mark => ' ',
|
67
87
|
:remainder_mark => '・',
|
68
|
-
:title => "Break"
|
69
|
-
|
88
|
+
:title => "Break",
|
89
|
+
:start => 0,
|
90
|
+
:total => 300)
|
91
|
+
300.times { sleep(1); progressbar.refresh; progressbar.increment; }
|
70
92
|
end
|
71
93
|
|
72
94
|
def display_25_minutes_timer
|
73
95
|
progressbar = ProgressBar.create( :format => '%a %b %p%% %t',
|
74
|
-
:title => "Work"
|
75
|
-
|
96
|
+
:title => "Work",
|
97
|
+
:start => 0,
|
98
|
+
:total => 1500)
|
99
|
+
1500.times { sleep(1); progressbar.refresh; progressbar.increment; }
|
76
100
|
end
|
77
101
|
|
78
102
|
def get_key!
|
@@ -96,6 +120,20 @@ private ##############
|
|
96
120
|
puts "\nBye!"
|
97
121
|
end
|
98
122
|
end
|
123
|
+
|
124
|
+
def hash_to_json
|
125
|
+
File.delete(PATH_TO_PREV_ISSUE) if File.exists?(PATH_TO_PREV_ISSUE)
|
126
|
+
File.open(PATH_TO_PREV_ISSUE, "a+") { |f| f.write @prev_issue.to_json }
|
127
|
+
end
|
128
|
+
|
129
|
+
def json_to_hash
|
130
|
+
if File.exists? PATH_TO_PREV_ISSUE
|
131
|
+
JSON.parse(IO.read PATH_TO_PREV_ISSUE)
|
132
|
+
else
|
133
|
+
p "Haven't any previous issues. Start to do issue. 'et start {issue_number}'"
|
134
|
+
abort
|
135
|
+
end
|
136
|
+
end
|
99
137
|
end
|
100
138
|
|
101
139
|
CLI.start(ARGV)
|
data/lib/evados_tracker.rb
CHANGED
@@ -3,11 +3,11 @@ require 'ruby-progressbar'
|
|
3
3
|
|
4
4
|
module EvadosTracker
|
5
5
|
class Core
|
6
|
-
attr_accessor :numerated_list, :
|
6
|
+
attr_accessor :numerated_list, :current_issue_id, :pomodoro_id, :key
|
7
7
|
|
8
8
|
def initialize(key)
|
9
9
|
@key = key
|
10
|
-
@
|
10
|
+
@current_issue_id
|
11
11
|
@pomodoro_id
|
12
12
|
@numerated_list = {}
|
13
13
|
end
|
@@ -22,21 +22,21 @@ module EvadosTracker
|
|
22
22
|
|
23
23
|
def create_pomodoro
|
24
24
|
check_rescue do
|
25
|
-
@pomodoro_id = HTTParty.post("http://pm.evados.com/api/v1/issues/" + "#{@
|
25
|
+
@pomodoro_id = HTTParty.post("http://pm.evados.com/api/v1/issues/" + "#{@current_issue_id}" +
|
26
26
|
"/pomodoros.json?auth_token=" + "#{@key}")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def commit_pomodoro
|
31
31
|
check_rescue do
|
32
|
-
response = HTTParty.put("http://pm.evados.com/api/v1/issues/" + "#{@
|
32
|
+
response = HTTParty.put("http://pm.evados.com/api/v1/issues/" + "#{@current_issue_id}" +
|
33
33
|
"/pomodoros/" + "#{@pomodoro_id}" + ".json?auth_token=" + "#{@key}")
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
def delete_pomodoro
|
38
38
|
check_rescue do
|
39
|
-
response = HTTParty.delete("http://pm.evados.com/api/v1/issues/" + "#{@
|
39
|
+
response = HTTParty.delete("http://pm.evados.com/api/v1/issues/" + "#{@current_issue_id}" +
|
40
40
|
"/pomodoros/" + "#{@pomodoro_id}" + ".json?auth_token=" + "#{@key}")
|
41
41
|
end
|
42
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evados-tracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seva Rybakov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|