todorb 1.0.0 → 1.1.0

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/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ = todorb 1.0.0, 2010-06-22 16:16
2
+ * using subcommand gem
3
+ * suboptions will come *after* command but before arguments
4
+
5
+
1
6
  = todorb 0.2.2, 2010-06-15
2
7
  * Added subtask addition. One may add subtasks under a task.
3
8
  * This effects everything! Deleting a task, you may wanna delete all
data/Makefile CHANGED
@@ -1,10 +1,11 @@
1
- DISTFILES := README.markdown get_serial_number colors.sh todoapp.sh
2
- VERSION := `cat VERSION_FILE`
1
+ #DISTFILES := README.markdown get_serial_number colors.sh todoapp.sh
2
+ #VERSION := `cat VERSION`
3
3
 
4
4
  all: install
5
5
 
6
6
  install:
7
7
 
8
+ # sed -i.bk 's/^VERSION = .*/VERSION = \"'$(VERSION)'\"/g' lib/todorb.rb
8
9
  rake build && sudo rake install
9
10
 
10
11
  #
data/Rakefile CHANGED
@@ -5,13 +5,14 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "todorb"
8
- gem.summary = %Q{command-line todo list manager }
9
- gem.description = %Q{command-line program that manages a todo list text file }
8
+ gem.summary = %Q{comprehensive command-line todo list manager with subtasks and more }
9
+ gem.description = %Q{command-line program that manages a todo list text file, incl subtasks }
10
10
  gem.email = "sentinel1879@gmail.com"
11
11
  gem.homepage = "http://github.com/rkumar/todorb"
12
12
  gem.authors = ["Rahul Kumar"]
13
13
  gem.rubyforge_project = "todorb"
14
14
  #gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
15
+ gem.add_development_dependency "subcommand", ">= 0"
15
16
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
17
  end
17
18
  Jeweler::GemcutterTasks.new
@@ -52,3 +53,12 @@ Rake::RDocTask.new do |rdoc|
52
53
  rdoc.rdoc_files.include('README*')
53
54
  rdoc.rdoc_files.include('lib/**/*.rb')
54
55
  end
56
+ begin
57
+ require 'yard'
58
+ YARD::Rake::YardocTask.new
59
+ rescue LoadError
60
+ task :yardoc do
61
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
62
+ end
63
+ end
64
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
data/lib/common/cmdapp.rb CHANGED
@@ -5,8 +5,7 @@
5
5
  * : Moving some methods from todorb.rb here
6
6
  * Author : rkumar
7
7
  * Date : 2010-06-20 11:18
8
- * License :
9
- Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
8
+ * License: Ruby License
10
9
 
11
10
  =end
12
11
  require 'common/sed'
@@ -22,12 +21,13 @@ module Cmdapp
22
21
  # @app_serial_path - serial_number file
23
22
  ##
24
23
  # check whether this action is mapped to some alias and *changes*
25
- # @action and @argv if true.
24
+ # variables@action and @argv if true.
26
25
  # @param [String] action asked by user
27
26
  # @param [Array] rest of args on command line
28
27
  # @return [Boolean] whether it is mapped or not.
29
28
  #
30
29
  def check_aliases action, args
30
+ return false unless @aliases
31
31
  ret = @aliases[action]
32
32
  if ret
33
33
  a = ret.shift
@@ -46,13 +46,11 @@ module Cmdapp
46
46
  def run
47
47
  @action = @argv[0] || @app_default_action
48
48
  @action = @action.downcase
49
- @action.sub!('priority', 'pri')
50
- @action.sub!(/^del$/, 'delete')
51
49
 
52
50
 
53
51
  ret = 0
54
52
  @argv.shift
55
- if @actions.include? @action
53
+ if respond_to? @action
56
54
  ret = send(@action, @argv)
57
55
  else
58
56
  # check aliases
@@ -67,14 +65,26 @@ module Cmdapp
67
65
  ret = 0 if ret != ERRCODE
68
66
  return ret
69
67
  end
68
+ # not required if using Subcommand
70
69
  def help args
71
- puts "Actions are "
72
- @actions.each_pair { |name, val| puts "#{name}\t#{val}" }
70
+ if @actions
71
+ puts "Actions are "
72
+ @actions.each_pair { |name, val| puts "#{name}\t#{val}" }
73
+ end
73
74
  puts " "
74
75
  puts "Aliases are "
75
76
  @aliases.each_pair { |name, val| puts "#{name}:\t#{val.join(' ')}" }
76
77
  0
77
78
  end
79
+ ##
80
+ def alias_command name, *args
81
+ @aliases ||= {}
82
+ @aliases[name.to_s] = args
83
+ end
84
+ def add_action name, descr
85
+ @actions ||= {}
86
+ @actions[name.to_s] = desc
87
+ end
78
88
 
79
89
  ##
80
90
  # reads serial_number file, returns serialno for this app
@@ -109,6 +119,10 @@ module Cmdapp
109
119
  appname = @appname
110
120
  pattern = Regexp.new "^#{appname}:.*$"
111
121
  filename = @app_serial_path || "serial_numbers"
122
+ # during testing redo this file does not exist, so i get errors
123
+ if !File.exists? filename
124
+ _get_serial_number
125
+ end
112
126
  _backup filename
113
127
  change_row filename, pattern, "#{appname}:#{number}"
114
128
  end
@@ -150,6 +164,7 @@ module Cmdapp
150
164
  $valid_array = false
151
165
  @data = []
152
166
  File.open(@app_file_path).each do |line|
167
+ # FIXME: use @app_delim
153
168
  row = line.chomp.split "\t"
154
169
  @data << row
155
170
  end
@@ -162,9 +177,27 @@ module Cmdapp
162
177
  raise "Cannot save array! Please use load_array to load" if $valid_array == false
163
178
 
164
179
  File.open(@app_file_path, "w") do |file|
180
+ # FIXME: use join with @app_delim
165
181
  @data.each { |row| file.puts "#{row[0]}\t#{row[1]}" }
166
182
  end
167
183
  end
184
+ ##
185
+ # retrieve version info updated by jeweler.
186
+ # Typically used by --version option of any command.
187
+ # @return [String, nil] version as string, or nil if file not found
188
+ def version_info
189
+ # thanks to Roger Pack on ruby-forum for how to get to the version
190
+ # file
191
+ filename = File.open(File.dirname(__FILE__) + "/../../VERSION")
192
+ v = nil
193
+ if File.exists?(filename)
194
+ v = File.open(filename).read.chomp if File.exists?(filename)
195
+ #else
196
+ #$stderr.puts "could not locate file #{filename}. "
197
+ #puts `pwd`
198
+ end
199
+ v
200
+ end
168
201
 
169
202
 
170
203
  end
data/lib/common/sed.rb CHANGED
@@ -1,10 +1,13 @@
1
1
  #!/usr/bin/env ruby -w
2
- #*************************************************************
3
- # Sed like operations - just change row and delete row
4
- # While converting some shell scripts in which i have used
5
- # sed extensively, I need this kind of functionality
6
- #
7
- #*************************************************************
2
+ =begin
3
+ * Name: sed.rb
4
+ * Description: Sed like operations
5
+ * Author: rkumar
6
+ * Date: 2010-06-10 20:10
7
+ * License: Ruby License
8
+
9
+ =end
10
+
8
11
  ##
9
12
  # changes one or more rows based on pattern and replacement
10
13
  # Also if replacement is not given, expects a block and yields