rubdo 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/Rakefile +7 -0
- data/bin/rubdo +1 -1
- data/lib/rubdo/cli.rb +6 -5
- data/lib/rubdo/item.rb +1 -2
- data/lib/rubdo/list.rb +14 -7
- data/lib/rubdo/version.rb +1 -1
- data/rubdo.gemspec +2 -2
- data/spec/rubdo_tests.rb +55 -0
- metadata +7 -5
data/README.md
CHANGED
data/Rakefile
CHANGED
data/bin/rubdo
CHANGED
data/lib/rubdo/cli.rb
CHANGED
@@ -31,15 +31,16 @@ module Rubdo
|
|
31
31
|
|
32
32
|
def list
|
33
33
|
@list.to_a.each_with_index { |item, index| puts "#{index + 1}: #{item.description}" }
|
34
|
-
puts "no tasks" if @list.
|
34
|
+
puts "no tasks" if @list.to_a.empty?
|
35
35
|
end
|
36
36
|
|
37
37
|
def edit
|
38
|
-
abort("not a valid id") if @id == -1 or @id > @list.
|
39
|
-
|
40
|
-
|
38
|
+
abort("not a valid id") if @id == -1 or @id > @list.to_a.length
|
39
|
+
|
40
|
+
tmp_file = Tempfile.new('new_description')
|
41
|
+
File.open(tmp_file.path, 'w') { |f| f.write(@list.to_a[@id].description) }
|
41
42
|
system("$EDITOR #{tmp_file.path}")
|
42
|
-
@list.
|
43
|
+
@list.to_a[@id].description = File.read(tmp_file).chomp
|
43
44
|
tmp_file.delete
|
44
45
|
save
|
45
46
|
end
|
data/lib/rubdo/item.rb
CHANGED
data/lib/rubdo/list.rb
CHANGED
@@ -4,11 +4,13 @@ require 'fileutils'
|
|
4
4
|
|
5
5
|
module Rubdo
|
6
6
|
class List
|
7
|
-
|
7
|
+
attr_accessor :items, :storage
|
8
8
|
|
9
9
|
def self.read(file)
|
10
|
-
|
11
|
-
[]
|
10
|
+
todos = YAML.load_file(file) if File.exists? file
|
11
|
+
todos ||=[]
|
12
|
+
|
13
|
+
todos
|
12
14
|
end
|
13
15
|
|
14
16
|
def initialize(todos)
|
@@ -21,18 +23,23 @@ module Rubdo
|
|
21
23
|
@items << Item.new(description)
|
22
24
|
end
|
23
25
|
|
24
|
-
def write
|
25
|
-
File.open(self.storage, 'w') { |todos| todos.write(@items.to_yaml) }
|
26
|
-
end
|
27
|
-
|
28
26
|
def done(id)
|
29
27
|
@items.delete_at id
|
30
28
|
end
|
31
29
|
|
30
|
+
def edit(id)
|
31
|
+
@items[id]
|
32
|
+
end
|
33
|
+
|
34
|
+
def write
|
35
|
+
File.open(self.storage, 'w') { |todos| todos.write(@items.to_yaml) }
|
36
|
+
end
|
37
|
+
|
32
38
|
def to_a
|
33
39
|
self.items
|
34
40
|
end
|
35
41
|
|
36
42
|
alias_method :<<, :add
|
43
|
+
alias_method :save, :write
|
37
44
|
end
|
38
45
|
end
|
data/lib/rubdo/version.rb
CHANGED
data/rubdo.gemspec
CHANGED
@@ -4,8 +4,8 @@ require File.expand_path('../lib/rubdo/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Teo Ljungberg"]
|
6
6
|
gem.email = ["teo.ljungberg@gmail.com"]
|
7
|
-
gem.description = %q{
|
8
|
-
gem.summary = %q{
|
7
|
+
gem.description = %q{My take on the todo-applications}
|
8
|
+
gem.summary = %q{My take on the todo-applications}
|
9
9
|
gem.homepage = "http://github.com/metamorfos/rubdo"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
data/spec/rubdo_tests.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'rubdo'
|
3
|
+
|
4
|
+
describe Rubdo::Item do
|
5
|
+
before do
|
6
|
+
@item = Rubdo::Item.new('New todo item')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#new' do
|
10
|
+
it 'assigns a text value to rubdo' do
|
11
|
+
@item.description.should eq('New todo item')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe Rubdo::List do
|
17
|
+
before do
|
18
|
+
@list = Rubdo::List.new(Rubdo::List.read(File.join(File.dirname(__FILE__), 'test.yml')))
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#add' do
|
22
|
+
it 'adds 3 todo items' do
|
23
|
+
@list.add('Buy milk')
|
24
|
+
@list.add('Buy beer')
|
25
|
+
@list.add('But peanuts')
|
26
|
+
@list.to_a.size.should eq(3)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#done' do
|
31
|
+
before do
|
32
|
+
@list = Rubdo::List.new(Rubdo::List.read(File.join(File.dirname(__FILE__), 'test.yml')))
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'deletes a todo item' do
|
36
|
+
@list.add('Watch TV')
|
37
|
+
@list.add('Walk the dog')
|
38
|
+
@list.done(0).description.should eq('Watch TV')
|
39
|
+
@list.to_a.size.should eq(1)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#edit' do
|
44
|
+
before do
|
45
|
+
@list = Rubdo::List.new(Rubdo::List.read(File.join(File.dirname(__FILE__), 'test.yml')))
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'edits a task' do
|
49
|
+
@list.add("I can't go out, I'm sik")
|
50
|
+
@list.edit(0).description = "I can't go out, I'm sick"
|
51
|
+
@list.to_a[0].description.should eq("I can't go out, I'm sick")
|
52
|
+
@list.to_a.size.should eq(1)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubdo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,9 +9,9 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-22 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description:
|
14
|
+
description: My take on the todo-applications
|
15
15
|
email:
|
16
16
|
- teo.ljungberg@gmail.com
|
17
17
|
executables:
|
@@ -32,6 +32,7 @@ files:
|
|
32
32
|
- lib/rubdo/list.rb
|
33
33
|
- lib/rubdo/version.rb
|
34
34
|
- rubdo.gemspec
|
35
|
+
- spec/rubdo_tests.rb
|
35
36
|
homepage: http://github.com/metamorfos/rubdo
|
36
37
|
licenses: []
|
37
38
|
post_install_message:
|
@@ -55,5 +56,6 @@ rubyforge_project:
|
|
55
56
|
rubygems_version: 1.8.23
|
56
57
|
signing_key:
|
57
58
|
specification_version: 3
|
58
|
-
summary:
|
59
|
-
test_files:
|
59
|
+
summary: My take on the todo-applications
|
60
|
+
test_files:
|
61
|
+
- spec/rubdo_tests.rb
|