juretta-things 0.1.0-x86-darwin-9

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.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Stefan Saasen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,16 @@
1
+ = things
2
+
3
+ A command line client for the Things task management application (Mac only).
4
+
5
+ = Usage
6
+ You can pipe the to-do title into the things command:
7
+ echo "The new todo" | things
8
+ OR
9
+ things < todo.txt # => todo.txt contains the title of the new todo
10
+ You can supply an argument. In this case things assumes that the given argument is a file.
11
+ The file content will be the note of the new todo.
12
+ things things.txt
13
+
14
+ == Copyright
15
+
16
+ Copyright (c) 2009 Stefan Saasen. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,60 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "things"
8
+ gem.summary = %Q{Command line access for the Things task management application (Mac).}
9
+ gem.email = "s@juretta.com"
10
+ gem.homepage = "http://github.com/juretta/things"
11
+ gem.authors = ["Stefan Saasen"]
12
+ gem.rubyforge_project = "things"
13
+ gem.bindir = 'bin'
14
+ gem.executables = ['things']
15
+ gem.platform = Gem::Platform::CURRENT
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
21
+ end
22
+
23
+ require 'rake/testtask'
24
+ Rake::TestTask.new(:test) do |test|
25
+ test.libs << 'lib' << 'test'
26
+ test.pattern = 'test/**/*_test.rb'
27
+ test.verbose = true
28
+ end
29
+
30
+ begin
31
+ require 'rcov/rcovtask'
32
+ Rcov::RcovTask.new do |test|
33
+ test.libs << 'test'
34
+ test.pattern = 'test/**/*_test.rb'
35
+ test.verbose = true
36
+ end
37
+ rescue LoadError
38
+ task :rcov do
39
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
40
+ end
41
+ end
42
+
43
+
44
+ task :default => :test
45
+
46
+ require 'rake/rdoctask'
47
+ Rake::RDocTask.new do |rdoc|
48
+ if File.exist?('VERSION.yml')
49
+ config = YAML.load(File.read('VERSION.yml'))
50
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
51
+ else
52
+ version = ""
53
+ end
54
+
55
+ rdoc.rdoc_dir = 'rdoc'
56
+ rdoc.title = "things #{version}"
57
+ rdoc.rdoc_files.include('README*')
58
+ rdoc.rdoc_files.include('lib/**/*.rb')
59
+ end
60
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/things ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ # == Synopsis
3
+ # The things command can be used to create new todos from the command line
4
+ #
5
+ # == Usage
6
+ # You can pipe the to-do title into the things command:
7
+ # echo "The new todo" | things
8
+ # OR
9
+ # things < todo.txt # => todo.txt contains the title of the new todo
10
+ #
11
+ # You can supply an argument. In this case things assumes that the given argument is a file.
12
+ # The file content will be the note of the new todo.
13
+ #
14
+ # things things.txt
15
+ #
16
+ # == Author
17
+ # Stefan Saasen
18
+ #
19
+ # == Copyright
20
+ # Copyright(c), 2009 Stefan Saasen juretta.com
21
+ require 'things'
22
+
23
+ Things::CLI.new.run(ARGV)
data/lib/things.rb ADDED
@@ -0,0 +1,123 @@
1
+ # == Synopsis
2
+ # The things command can be used to create new todos from the command line
3
+ #
4
+ # == Usage
5
+ # You can pipe the to-do title into the things command:
6
+ # echo "The new todo" | things
7
+ # OR
8
+ # things < todo.txt # => todo.txt contains the title of the new todo
9
+ #
10
+ # You can supply an argument. In this case things assumes that the given argument is a file.
11
+ # The file content will be the note of the new todo.
12
+ #
13
+ # things things.txt
14
+ #
15
+ # == Author
16
+ # Stefan Saasen
17
+ #
18
+ # == Copyright
19
+ # Copyright(c), 2009 Stefan Saasen juretta.com
20
+ require 'rdoc/usage'
21
+
22
+ module Things
23
+
24
+ ADD_TODO_CMD = <<-TODO_CMD
25
+ on run argv
26
+ tell application "Things"
27
+ set newToDo to make new to do with properties %CMD%
28
+ end tell
29
+ end run
30
+ TODO_CMD
31
+
32
+ class CLI
33
+ def todo_with_note(note)
34
+ things_add_todo("", note)
35
+ end
36
+
37
+ def todo_with_title(title)
38
+ things_add_todo(title)
39
+ end
40
+
41
+ def run(args) # :nodoc:
42
+ if STDIN.tty?
43
+ args.size < 1 ? print_usage : todo_with_note(open(args[0]).read)
44
+ else
45
+ todo_with_title(STDIN.read)
46
+ end
47
+ end
48
+
49
+ private
50
+ def things_add_todo(title, note = nil)
51
+ if note
52
+ prop = '{name: item 1 of argv, notes:item 2 of argv}'
53
+ arg = "'#{title.strip}' '#{note.strip}'"
54
+ else
55
+ prop = '{name:item 1 of argv}'
56
+ arg = "'#{title.strip}'"
57
+ end
58
+ lines = ADD_TODO_CMD.split("\n").inject("") do |str, line|
59
+ line = line.gsub(/%CMD%/, prop) if line =~ /%CMD%/
60
+ str << "-e '#{line.strip}' "
61
+ str
62
+ end
63
+ cmd = "osascript #{lines} #{arg}"
64
+ p cmd if $DEBUG
65
+ `#{cmd}`
66
+ end
67
+
68
+ # Slightly modified from Rdoc::usage
69
+ def print_usage # :nodoc:
70
+ # RDoc::usage('usage') # => use the comment of the main file - this is the gem created stub... can't use it
71
+ comment = File.open(__FILE__) do |f|
72
+ str = ""
73
+ f.each do |line|
74
+ str << line if line =~ /^#/
75
+ end
76
+ str = str.gsub(/^\s*#/, '')
77
+ end
78
+ raise unless comment.size > 0
79
+ markup = SM::SimpleMarkup.new
80
+ flow_convertor = SM::ToFlow.new
81
+
82
+ flow = markup.convert(comment, flow_convertor)
83
+
84
+ format = "plain"
85
+ flow = extract_sections(flow, %w(usage))
86
+ options = RI::Options.instance
87
+ formatter = options.formatter.new(options, "")
88
+ formatter.display_flow(flow)
89
+ end
90
+
91
+ def extract_sections(flow, sections) # :nodoc:
92
+ result = []
93
+ sections.each do |name|
94
+ name = name.downcase
95
+ copy_upto_level = nil
96
+
97
+ flow.each do |item|
98
+ case item
99
+ when SM::Flow::H
100
+ if copy_upto_level && item.level >= copy_upto_level
101
+ copy_upto_level = nil
102
+ else
103
+ if item.text.downcase == name
104
+ result << item
105
+ copy_upto_level = item.level
106
+ end
107
+ end
108
+ else
109
+ if copy_upto_level
110
+ result << item
111
+ end
112
+ end
113
+ end
114
+ end
115
+ if result.empty?
116
+ puts "Note to developer: requested section(s) [#{sections.join(', ')}] " +
117
+ "not found"
118
+ result = flow
119
+ end
120
+ result
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'things'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class ThingsTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: juretta-things
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: x86-darwin-9
6
+ authors:
7
+ - Stefan Saasen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-06-12 00:00:00 -07:00
13
+ default_executable: things
14
+ dependencies: []
15
+
16
+ description:
17
+ email: s@juretta.com
18
+ executables:
19
+ - things
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ files:
26
+ - .document
27
+ - .gitignore
28
+ - LICENSE
29
+ - README.rdoc
30
+ - Rakefile
31
+ - VERSION
32
+ - bin/things
33
+ - lib/things.rb
34
+ - test/test_helper.rb
35
+ - test/things_test.rb
36
+ has_rdoc: true
37
+ homepage: http://github.com/juretta/things
38
+ post_install_message:
39
+ rdoc_options:
40
+ - --charset=UTF-8
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project: things
58
+ rubygems_version: 1.2.0
59
+ signing_key:
60
+ specification_version: 2
61
+ summary: Command line access for the Things task management application (Mac).
62
+ test_files:
63
+ - test/test_helper.rb
64
+ - test/things_test.rb