rudo 0.1.00 → 0.2.00

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.
data/Gemfile CHANGED
@@ -3,5 +3,6 @@ source "http://rubygems.org"
3
3
  gem 'rake'
4
4
  gem 'colored'
5
5
  gem 'trollop'
6
+ gem 'rspec'
6
7
 
7
8
  gemspec
@@ -0,0 +1,53 @@
1
+ # RUDO
2
+
3
+ ![status](https://secure.travis-ci.org/mockdeep/rudo.png?branch=master)
4
+
5
+ Rudo is a simple command line based todo list editor. Here are the commands:
6
+
7
+ see the first n items on the list (default 5)
8
+
9
+ ```
10
+ rudo
11
+ ```
12
+
13
+ add a task to the list
14
+
15
+ ```
16
+ rad 'my task'
17
+ ```
18
+
19
+ add a task to the 2nd position
20
+
21
+ ```
22
+ rad 'another task' 2
23
+ ```
24
+
25
+ mark the first task finished
26
+
27
+ ```
28
+ dun
29
+ ```
30
+
31
+ mark the 5th task finished
32
+
33
+ ```
34
+ dun 5
35
+ ```
36
+
37
+ mark the first 3 tasks finished
38
+
39
+ ```
40
+ dun 3x
41
+ ```
42
+
43
+ move the first item to the back of the list
44
+
45
+ ```
46
+ walk
47
+ ```
48
+
49
+ move the first 3 items to the back of the list
50
+
51
+ ```
52
+ walk 3
53
+ ```
data/bin/dun CHANGED
@@ -9,4 +9,4 @@ end
9
9
 
10
10
  r = Rudo.new(options)
11
11
  r.remove(ARGV[0])
12
- r.print(options)
12
+ puts r
data/bin/rad CHANGED
@@ -15,4 +15,4 @@ end
15
15
 
16
16
  r = Rudo.new(options)
17
17
  r.add(ARGV[0], position)
18
- r.print(options)
18
+ puts r
data/bin/rudo CHANGED
@@ -8,4 +8,4 @@ options = Trollop::options do
8
8
  end
9
9
 
10
10
  r = Rudo.new(options)
11
- r.print(options)
11
+ puts r
data/bin/walk CHANGED
@@ -11,4 +11,4 @@ steps = ARGV[0] ? Integer(ARGV[0]) : 1
11
11
 
12
12
  r = Rudo.new(options)
13
13
  r.walk(steps)
14
- r.print(options)
14
+ puts r
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'colored'
3
3
  require 'yaml'
4
+ require 'rudo/list'
4
5
 
5
6
  class Rudo
6
7
  def initialize(options={})
@@ -9,20 +10,6 @@ class Rudo
9
10
  @tasks = YAML.load(File.read(@file_path))
10
11
  end
11
12
 
12
- def print(options={})
13
- colored = options.delete(:color) { true }
14
- puts stars
15
- @tasks.each_with_index do |task, index|
16
- puts "#{index + 1}: #{task}"
17
- end
18
- puts stars
19
- if colored
20
- puts "#{@tasks.length} tasks remaining".green
21
- else
22
- puts "#{@tasks.length} tasks remaining"
23
- end
24
- end
25
-
26
13
  def add(task, position=nil)
27
14
  position ||= @tasks.length
28
15
  @tasks.insert(position, task)
@@ -49,6 +36,17 @@ class Rudo
49
36
  write_tasks
50
37
  end
51
38
 
39
+ def to_s
40
+ string = "#{stars}\n"
41
+
42
+ @tasks.each_with_index do |task, index|
43
+ string << "#{index + 1}: #{task}\n"
44
+ end
45
+
46
+ string << "#{stars}\n"
47
+ string << "#{@tasks.length} tasks remaining".green
48
+ end
49
+
52
50
  private
53
51
 
54
52
  def stars
@@ -0,0 +1,5 @@
1
+ class Rudo
2
+ class List
3
+
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rudo::List do
4
+ end
@@ -1,172 +1,122 @@
1
- require 'rspec'
2
- require 'colored'
3
1
  require 'spec_helper'
4
2
 
5
- require './lib/rudo.rb'
6
-
7
3
  describe Rudo do
4
+ let(:empty_path) { File.expand_path('./spec/fixtures/empty.yml') }
5
+ let(:tasks_path) { File.expand_path('./spec/fixtures/tasks.yml') }
6
+ let(:stars) { '*' * 40 }
7
+
8
8
  before(:each) do
9
- @empty_path = './spec/fixtures/empty.yml'
10
- @tasks_path = './spec/fixtures/tasks.yml'
11
- @stars = '*' * 40
12
9
  File.stub(:write)
13
10
  end
14
11
 
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
12
  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
13
+ let(:tasks) { YAML.load(File.read(tasks_path)) }
14
+ let(:rudo) { Rudo.new(:file_path => tasks_path) }
77
15
 
78
16
  context 'when position is nil' do
79
17
  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')
18
+ expected_tasks = tasks + ['blah']
19
+ File.should_receive(:write).with(tasks_path, YAML.dump(expected_tasks))
20
+ rudo.add('blah')
84
21
  end
85
22
  end
86
23
 
87
24
  context 'when position is given' do
88
25
  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)
26
+ expected_tasks = ['blah'] + tasks
27
+ File.should_receive(:write).with(tasks_path, YAML.dump(expected_tasks))
28
+ rudo.add('blah', 0)
93
29
  end
94
30
  end
95
31
  end
96
32
 
97
33
  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
34
+ let(:tasks) { YAML.load(File.read(tasks_path)) }
35
+ let(:rudo) { Rudo.new(:file_path => tasks_path) }
102
36
 
103
37
  context 'when position is some number followed by an "x"' do
104
38
  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')
39
+ expected_tasks = tasks[2..-1]
40
+ File.should_receive(:write).with(tasks_path, YAML.dump(expected_tasks))
41
+ rudo.remove('2x')
109
42
  end
110
43
  end
111
44
 
112
45
  context 'when the position is a number' do
113
46
  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')
47
+ expected_tasks = [ tasks.first, tasks.last ]
48
+ File.should_receive(:write).with(tasks_path, YAML.dump(expected_tasks))
49
+ rudo.remove('2')
118
50
  end
119
51
  end
120
52
 
121
53
  context 'when the position is trash text' do
122
54
  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')
55
+ expected_tasks = tasks[1..-1]
56
+ File.should_receive(:write).with(tasks_path, YAML.dump(expected_tasks))
57
+ rudo.remove('trash')
127
58
  end
128
59
  end
129
60
 
130
61
  context 'when the position is nil' do
131
62
  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)
63
+ expected_tasks = tasks[1..-1]
64
+ File.should_receive(:write).with(tasks_path, YAML.dump(expected_tasks))
65
+ rudo.remove(nil)
136
66
  end
137
67
  end
138
68
 
139
69
  context 'when the position is not given' do
140
70
  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
71
+ expected_tasks = tasks[1..-1]
72
+ File.should_receive(:write).with(tasks_path, YAML.dump(expected_tasks))
73
+ rudo.remove
145
74
  end
146
75
  end
147
76
  end
148
77
 
149
78
  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
79
+ let(:tasks) { YAML.load(File.read(tasks_path)) }
80
+ let(:rudo) { Rudo.new(:file_path => tasks_path) }
154
81
 
155
82
  context 'when no argument is given' do
156
83
  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
84
+ expected_tasks = tasks[1..-1] + tasks[0, 1]
85
+ File.should_receive(:write).with(tasks_path, YAML.dump(expected_tasks))
86
+ rudo.walk
161
87
  end
162
88
  end
163
89
 
164
90
  context 'when a number is given' do
165
91
  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)
92
+ expected_tasks = tasks[2..-1] + tasks[0, 2]
93
+ File.should_receive(:write).with(tasks_path, YAML.dump(expected_tasks))
94
+ rudo.walk(2)
95
+ end
96
+ end
97
+ end
98
+
99
+ describe '#to_s' do
100
+ context 'when there are no tasks' do
101
+ let(:rudo) { Rudo.new(:file_path => empty_path) }
102
+
103
+ it "returns two lines of stars and 0 tasks remaining" do
104
+ expected = "#{stars}\n#{stars}\n#{"0 tasks remaining".green}"
105
+ rudo.to_s.should == expected
106
+ end
107
+ end
108
+
109
+ context 'when there are tasks' do
110
+ let(:rudo) { Rudo.new(:file_path => tasks_path) }
111
+
112
+ it "returns the task with the count in green" do
113
+ expected = "#{stars}\n"
114
+ expected << "1: clean gutters\n"
115
+ expected << "2: do laundry\n"
116
+ expected << "3: eat pizza\n"
117
+ expected << "#{stars}\n"
118
+ expected << "3 tasks remaining".green
119
+ rudo.to_s.should == expected
170
120
  end
171
121
  end
172
122
  end
@@ -1,7 +1,8 @@
1
+ require './lib/rudo.rb'
2
+
1
3
  RSpec.configure do |config|
2
4
  config.color_enabled = true
3
5
  config.tty = true
4
- config.formatter = :documentation
5
6
 
6
7
  config.filter_run :focus => true
7
8
  config.run_all_when_everything_filtered = true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rudo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.00
4
+ version: 0.2.00
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colored
16
- requirement: &20227880 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '1.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *20227880
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '1.2'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: trollop
27
- requirement: &20226960 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: 1.16.2
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *20226960
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.16.2
36
46
  description: Tasks are saved in ~/rudo.yml
37
47
  email: lobatifricha@gmail.com
38
48
  executables:
@@ -43,19 +53,21 @@ executables:
43
53
  extensions: []
44
54
  extra_rdoc_files: []
45
55
  files:
56
+ - lib/rudo/list.rb
46
57
  - lib/rudo.rb
47
58
  - spec/rudo_spec.rb
48
- - spec/fixtures/empty.yml
49
- - spec/fixtures/tasks.yml
50
59
  - spec/spec_helper.rb
60
+ - spec/fixtures/tasks.yml
61
+ - spec/fixtures/empty.yml
62
+ - spec/rudo/list_spec.rb
51
63
  - bin/dun
52
64
  - bin/walk
53
- - bin/rad
54
65
  - bin/rudo
55
- - Rakefile
66
+ - bin/rad
67
+ - README.md
56
68
  - MIT-LICENSE
57
69
  - Gemfile
58
- - README
70
+ - Rakefile
59
71
  homepage: https://github.com/mockdeep/rudo
60
72
  licenses: []
61
73
  post_install_message:
@@ -76,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
88
  version: '0'
77
89
  requirements: []
78
90
  rubyforge_project:
79
- rubygems_version: 1.8.17
91
+ rubygems_version: 1.8.24
80
92
  signing_key:
81
93
  specification_version: 3
82
94
  summary: A simple, semi-pretty command line based todo list manager
data/README DELETED
@@ -1,25 +0,0 @@
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