get_to_work 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -1
- data/lib/get_to_work.rb +1 -0
- data/lib/get_to_work/cli.rb +8 -5
- data/lib/get_to_work/command.rb +3 -1
- data/lib/get_to_work/command/bootstrap.rb +19 -20
- data/lib/get_to_work/command/last_story.rb +11 -0
- data/lib/get_to_work/command/start.rb +5 -5
- data/lib/get_to_work/command/stop.rb +2 -2
- data/lib/get_to_work/menu.rb +1 -1
- data/lib/get_to_work/service/harvest.rb +3 -1
- data/lib/get_to_work/service/pivotal_tracker.rb +3 -1
- data/lib/get_to_work/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99db98a21f49f1746d65a6a247c7e36493b06e17
|
4
|
+
data.tar.gz: 50c64d83496558636bc06bfe78c94f92620accdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0577c64c70c83fe6a8e54b7b1874c11f59f972d686bc88fb5fe07ceddcac16aad42464f54d322d6b4a21e4931573c341974cf8ebcfda3d0f7fd18adb6452c54
|
7
|
+
data.tar.gz: e14692a6e1efe9287a15004688399c66eb5877dcc7517ed2d8a2be9c29ea0e2f7172c3acfa3a8903566da30ced26389a2f66494ad188d1b50e9cda32410f9a24
|
data/.rubocop.yml
CHANGED
@@ -4,6 +4,8 @@ AllCops:
|
|
4
4
|
- "vendor/**/*"
|
5
5
|
- "db/schema.rb"
|
6
6
|
UseCache: false
|
7
|
+
Style/LineLength:
|
8
|
+
Max: 130
|
7
9
|
Style/CollectionMethods:
|
8
10
|
Description: Preferred collection methods.
|
9
11
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
|
@@ -36,7 +38,7 @@ Style/IfUnlessModifier:
|
|
36
38
|
Description: Favor modifier if/unless usage when you have a single-line body.
|
37
39
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
|
38
40
|
Enabled: false
|
39
|
-
MaxLineLength:
|
41
|
+
MaxLineLength: 130
|
40
42
|
Style/OptionHash:
|
41
43
|
Description: Don't use option hashes when you can use keyword arguments.
|
42
44
|
Enabled: false
|
data/lib/get_to_work.rb
CHANGED
@@ -11,6 +11,7 @@ require "get_to_work/keychain"
|
|
11
11
|
require "get_to_work/command/bootstrap"
|
12
12
|
require "get_to_work/command/start"
|
13
13
|
require "get_to_work/command/stop"
|
14
|
+
require "get_to_work/command/last_story"
|
14
15
|
require "get_to_work/service"
|
15
16
|
require "get_to_work/service/pivotal_tracker"
|
16
17
|
require "get_to_work/service/harvest"
|
data/lib/get_to_work/cli.rb
CHANGED
@@ -1,20 +1,23 @@
|
|
1
1
|
module GetToWork
|
2
2
|
class CLI < Thor
|
3
|
-
include GetToWork::Menu
|
4
|
-
|
5
3
|
desc "bootstrap", "creates .gtw configuration for your current working directory"
|
6
4
|
def bootstrap
|
7
|
-
GetToWork::Command::Bootstrap.run
|
5
|
+
GetToWork::Command::Bootstrap.run
|
8
6
|
end
|
9
7
|
|
10
8
|
desc "start <Pivotal Tracker Story ID or URL>", "start working on a pivotal tracker story"
|
11
9
|
def start(pt_id = nil)
|
12
|
-
GetToWork::Command::Start.run(
|
10
|
+
GetToWork::Command::Start.run(pt_id: pt_id)
|
13
11
|
end
|
14
12
|
|
15
13
|
desc "stop", "#stop working on your current story"
|
16
14
|
def stop
|
17
|
-
GetToWork::Command::Stop.run
|
15
|
+
GetToWork::Command::Stop.run
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "last_story", "returns the id of the last story started"
|
19
|
+
def last_story
|
20
|
+
GetToWork::Command::LastStory.run
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
data/lib/get_to_work/command.rb
CHANGED
@@ -2,13 +2,15 @@ require "keychain"
|
|
2
2
|
|
3
3
|
module GetToWork
|
4
4
|
class Command
|
5
|
+
include Thor::Shell
|
6
|
+
include GetToWork::Menu
|
7
|
+
|
5
8
|
def self.run(opts = {})
|
6
9
|
trap("SIGINT") { exit! }
|
7
10
|
new(opts).run
|
8
11
|
end
|
9
12
|
|
10
13
|
def initialize(opts = {})
|
11
|
-
@cli = opts[:cli]
|
12
14
|
end
|
13
15
|
|
14
16
|
def config_file
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module GetToWork
|
2
2
|
class Command
|
3
3
|
class Bootstrap < GetToWork::Command
|
4
|
-
|
5
|
-
|
6
|
-
def run(opts = {})
|
4
|
+
def run
|
7
5
|
check_for_config_file
|
8
6
|
|
9
7
|
pt = GetToWork::Service::PivotalTracker.new
|
10
8
|
|
11
|
-
|
12
|
-
|
9
|
+
shell.say "\n\nStep #1 #{pt.display_name} Setup", :magenta
|
10
|
+
shell.say "-----------------------------", :magenta
|
13
11
|
|
14
12
|
if pt.keychain
|
15
13
|
pt.authenticate_with_keychain
|
@@ -23,9 +21,8 @@ module GetToWork
|
|
23
21
|
|
24
22
|
GetToWork::ConfigFile.save
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
@cli.say "-----------------------------", :magenta
|
24
|
+
shell.say "\n\nStep #2 #{harvest_service.display_name} Setup", :magenta
|
25
|
+
shell.say "-----------------------------", :magenta
|
29
26
|
|
30
27
|
unless harvest_service.authenticate_with_keychain
|
31
28
|
subdomain, username, password = prompt_for_subdomain_and_login(harvest_service)
|
@@ -50,36 +47,34 @@ module GetToWork
|
|
50
47
|
end
|
51
48
|
|
52
49
|
def check_for_config_file
|
53
|
-
|
54
|
-
|
55
|
-
if @config_file
|
56
|
-
unless @cli.yes?("Would you like to overwrite your existing #{GetToWork::ConfigFile.filename} file? [y/N]", :green)
|
50
|
+
if config_file
|
51
|
+
unless shell.yes?("Would you like to overwrite your existing #{GetToWork::ConfigFile.filename} file? [y/N]", :green)
|
57
52
|
exit(0)
|
58
53
|
end
|
59
54
|
end
|
60
55
|
end
|
61
56
|
|
62
57
|
def prompt_for_login(service)
|
63
|
-
username =
|
64
|
-
password =
|
58
|
+
username = shell.ask "#{service.display_name} Username:", :green
|
59
|
+
password = shell.ask "#{service.display_name} Password:", :green, echo: false
|
65
60
|
|
66
61
|
[username, password]
|
67
62
|
end
|
68
63
|
|
69
64
|
def prompt_for_subdomain_and_login(service)
|
70
|
-
subdomain =
|
65
|
+
subdomain = shell.ask "#{service.display_name} Subdomain:", :green
|
71
66
|
username, password = prompt_for_login(service)
|
72
67
|
|
73
68
|
[subdomain, username, password]
|
74
69
|
end
|
75
70
|
|
76
71
|
def auth_with_service(service:, username:, password:, subdomain: nil)
|
77
|
-
|
72
|
+
shell.say "\n\nAuthenticating with #{service.display_name}...", :magenta
|
78
73
|
|
79
74
|
begin
|
80
75
|
service.authenticate(username: username, password: password, subdomain: subdomain)
|
81
76
|
rescue Service::UnauthorizedError
|
82
|
-
|
77
|
+
shell.say "Could not authenticate with #{service.display_name}", :red
|
83
78
|
exit(1)
|
84
79
|
end
|
85
80
|
|
@@ -89,7 +84,7 @@ module GetToWork
|
|
89
84
|
def prompt_select_project(service)
|
90
85
|
project_options = GetToWork::MenuPresenter.with_collection(service.projects)
|
91
86
|
|
92
|
-
|
87
|
+
menu_ask(
|
93
88
|
"\nSelect a #{service.display_name} project:",
|
94
89
|
project_options,
|
95
90
|
:green,
|
@@ -98,9 +93,13 @@ module GetToWork
|
|
98
93
|
end
|
99
94
|
|
100
95
|
def prompt_select_tasks(service, project)
|
101
|
-
|
96
|
+
tasks = project["tasks"].sort do |x, y|
|
97
|
+
x[:name] <=> y[:name]
|
98
|
+
end
|
99
|
+
|
100
|
+
project_options = GetToWork::MenuPresenter.with_collection(tasks)
|
102
101
|
|
103
|
-
|
102
|
+
menu_ask(
|
104
103
|
"\nSelect a #{service.display_name} Task:",
|
105
104
|
project_options,
|
106
105
|
:green,
|
@@ -32,10 +32,10 @@ module GetToWork
|
|
32
32
|
last_story = config_file["last_story"]
|
33
33
|
|
34
34
|
if last_story
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
answer =
|
35
|
+
shell.say "\nWould you like to start a timer for your last story?", :green
|
36
|
+
shell.say " ##{last_story[:id.to_s]} ", [:bold, :cyan]
|
37
|
+
shell.say "#{last_story[:name.to_s]}", :magenta
|
38
|
+
answer = shell.yes? "\n[y/N]", :green
|
39
39
|
|
40
40
|
if answer
|
41
41
|
@pt_id = last_story["id"]
|
@@ -43,7 +43,7 @@ module GetToWork
|
|
43
43
|
exit(0)
|
44
44
|
end
|
45
45
|
else
|
46
|
-
|
46
|
+
shell.say "Couldn't find your last started timer. Please specify a story id."
|
47
47
|
exit(0)
|
48
48
|
end
|
49
49
|
end
|
@@ -3,7 +3,7 @@ module GetToWork
|
|
3
3
|
class Stop < GetToWork::Command
|
4
4
|
def run
|
5
5
|
if last_timer
|
6
|
-
|
6
|
+
shell.say "\nStopping your current timer...\n\n", :green
|
7
7
|
result = harvest_service.stop_timer(last_timer)
|
8
8
|
|
9
9
|
if result["id"]
|
@@ -11,7 +11,7 @@ module GetToWork
|
|
11
11
|
config_file.save
|
12
12
|
end
|
13
13
|
else
|
14
|
-
|
14
|
+
shell.say "\nYour timer has already been stopped.\n\n", :red
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/lib/get_to_work/menu.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module GetToWork
|
2
2
|
module Menu
|
3
3
|
def menu_ask(statement, options, *args)
|
4
|
-
print_table(options.table) # Assuming MenuPresenter type
|
4
|
+
shell.print_table(options.table) # Assuming MenuPresenter type
|
5
5
|
choice = ask(statement, *args)
|
6
6
|
options.item_for(choice: choice)
|
7
7
|
end
|
data/lib/get_to_work/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: get_to_work
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Rittersdorf
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -217,6 +217,7 @@ files:
|
|
217
217
|
- lib/get_to_work/cli.rb
|
218
218
|
- lib/get_to_work/command.rb
|
219
219
|
- lib/get_to_work/command/bootstrap.rb
|
220
|
+
- lib/get_to_work/command/last_story.rb
|
220
221
|
- lib/get_to_work/command/start.rb
|
221
222
|
- lib/get_to_work/command/stop.rb
|
222
223
|
- lib/get_to_work/config_file.rb
|