markdo 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: 0d0923b1a531a4f5bfb3ef56d910acd10d040775
4
- data.tar.gz: 7574cc21bd5bb6c1336937208554e12829ac03a4
3
+ metadata.gz: 8a2e5bd0ee34d868e2dd11b5dee89f9a0fbc52c4
4
+ data.tar.gz: b5abfb1983a281bc00b59ffbe915e2a63fdc4c92
5
5
  SHA512:
6
- metadata.gz: 1db599021903ea12d49af92b0d48dd55746e1cdc269b35b8ecd8a27a6d2262761d7776eaaa3af39fabf60cb9bb9ed36f6da806a31164c9fdf621bd9d5e0f826a
7
- data.tar.gz: 5d4c29e9822778ed2d6a4662b4b76a2c9f2c3e2375e705da4a683c97a4eac032de9b1ac4ff99632ff9117bee7d81c1d52963d39a46e3aeed6b080db9be37dac5
6
+ metadata.gz: 5385ec1014d033eb4e620f24d87b9e982040f92cc34a32b35ad0835b08dad8ef724d338e6532a804a3ee3cbdccaee149213e0eb3e67a65101e0bcdf40a61a1bc
7
+ data.tar.gz: 25dee892bf97eb1fe6c1d71f739b8e8f3421c9394f5fe0f451e4d9b613f83ba8c9426efdf97a30d20f349cc6fbdf3e341185b37cfa834bfc0721e4d44888cf7f
@@ -0,0 +1 @@
1
+ 2.3.1
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache: bundler
4
+ rvm:
5
+ - 1.9.3
6
+ - 2.0.0
7
+ - 2.1.10
8
+ - 2.2.5
9
+ - 2.3.1
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Markdo
2
2
 
3
+ [![Build Status](https://travis-ci.org/benjaminoakes/markdo.svg?branch=master)](https://travis-ci.org/benjaminoakes/markdo)
4
+
3
5
  Markdown-based task manager. Inspired by [OmniFocus][omnifocus], [TaskPaper][taskpaper], and [GitHub Flavored Markdown's task lists][gfm-task-lists].
4
6
 
5
7
  [gfm-task-lists]: https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments
@@ -1,6 +1,7 @@
1
1
  require 'markdo/add_command'
2
2
  require 'markdo/edit_command'
3
3
  require 'markdo/help_command'
4
+ require 'markdo/ics_command'
4
5
  require 'markdo/overview_command'
5
6
  require 'markdo/query_command'
6
7
  require 'markdo/rss_command'
@@ -24,6 +25,8 @@ module Markdo
24
25
  AddCommand
25
26
  when 'edit'
26
27
  EditCommand
28
+ when 'ics'
29
+ IcsCommand
27
30
  when 'overdue'
28
31
  OverdueCommand
29
32
  when 'overview'
@@ -9,6 +9,8 @@ Markdown-based task manager.
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
11
  help, --help Display this help text.
12
+ ics Make an iCalendar feed of all due dates in Markdo. Can be imported
13
+ or subscribed to if on a remote server.
12
14
  overview Get overview of overdue, starred, today's, and tomorrow's tasks.
13
15
  overdue Search *.md files for previous dates. (YYYY-MM-DD format.)
14
16
  tag "string" Search *.md files for @string.
@@ -0,0 +1,71 @@
1
+ require 'markdo/command'
2
+ require 'date'
3
+ require 'uri'
4
+
5
+ module Markdo
6
+ class IcsCommand < Command
7
+ def run
8
+ events = Dir.
9
+ glob(markdown_glob).
10
+ map { |path| File.readlines(path, encoding: 'UTF-8') }.
11
+ flatten.
12
+ grep(date_regexp).
13
+ map { |line|
14
+ begin
15
+ raw_due_date = line.match(date_regexp)
16
+ due_date = Date.parse(raw_due_date[0])
17
+ Event.new(due_date, due_date, clean(line))
18
+ rescue ArgumentError
19
+ # invalid date, skip it
20
+ end
21
+ }.compact
22
+
23
+ ics = template(events)
24
+
25
+ @stdout.puts(ics)
26
+ end
27
+
28
+ protected
29
+
30
+ Event = Struct.new(:date_start, :date_end, :summary) do
31
+ def to_ics
32
+ buf = []
33
+ buf << 'BEGIN:VEVENT'
34
+ buf << "DTSTART;VALUE=DATE:#{date_start.strftime('%Y%m%d')}"
35
+ buf << "DTEND;VALUE=DATE:#{date_end.strftime('%Y%m%d')}"
36
+ buf << "SUMMARY:#{summary}"
37
+ buf << 'END:VEVENT'
38
+ buf.join("\n")
39
+ end
40
+ end
41
+
42
+ def markdown_glob
43
+ "#{@env['MARKDO_ROOT']}/*.md"
44
+ end
45
+
46
+ def date_regexp
47
+ %r(\b\d{4}-\d{2}-\d{2}\b)
48
+ end
49
+
50
+ def clean(line)
51
+ line.
52
+ sub(/\s*[-*] \[.\]\s+/, '').
53
+ sub(date_regexp, '').
54
+ strip
55
+ end
56
+
57
+ def template(events)
58
+ buf = []
59
+
60
+ buf << 'BEGIN:VCALENDAR'
61
+ buf << 'VERSION:2.0'
62
+ buf << 'CALSCALE:GREGORIAN'
63
+ buf << 'METHOD:PUBLISH'
64
+ buf << 'X-WR-CALNAME:Markdo Due Dates'
65
+ buf << events.map { |event| event.to_ics }
66
+ buf << 'END:VCALENDAR'
67
+
68
+ buf.flatten.join("\n")
69
+ end
70
+ end
71
+ end
@@ -40,30 +40,26 @@ module Markdo
40
40
  end
41
41
 
42
42
  def template(items)
43
+ buf = []
44
+
43
45
  # No beginning of line whitespace allowed
44
- buf = '<?xml version="1.0" encoding="UTF-8"?>'
46
+ buf << %(<?xml version="1.0" encoding="UTF-8"?>)
45
47
 
46
- buf = <<-XML
47
- <rss version="2.0">
48
- <channel>
49
- <title>Links in Markdo</title>
50
- XML
48
+ buf << %(<rss version="2.0">)
49
+ buf << %(<channel>)
50
+ buf << %(<title>Links in Markdo</title>)
51
51
 
52
52
  items.each do |item|
53
- buf << <<-XML
54
- <item>
55
- <title>#{item.title}</title>
56
- <link>#{item.link}</link>
57
- </item>
58
- XML
53
+ buf << %(<item>)
54
+ buf << %(<title>#{item.title}</title>)
55
+ buf << %(<link>#{item.link}</link>)
56
+ buf << %(</item>)
59
57
  end
60
58
 
61
- buf << <<-XML
62
- </channel>
63
- </rss>
64
- XML
59
+ buf << %(</channel>)
60
+ buf << %(</rss>)
65
61
 
66
- buf
62
+ buf.join("\n")
67
63
  end
68
64
  end
69
65
  end
@@ -1,3 +1,3 @@
1
1
  module Markdo
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -19,5 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "minitest"
22
23
  spec.add_development_dependency "rake"
23
24
  end
@@ -0,0 +1,4 @@
1
+ - [ ] Task 1
2
+ - [ ] 2016-06-31 Task with invalid date
3
+ - [ ] 2014-04-01 Task with long-past due date
4
+ - [ ] 2016-04-01 Task with due date
@@ -0,0 +1,33 @@
1
+ require 'test_helper'
2
+ require 'markdo/ics_command'
3
+
4
+ module Markdo
5
+ describe IcsCommand do
6
+ it 'outputs an iCalendar feed from the input Markdown, skipping invalid dates' do
7
+ out = StringIO.new
8
+ err = StringIO.new
9
+ env = { 'MARKDO_ROOT' => 'test/fixtures' }
10
+
11
+ IcsCommand.new(out, err, env).run
12
+
13
+ out.string.must_equal <<-ICS
14
+ BEGIN:VCALENDAR
15
+ VERSION:2.0
16
+ CALSCALE:GREGORIAN
17
+ METHOD:PUBLISH
18
+ X-WR-CALNAME:Markdo Due Dates
19
+ BEGIN:VEVENT
20
+ DTSTART;VALUE=DATE:20140401
21
+ DTEND;VALUE=DATE:20140401
22
+ SUMMARY:Task with long-past due date
23
+ END:VEVENT
24
+ BEGIN:VEVENT
25
+ DTSTART;VALUE=DATE:20160401
26
+ DTEND;VALUE=DATE:20160401
27
+ SUMMARY:Task with due date
28
+ END:VEVENT
29
+ END:VCALENDAR
30
+ ICS
31
+ end
32
+ end
33
+ end
@@ -10,9 +10,9 @@ module Markdo
10
10
 
11
11
  RssCommand.new(out, err, env).run
12
12
 
13
- out.string.must_equal <<-XML
14
- <?xml version=\"1.0\" encoding=\"UTF-8\"?>
15
- <rss>
13
+ xml_must_equal out.string, <<-XML
14
+ <?xml version="1.0" encoding="UTF-8"?>
15
+ <rss version="2.0">
16
16
  <channel>
17
17
  <title>Links in Markdo</title>
18
18
  <item>
@@ -31,5 +31,9 @@ module Markdo
31
31
  </rss>
32
32
  XML
33
33
  end
34
+
35
+ def xml_must_equal(actual, expected)
36
+ actual.must_equal(expected.gsub(/^\s*/, ''))
37
+ end
34
38
  end
35
39
  end
@@ -1,2 +1,3 @@
1
+ gem 'minitest'
1
2
  require 'minitest/autorun'
2
3
  require 'stringio'
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.3
4
+ version: 0.1.4
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-03-30 00:00:00.000000000 Z
11
+ date: 2016-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -47,6 +61,8 @@ extensions: []
47
61
  extra_rdoc_files: []
48
62
  files:
49
63
  - ".gitignore"
64
+ - ".ruby-version"
65
+ - ".travis.yml"
50
66
  - Gemfile
51
67
  - LICENSE.txt
52
68
  - README.md
@@ -59,6 +75,7 @@ files:
59
75
  - lib/markdo/date_command.rb
60
76
  - lib/markdo/edit_command.rb
61
77
  - lib/markdo/help_command.rb
78
+ - lib/markdo/ics_command.rb
62
79
  - lib/markdo/overdue_command.rb
63
80
  - lib/markdo/overview_command.rb
64
81
  - lib/markdo/query_command.rb
@@ -70,7 +87,9 @@ files:
70
87
  - lib/markdo/version.rb
71
88
  - lib/markdo/version_command.rb
72
89
  - markdo.gemspec
90
+ - test/fixtures/ics_command.md
73
91
  - test/fixtures/rss_command.md
92
+ - test/ics_command_test.rb
74
93
  - test/rss_command_test.rb
75
94
  - test/test_helper.rb
76
95
  homepage: http://github.com/benjaminoakes/markdo
@@ -93,11 +112,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
112
  version: '0'
94
113
  requirements: []
95
114
  rubyforge_project:
96
- rubygems_version: 2.4.6
115
+ rubygems_version: 2.5.1
97
116
  signing_key:
98
117
  specification_version: 4
99
118
  summary: Markdown-based task manager
100
119
  test_files:
120
+ - test/fixtures/ics_command.md
101
121
  - test/fixtures/rss_command.md
122
+ - test/ics_command_test.rb
102
123
  - test/rss_command_test.rb
103
124
  - test/test_helper.rb