plan 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'json'
2
3
 
3
4
  module Plan
@@ -61,7 +62,7 @@ module Plan
61
62
  # Mark a task or group of tasks as "unfinished"
62
63
  def unfinish(paths)
63
64
  if paths.empty?
64
- raise Plan::Advice.new 'please drill down to a level to unfinish'
65
+ raise Plan::Advice.new('please drill down to a level to unfinish')
65
66
  end
66
67
  # go to the right depth and unfinish
67
68
  item = path_tree.descend(paths)
@@ -74,7 +75,7 @@ module Plan
74
75
  # Mark a task or group of tasks as "finished"
75
76
  def finish(paths)
76
77
  if paths.empty?
77
- raise Plan::Advice.new 'please drill down to a level to finish'
78
+ raise Plan::Advice.new('please drill down to a level to finish')
78
79
  end
79
80
  # descend and finish
80
81
  item = path_tree.descend(paths)
@@ -88,7 +89,7 @@ module Plan
88
89
  def list(paths)
89
90
  item = path_tree.descend(paths)
90
91
  if item.visible_child_count == 0
91
- raise Plan::Advice.new 'no events here - create some with `plan create`'
92
+ raise Plan::Advice.new('no events here - create some with `plan create`')
92
93
  end
93
94
  print_depth item
94
95
  end
@@ -96,13 +97,13 @@ module Plan
96
97
  # create a new todo
97
98
  def create(paths)
98
99
  if paths.empty?
99
- raise Plan::Advice.new 'please provide something to create'
100
+ raise Plan::Advice.new('please provide something to create')
100
101
  end
101
102
  # descend to the right depth
102
103
  item = path_tree.descend(paths[0..-2])
103
104
  # and then create
104
105
  if item.children.any? { |c| !c.hidden? && c.has_label?(paths[-1]) }
105
- raise Plan::Advice.new "duplicate entry at level: #{paths[-1]}"
106
+ raise Plan::Advice.new("duplicate entry at level: #{paths[-1]}")
106
107
  else
107
108
  item.children << Item.new(paths[-1])
108
109
  save_path_tree
@@ -117,7 +118,7 @@ module Plan
117
118
  DATE_FORMAT = '%b. %e, %Y %l:%M %P'
118
119
 
119
120
  def unknown_command(cmd)
120
- raise Plan::Advice.new "unknown command: #{cmd}. try `plan help` for options."
121
+ raise Plan::Advice.new("unknown command: #{cmd}. try `plan help` for options.")
121
122
  end
122
123
 
123
124
  # print the item and its descendents
@@ -27,7 +27,7 @@ module Plan
27
27
 
28
28
  # count of the visible children
29
29
  def visible_child_count
30
- children.count { |c| !c.hidden? }
30
+ children.select { |c| !c.hidden? }.size
31
31
  end
32
32
 
33
33
  # remove all finished items from this tree, by hiding them
@@ -73,18 +73,19 @@ module Plan
73
73
  lines = []
74
74
  lines << "no match for #{paths.first}"
75
75
  unless children.empty?
76
- lines << "available options are: #{children.reject(&:hidden?).map(&:label).join(', ')}"
76
+ avail = children.map { |c| c.label unless c.hidden? }.compact
77
+ lines << "available options are: #{avail.join(', ')}"
77
78
  end
78
- raise Plan::Advice.new *lines
79
+ raise Plan::Advice.new(*lines)
79
80
  end
80
81
  # give an error if we have too many matches
81
- if next_items.count > 1
82
+ if next_items.size > 1
82
83
  lines = []
83
84
  lines << "ambiguous match for '#{paths.first}' - please choose one of:"
84
85
  next_items.each do |np|
85
86
  lines << "* #{np.label}"
86
87
  end
87
- raise Plan::Advice.new *lines
88
+ raise Plan::Advice.new(*lines)
88
89
  end
89
90
  # and off we go, continuing to descent
90
91
  next_items.first.descend(paths[1..-1])
@@ -104,7 +105,7 @@ module Plan
104
105
  data = {}
105
106
  data['label'] = label
106
107
  data['finished'] = finished.nil? ? nil : finished.to_i
107
- data['children'] = children.map(&:dump)
108
+ data['children'] = children.map { |c| c.dump }
108
109
  data['hidden'] = true if hidden?
109
110
  data
110
111
  end
@@ -1,5 +1,5 @@
1
1
  module Plan
2
2
 
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-27 00:00:00.000000000Z
12
+ date: 2011-09-28 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70151867057320 !ruby/object:Gem::Requirement
16
+ requirement: &70150181159280 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,18 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70151867057320
24
+ version_requirements: *70150181159280
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ requirement: &70150181158860 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70150181158860
25
36
  description: plan is a simple command-line todo-list manager
26
37
  email: john.crepezzi@gmail.com
27
38
  executables:
@@ -36,7 +47,7 @@ files:
36
47
  - lib/plan.rb
37
48
  - bin/plan
38
49
  - spec/spec_helper.rb
39
- homepage: http://github.com/seejohnrun/plan
50
+ homepage: http://seejohncode.com/plan/
40
51
  licenses: []
41
52
  post_install_message:
42
53
  rdoc_options: []