sredder 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sredder.rb +1 -0
- data/lib/sredder/arg_parser.rb +20 -3
- data/lib/sredder/version.rb +1 -1
- data/lib/sredder/wrike_auth.rb +3 -3
- data/spec/sredder/arg_parser_spec.rb +14 -0
- data/spec/sredder/wrike_auth_spec.rb +3 -1
- metadata +1 -1
data/lib/sredder.rb
CHANGED
data/lib/sredder/arg_parser.rb
CHANGED
@@ -4,6 +4,14 @@ require 'optparse/time'
|
|
4
4
|
module Sredder
|
5
5
|
class ArgParser
|
6
6
|
|
7
|
+
FOLDER_NAMES = {
|
8
|
+
:p =>'Programming',
|
9
|
+
:s =>'Project Supervision',
|
10
|
+
:r =>'Requirements Engineering',
|
11
|
+
:a =>'Software architecture and design',
|
12
|
+
:t =>'Testing'
|
13
|
+
}
|
14
|
+
|
7
15
|
def options
|
8
16
|
@options ||= defaults
|
9
17
|
end
|
@@ -44,7 +52,7 @@ module Sredder
|
|
44
52
|
options[:date] = Util.time_stamp(date)
|
45
53
|
end
|
46
54
|
|
47
|
-
opts.on("-f", "--folder FOLDER", "The wrike FOLDER in which to place the task (default #{defaults[:folder]})") do |folder|
|
55
|
+
opts.on("-f", "--folder FOLDER", FOLDER_NAMES.values, FOLDER_NAMES, "The wrike FOLDER in which to place the task (default #{defaults[:folder]})") do |folder|
|
48
56
|
options[:folder] = folder
|
49
57
|
end
|
50
58
|
|
@@ -53,6 +61,15 @@ module Sredder
|
|
53
61
|
exit
|
54
62
|
end
|
55
63
|
|
64
|
+
opts.on_tail("--folders", "Show available folders") do
|
65
|
+
puts "The available wrike folders are:"
|
66
|
+
puts "\t" + FOLDER_NAMES.values.join(', ')
|
67
|
+
puts "\nFor convenience you can use the shortest unambiguous string of characters or one of the following mappings:"
|
68
|
+
puts ""
|
69
|
+
FOLDER_NAMES.each {|k,v| puts "\t#{k} => #{v}" }
|
70
|
+
exit
|
71
|
+
end
|
72
|
+
|
56
73
|
opts.on_tail("--version", "Show version") do
|
57
74
|
puts Sredder::VERSION
|
58
75
|
exit
|
@@ -67,10 +84,10 @@ module Sredder
|
|
67
84
|
|
68
85
|
def defaults
|
69
86
|
{
|
70
|
-
:folder =>
|
87
|
+
:folder => FOLDER_NAMES.values[0],
|
71
88
|
:date => Util.time_stamp
|
72
89
|
}
|
73
90
|
end
|
74
91
|
|
75
92
|
end
|
76
|
-
end
|
93
|
+
end
|
data/lib/sredder/version.rb
CHANGED
data/lib/sredder/wrike_auth.rb
CHANGED
@@ -26,8 +26,8 @@ module Sredder
|
|
26
26
|
|
27
27
|
def run_oauth_procedure
|
28
28
|
@request_token = consumer.get_request_token
|
29
|
-
puts 'Sredder is about to open your browser
|
30
|
-
puts 'Please return to the terminal after you
|
29
|
+
puts 'Sredder is about to open your browser to complete the oauth protocol.'
|
30
|
+
puts 'Please return to the terminal after you authenticate with Wrike.'
|
31
31
|
|
32
32
|
Util.wait_for_input
|
33
33
|
|
@@ -71,4 +71,4 @@ module Sredder
|
|
71
71
|
|
72
72
|
end
|
73
73
|
|
74
|
-
end
|
74
|
+
end
|
@@ -9,6 +9,16 @@ describe Sredder::ArgParser do
|
|
9
9
|
|
10
10
|
describe 'parse' do
|
11
11
|
|
12
|
+
it 'accepts short hand for the folder name' do
|
13
|
+
result = parser.parse(['-f', 's'])
|
14
|
+
result[:folder].should == 'Project Supervision'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'accepts the full folder name' do
|
18
|
+
result = parser.parse(['-f', 'Project Supervision'])
|
19
|
+
result[:folder].should == 'Project Supervision'
|
20
|
+
end
|
21
|
+
|
12
22
|
it 'parses the message' do
|
13
23
|
result = parser.parse(['-m', 'some message'])
|
14
24
|
result[:message].should == 'some message'
|
@@ -44,6 +54,10 @@ describe Sredder::ArgParser do
|
|
44
54
|
lambda { parser.parse(['--version']) }.should raise_error SystemExit
|
45
55
|
end
|
46
56
|
|
57
|
+
it 'it can print the folder mappings' do
|
58
|
+
lambda { parser.parse(['--folders']) }.should raise_error SystemExit
|
59
|
+
end
|
60
|
+
|
47
61
|
it 'sets defaults' do
|
48
62
|
result = parser.parse([])
|
49
63
|
result[:date].should_not be_nil
|
@@ -18,7 +18,9 @@ describe Sredder::WrikeAuth do
|
|
18
18
|
|
19
19
|
describe '#authorized?' do
|
20
20
|
|
21
|
-
it 'returns false
|
21
|
+
it 'returns false if the token and secret attrs not are set' do
|
22
|
+
auth.token = nil
|
23
|
+
auth.secret = 'blah'
|
22
24
|
auth.authorized?.should be_false
|
23
25
|
end
|
24
26
|
|