doing 0.1.3 → 0.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 099152d20912d3303aaa11fe984099c26dd658c0
4
- data.tar.gz: e8a2977882d97fe1b93a913fbd2a2059f2d2bd43
3
+ metadata.gz: 63ac7ddde25074344e59d1b2205b47c0721511f7
4
+ data.tar.gz: 51097a7e2ad2bee2a3d45cca702b3846be7cdf91
5
5
  SHA512:
6
- metadata.gz: 0e33df82c4ada897a07b08e129024b34c357c10438df188cc50a18cd00a9bd9e1ccf029e78448e6ed7993077352c17040533f4cfd39bfc72fb7f6794f58561a0
7
- data.tar.gz: 07a8ff1889b6f7f8a7864cdc6561f3ae33cf01f0f1fd884ac135a279342699ab84fd1816485ef79045adf76b0a8dbd1cdeeb6e491098034a8c55b52750890aa3
6
+ metadata.gz: 6ede9fd7ced675665f25f9858abf86e981f30688e202bac3040f5101c27dec85578bebcc18fe59c252f7d99f686947cc63b3867b5d3334399368681d685501fb
7
+ data.tar.gz: 0fb124bcb05e1328f58033038ea08365505f12d829cfae7e3bd7e4636bda78ae4e8d1ac1402b1a6547fd719111481484e2f8e4eda77919f26cc87afb0cf4173b
data/README.rdoc CHANGED
@@ -33,6 +33,7 @@ Commands:
33
33
  archive - Archive all but the most recent 5 entries
34
34
  choose - Select a section to display
35
35
  config - Edit the default configuration
36
+ done - Add an entry tagged with @done(YYYY-mm-dd hh:mm)
36
37
  help - Shows a list of commands or help for one command
37
38
  last - Show the last entry
38
39
  later - Add an item to the Later section
data/bin/doing CHANGED
@@ -50,6 +50,29 @@ command :later do |c|
50
50
  end
51
51
  end
52
52
 
53
+ desc 'Add a completed item with @done(date)'
54
+ arg_name 'entry'
55
+ command :done do |c|
56
+ c.desc 'Immediately archive the entry'
57
+ c.switch [:a,:archive], :negatable => true
58
+
59
+ c.desc 'Section'
60
+ c.default_value wwid.current_section
61
+ c.flag [:s,:section], :default_value => wwid.current_section
62
+
63
+ c.action do |global_options,options,args|
64
+ if args.length > 0
65
+ task = args.join(" ").cap_first
66
+ task += " @done(#{Time.now.strftime('%F %R')})"
67
+ section = options[:a] ? "Archive" : options[:s]
68
+ wwid.add_item(task, section)
69
+ wwid.write(wwid.doing_file)
70
+ else
71
+ raise "You must provide content when creating a new entry"
72
+ end
73
+ end
74
+ end
75
+
53
76
  desc 'List all entries'
54
77
  arg_name 'section'
55
78
  command :show do |c|
@@ -113,24 +136,68 @@ command :choose do |c|
113
136
  end
114
137
  end
115
138
 
116
- desc 'Move all but the most recent 5 entries to the Archive section'
117
- default_value wwid.current_section
139
+ desc 'Add a new section to the "doing" file'
140
+ arg_name 'section_name'
141
+ command :add_section do |c|
142
+ c.action do |global_options,options,args|
143
+ unless wwid.sections.include?(args[0])
144
+ wwid.add_section(args[0].cap_first)
145
+ wwid.write(wwid.doing_file)
146
+ else
147
+ raise "Section #{args[0]} already exists"
148
+ end
149
+ end
150
+ end
151
+
152
+ desc 'Display a user-created view'
153
+ arg_name 'view_name'
154
+ command :view do |c|
155
+ c.desc 'Section'
156
+ c.flag [:s,:section]
157
+
158
+ c.desc 'Count to display'
159
+ c.flag [:c,:count], :must_match => /^\d+$/, :type => Integer
160
+
161
+ c.action do |global_options,options,args|
162
+ view = wwid.get_view(args[0])
163
+ if view
164
+ template = view.has_key?('template') ? view['template'] : nil
165
+ format = view.has_key?('date_format') ? view['date_format'] : nil
166
+ count = options[:c] ? options[:c] : view.has_key?('count') ? view['count'] : 10
167
+ section = options[:s] ? options[:s] : view.has_key?('section') ? view['section'] : wwid.current_section
168
+ puts wwid.list_section({:section => section, :count => count, :template => template, :format => format})
169
+ else
170
+ raise "View #{args[0]} not found in config"
171
+ end
172
+ end
173
+ end
174
+
175
+ desc 'Move all but the most recent 5 entries in a section to Archive'
118
176
  arg_name 'section'
177
+ default_value wwid.current_section
119
178
  command :archive do |c|
179
+ c.desc 'Count to keep'
180
+ c.default_value 5
181
+ c.flag [:k,:keep], :default_value => 5, :must_match => /^\d+$/, :type => Integer
182
+
120
183
  c.action do |global_options,options,args|
121
184
  if args.length > 0
122
185
  section = args.join(" ").capitalize
123
186
  else
124
187
  section = wwid.current_section
125
188
  end
126
- wwid.archive(section)
189
+ wwid.archive(section,options[:k])
127
190
  end
128
191
  end
129
192
 
130
- desc 'Edit the default configuration'
193
+ desc 'Edit the configuration file'
131
194
  command :config do |c|
195
+ c.desc 'Editor to use'
196
+ c.default_value ENV['EDITOR']
197
+ c.flag [:e,:editor]
198
+
132
199
  c.action do |global_options,options,args|
133
- system %Q{"#{ENV['EDITOR']}" "#{DOING_CONFIG}"}
200
+ system %Q{"#{options[:e]}" "#{File.expand_path(DOING_CONFIG)}"}
134
201
  end
135
202
  end
136
203
 
data/lib/doing/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Doing
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
data/lib/doing/wwid.rb CHANGED
@@ -36,14 +36,23 @@ class WWID
36
36
  'wrap_width' => 0
37
37
  }
38
38
  @config['templates']['last'] ||= {
39
- 'date_format' => '%_I:%M%P',
40
- 'template' => '%date: %title%note',
41
- 'wrap_width' => 60
39
+ 'date_format' => '%-I:%M%P on %a',
40
+ 'template' => '%title (at %date)%odnote',
41
+ 'wrap_width' => 88
42
42
  }
43
43
  @config['templates']['recent'] ||= {
44
44
  'date_format' => '%_I:%M%P',
45
45
  'template' => '%shortdate: %title',
46
- 'wrap_width' => 60
46
+ 'wrap_width' => 88
47
+ }
48
+ @config['views'] ||= {
49
+ 'sample' => {
50
+ 'date_format' => '%_I:%M%P',
51
+ 'template' => '%date | %title%note',
52
+ 'wrap_width' => 0,
53
+ 'section' => 'section_name',
54
+ 'count' => 5
55
+ }
47
56
  }
48
57
 
49
58
  @doing_file = File.expand_path(config['doing_file'])
@@ -132,7 +141,7 @@ class WWID
132
141
  end
133
142
 
134
143
  def add_item(title,section=nil,opt={})
135
- section = @current_section if section.nil?
144
+ section ||= @current_section
136
145
  add_section(section) unless @content.has_key?(section)
137
146
  opt[:date] ||= Time.now
138
147
  opt[:note] ||= ""
@@ -176,6 +185,13 @@ class WWID
176
185
  return sections[num.to_i - 1]
177
186
  end
178
187
 
188
+ def get_view(title)
189
+ if @config['views'].has_key?(title)
190
+ return @config['views'][title]
191
+ end
192
+ false
193
+ end
194
+
179
195
  def list_section(opt={})
180
196
  opt[:count] ||= 0
181
197
  count = opt[:count] - 1
@@ -263,14 +279,14 @@ class WWID
263
279
  return out
264
280
  end
265
281
 
266
- def archive(section=nil)
282
+ def archive(section=nil,count=10)
267
283
  section = choose_section if section.nil? || section =~ /choose/i
268
284
  if sections.include?(section)
269
285
  items = @content[section]['items']
270
286
  return if items.length < 10
271
287
  @content[section]['items'] = items[0..5]
272
288
  add_section('Archive') unless sections.include?('Archive')
273
- @content['Archive']['items'] += items[6..-1]
289
+ @content['Archive']['items'] += items[count..-1]
274
290
  write(@doing_file)
275
291
  end
276
292
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-15 00:00:00.000000000 Z
11
+ date: 2014-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake