taskpaper 0.1
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 +7 -0
- data/Gemfile +4 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/taskpaper +13 -0
- data/lib/.taskpaper.rb.swp +0 -0
- data/lib/taskpaper.rb +8 -0
- data/lib/taskpaper/.item.rb.swp +0 -0
- data/lib/taskpaper/document.rb +39 -0
- data/lib/taskpaper/item.rb +60 -0
- data/lib/taskpaper/note.rb +4 -0
- data/lib/taskpaper/project.rb +4 -0
- data/lib/taskpaper/task.rb +66 -0
- data/lib/taskpaper/version.rb +3 -0
- data/taskpaper.gemspec +22 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c92d61085a02597bb8b163f1a3b0d20dcd27db42
|
4
|
+
data.tar.gz: ee92243b2313b05739e764e0104989c1010895a2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e58b2ad20b0b0834b2e14f607312614dbb8efd60dccf89d169509d87d1a97748d84fb1a8edee69e51ece3788f03587b65c30a95dcb29e7e7d75173ce50bba63
|
7
|
+
data.tar.gz: 97e80112c4a11afff1525004dcf738390c0e2082e78d55e096d078c5280c6067ba79ed4cd9ba295f9d6ab00932fdc3b2c63938788e628ff33e1873853ac93d64
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Taskpaper
|
2
|
+
|
3
|
+
Interact with your taskpaper files with Ruby.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'taskpaper'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install taskpaper
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: WRITE THIS
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/lodestone/taskpaper.
|
34
|
+
|
35
|
+
© Copyright 2016 Matthew Petty @lodestone
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "taskpaper"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/bin/taskpaper
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "rubygems"
|
3
|
+
require "thor"
|
4
|
+
require_relative "../lib/taskpaper"
|
5
|
+
|
6
|
+
class TaskpaperCLI < Thor
|
7
|
+
desc "parse", "parses a taskpaper file"
|
8
|
+
def parse(*args)
|
9
|
+
puts Taskpaper.parse(args.first)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
TaskpaperCLI.start
|
Binary file
|
data/lib/taskpaper.rb
ADDED
Binary file
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Taskpaper
|
2
|
+
class Document
|
3
|
+
|
4
|
+
attr_accessor :filename, :doc
|
5
|
+
|
6
|
+
def parse
|
7
|
+
@doc = []
|
8
|
+
@text.each_line do |line|
|
9
|
+
item = Taskpaper::Item.new line
|
10
|
+
@doc << item.classify.new(line)
|
11
|
+
end
|
12
|
+
@doc
|
13
|
+
end
|
14
|
+
|
15
|
+
#---------------------
|
16
|
+
def initialize(file)
|
17
|
+
@filename = file
|
18
|
+
@text = File.open(filename, "r").read
|
19
|
+
parse
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_text
|
23
|
+
@text
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_html
|
27
|
+
# TODO: to_html
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_json
|
31
|
+
# TODO: to_json
|
32
|
+
end
|
33
|
+
|
34
|
+
def inspect
|
35
|
+
doc.map(&:inspect)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Taskpaper
|
2
|
+
class Item
|
3
|
+
|
4
|
+
attr_accessor :description, :level
|
5
|
+
|
6
|
+
def initialize(string)
|
7
|
+
@description = string || ""
|
8
|
+
end
|
9
|
+
|
10
|
+
def untagged_description
|
11
|
+
tags.each do |tag|
|
12
|
+
line.gsub!(tag, "")
|
13
|
+
end
|
14
|
+
line
|
15
|
+
end
|
16
|
+
|
17
|
+
def tag_regex
|
18
|
+
/@[[:alnum:]_-]*\([[:alnum:]\s\-\_\:\'\"]*\)*|@[[:alnum:]]*/
|
19
|
+
end
|
20
|
+
|
21
|
+
def project_regex
|
22
|
+
/(?<project>[[:alnum:]\s\'\"\_\-\(\)\{\}\[\]\<\>\?\+\!\@\#\$\%\^\&\*\|\\\~\`\,\.\=]+):/
|
23
|
+
end
|
24
|
+
|
25
|
+
def task_regex
|
26
|
+
/(?<task>\-[[:alnum:]\s'"]+)/
|
27
|
+
end
|
28
|
+
|
29
|
+
def level
|
30
|
+
description.scan(/^\t|\ \ /).count
|
31
|
+
end
|
32
|
+
|
33
|
+
def classify
|
34
|
+
return Taskpaper::Project if description.match project_regex
|
35
|
+
return Taskpaper::Task if description.match task_regex
|
36
|
+
return Taskpaper::Note
|
37
|
+
end
|
38
|
+
|
39
|
+
def tags
|
40
|
+
description.scan(tag_regex).map(&:strip)
|
41
|
+
end
|
42
|
+
|
43
|
+
def inspect
|
44
|
+
"#<#{self.class}:#{object_id} \"#{description.strip}\" tags: #{tags.inspect}>"
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_s
|
48
|
+
description
|
49
|
+
end
|
50
|
+
|
51
|
+
# def method_missing(method, *args)
|
52
|
+
# if description.respond_to?(method)
|
53
|
+
# description.send(method, *args)
|
54
|
+
# else
|
55
|
+
# raise "Undefined method :#{method} for #{self.inspect}"
|
56
|
+
# end
|
57
|
+
# end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
class Taskpaper::Task < Taskpaper::Item
|
2
|
+
|
3
|
+
def initialize(string)
|
4
|
+
@description = string
|
5
|
+
end
|
6
|
+
|
7
|
+
def complete!(polarity=nil,time=Time.now)
|
8
|
+
if !polarity.nil?
|
9
|
+
if polarity == false
|
10
|
+
# Set to incomplete
|
11
|
+
description.gsub!(/^x/, '-')
|
12
|
+
remove_done_tags
|
13
|
+
else
|
14
|
+
# Set to complete with @done(TIME)
|
15
|
+
description.gsub!(/^.\s/, 'x ')
|
16
|
+
remove_done_tags
|
17
|
+
description.strip!
|
18
|
+
description << " @done(#{time})"
|
19
|
+
end
|
20
|
+
description.strip!
|
21
|
+
description
|
22
|
+
else
|
23
|
+
# Polarity unspecified so.... REVERSE POLARITY!!!!
|
24
|
+
complete!(!complete?)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def complete=(time)
|
29
|
+
completed_at(time)
|
30
|
+
end
|
31
|
+
|
32
|
+
def completed_at(time)
|
33
|
+
complete!(true, time)
|
34
|
+
end
|
35
|
+
alias_method :complete_at, :completed_at
|
36
|
+
|
37
|
+
def complete?
|
38
|
+
begins_with_x? || tagged_done?
|
39
|
+
end
|
40
|
+
alias_method :complete, :complete?
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def tagged_done?
|
45
|
+
!!tags.detect{|tag| tag[done_regex] }
|
46
|
+
end
|
47
|
+
|
48
|
+
def begins_with_x?
|
49
|
+
!!description[/^x\s.*/]
|
50
|
+
end
|
51
|
+
|
52
|
+
def remove_done_tags
|
53
|
+
tags.each do |tag|
|
54
|
+
description.gsub!(tag, "") if tag =~ done_regex
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# def inspect
|
59
|
+
# "<Taskpaper:Task#{object_id} @description=\"#{description}\" complete: #{complete?} tags: #{tags.inspect}"
|
60
|
+
# end
|
61
|
+
|
62
|
+
def done_regex
|
63
|
+
/@done\([[:alnum:]\s\-\_\:]*\)|@done/
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
data/taskpaper.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "taskpaper"
|
7
|
+
spec.version = "0.1"
|
8
|
+
spec.authors = ["Matt Petty"]
|
9
|
+
spec.email = ["matt@kizmeta.com"]
|
10
|
+
spec.licenses = ['MIT']
|
11
|
+
spec.summary = %q{library for interacting with Taskpaper files}
|
12
|
+
spec.description = %q{I suppose I should write a longer description someday.}
|
13
|
+
spec.homepage = "https://github.com/lodestone/taskpaper"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: taskpaper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Petty
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: I suppose I should write a longer description someday.
|
42
|
+
email:
|
43
|
+
- matt@kizmeta.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- Gemfile
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- bin/console
|
52
|
+
- bin/setup
|
53
|
+
- bin/taskpaper
|
54
|
+
- lib/.taskpaper.rb.swp
|
55
|
+
- lib/taskpaper.rb
|
56
|
+
- lib/taskpaper/.item.rb.swp
|
57
|
+
- lib/taskpaper/document.rb
|
58
|
+
- lib/taskpaper/item.rb
|
59
|
+
- lib/taskpaper/note.rb
|
60
|
+
- lib/taskpaper/project.rb
|
61
|
+
- lib/taskpaper/task.rb
|
62
|
+
- lib/taskpaper/version.rb
|
63
|
+
- taskpaper.gemspec
|
64
|
+
homepage: https://github.com/lodestone/taskpaper
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.4.5.1
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: library for interacting with Taskpaper files
|
88
|
+
test_files: []
|