tod-gem 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -0
  3. data/bin/tod +14 -7
  4. data/tod-gem.gemspec +8 -8
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 368ef80d53e5cb545486dfb66e8190ec3a5a4f5a
4
- data.tar.gz: ddeaf57048d804a9c2b3fdb95008bff11913549c
3
+ metadata.gz: 316c0db9ee8e4d1d8f06cbc8a88dad4353d27b06
4
+ data.tar.gz: 8a15944e15fa5bcc947742f66012b8aeb825e31c
5
5
  SHA512:
6
- metadata.gz: 9e77cb83b5296ebdb3847fc555c14385d8210afe05d015cd39533640e6732dab8c0c70d5584bf670a3392551eba0292533e27c4f17710c456680a86c17873171
7
- data.tar.gz: cc98020805f47dcbdc4dfc9483d9a65a17e076ad700695bd5c9d5c3b830c00540933b7d97881bffdf28efdbd9b1fa5d3ed1718c081ec0190536bfcee726bd8c9
6
+ metadata.gz: 8d4eeacee2f51f1d34830169bf68e040818a3ef14c27294055f0cf3265c679239b9a8c12c1484a16105b6e8cc7133ca930b31afe1617e7f25c5ee9a1317758bd
7
+ data.tar.gz: 2dfde49506997c1b3805ff37b316266c7f38844554714d3a47768fdef4b9fef576ca4d1cde9148396ef1f4843e78a1d8e6b1a363f24fdd0f19d75ea7a7c584a6
data/README.md CHANGED
@@ -3,6 +3,34 @@ tod
3
3
 
4
4
  A simple command line todo manager
5
5
 
6
+ Overview
7
+ --------
8
+ I was looking for a simple cli todo manager, but couldn't find one. Either they were too sophisticated or their documentation was unreadable, so I decided to create a very, very simple one myself.
9
+ Say hi to tod.
10
+
11
+ Installation
12
+ ------------
13
+
14
+ gem install tod-gem
15
+
16
+ (you may need to run it with sudo on some systems)
17
+
18
+ Usage
19
+ -----
20
+ * Simply running `tod` will list current pending todos in current directory.
21
+
22
+ * `tod add 'buy a new pen'` creates a new todo named 'buy a new pen'.
23
+
24
+ * `tod done 'buy a new'` finds the first todo containing the provided string in its name and marks it as done.
25
+
26
+ * `tod all` lists all todos in current directory - including marked as done.
27
+
28
+ * `tod finished` lists only marked as done todos in current directory.
29
+
30
+ * `tod clear` permanently deletes todos marked as done from the register of current directory.
31
+
32
+ The todo register is kept in the file named `.todfile` once you create at least one todo in given directory. This way you can add the file to a git or svn repository and distribute it between machines.
33
+
6
34
  License
7
35
  -------
8
36
  Copyright 2013 Michal Siwek
data/bin/tod CHANGED
@@ -1,12 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'colorize'
3
3
 
4
- @command = ARGV[0]
5
- @todfile_exists = File.exists?('.todfile')
4
+ def find_todfile(path)
5
+ expanded_path = File.expand_path(path)
6
+ return File.expand_path("#{path}/.todfile") if File.exists?("#{path}/.todfile") || expanded_path == "/" || expanded_path == ENV['HOME']
7
+ find_todfile("../#{path}")
8
+ end
6
9
 
7
10
  def list(kind = 'left')
8
11
  if @todfile_exists
9
- File.open('.todfile').each_line do |line|
12
+ File.open(@todfile_path).each_line do |line|
10
13
  unless kind == 'done'
11
14
  if line.chars.first == '-'
12
15
  puts '*'.yellow + line.reverse.chop.reverse
@@ -29,7 +32,7 @@ def list(kind = 'left')
29
32
  end
30
33
 
31
34
  def add(todo)
32
- File.open('.todfile', 'a') do |todfile|
35
+ File.open(@todfile_path, 'a') do |todfile|
33
36
  todfile.puts '- ' + todo
34
37
  end
35
38
  end
@@ -38,7 +41,7 @@ def done(todo)
38
41
  if @todfile_exists
39
42
  newlines = []
40
43
 
41
- File.open('.todfile').each_line do |line|
44
+ File.open(@todfile_path).each_line do |line|
42
45
  unless line.include?(todo)
43
46
  newlines << line.chomp
44
47
  else
@@ -54,7 +57,7 @@ def clear_done
54
57
  if @todfile_exists
55
58
  newlines = []
56
59
 
57
- File.open('.todfile').each_line do |line|
60
+ File.open(@todfile_path).each_line do |line|
58
61
  newlines << line unless line.chars.first == '+'
59
62
  end
60
63
 
@@ -63,11 +66,15 @@ def clear_done
63
66
  end
64
67
 
65
68
  def replace_todfile_with(lines)
66
- File.open('.todfile', 'w') do |todfile|
69
+ File.open(@todfile_path, 'w') do |todfile|
67
70
  lines.each { |line| todfile.puts line }
68
71
  end
69
72
  end
70
73
 
74
+ @command = ARGV[0]
75
+ @todfile_path = find_todfile(".")
76
+ @todfile_exists = File.exists?(@todfile_path)
77
+
71
78
  case @command
72
79
  when nil
73
80
  list
data/tod-gem.gemspec CHANGED
@@ -1,12 +1,12 @@
1
1
  Gem::Specification.new do |s|
2
- s.name = 'tod-gem'
3
- s.version = '0.1'
4
- s.summary = 'Simple command line todo manager'
5
- s.authors = ['Michal Siwek']
6
- s.email = 'mike21@aol.pl'
7
- s.license = 'GPL-3.0'
8
- s.files = `git ls-files`.split("\n")
9
- s.executables << 'tod'
2
+ s.name = 'tod-gem'
3
+ s.version = '0.2'
4
+ s.summary = 'Simple command line todo manager'
5
+ s.authors = ['Michal Siwek']
6
+ s.email = 'mike21@aol.pl'
7
+ s.license = 'GPL-3.0'
8
+ s.files = `git ls-files`.split("\n")
9
+ s.executables = ['tod']
10
10
 
11
11
  s.add_runtime_dependency 'colorize'
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tod-gem
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Siwek