cgiacomi / r2do

Simple ruby todo gem to be used from the CLI.
Apache License 2.0
6 stars 3 forks source link

Feature #17

Closed fntz closed 12 years ago

fntz commented 12 years ago

Hi.

I added tests for commands. Also I added a command to display all tasks into categories.

 r2do t --all

And i added spec task in Rakefile. Thanks.

cgiacomi commented 12 years ago

Hi fntzr, that is really cool, the commands where completely not tested. I must admit, looking at your code I also learned a couple of cool trick when testing, especially the following:

'R2do::UI.stub!(:input) { "Y" }'

and

'Object.should_receive(:puts).with("Selected task 'NewTask'")'

I didn't know you could do it like that! :))

The code looks really nice and I will merge it immediately.

Thank you for the great work.

fntz commented 12 years ago

You're welcome :)

cgiacomi commented 12 years ago

HI, I just noticed a small thing with showing all the tasks. The code does not take into consideration that a task description has a max length of 30 characters. The output risks or not being properly aligned. Should I change it or would you like to do it?

  #List all tags in state
  #@param [void]
  #@return [void]
  def all_tasks()
    UI.status(" "*4+"Task" + " "*16 + "Category")
    UI.status(" "*4 + "-"*30)

    @state.categories.each do |name, category|
      category.tasks.each do |task|
        result = StringIO.new
        result << "    %-15s     %s\n" % [task.description, name]
        UI.status(result.string)
      end
    end
  end

cheers,

Chris

fntz commented 12 years ago

You change, if it is not difficult to you.

Thanks.

cgiacomi commented 12 years ago

LOL no it's not difficult... was just being polite :) since you wrote the code.

cheers

fntz commented 12 years ago

:) You already to rewrite the code for sqlite?

cgiacomi commented 12 years ago

Actually yes... using DataMapper as the ORM and it's nearly done.

fntz commented 12 years ago

Make a separate branch, I would help write the code.