sredder 0.0.2 → 0.0.4

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.
@@ -47,6 +47,7 @@ module Sredder
47
47
  request.post('/api/json/v2/wrike.task.add', {
48
48
  title: title,
49
49
  description: description,
50
+ status: 1,
50
51
  parents: parent_folder_ids
51
52
  })
52
53
  request.json["task"]["id"] if request.success?
@@ -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 => 'Programming',
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
@@ -1,3 +1,3 @@
1
1
  module Sredder
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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 too complete the oauth protocol.'
30
- puts 'Please return to the terminal after you athenticate with write.'
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 by default' do
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
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sredder
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matthew Robertson