create_task 0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 72e2e4d087b94b6a90d2d176b357f009aa4d2647
4
+ data.tar.gz: d87bf6e7c8025a93a626924050ef8f72dd8823ac
5
+ SHA512:
6
+ metadata.gz: f96d769a6a4264481fb13ef579cb413b68987a8a7184d22b37642a746939f6d28efe0691e6f6fd4812d35b47e70ae248761a0a1b4d1cdd6f445d10706a3c021c
7
+ data.tar.gz: 5fe39aa087e10fd23e3d10c5832adea6b29f281a50a3cfd47a6dd95acd980d538bf0545fc11dff57bf509ed51086835932d512972cfc089cfe65aeb5768c3d3d
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.0
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ ruby '2.0'
2
+ source 'https://rubygems.org'
3
+ gem 'mechanize'
4
+ gem 'amatch'
5
+ gem 'rb-appscript'
6
+ gem 'highline'
7
+ gem 'chronic'
8
+ gem 'sqlite3'
data/Gemfile.lock ADDED
@@ -0,0 +1,48 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ amatch (0.3.0)
5
+ tins (~> 1.0)
6
+ chronic (0.10.2)
7
+ domain_name (0.5.24)
8
+ unf (>= 0.0.5, < 1.0.0)
9
+ highline (1.7.3)
10
+ http-cookie (1.0.2)
11
+ domain_name (~> 0.5)
12
+ mechanize (2.7.3)
13
+ domain_name (~> 0.5, >= 0.5.1)
14
+ http-cookie (~> 1.0)
15
+ mime-types (~> 2.0)
16
+ net-http-digest_auth (~> 1.1, >= 1.1.1)
17
+ net-http-persistent (~> 2.5, >= 2.5.2)
18
+ nokogiri (~> 1.4)
19
+ ntlm-http (~> 0.1, >= 0.1.1)
20
+ webrobots (>= 0.0.9, < 0.2)
21
+ mime-types (2.6.1)
22
+ mini_portile (0.6.2)
23
+ net-http-digest_auth (1.4)
24
+ net-http-persistent (2.9.4)
25
+ nokogiri (1.6.6.2)
26
+ mini_portile (~> 0.6.0)
27
+ ntlm-http (0.1.1)
28
+ rb-appscript (0.6.1)
29
+ sqlite3 (1.3.10)
30
+ tins (1.6.0)
31
+ unf (0.1.4)
32
+ unf_ext
33
+ unf_ext (0.0.7.1)
34
+ webrobots (0.1.1)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ amatch
41
+ chronic
42
+ highline
43
+ mechanize
44
+ rb-appscript
45
+ sqlite3
46
+
47
+ BUNDLED WITH
48
+ 1.10.4
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ #Create Task
2
+ _A module for creating tasks in OmniFocus, Things, DueApp, and Apple Reminders on the Mac_
3
+
4
+ I created this module for easy integration from my ruby apps into the Big 4 of Task Managers.
5
+
6
+ To use this in your app, simply include
7
+ lib/create_todo.rb
8
+ in your source.
9
+
10
+ __Creating tasks is as easy as__
11
+
12
+ CreateTask::OmniFocus.new(name: "Task name", note: "Task note", start_date: "7/17/2013", due_date: "7/29/2013")
13
+
14
+ CreateTask::Things.new(name: "Task name", note: "Task note", due_date: "7/17/2013", tags: "github, gtd")
15
+
16
+ CreateTask::DueApp.new(name: "Task name", due_date: "7/17/2013")
17
+
18
+ CreateTask::Reminders.new(name: "Task name", due_date: "7/17/2013")
19
+
20
+
21
+ ###Requirements:
22
+
23
+ - AppScript (for OmniFocus)
24
+ - Chronic (for date parsing)
25
+ - A Mac (no brainer)
26
+
27
+ Credits:
28
+ Brett Terpstra (@ttscoff) for OmniFocus task inspiration and his date parser method
data/bin/create_task ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/ruby
2
+ require_relative '../lib/create_task'
3
+ # require 'create_task'
4
+ app = ARGV.shift
5
+ task = {
6
+ name: ARGV.shift, due_date: ARGV.shift,
7
+ start_date: ARGV.shift, note: ARGV.shift }
8
+ CreateTask::Helper.new_task(task, app)
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'create_task/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'create_task'
8
+ spec.version = CreateTask::VERSION
9
+ spec.authors = ['Nick Prokesch']
10
+ spec.email = ['nick@prokes.ch']
11
+ spec.summary = 'Handles task creation for a variety of todo apps'
12
+ spec.description = 'Creates tasks for omnifocus, things, reminders'
13
+ spec.homepage = 'https://github.com/prokizzle/create_task'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($RS)
17
+ spec.require_paths = ['lib']
18
+ spec.bindir = 'bin'
19
+ spec.executables << 'create_task'
20
+
21
+ spec.add_dependency 'mechanize', '~> 2.7'
22
+ spec.add_dependency 'amatch', '~> 0.2'
23
+ spec.add_dependency 'rb-appscript', '~> 0.6'
24
+ spec.add_dependency 'highline', '~> 1.6'
25
+ spec.add_dependency 'chronic', '~> 0.10'
26
+ spec.add_dependency 'sqlite3', '~> 1.3'
27
+ end
@@ -0,0 +1,28 @@
1
+ require 'yaml'
2
+ require 'highline/import'
3
+ require 'appscript'
4
+ class Appscript::Reference # :nodoc:
5
+ # HACK: There is apparently a bug in ruby 1.9 where if you have
6
+ # method_missing defined and do some action that calls to_ary, then
7
+ # to_ary will be called on your instance REGARDLESS of whether
8
+ # respond_to_(:to_ary) returns true or not.
9
+ #
10
+ # http://tenderlovemaking.com/2011/06/28/til-its-ok-to-return-nil-from-to_ary/
11
+
12
+ def to_ary # :nodoc:
13
+ nil
14
+ end
15
+ end if RUBY_VERSION >= "1.9"
16
+ include Appscript
17
+ require 'amatch'
18
+ include Amatch
19
+ require 'chronic'
20
+ require 'mechanize'
21
+ require 'open-uri'
22
+
23
+ # Requires all gem files
24
+ module CreateTask
25
+ Dir[File.dirname(__FILE__) + '/create_task/*.rb'].each do |file|
26
+ require file
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ # CreateTask gem
2
+ module CreateTask
3
+ # Helper for creating tasks
4
+ class Helper
5
+ def self.new_task(task, app)
6
+ CreateTask::OmniFocus.create(task) if app == 'omnifocus'
7
+ CreateTask::Reminders.create(task) if app == 'reminders'
8
+ CreateTask::Things.create(task) if app == 'things'
9
+ CreateTask::DueApp.create(task) if app == 'dueapp'
10
+ end
11
+
12
+ def default_parsed_date(datestring)
13
+ Chronic.parse(
14
+ datestring.to_s,
15
+ context: :future, ambiguous_time_range: 8
16
+ )
17
+ end
18
+
19
+ def parse_date(datestring)
20
+ return default_parsed_date(datestring) unless datestring =~ /^\+(\d+)$/
21
+ days = (60 * 60 * 24 * Regexp.last_match[1].to_i)
22
+ Time.now + days
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ # CreateTask Gem
2
+ module CreateTask
3
+ # Creates a task in Due App
4
+ class DueApp < CreateTask::Helper
5
+ # include 'helper'
6
+ def self.create(args)
7
+ name = args[:name]
8
+ due_date = args[:due_date]
9
+ `osascript << 'APPLESCRIPT'
10
+ set d_date to date "#{due_date}"
11
+ set theURl to "due:///add?title=#{name}&due_date=" & d_date
12
+ tell application "Finder" to open location theURl
13
+ tell application "Due" to activate
14
+ delay 0.5 -- This delay can be tweaked for your system
15
+ tell application "Due" to activate
16
+ tell application "System Events" to key code 36
17
+ delay 1 -- This delay can be tweaked for your system
18
+ APPLESCRIPT`
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # CreateTask Gem
2
+ module CreateTask
3
+ # Creates a task in OmniFocus
4
+ class OmniFocus < CreateTask::Helper
5
+ def self.create(args)
6
+ of = app('OmniFocus')
7
+ dd= of.default_document
8
+ dd.make(new: :inbox_task, with_properties: processed_args(args))
9
+ end
10
+
11
+ def self.processed_args(args)
12
+ args.each{ |k,v| args.delete(k) if v.nil? }
13
+ args[:defer_date] = args[:start_date] if args[:start_date]
14
+ args.delete(:start_date)
15
+ args[:due_date] = parse_date(args[:due_date]) if args[:due_date]
16
+ args[:defer_date] = parse_date(args[:defer_date]) if args[:defer_date]
17
+ puts args
18
+ args
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ # CreateTask gem
2
+ module CreateTask
3
+ # Creates a task in Reminders for Mac
4
+ class Reminders < CreateTask::Helper
5
+ def self.create(args)
6
+ name = args[:name]
7
+ `osascript <<'APPLESCRIPT'
8
+ set d_date to date "#{args[:due_date]}"
9
+ tell application "Reminders" to show
10
+ (make new reminder with properties {name:"#{name}", due date:(d_date)})
11
+ APPLESCRIPT`
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ # CreateTask Gem
2
+ module CreateTask
3
+ # Creates a task in Things app
4
+ class Things < CreateTask::Helper
5
+ def self.create(args)
6
+ `osascript << 'APPLESCRIPT'
7
+ set d_date to date "#{args[:due_date]}"
8
+ tell application "Things"
9
+ set newToDo to make new to do with properties {name: "#{args[:name]}"}
10
+ set newToDo's notes to "#{args[:due_date]}"
11
+ set newToDo's due date to d_date
12
+ set tag names of newToDo to "#{args[:tag]}"
13
+ end tell
14
+ APPLESCRIPT`
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module CreateTask
2
+ VERSION = '0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: create_task
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Nick Prokesch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mechanize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: amatch
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rb-appscript
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.6'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: highline
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.6'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: chronic
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.10'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.3'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.3'
97
+ description: Creates tasks for omnifocus, things, reminders
98
+ email:
99
+ - nick@prokes.ch
100
+ executables:
101
+ - create_task
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".ruby-version"
107
+ - Gemfile
108
+ - Gemfile.lock
109
+ - README.md
110
+ - bin/create_task
111
+ - create_task.gemspec
112
+ - lib/create_task.rb
113
+ - lib/create_task/_helper.rb
114
+ - lib/create_task/due_app.rb
115
+ - lib/create_task/omnifocus.rb
116
+ - lib/create_task/reminders.rb
117
+ - lib/create_task/things.rb
118
+ - lib/create_task/version.rb
119
+ homepage: https://github.com/prokizzle/create_task
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.4.8
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Handles task creation for a variety of todo apps
143
+ test_files: []