rudo 0.0.11 → 0.1.00
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +7 -0
- data/MIT-LICENSE +19 -0
- data/README +25 -0
- data/Rakefile +10 -0
- data/bin/dun +0 -0
- data/bin/rad +0 -0
- data/bin/rudo +0 -0
- data/bin/walk +0 -0
- data/lib/rudo.rb +8 -7
- data/spec/fixtures/empty.yml +1 -0
- data/spec/fixtures/tasks.yml +4 -0
- data/spec/rudo_spec.rb +173 -0
- data/spec/spec_helper.rb +8 -0
- metadata +46 -67
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2011 by Robert Fletcher
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Rudo is a simple command line based todo list editor. Here are the commands:
|
2
|
+
|
3
|
+
# see the first n items on the list (default 5)
|
4
|
+
rudo
|
5
|
+
|
6
|
+
# add a task to the list
|
7
|
+
rad 'my task'
|
8
|
+
|
9
|
+
# add a task to the 2nd position
|
10
|
+
rad 'another task' 2
|
11
|
+
|
12
|
+
# mark the first task finished
|
13
|
+
dun
|
14
|
+
|
15
|
+
# mark the 5th task finished
|
16
|
+
dun 5
|
17
|
+
|
18
|
+
# mark the first 3 tasks finished
|
19
|
+
dun 3x
|
20
|
+
|
21
|
+
# move the first item to the back of the list
|
22
|
+
walk
|
23
|
+
|
24
|
+
# move the first 3 items to the back of the list
|
25
|
+
walk 3
|
data/Rakefile
ADDED
data/bin/dun
CHANGED
File without changes
|
data/bin/rad
CHANGED
File without changes
|
data/bin/rudo
CHANGED
File without changes
|
data/bin/walk
CHANGED
File without changes
|
data/lib/rudo.rb
CHANGED
@@ -6,16 +6,16 @@ class Rudo
|
|
6
6
|
def initialize(options={})
|
7
7
|
@file_path = File.expand_path(options.delete(:file_path) { '~/rudo.yml' })
|
8
8
|
|
9
|
-
@tasks = YAML.load(File.
|
9
|
+
@tasks = YAML.load(File.read(@file_path))
|
10
10
|
end
|
11
11
|
|
12
12
|
def print(options={})
|
13
13
|
colored = options.delete(:color) { true }
|
14
|
-
puts
|
14
|
+
puts stars
|
15
15
|
@tasks.each_with_index do |task, index|
|
16
16
|
puts "#{index + 1}: #{task}"
|
17
17
|
end
|
18
|
-
puts
|
18
|
+
puts stars
|
19
19
|
if colored
|
20
20
|
puts "#{@tasks.length} tasks remaining".green
|
21
21
|
else
|
@@ -51,10 +51,11 @@ class Rudo
|
|
51
51
|
|
52
52
|
private
|
53
53
|
|
54
|
+
def stars
|
55
|
+
"*" * 40
|
56
|
+
end
|
57
|
+
|
54
58
|
def write_tasks
|
55
|
-
File.
|
56
|
-
file.write(YAML.dump(@tasks))
|
57
|
-
end
|
58
|
-
true
|
59
|
+
File.write(@file_path, YAML.dump(@tasks))
|
59
60
|
end
|
60
61
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
--- []
|
data/spec/rudo_spec.rb
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'colored'
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
require './lib/rudo.rb'
|
6
|
+
|
7
|
+
describe Rudo do
|
8
|
+
before(:each) do
|
9
|
+
@empty_path = './spec/fixtures/empty.yml'
|
10
|
+
@tasks_path = './spec/fixtures/tasks.yml'
|
11
|
+
@stars = '*' * 40
|
12
|
+
File.stub(:write)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#print' do
|
16
|
+
context 'when the color option is set to false' do
|
17
|
+
before(:each) do
|
18
|
+
@rudo = Rudo.new(:file_path => @empty_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'does not color output' do
|
22
|
+
@rudo.should_receive(:puts).with(@stars).twice
|
23
|
+
@rudo.should_receive(:puts).with('0 tasks remaining')
|
24
|
+
@rudo.print({:color => false})
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when there are no tasks' do
|
29
|
+
before(:each) do
|
30
|
+
@rudo = Rudo.new(:file_path => @empty_path)
|
31
|
+
@rudo.stub(:puts).with(@stars)
|
32
|
+
@rudo.stub(:puts).with('0 tasks remaining'.green)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'prints two lines of stars' do
|
36
|
+
@rudo.should_receive(:puts).with(@stars).twice
|
37
|
+
@rudo.print
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'prints "0 tasks remaining" in green' do
|
41
|
+
@rudo.should_receive(:puts).with('0 tasks remaining'.green)
|
42
|
+
@rudo.print
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when there are tasks' do
|
47
|
+
before(:each) do
|
48
|
+
@rudo = Rudo.new(:file_path => @tasks_path)
|
49
|
+
@rudo.stub(:puts).with(@stars)
|
50
|
+
@rudo.stub(:puts).with('1: clean gutters')
|
51
|
+
@rudo.stub(:puts).with('2: do laundry')
|
52
|
+
@rudo.stub(:puts).with('3: eat pizza')
|
53
|
+
@rudo.stub(:puts).with('3 tasks remaining'.green)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'prints tasks between rows of stars' do
|
57
|
+
@rudo.should_receive(:puts).with(@stars)
|
58
|
+
@rudo.should_receive(:puts).with('1: clean gutters')
|
59
|
+
@rudo.should_receive(:puts).with('2: do laundry')
|
60
|
+
@rudo.should_receive(:puts).with('3: eat pizza')
|
61
|
+
@rudo.should_receive(:puts).with(@stars)
|
62
|
+
@rudo.print
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'prints the task count in green' do
|
66
|
+
@rudo.should_receive(:puts).with('3 tasks remaining'.green)
|
67
|
+
@rudo.print
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#add' do
|
73
|
+
before(:each) do
|
74
|
+
@tasks = YAML.load(File.read(@tasks_path))
|
75
|
+
@rudo = Rudo.new(:file_path => @tasks_path)
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when position is nil' do
|
79
|
+
it 'adds the task at the end of the list' do
|
80
|
+
@tasks += ['blah']
|
81
|
+
File.should_receive(:write).
|
82
|
+
with(File.expand_path(@tasks_path), YAML.dump(@tasks))
|
83
|
+
@rudo.add('blah')
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when position is given' do
|
88
|
+
it 'adds the task at that position in the list' do
|
89
|
+
@tasks = ['blah'] + @tasks
|
90
|
+
File.should_receive(:write).
|
91
|
+
with(File.expand_path(@tasks_path), YAML.dump(@tasks))
|
92
|
+
@rudo.add('blah', 0)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#remove' do
|
98
|
+
before(:each) do
|
99
|
+
@tasks = YAML.load(File.read(@tasks_path))
|
100
|
+
@rudo = Rudo.new(:file_path => @tasks_path)
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'when position is some number followed by an "x"' do
|
104
|
+
it 'removes the first n items' do
|
105
|
+
expected_tasks = @tasks[2..-1]
|
106
|
+
File.should_receive(:write).
|
107
|
+
with(File.expand_path(@tasks_path), YAML.dump(expected_tasks))
|
108
|
+
@rudo.remove('2x')
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context 'when the position is a number' do
|
113
|
+
it 'removes the item specified' do
|
114
|
+
expected_tasks = [ @tasks.first, @tasks.last ]
|
115
|
+
File.should_receive(:write).
|
116
|
+
with(File.expand_path(@tasks_path), YAML.dump(expected_tasks))
|
117
|
+
@rudo.remove('2')
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'when the position is trash text' do
|
122
|
+
it 'removes the first item in the list' do
|
123
|
+
expected_tasks = @tasks[1..-1]
|
124
|
+
File.should_receive(:write).
|
125
|
+
with(File.expand_path(@tasks_path), YAML.dump(expected_tasks))
|
126
|
+
@rudo.remove('trash')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'when the position is nil' do
|
131
|
+
it 'removes the first item in the list' do
|
132
|
+
expected_tasks = @tasks[1..-1]
|
133
|
+
File.should_receive(:write).
|
134
|
+
with(File.expand_path(@tasks_path), YAML.dump(expected_tasks))
|
135
|
+
@rudo.remove(nil)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context 'when the position is not given' do
|
140
|
+
it 'removes the first item in the list' do
|
141
|
+
expected_tasks = @tasks[1..-1]
|
142
|
+
File.should_receive(:write).
|
143
|
+
with(File.expand_path(@tasks_path), YAML.dump(expected_tasks))
|
144
|
+
@rudo.remove
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe '#walk' do
|
150
|
+
before(:each) do
|
151
|
+
@tasks = YAML.load(File.read(@tasks_path))
|
152
|
+
@rudo = Rudo.new(:file_path => @tasks_path)
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'when no argument is given' do
|
156
|
+
it 'moves the first item in the list to the end' do
|
157
|
+
expected_tasks = @tasks[1..-1] + @tasks[0, 1]
|
158
|
+
File.should_receive(:write).
|
159
|
+
with(File.expand_path(@tasks_path), YAML.dump(expected_tasks))
|
160
|
+
@rudo.walk
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'when a number is given' do
|
165
|
+
it 'moves n items to the end of the list' do
|
166
|
+
expected_tasks = @tasks[2..-1] + @tasks[0, 2]
|
167
|
+
File.should_receive(:write).
|
168
|
+
with(File.expand_path(@tasks_path), YAML.dump(expected_tasks))
|
169
|
+
@rudo.walk(2)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,104 +1,83 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rudo
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 11
|
10
|
-
version: 0.0.11
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.00
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Robert Fletcher
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-04-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: colored
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &20227880 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 2
|
33
|
-
version: "1.2"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.2'
|
34
22
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: trollop
|
38
23
|
prerelease: false
|
39
|
-
|
24
|
+
version_requirements: *20227880
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: trollop
|
27
|
+
requirement: &20226960 !ruby/object:Gem::Requirement
|
40
28
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
hash: 83
|
45
|
-
segments:
|
46
|
-
- 1
|
47
|
-
- 16
|
48
|
-
- 2
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
49
32
|
version: 1.16.2
|
50
33
|
type: :runtime
|
51
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *20226960
|
52
36
|
description: Tasks are saved in ~/rudo.yml
|
53
37
|
email: lobatifricha@gmail.com
|
54
|
-
executables:
|
38
|
+
executables:
|
55
39
|
- rudo
|
56
40
|
- rad
|
57
41
|
- dun
|
58
42
|
- walk
|
59
43
|
extensions: []
|
60
|
-
|
61
44
|
extra_rdoc_files: []
|
62
|
-
|
63
|
-
files:
|
45
|
+
files:
|
64
46
|
- lib/rudo.rb
|
65
|
-
-
|
66
|
-
-
|
47
|
+
- spec/rudo_spec.rb
|
48
|
+
- spec/fixtures/empty.yml
|
49
|
+
- spec/fixtures/tasks.yml
|
50
|
+
- spec/spec_helper.rb
|
67
51
|
- bin/dun
|
68
52
|
- bin/walk
|
69
|
-
|
53
|
+
- bin/rad
|
54
|
+
- bin/rudo
|
55
|
+
- Rakefile
|
56
|
+
- MIT-LICENSE
|
57
|
+
- Gemfile
|
58
|
+
- README
|
70
59
|
homepage: https://github.com/mockdeep/rudo
|
71
60
|
licenses: []
|
72
|
-
|
73
61
|
post_install_message:
|
74
62
|
rdoc_options: []
|
75
|
-
|
76
|
-
require_paths:
|
63
|
+
require_paths:
|
77
64
|
- lib
|
78
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
66
|
none: false
|
80
|
-
requirements:
|
81
|
-
- -
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
|
84
|
-
|
85
|
-
- 0
|
86
|
-
version: "0"
|
87
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
72
|
none: false
|
89
|
-
requirements:
|
90
|
-
- -
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
|
93
|
-
segments:
|
94
|
-
- 0
|
95
|
-
version: "0"
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
96
77
|
requirements: []
|
97
|
-
|
98
78
|
rubyforge_project:
|
99
|
-
rubygems_version: 1.
|
79
|
+
rubygems_version: 1.8.17
|
100
80
|
signing_key:
|
101
81
|
specification_version: 3
|
102
82
|
summary: A simple, semi-pretty command line based todo list manager
|
103
83
|
test_files: []
|
104
|
-
|