rubdo 0.2.5 → 0.2.6

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rubdo
2
2
 
3
- A quick and dirty todo application
3
+ Why does todo applications need to be so complicated?
4
4
 
5
5
  ## Installation
6
6
 
data/Rakefile CHANGED
@@ -1,2 +1,9 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+
4
+ task :default => :spec
5
+ desc 'Run all tests' do
6
+ task :spec do
7
+ `rspec --color --format nested spec/*`
8
+ end
9
+ end
data/bin/rubdo CHANGED
@@ -9,5 +9,5 @@ cli.list if ARGV[0].nil?
9
9
  begin
10
10
  cli.send methods[ARGV[0]] unless ARGV[0].nil?
11
11
  rescue
12
- puts "cowardly refuses"
12
+ puts "cowardly refuses" unless methods[ARGV[0]]
13
13
  end
@@ -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.items.empty?
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.items.length
39
- tmp_file = Tempfile.new('new_desc')
40
- File.open(tmp_file.path, 'w') { |f| f.write(@list.items[@id].description) }
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.items[@id].description = File.read(tmp_file).chomp
43
+ @list.to_a[@id].description = File.read(tmp_file).chomp
43
44
  tmp_file.delete
44
45
  save
45
46
  end
@@ -1,7 +1,6 @@
1
1
  module Rubdo
2
2
  class Item
3
- attr_accessor :description, :done
4
- attr_reader :description
3
+ attr_accessor :description
5
4
 
6
5
  def initialize(description)
7
6
  @description = description
@@ -4,11 +4,13 @@ require 'fileutils'
4
4
 
5
5
  module Rubdo
6
6
  class List
7
- attr_reader :items, :completed, :storage
7
+ attr_accessor :items, :storage
8
8
 
9
9
  def self.read(file)
10
- return YAML.load_file(file) if File.exists? file
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
@@ -1,3 +1,3 @@
1
1
  module Rubdo
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -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{A quick and dirty todo application}
8
- gem.summary = %q{A quick and dirty todo application}
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($\)
@@ -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.5
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-10-31 00:00:00.000000000 Z
12
+ date: 2012-11-22 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: A quick and dirty todo application
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: A quick and dirty todo application
59
- test_files: []
59
+ summary: My take on the todo-applications
60
+ test_files:
61
+ - spec/rubdo_tests.rb