milkmaid 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +50 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +63 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/bin/milkmaid +117 -0
- data/lib/milkmaid.rb +99 -0
- data/spec/milkmaid_spec.rb +152 -0
- data/spec/spec_helper.rb +12 -0
- metadata +180 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
gem "main", "~> 4.7.7"
|
3
|
+
gem "moocow", "~> 1.1.0"
|
4
|
+
gem "paint", "~> 0.8.3"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec"
|
10
|
+
gem "bundler"
|
11
|
+
gem "jeweler"
|
12
|
+
gem "ZenTest"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
ZenTest (4.6.2)
|
5
|
+
arrayfields (4.7.4)
|
6
|
+
chronic (0.6.4)
|
7
|
+
diff-lcs (1.1.3)
|
8
|
+
fattr (2.2.0)
|
9
|
+
git (1.2.5)
|
10
|
+
gli (1.3.3)
|
11
|
+
httparty (0.8.0)
|
12
|
+
multi_json
|
13
|
+
multi_xml
|
14
|
+
jeweler (1.6.4)
|
15
|
+
bundler (~> 1.0)
|
16
|
+
git (>= 1.2.5)
|
17
|
+
rake
|
18
|
+
main (4.7.7)
|
19
|
+
arrayfields (~> 4.7.4)
|
20
|
+
chronic (~> 0.6.2)
|
21
|
+
fattr (~> 2.2.0)
|
22
|
+
map (~> 4.3.0)
|
23
|
+
map (4.3.0)
|
24
|
+
moocow (1.1.0)
|
25
|
+
gli (>= 0.1.5)
|
26
|
+
httparty (>= 0.3.1)
|
27
|
+
multi_json (1.0.3)
|
28
|
+
multi_xml (0.4.1)
|
29
|
+
paint (0.8.3)
|
30
|
+
rake (0.9.2)
|
31
|
+
rspec (2.6.0)
|
32
|
+
rspec-core (~> 2.6.0)
|
33
|
+
rspec-expectations (~> 2.6.0)
|
34
|
+
rspec-mocks (~> 2.6.0)
|
35
|
+
rspec-core (2.6.4)
|
36
|
+
rspec-expectations (2.6.0)
|
37
|
+
diff-lcs (~> 1.1.2)
|
38
|
+
rspec-mocks (2.6.0)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
ZenTest
|
45
|
+
bundler
|
46
|
+
jeweler
|
47
|
+
main (~> 4.7.7)
|
48
|
+
moocow (~> 1.1.0)
|
49
|
+
paint (~> 0.8.3)
|
50
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Marius Grigoriu
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
= Milkmaid
|
2
|
+
|
3
|
+
Milkmaid is a command-line client for Remember the Milk.
|
4
|
+
|
5
|
+
==Features
|
6
|
+
* View a list of incomplete tasks, and their due dates
|
7
|
+
* Complete a task
|
8
|
+
* Postpone a task
|
9
|
+
* Add a new task, setting properties using the Smart Add feature
|
10
|
+
|
11
|
+
== Installing
|
12
|
+
|
13
|
+
$ gem install milkmaid
|
14
|
+
|
15
|
+
== Authorizing
|
16
|
+
|
17
|
+
Before you can connect to your tasks you must authorize the client.
|
18
|
+
|
19
|
+
1. $ milkmaid auth start
|
20
|
+
2. Follow the generated link
|
21
|
+
3. $ milkmaid auth finish
|
22
|
+
|
23
|
+
Now you are ready to work with your tasks.
|
24
|
+
|
25
|
+
== Commands
|
26
|
+
|
27
|
+
View a list of incomplete tasks and get task numbers. You will need a task
|
28
|
+
number to do things to tasks like completing or postponing them. The task
|
29
|
+
number appears at the beginning.
|
30
|
+
|
31
|
+
$ milkmaid list
|
32
|
+
|
33
|
+
Complete a task
|
34
|
+
|
35
|
+
$ milkmaid complete <task number>
|
36
|
+
|
37
|
+
|
38
|
+
Postpone a task
|
39
|
+
|
40
|
+
$ milkmaid postpone <task number>
|
41
|
+
|
42
|
+
Add a task (Use single quotes to contain the task name)
|
43
|
+
|
44
|
+
Adding a task supports Remember the Milk's Smart Add feature. With it you
|
45
|
+
can set properties such as the due date, priority, etc.
|
46
|
+
|
47
|
+
$ milkmaid add '<task name>'
|
48
|
+
|
49
|
+
== Contributing to Milkmaid
|
50
|
+
|
51
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
52
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
53
|
+
* Fork the project
|
54
|
+
* Start a feature/bugfix branch
|
55
|
+
* Commit and push until you are happy with your contribution
|
56
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
57
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
58
|
+
|
59
|
+
== Copyright
|
60
|
+
|
61
|
+
Copyright (c) 2011 Marius Grigoriu. See LICENSE.txt for
|
62
|
+
further details.
|
63
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "milkmaid"
|
18
|
+
gem.homepage = "http://github.com/mariusgrigoriu/milkmaid"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Milkmaid is a command-line client for Remember the Milk}
|
21
|
+
gem.description = %Q{Milkmaid is a command-line client for Remember the Milk}
|
22
|
+
gem.email = "marius.grigoriu@live.com"
|
23
|
+
gem.authors = ["Marius Grigoriu"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "Milkmaid #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/milkmaid
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
|
+
|
5
|
+
require 'main'
|
6
|
+
require 'paint'
|
7
|
+
require 'milkmaid'
|
8
|
+
|
9
|
+
def milkmaid
|
10
|
+
@milkmaid ||= Milkmaid.new
|
11
|
+
end
|
12
|
+
|
13
|
+
Main {
|
14
|
+
def run
|
15
|
+
help!
|
16
|
+
end
|
17
|
+
|
18
|
+
mode :list do
|
19
|
+
def run
|
20
|
+
begin
|
21
|
+
milkmaid.incomplete_tasks.each_with_index do |taskseries, i|
|
22
|
+
text = "#{i+1}: #{taskseries['name']}"
|
23
|
+
text << "(R)" unless taskseries['rrule'].nil?
|
24
|
+
text << " #{Time.parse(taskseries['task']['due']).getlocal.strftime(
|
25
|
+
"%A %b %d, %Y %I:%M %p")}" unless taskseries['task']['due'].empty?
|
26
|
+
color = {
|
27
|
+
'1'=>[234, 82, 0],
|
28
|
+
'2'=>[0, 96, 191],
|
29
|
+
'3'=>[53, 154, 255],
|
30
|
+
'N'=>:nothing
|
31
|
+
}
|
32
|
+
mode1 = mode2 = nil
|
33
|
+
case Date.today <=> Date.parse(taskseries['task']['due'])
|
34
|
+
when 0
|
35
|
+
mode1 = :bold
|
36
|
+
when 1
|
37
|
+
mode1 = :bold
|
38
|
+
mode2 = :underline
|
39
|
+
end unless taskseries['task']['due'].empty?
|
40
|
+
puts Paint[text, color[taskseries['task']['priority']], mode1, mode2]
|
41
|
+
end
|
42
|
+
rescue RTM::NoTokenException
|
43
|
+
puts "Authentication token not found. Run `#{__FILE__} auth start`"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
mode :complete do
|
49
|
+
argument(:tasknum) {
|
50
|
+
cast :int
|
51
|
+
}
|
52
|
+
|
53
|
+
def run
|
54
|
+
begin
|
55
|
+
milkmaid.complete_task params['tasknum'].value
|
56
|
+
rescue Milkmaid::TaskNotFound
|
57
|
+
puts "Task ##{params['tasknum'].value} not found. Run `#{__FILE__} list` " +
|
58
|
+
"to load a list of tasks."
|
59
|
+
rescue RTM::NoTokenException
|
60
|
+
puts "Authentication token not found. Run `#{__FILE__} auth start`"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
mode :postpone do
|
66
|
+
argument(:tasknum) {
|
67
|
+
cast :int
|
68
|
+
}
|
69
|
+
|
70
|
+
def run
|
71
|
+
begin
|
72
|
+
milkmaid.postpone_task params['tasknum'].value
|
73
|
+
rescue Milkmaid::TaskNotFound
|
74
|
+
puts "Task ##{params['tasknum'].value} not found. Run `#{__FILE__} list` " +
|
75
|
+
"to load a list of tasks."
|
76
|
+
rescue RTM::NoTokenException
|
77
|
+
puts "Authentication token not found. Run `#{__FILE__} auth start`"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
mode :add do
|
83
|
+
argument(:taskname)
|
84
|
+
|
85
|
+
def run
|
86
|
+
begin
|
87
|
+
milkmaid.add_task params['taskname'].value
|
88
|
+
rescue RTM::NoTokenException
|
89
|
+
puts "Authentication token not found. Run `#{__FILE__} auth start`"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
mode :auth do
|
95
|
+
mode :start do
|
96
|
+
def run
|
97
|
+
puts '1. Visit the URL to authorize the application to access your account.'
|
98
|
+
puts "2. Run `#{__FILE__} auth finish`"
|
99
|
+
puts
|
100
|
+
puts milkmaid.auth_start
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
mode :finish do
|
105
|
+
def run
|
106
|
+
begin
|
107
|
+
milkmaid.auth_finish
|
108
|
+
puts 'Authentication token saved.'
|
109
|
+
rescue RTM::VerificationException
|
110
|
+
puts "Invalid frob. Did you visit the link from `#{__FILE__} auth start`?"
|
111
|
+
rescue RuntimeError
|
112
|
+
puts "Frob does not exist. Did you run `#{__FILE__} auth start`?"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
}
|
data/lib/milkmaid.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'moocow'
|
2
|
+
|
3
|
+
class Milkmaid
|
4
|
+
def initialize
|
5
|
+
@rtm = RTM::RTM.new(RTM::Endpoint.new('31308536ffed80061df846c3a4564a27', 'c1476318e3483441'))
|
6
|
+
begin
|
7
|
+
@config_file = File.join(ENV['HOME'], '.milkmaid')
|
8
|
+
@config = YAML.load_file(@config_file)
|
9
|
+
@auth = @rtm.auth
|
10
|
+
@auth.frob = @config[:frob]
|
11
|
+
@rtm.token = @config[:token]
|
12
|
+
@timeline = @rtm.timelines.create['timeline']
|
13
|
+
rescue Errno::ENOENT
|
14
|
+
@config = {}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def incomplete_tasks
|
19
|
+
entries = []
|
20
|
+
list_id = nil
|
21
|
+
@rtm.tasks.get_list['tasks']['list'].as_array.each do |items|
|
22
|
+
list_id = items['id']
|
23
|
+
if !items['taskseries'].nil?
|
24
|
+
items['taskseries'].as_array.each do |taskseries|
|
25
|
+
taskseries['list_id'] = list_id
|
26
|
+
entries << taskseries if taskseries['task']['completed'].empty?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
entries.sort! do |a, b|
|
31
|
+
result = a['task']['priority'] <=> b['task']['priority']
|
32
|
+
if result == 0
|
33
|
+
if a['task']['due'].empty?
|
34
|
+
1
|
35
|
+
elsif b['task']['due'].empty?
|
36
|
+
-1
|
37
|
+
else
|
38
|
+
Time.parse(a['task']['due']) <=> Time.parse(b['task']['due'])
|
39
|
+
end
|
40
|
+
else
|
41
|
+
result
|
42
|
+
end
|
43
|
+
end
|
44
|
+
entries.each_with_index do |taskseries, i|
|
45
|
+
@config["#{i+1}list_id"] = taskseries['list_id']
|
46
|
+
@config["#{i+1}taskseries_id"] = taskseries['id']
|
47
|
+
@config["#{i+1}task_id"] = taskseries['task']['id']
|
48
|
+
end
|
49
|
+
save_config
|
50
|
+
entries
|
51
|
+
end
|
52
|
+
|
53
|
+
def complete_task(tasknum)
|
54
|
+
check_task_ids tasknum
|
55
|
+
call_rtm_api :complete, tasknum
|
56
|
+
end
|
57
|
+
|
58
|
+
def postpone_task(tasknum)
|
59
|
+
check_task_ids tasknum
|
60
|
+
call_rtm_api :postpone, tasknum
|
61
|
+
end
|
62
|
+
|
63
|
+
def add_task(name)
|
64
|
+
@rtm.tasks.add :name=>name, :parse=>'1', :timeline=>@timeline
|
65
|
+
end
|
66
|
+
|
67
|
+
def auth_start
|
68
|
+
url = @auth.url
|
69
|
+
@config[:frob] = @auth.frob
|
70
|
+
save_config
|
71
|
+
url
|
72
|
+
end
|
73
|
+
|
74
|
+
def auth_finish
|
75
|
+
@config[:token] = @auth.get_token
|
76
|
+
save_config
|
77
|
+
end
|
78
|
+
|
79
|
+
class TaskNotFound < StandardError
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
def save_config
|
84
|
+
File.open(@config_file, 'w') { |f| YAML.dump(@config, f) }
|
85
|
+
end
|
86
|
+
|
87
|
+
def check_task_ids(tasknum)
|
88
|
+
raise TaskNotFound if @config["#{tasknum}list_id"].nil? ||
|
89
|
+
@config["#{tasknum}taskseries_id"].nil? ||
|
90
|
+
@config["#{tasknum}task_id"].nil?
|
91
|
+
end
|
92
|
+
|
93
|
+
def call_rtm_api(method, tasknum)
|
94
|
+
@rtm.tasks.send method, :list_id=>@config["#{tasknum}list_id"],
|
95
|
+
:taskseries_id=>@config["#{tasknum}taskseries_id"],
|
96
|
+
:task_id=>@config["#{tasknum}task_id"],
|
97
|
+
:timeline=>@timeline
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Milkmaid" do
|
4
|
+
let(:lib) { Milkmaid.new }
|
5
|
+
let(:auth_double) { double('auth').as_null_object }
|
6
|
+
let(:rtm_double) { double('rtm').as_null_object }
|
7
|
+
let(:timeline_double) { double('timeline').as_null_object }
|
8
|
+
let(:tasks_double) { double('tasks') }
|
9
|
+
|
10
|
+
before do
|
11
|
+
RTM::RTM.stub(:new) { rtm_double }
|
12
|
+
rtm_double.stub(:auth) { auth_double }
|
13
|
+
YAML.stub(:load_file).and_return({})
|
14
|
+
File.stub(:open)
|
15
|
+
rtm_double.stub_chain(:timelines, :create) { timeline_double }
|
16
|
+
rtm_double.stub(:tasks) { tasks_double }
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when config dotfile exists" do
|
20
|
+
it "loads the configuration dotfile" do
|
21
|
+
ENV['HOME'] = 'testhome'
|
22
|
+
YAML.should_receive(:load_file).with('testhome/.milkmaid') {
|
23
|
+
{:frob=>'testfrob',
|
24
|
+
:token=>'testtoken'} }
|
25
|
+
auth_double.should_receive(:frob=).with('testfrob')
|
26
|
+
rtm_double.should_receive(:token=).with('testtoken')
|
27
|
+
lib
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "when config dotfile does not exist" do
|
32
|
+
it "does not crash" do
|
33
|
+
YAML.stub(:load_file).and_raise(Errno::ENOENT)
|
34
|
+
lib
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "listing tasks" do
|
39
|
+
let(:a) {{"name"=>"a", "id"=>"ats", "task"=>{"completed"=>"", "priority"=>"1",
|
40
|
+
"id"=>"at", "due"=>""}}}
|
41
|
+
let(:b) {{"name"=>"b", "id"=>"bts", "task"=>{"completed"=>"", "priority"=>"1",
|
42
|
+
"id"=>"bt", "due"=>"2011-10-02T02:52:58Z"}}}
|
43
|
+
let(:c) {{"name"=>"c", "id"=>"cts", "task"=>{"completed"=>"", "priority"=>"N",
|
44
|
+
"id"=>"ct", "due"=>"2012-10-02T02:52:58Z"}}}
|
45
|
+
let(:d) {{"name"=>"d", "id"=>"dts", "task"=>{"completed"=>"", "priority"=>"N",
|
46
|
+
"id"=>"dt", "due"=>"2011-10-02T02:52:58Z"}}}
|
47
|
+
before do
|
48
|
+
RTM::RTM.stub_chain(:new, :tasks, :get_list) {
|
49
|
+
{"tasks"=>{"list"=>[{"id"=>"21242147", "taskseries"=>[
|
50
|
+
a, b, c, d,
|
51
|
+
{"name"=>"done task", "task"=>{"completed"=>"2011-10-02T02:52:58Z"}}
|
52
|
+
]},
|
53
|
+
{"id"=>"21242148"},
|
54
|
+
{"id"=>"21242149"},
|
55
|
+
{"id"=>"21242150"},
|
56
|
+
{"id"=>"21242151"},
|
57
|
+
{"id"=>"21242152"}],
|
58
|
+
"rev"=>"4k555btb3vcwscc8g44sog8kw4ccccc"},
|
59
|
+
"stat"=>"ok"}
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
it "returns all incomplete tasks in order of priority then due date" do
|
64
|
+
lib.incomplete_tasks.should == [b, a, d, c]
|
65
|
+
end
|
66
|
+
|
67
|
+
it "assigns and stores a local ID number to each task for easy addressing" do
|
68
|
+
should_store_in_configuration({
|
69
|
+
'1list_id'=>'21242147', '1taskseries_id'=>'bts', '1task_id'=>'bt',
|
70
|
+
'2list_id'=>'21242147', '2taskseries_id'=>'ats', '2task_id'=>'at',
|
71
|
+
'3list_id'=>'21242147', '3taskseries_id'=>'dts', '3task_id'=>'dt',
|
72
|
+
'4list_id'=>'21242147', '4taskseries_id'=>'cts', '4task_id'=>'ct'
|
73
|
+
})
|
74
|
+
lib.incomplete_tasks
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "working with existing tasks" do
|
79
|
+
it "raises an error when unable to find the desired task in config" do
|
80
|
+
lambda { lib.complete_task 1 }.should raise_error(Milkmaid::TaskNotFound)
|
81
|
+
lambda { lib.postpone_task 1 }.should raise_error(Milkmaid::TaskNotFound)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "marks the task as complete" do
|
85
|
+
should_call_rtm_api(:complete, 1)
|
86
|
+
lib.complete_task 1
|
87
|
+
end
|
88
|
+
|
89
|
+
it "postpones a task" do
|
90
|
+
should_call_rtm_api(:postpone, 2)
|
91
|
+
lib.postpone_task 2
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
it "adds a task to the inbox using Smart Add" do
|
96
|
+
tasks_double.should_receive(:add).with(:name=>'TestName', :parse=>'1',
|
97
|
+
:timeline=>timeline_double)
|
98
|
+
lib.add_task 'TestName'
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "authentication" do
|
102
|
+
before do
|
103
|
+
auth_double.stub(:url) { 'http://testurl' }
|
104
|
+
auth_double.stub(:frob) { 'testfrob' }
|
105
|
+
File.stub(:open)
|
106
|
+
end
|
107
|
+
|
108
|
+
context "when frob exists in config" do
|
109
|
+
before do
|
110
|
+
YAML.stub(:load_file) { {:frob=>'testfrob'} }
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "setup" do
|
114
|
+
it "directs the user to setup auth" do
|
115
|
+
lib.auth_start.should == 'http://testurl'
|
116
|
+
end
|
117
|
+
|
118
|
+
it "stores the frob in configuration" do
|
119
|
+
should_store_in_configuration({:frob=>"testfrob"})
|
120
|
+
lib.auth_start
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "completion" do
|
125
|
+
it "stores the auth token in the dotfile" do
|
126
|
+
auth_double.stub(:get_token) {'testtoken'}
|
127
|
+
should_store_in_configuration({
|
128
|
+
:frob=>'testfrob',
|
129
|
+
:token=>'testtoken'})
|
130
|
+
lib.auth_finish
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def should_store_in_configuration(config)
|
138
|
+
io_double = double('io')
|
139
|
+
File.should_receive(:open).and_yield(io_double)
|
140
|
+
YAML.should_receive(:dump).with(config, io_double)
|
141
|
+
end
|
142
|
+
|
143
|
+
def should_call_rtm_api(method, tasknum)
|
144
|
+
YAML.stub(:load_file) {{
|
145
|
+
"#{tasknum}list_id"=>"#{tasknum}l",
|
146
|
+
"#{tasknum}taskseries_id"=>"#{tasknum}ts",
|
147
|
+
"#{tasknum}task_id"=>"#{tasknum}t"
|
148
|
+
}}
|
149
|
+
tasks_double.should_receive(method).with(
|
150
|
+
:list_id=>"#{tasknum}l", :taskseries_id=>"#{tasknum}ts",
|
151
|
+
:task_id=>"#{tasknum}t", :timeline=>timeline_double)
|
152
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'milkmaid'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: milkmaid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Marius Grigoriu
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-10-03 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 45
|
27
|
+
segments:
|
28
|
+
- 4
|
29
|
+
- 7
|
30
|
+
- 7
|
31
|
+
version: 4.7.7
|
32
|
+
name: main
|
33
|
+
prerelease: false
|
34
|
+
type: :runtime
|
35
|
+
requirement: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 19
|
43
|
+
segments:
|
44
|
+
- 1
|
45
|
+
- 1
|
46
|
+
- 0
|
47
|
+
version: 1.1.0
|
48
|
+
name: moocow
|
49
|
+
prerelease: false
|
50
|
+
type: :runtime
|
51
|
+
requirement: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 57
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
- 8
|
62
|
+
- 3
|
63
|
+
version: 0.8.3
|
64
|
+
name: paint
|
65
|
+
prerelease: false
|
66
|
+
type: :runtime
|
67
|
+
requirement: *id003
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
name: rspec
|
79
|
+
prerelease: false
|
80
|
+
type: :development
|
81
|
+
requirement: *id004
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: 3
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
version: "0"
|
92
|
+
name: bundler
|
93
|
+
prerelease: false
|
94
|
+
type: :development
|
95
|
+
requirement: *id005
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
version: "0"
|
106
|
+
name: jeweler
|
107
|
+
prerelease: false
|
108
|
+
type: :development
|
109
|
+
requirement: *id006
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
hash: 3
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
version: "0"
|
120
|
+
name: ZenTest
|
121
|
+
prerelease: false
|
122
|
+
type: :development
|
123
|
+
requirement: *id007
|
124
|
+
description: Milkmaid is a command-line client for Remember the Milk
|
125
|
+
email: marius.grigoriu@live.com
|
126
|
+
executables:
|
127
|
+
- milkmaid
|
128
|
+
extensions: []
|
129
|
+
|
130
|
+
extra_rdoc_files:
|
131
|
+
- LICENSE.txt
|
132
|
+
- README.rdoc
|
133
|
+
files:
|
134
|
+
- .document
|
135
|
+
- .rspec
|
136
|
+
- Gemfile
|
137
|
+
- Gemfile.lock
|
138
|
+
- LICENSE.txt
|
139
|
+
- README.rdoc
|
140
|
+
- Rakefile
|
141
|
+
- VERSION
|
142
|
+
- bin/milkmaid
|
143
|
+
- lib/milkmaid.rb
|
144
|
+
- spec/milkmaid_spec.rb
|
145
|
+
- spec/spec_helper.rb
|
146
|
+
homepage: http://github.com/mariusgrigoriu/milkmaid
|
147
|
+
licenses:
|
148
|
+
- MIT
|
149
|
+
post_install_message:
|
150
|
+
rdoc_options: []
|
151
|
+
|
152
|
+
require_paths:
|
153
|
+
- lib
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
hash: 3
|
160
|
+
segments:
|
161
|
+
- 0
|
162
|
+
version: "0"
|
163
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
|
+
none: false
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
hash: 3
|
169
|
+
segments:
|
170
|
+
- 0
|
171
|
+
version: "0"
|
172
|
+
requirements: []
|
173
|
+
|
174
|
+
rubyforge_project:
|
175
|
+
rubygems_version: 1.8.10
|
176
|
+
signing_key:
|
177
|
+
specification_version: 3
|
178
|
+
summary: Milkmaid is a command-line client for Remember the Milk
|
179
|
+
test_files: []
|
180
|
+
|