rubdo 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rubdo.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Teo Ljungberg
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Rubdo
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rubdo'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rubdo
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/rubdo ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require 'rubdo'
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'rubdo'
8
+ end
9
+
10
+ cli = Rubdo::CLI.new
11
+ cli.list if ARGV[0].nil?
12
+ cli.send ARGV[0] unless ARGV[0].nil?
13
+ cli.save
data/lib/rubdo/cli.rb ADDED
@@ -0,0 +1,69 @@
1
+ module Rubdo
2
+ class CLI
3
+ def initialize
4
+ @list = List.new
5
+ @id = ARGV[1].to_i - 1
6
+ end
7
+
8
+ def add
9
+ @list.add ARGV[1]
10
+ end
11
+
12
+ def done
13
+ @list.done @id
14
+ end
15
+
16
+ def remove
17
+ @list.remove @id
18
+ end
19
+
20
+ def save
21
+ @list.write
22
+ end
23
+
24
+ def list
25
+ @list.items.each_with_index { |item, index| puts "#{index + 1}: #{item.description}" }
26
+ end
27
+
28
+ def info
29
+ puts @list.info @id
30
+ end
31
+
32
+ def completed
33
+ @list.completed.each { |item| puts "#{item.description}, completed at: #{item.completed_at.strftime('%m.%d.%y - %H:%M')}" }
34
+ end
35
+
36
+ def edit
37
+ tmp_file = '/tmp/todo_desc.txt'
38
+ system("echo '#{@list.items[@id].description}' > #{tmp_file}")
39
+ system("$EDITOR #{tmp_file}")
40
+ @list.items[@id].description = File.read(tmp_file).chomp
41
+ File.delete(tmp_file)
42
+ end
43
+
44
+ def remove
45
+ @list.items.delete_at(@id)
46
+ end
47
+
48
+ def help(onoe = nil)
49
+ puts <<-HELP
50
+ Commands for todo:
51
+ ------------------
52
+ add/a [task description] - Add a new tas
53
+ list/ls - Lists all tasks
54
+ completed - List all completed tasks
55
+ done/d [task id] - Complete a task
56
+ info [task id] - Gives info about the specific task
57
+ edit/e [task id] - Opens up $EDITOR to edit the task description
58
+ remove/rm [task id] - Deleted task id from the list
59
+ help - Prints out this information
60
+ HELP
61
+ end
62
+
63
+ alias_method :a, :add
64
+ alias_method :ls, :list
65
+ alias_method :d, :done
66
+ alias_method :e, :edit
67
+ alias_method :rm, :remove
68
+ end
69
+ end
data/lib/rubdo/item.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'time'
2
+
3
+ module Rubdo
4
+ class Item
5
+ attr_accessor :description, :done, :completed_at
6
+ attr_reader :id, :created_at
7
+
8
+ def initialize(description)
9
+ @done = false
10
+ @description = description
11
+ @created_at = Time.now
12
+ end
13
+
14
+ def to_s
15
+ "#{description}: created at #{created_at.strftime('%m.%d.%y - %H:%M') }"
16
+ end
17
+ end
18
+ end
data/lib/rubdo/list.rb ADDED
@@ -0,0 +1,43 @@
1
+ require 'time'
2
+ require 'yaml'
3
+
4
+ module Rubdo
5
+ class List
6
+ attr_reader :items, :completed, :storage, :archive
7
+
8
+ def initialize
9
+ @storage = File.expand_path('~/Dropbox/tasks/Todo.yml')
10
+ @archive = File.expand_path('~/Dropbox/tasks/Archive.yml')
11
+ @items, @completed = [], []
12
+ @items = load @storage
13
+ @completed = load @archive
14
+ end
15
+
16
+ def add(description)
17
+ @items << Item.new(description)
18
+ end
19
+
20
+ def write
21
+ File.open(@storage, 'w') { |todos| todos.write(@items.select { |item| item.done == false }.to_yaml) }
22
+ File.open(@archive, 'w') { |todos| todos.write(@completed.to_yaml) }
23
+ end
24
+
25
+ def load(file)
26
+ return YAML.load_file(file) if File.exists? file
27
+ []
28
+ end
29
+
30
+ def done(id)
31
+ abort("that id doesn't exists") if @items[id].nil?
32
+ @items[id].done = true
33
+ @items[id].completed_at = Time.new
34
+ @completed << @items[id]
35
+ end
36
+
37
+ def info(id)
38
+ @items[id].to_s
39
+ end
40
+
41
+ alias_method :<<, :add
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ module Rubdo
2
+ VERSION = "0.0.1"
3
+ end
data/lib/rubdo.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "rubdo/version"
2
+ require 'rubdo/cli'
3
+ require 'rubdo/item'
4
+ require 'rubdo/list'
data/rubdo.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/rubdo/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Teo Ljungberg"]
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}
9
+ gem.homepage = "http://github.com/metamorfos/rubdo"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "rubdo"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Rubdo::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubdo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Teo Ljungberg
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-08 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A quick and dirty todo application
15
+ email:
16
+ - teo.ljungberg@gmail.com
17
+ executables:
18
+ - rubdo
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE
25
+ - README.md
26
+ - Rakefile
27
+ - bin/rubdo
28
+ - lib/rubdo.rb
29
+ - lib/rubdo/cli.rb
30
+ - lib/rubdo/item.rb
31
+ - lib/rubdo/list.rb
32
+ - lib/rubdo/version.rb
33
+ - rubdo.gemspec
34
+ homepage: http://github.com/metamorfos/rubdo
35
+ licenses: []
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 1.8.23
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: A quick and dirty todo application
58
+ test_files: []
59
+ has_rdoc: