markdo 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a71f1e99a267cfca241e89d0e707a6da7a38e3d
4
- data.tar.gz: 08798b77939ecb5a2c5f98c0bf411f0017444081
3
+ metadata.gz: 3af72a1862891028263caacca3bd0d95932aacb5
4
+ data.tar.gz: 25594deae9cd552eb401f00acfbd8cd6fd7aedfe
5
5
  SHA512:
6
- metadata.gz: 8c58f87e3af7bf2f6c914c9fe89920f0bab220af1d6d397d56588a0402f74a4dccfb8080dadcf063de9189f68fa64d97a371f6cd01c367b22219ef31d7bc6380
7
- data.tar.gz: 18416b125225f4cf78dea8d2c40c3d571e71f98d4f68c6827a630077f2330d0df863e324ecf23b8dd19353f5c588b763e04d10820a3e9e468175154de47502af
6
+ metadata.gz: 137137bbf1175513b0c2f5711f09b67c62c7afac050cbef6da61e5605cf3a0de57b5d5954b2c1415cc8b9c3f1057c3883ac937efa07085c333b4c19526bd81f5
7
+ data.tar.gz: ac0ead1ae05ead74ec67b08f67fdd9fd506a2119ce2efa0eeedd8527a070a018503e3a02dd9f8a39e9e8f0bd461cca3fbb740a79a68e670bb8f9607cf84aa3bd
@@ -1,5 +1,6 @@
1
1
  require 'markdo/add_command'
2
2
  require 'markdo/edit_command'
3
+ require 'markdo/forecast_command'
3
4
  require 'markdo/help_command'
4
5
  require 'markdo/ics_command'
5
6
  require 'markdo/inbox_command'
@@ -28,6 +29,8 @@ module Markdo
28
29
  AddCommand
29
30
  when 'edit'
30
31
  EditCommand
32
+ when 'forecast'
33
+ ForecastCommand
31
34
  when 'ics'
32
35
  IcsCommand
33
36
  when 'inbox'
@@ -0,0 +1,61 @@
1
+ require 'date'
2
+ require 'stringio'
3
+ require 'markdo/query_command'
4
+ require 'markdo/week_command'
5
+
6
+ module Markdo
7
+ # TODO: More testing of this logic. As of 2016-01-23, I was building this
8
+ # project as a proof of concept.
9
+ class ForecastCommand < WeekCommand
10
+ def initialize(*)
11
+ @date = Date.today
12
+ super
13
+ end
14
+
15
+ def run
16
+ # This is pretty ugly, but works. Just testing out how useful the concept is.
17
+ dates = dates_over_the_next_week
18
+ dates.shift
19
+ dates.shift
20
+
21
+ dates.each do |query|
22
+ stringio = StringIO.new
23
+ query_command = QueryCommand.new(stringio, @stderr, @env)
24
+ query_command.run(query)
25
+
26
+ abbreviation = weekday_abbreviation(query)
27
+ count = stringio.string.split("\n").length
28
+
29
+ @stdout.puts("#{abbreviation}: #{count}")
30
+ end
31
+
32
+ stringio = StringIO.new
33
+ next_week_command = WeekCommand.new(stringio, @stderr, @env)
34
+ next_week_command.date = @date + 7
35
+ next_week_command.run
36
+ next_week_count = stringio.string.split("\n").length
37
+ @stdout.puts("Next: #{next_week_count}")
38
+ end
39
+
40
+ private
41
+
42
+ def abbreviations_by_wday(wday)
43
+ abbrevs = {
44
+ 0 => 'Su',
45
+ 1 => 'Mo',
46
+ 2 => 'Tu',
47
+ 3 => 'We',
48
+ 4 => 'Th',
49
+ 5 => 'Fr',
50
+ 6 => 'Sa',
51
+ }
52
+
53
+ abbrevs[wday]
54
+ end
55
+
56
+ def weekday_abbreviation(iso8601_date)
57
+ wday = Date.strptime(iso8601_date, '%Y-%m-%d').wday
58
+ abbreviations_by_wday(wday)
59
+ end
60
+ end
61
+ end
@@ -8,6 +8,7 @@ Markdown-based task manager.
8
8
 
9
9
  add "string" Add a task to the inbox. (Set $MARKDO_ROOT and $MARKDO_INBOX.)
10
10
  edit Edit $MARKDO_ROOT in $EDITOR.
11
+ forecast Display counts of dates in the next week. (YYYY-MM-DD format.)
11
12
  help, --help Display this help text.
12
13
  inbox Display contents of $MARKDO_INBOX.
13
14
  ics Make an iCalendar feed of all due dates in Markdo. Can be imported
@@ -1,3 +1,3 @@
1
1
  module Markdo
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
@@ -5,6 +5,8 @@ module Markdo
5
5
  # TODO: More testing of this logic. As of 2016-01-23, I was building this
6
6
  # project as a proof of concept.
7
7
  class WeekCommand < Command
8
+ attr_accessor :date
9
+
8
10
  def initialize(*)
9
11
  @date = Date.today
10
12
  super
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Oakes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-26 00:00:00.000000000 Z
11
+ date: 2016-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,6 +76,7 @@ files:
76
76
  - lib/markdo/date_command.rb
77
77
  - lib/markdo/edit_command.rb
78
78
  - lib/markdo/fake_version.rb
79
+ - lib/markdo/forecast_command.rb
79
80
  - lib/markdo/help_command.rb
80
81
  - lib/markdo/ics_command.rb
81
82
  - lib/markdo/inbox_command.rb