neverdone 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +20 -0
- data/README.md +13 -0
- data/Rakefile +45 -0
- data/bin/nd +178 -0
- data/lib/neverdone.rb +26 -0
- metadata +161 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "bundler", "~> 1.0.0"
|
10
|
+
gem "jeweler", "~> 1.5.2"
|
11
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Sergio Rubio
|
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.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'lib/neverdone'
|
4
|
+
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "neverdone"
|
18
|
+
gem.version = Neverdone::VERSION
|
19
|
+
gem.homepage = "http://github.com/rubiojr/neverdone"
|
20
|
+
gem.license = "MIT"
|
21
|
+
gem.summary = %Q{Command Line Todo for Evernote}
|
22
|
+
gem.description = %Q{Command Line Todo for Evernote}
|
23
|
+
gem.email = "rubiojr@frameos.org"
|
24
|
+
gem.authors = ["Sergio Rubio"]
|
25
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
26
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
27
|
+
gem.add_runtime_dependency 'everton', '>= 0.1.3'
|
28
|
+
gem.add_runtime_dependency 'clamp', '>= 0.2'
|
29
|
+
gem.add_runtime_dependency 'term-ansicolor'
|
30
|
+
gem.add_runtime_dependency 'highline'
|
31
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
32
|
+
end
|
33
|
+
Jeweler::RubygemsDotOrgTasks.new
|
34
|
+
|
35
|
+
task :default => :build
|
36
|
+
|
37
|
+
require 'rake/rdoctask'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "neverdone #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
+
end
|
data/bin/nd
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'neverdone'
|
4
|
+
require 'clamp'
|
5
|
+
require 'everton'
|
6
|
+
require 'term/ansicolor'
|
7
|
+
require 'highline/import'
|
8
|
+
|
9
|
+
class String
|
10
|
+
include Term::ANSIColor
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# Task Title Conventions
|
15
|
+
# s: = state (done,starred)
|
16
|
+
# r: = reminder (date_hour, format: 20110101_HHMM, hour optional)
|
17
|
+
# l: = list (list name, multiple todo list support)
|
18
|
+
|
19
|
+
# HACK, FIXME, BAD, SHIT: Ignore SSL warnings
|
20
|
+
class Net::HTTP
|
21
|
+
alias_method :old_initialize, :initialize
|
22
|
+
def initialize(*args)
|
23
|
+
old_initialize(*args)
|
24
|
+
@ssl_context = OpenSSL::SSL::SSLContext.new
|
25
|
+
@ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class NeverdoneCommand < Clamp::Command
|
30
|
+
|
31
|
+
def execute
|
32
|
+
begin
|
33
|
+
authenticate
|
34
|
+
@notebook = Everton::Notebook.find('Neverdone Todo')
|
35
|
+
rescue Evernote::EDAM::Error::EDAMSystemException
|
36
|
+
#token expired
|
37
|
+
authenticate force=true
|
38
|
+
@notebook = Everton::Notebook.find('Neverdone Todo')
|
39
|
+
end
|
40
|
+
if not @notebook
|
41
|
+
print "Neverdone Todo notebook not found, creating..."
|
42
|
+
@notebook = Everton::Notebook.create('Neverdone Todo')
|
43
|
+
puts ' Done'
|
44
|
+
end
|
45
|
+
lazy_execute
|
46
|
+
end
|
47
|
+
|
48
|
+
def authenticate(force=false)
|
49
|
+
@config = Neverdone::Config.load
|
50
|
+
auth = {
|
51
|
+
:user_store_url => @config[:user_store_url],
|
52
|
+
:consumer_key => Neverdone::CONSUMER_KEY,
|
53
|
+
:consumer_secret => Neverdone::CONSUMER_SECRET,
|
54
|
+
:access_token => @config[:access_token]
|
55
|
+
}
|
56
|
+
if not @config[:username]
|
57
|
+
auth[:username] = ask("Evernote username: ")
|
58
|
+
else
|
59
|
+
auth[:username] = @config[:username]
|
60
|
+
end
|
61
|
+
if not @config[:password]
|
62
|
+
auth[:password] = ask("Evernote password: ") { |q| q.echo = false }
|
63
|
+
puts "\nConfiguration stored at #{ENV['HOME']}/.neverdone.conf\n\n"
|
64
|
+
else
|
65
|
+
auth[:password] = @config[:password]
|
66
|
+
end
|
67
|
+
Everton::Remote.authenticate auth, force
|
68
|
+
@config[:access_token] = Everton::Remote.access_token
|
69
|
+
@config[:username] = auth[:username]
|
70
|
+
@config[:password] = auth[:password]
|
71
|
+
@config.save
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
class TasksCommand < NeverdoneCommand
|
77
|
+
option "--all", :flag, "Show completed tasks"
|
78
|
+
|
79
|
+
def lazy_execute
|
80
|
+
count = 0
|
81
|
+
notes = []
|
82
|
+
if all?
|
83
|
+
notes = @notebook.find_notes
|
84
|
+
else
|
85
|
+
notes = @notebook.find_notes("-intitle:s:done")
|
86
|
+
end
|
87
|
+
notes.sort! { |a,b| if a.title =~ /s:done/; -1; else 1;end}
|
88
|
+
notes.each do |n|
|
89
|
+
title = n.title
|
90
|
+
count += 1
|
91
|
+
flags = []
|
92
|
+
if title =~ /(s:done)/
|
93
|
+
flags << "s:done".green.bold
|
94
|
+
|
95
|
+
title.gsub!($1, '')
|
96
|
+
end
|
97
|
+
if title =~ /(l:\w+)/
|
98
|
+
flags << $1.white.bold
|
99
|
+
title.gsub!(/(l:\w+)/, '')
|
100
|
+
end
|
101
|
+
|
102
|
+
if flags.size > 0
|
103
|
+
puts "#{count}. #{title.ljust(40)} [#{flags.join(',')}]"
|
104
|
+
else
|
105
|
+
puts "#{count}. #{title}"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
class AddCommand < NeverdoneCommand
|
113
|
+
|
114
|
+
parameter "TITLE ...", "Task title", :attribute_name => "title"
|
115
|
+
option ["-n", "--note"], "TEXT ...", "Task text", :default => ''
|
116
|
+
option ["-l", "--list"], "LIST", "List to add the task to"
|
117
|
+
|
118
|
+
def lazy_execute
|
119
|
+
text = '' if not text
|
120
|
+
t = title.join(' ')
|
121
|
+
if list
|
122
|
+
@notebook.add_note("#{t} l:#{list.gsub(' ', '_')}", text)
|
123
|
+
else
|
124
|
+
@notebook.add_note(t, text)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
class CheckCommand < NeverdoneCommand
|
130
|
+
|
131
|
+
parameter "NUMBER", "Task number"
|
132
|
+
|
133
|
+
def lazy_execute
|
134
|
+
count = 0
|
135
|
+
@notebook.find_notes("-intitle:s:done").reverse.each do |n|
|
136
|
+
count += 1
|
137
|
+
if count == number.to_i
|
138
|
+
n.title = n.title + ' s:done'
|
139
|
+
n.update
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
class VersionCommand < NeverdoneCommand
|
146
|
+
|
147
|
+
option "--version", :flag, "print version"
|
148
|
+
|
149
|
+
def lazy_execute
|
150
|
+
puts Neverdone::VERSION
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
class Driver < Clamp::Command
|
155
|
+
|
156
|
+
option "--version", :flag, "print version" do
|
157
|
+
puts "Neverdone Version " + ::Neverdone::VERSION
|
158
|
+
exit
|
159
|
+
end
|
160
|
+
|
161
|
+
option "--all", :flag, "Print completed tasks also" do
|
162
|
+
TasksCommand.run(File.basename($0), ['--all'])
|
163
|
+
exit
|
164
|
+
end
|
165
|
+
|
166
|
+
default_subcommand "tasks", "Print pending tasks", TasksCommand
|
167
|
+
subcommand "add", "Add new task", AddCommand
|
168
|
+
subcommand "check", "Complete task", CheckCommand
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
begin
|
174
|
+
Driver.run
|
175
|
+
rescue SystemExit
|
176
|
+
rescue Exception => e
|
177
|
+
puts e.message
|
178
|
+
end
|
data/lib/neverdone.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Neverdone
|
4
|
+
VERSION = '0.1'
|
5
|
+
CONSUMER_KEY = 'rubiojr'
|
6
|
+
CONSUMER_SECRET = 'c4f8a1e0f09c27ec'
|
7
|
+
|
8
|
+
class Config < Hash
|
9
|
+
|
10
|
+
def save
|
11
|
+
File.open "#{ENV['HOME']}/.neverdone.conf", 'w' do |f|
|
12
|
+
f.puts self.to_yaml
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.load
|
17
|
+
if File.exist?("#{ENV['HOME']}/.neverdone.conf")
|
18
|
+
c = Config.new.merge YAML.load_file("#{ENV['HOME']}/.neverdone.conf")
|
19
|
+
else
|
20
|
+
c = Config.new
|
21
|
+
end
|
22
|
+
c[:user_store_url] = 'https://www.evernote.com/edam/user' if not c[:user_store_url]
|
23
|
+
c
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neverdone
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: "0.1"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Sergio Rubio
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-07-18 00:00:00 Z
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
20
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
22
|
+
requirements:
|
23
|
+
- - ~>
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
hash: 23
|
26
|
+
segments:
|
27
|
+
- 1
|
28
|
+
- 0
|
29
|
+
- 0
|
30
|
+
version: 1.0.0
|
31
|
+
type: :development
|
32
|
+
requirement: *id001
|
33
|
+
prerelease: false
|
34
|
+
name: bundler
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
hash: 7
|
42
|
+
segments:
|
43
|
+
- 1
|
44
|
+
- 5
|
45
|
+
- 2
|
46
|
+
version: 1.5.2
|
47
|
+
type: :development
|
48
|
+
requirement: *id002
|
49
|
+
prerelease: false
|
50
|
+
name: jeweler
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 29
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
- 1
|
61
|
+
- 3
|
62
|
+
version: 0.1.3
|
63
|
+
type: :runtime
|
64
|
+
requirement: *id003
|
65
|
+
prerelease: false
|
66
|
+
name: everton
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 15
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
- 2
|
77
|
+
version: "0.2"
|
78
|
+
type: :runtime
|
79
|
+
requirement: *id004
|
80
|
+
prerelease: false
|
81
|
+
name: clamp
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: 3
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
version: "0"
|
92
|
+
type: :runtime
|
93
|
+
requirement: *id005
|
94
|
+
prerelease: false
|
95
|
+
name: term-ansicolor
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
version: "0"
|
106
|
+
type: :runtime
|
107
|
+
requirement: *id006
|
108
|
+
prerelease: false
|
109
|
+
name: highline
|
110
|
+
description: Command Line Todo for Evernote
|
111
|
+
email: rubiojr@frameos.org
|
112
|
+
executables:
|
113
|
+
- nd
|
114
|
+
extensions: []
|
115
|
+
|
116
|
+
extra_rdoc_files:
|
117
|
+
- LICENSE.txt
|
118
|
+
- README.md
|
119
|
+
files:
|
120
|
+
- .document
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- bin/nd
|
126
|
+
- lib/neverdone.rb
|
127
|
+
homepage: http://github.com/rubiojr/neverdone
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
hash: 3
|
141
|
+
segments:
|
142
|
+
- 0
|
143
|
+
version: "0"
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
hash: 3
|
150
|
+
segments:
|
151
|
+
- 0
|
152
|
+
version: "0"
|
153
|
+
requirements: []
|
154
|
+
|
155
|
+
rubyforge_project:
|
156
|
+
rubygems_version: 1.8.5
|
157
|
+
signing_key:
|
158
|
+
specification_version: 3
|
159
|
+
summary: Command Line Todo for Evernote
|
160
|
+
test_files: []
|
161
|
+
|