rudo 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.
Files changed (3) hide show
  1. data/bin/rudo +14 -0
  2. data/lib/rudo.rb +58 -0
  3. metadata +68 -0
data/bin/rudo ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rudo'
3
+ require 'trollop'
4
+
5
+ init_options = Trollop::options do
6
+ opt :file_path, "Alternate path to list, default ~/rudo.yml", :default => '~/rudo.yml'
7
+ end
8
+
9
+ print_options = Trollop::options do
10
+ opt :color, "Print with colors", :default => true
11
+ end
12
+
13
+ r = Rudo.new(init_options)
14
+ r.print(print_options)
data/lib/rudo.rb ADDED
@@ -0,0 +1,58 @@
1
+ require 'rubygems'
2
+ require 'colored'
3
+ require 'yaml'
4
+
5
+ class Rudo
6
+ def initialize(options={})
7
+ @file_path = File.expand_path(options.delete(:file_path) { '~/rudo.yml' })
8
+
9
+ @tasks = YAML.load(File.open(@file_path))
10
+ end
11
+
12
+ def print(options={})
13
+ colored = options.delete(:color) { true }
14
+ puts "*" * 40
15
+ @tasks.each do |task|
16
+ puts task
17
+ end
18
+ puts "*" * 40
19
+ if colored
20
+ puts "#{@tasks.length} tasks remaining".green
21
+ else
22
+ puts "#{@tasks.length} tasks remaining"
23
+ end
24
+ end
25
+
26
+ def add(task, position=nil)
27
+ position ||= @tasks.length
28
+ @tasks.insert(position, task)
29
+ write_tasks
30
+ end
31
+
32
+ def remove(position=nil)
33
+ position ||= 0
34
+ if position.is_a?(String) && position.match(/^(\d+)x/)
35
+ count = Integer($1)
36
+ count.times { @tasks.shift }
37
+ else
38
+ @tasks.delete_at(Integer(position))
39
+ end
40
+ write_tasks
41
+ end
42
+
43
+ def walk(steps=1)
44
+ steps.times do
45
+ task = @tasks.shift
46
+ @tasks << task
47
+ end
48
+ write_tasks
49
+ end
50
+
51
+ private
52
+
53
+ def write_tasks
54
+ File.open(@file_path, 'w') do |file|
55
+ file.write(YAML.dump(@tasks))
56
+ end
57
+ end
58
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rudo
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Robert Fletcher
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-05-15 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Tasks are saved in ~/rudo.yml
23
+ email: lobatifricha@gmail.com
24
+ executables:
25
+ - rudo
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - lib/rudo.rb
32
+ - bin/rudo
33
+ has_rdoc: true
34
+ homepage: https://github.com/mockdeep/rudo
35
+ licenses: []
36
+
37
+ post_install_message:
38
+ rdoc_options: []
39
+
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ hash: 3
48
+ segments:
49
+ - 0
50
+ version: "0"
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ requirements: []
61
+
62
+ rubyforge_project:
63
+ rubygems_version: 1.3.7
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: A simple, semi-pretty command line based todo list manager
67
+ test_files: []
68
+