hacker_todo_list 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/hacker_todo_list.gemspec +17 -0
- data/lib/hacker_todo_list/core_methods.rb +17 -0
- data/lib/hacker_todo_list/extensions.rb +9 -0
- data/lib/hacker_todo_list/setup.rb +18 -0
- data/lib/hacker_todo_list.rb +85 -0
- data/readme.md +14 -0
- metadata +86 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.hacker_todo
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'hacker_todo_list'
|
3
|
+
s.version = '1.0.0'
|
4
|
+
s.date = '2012-11-11'
|
5
|
+
s.summary = "A command line To-Do list"
|
6
|
+
s.description = %Q{
|
7
|
+
Hacker ToDo List is integrated with github and all your todo's are stored as private gists.
|
8
|
+
So, you need not worry about your to-do's when you switch from your office machine to your home machine.
|
9
|
+
Just provide your github credentials, your todo's will be synced.
|
10
|
+
}
|
11
|
+
s.authors = ["Manjunath"]
|
12
|
+
s.email = 'manjunath.nm89@gmail.com'
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.homepage = 'https://github.com/manjunath-nm89/Hacker-ToDo-List'
|
15
|
+
s.add_dependency "httparty", ">= 0.9.0"
|
16
|
+
s.add_dependency "json", ">= 1.7.5"
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Hacker ToDo Class Methods
|
2
|
+
module HackerToDo
|
3
|
+
def self.get_from_console(console_string, hide_input = false)
|
4
|
+
print "#{console_string} "
|
5
|
+
system "stty -echo" if hide_input
|
6
|
+
user_input = gets.chomp
|
7
|
+
system "stty echo" if hide_input
|
8
|
+
return user_input
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.list_formatter
|
12
|
+
puts ""
|
13
|
+
puts "Hacker ToDo List:"
|
14
|
+
yield
|
15
|
+
puts ""
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module HackerToDo
|
2
|
+
class Setup
|
3
|
+
CREDENTIAL_FILE = ".hacker_todo"
|
4
|
+
attr_accessor :auth
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
if File.exist?(CREDENTIAL_FILE)
|
8
|
+
@auth = YAML.load(File.read(CREDENTIAL_FILE))
|
9
|
+
else
|
10
|
+
@auth = {
|
11
|
+
:username => HackerToDo.get_from_console("Username:"),
|
12
|
+
:password => HackerToDo.get_from_console("Password:", true)
|
13
|
+
}
|
14
|
+
File.write(CREDENTIAL_FILE, @auth.to_yaml)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/hacker_todo_list/core_methods.rb"
|
2
|
+
require File.dirname(__FILE__) + "/hacker_todo_list/extensions"
|
3
|
+
require File.dirname(__FILE__) + "/hacker_todo_list/setup"
|
4
|
+
require "httparty"
|
5
|
+
require "yaml"
|
6
|
+
require "json"
|
7
|
+
|
8
|
+
module HackerToDo
|
9
|
+
GIST_FILE_NAME = "hacker_todo"
|
10
|
+
GIST_DESCRIPTION = "Hacker To Do"
|
11
|
+
|
12
|
+
class ToDoList
|
13
|
+
include HTTParty
|
14
|
+
base_uri "https://api.github.com"
|
15
|
+
attr_accessor :github_creds, :todo_id
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@github_creds = Setup.new.auth
|
19
|
+
@todo_gist = find_todo_entry
|
20
|
+
@todo_id = @todo_gist.nil? ? nil : @todo_gist["id"]
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_todo_content
|
24
|
+
YAML.load(@todo_gist["files"][GIST_FILE_NAME]["content"])
|
25
|
+
end
|
26
|
+
|
27
|
+
def list
|
28
|
+
content = get_todo_content
|
29
|
+
if @todo_id.nil? || content.empty?
|
30
|
+
puts "You need to create a ToDo"
|
31
|
+
else
|
32
|
+
HackerToDo.list_formatter do
|
33
|
+
content.each_with_index do |task, index|
|
34
|
+
puts "#{index + 1}. #{task}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def add(task_list)
|
41
|
+
content = task_list.split("\\n")
|
42
|
+
route = @todo_id.nil? ? "/gists" : "/gists/#{@todo_id}"
|
43
|
+
post_gist(route, append_todo_content(content))
|
44
|
+
puts "ToDo added successfully."
|
45
|
+
list
|
46
|
+
end
|
47
|
+
|
48
|
+
def delete(*indexes)
|
49
|
+
post_gist("/gists/#{@todo_id}", get_todo_content.delete_indexes(indexes.collect{|index| index.to_i - 1}))
|
50
|
+
puts "ToDo deleted successfully."
|
51
|
+
list
|
52
|
+
end
|
53
|
+
|
54
|
+
def find_todo_entry
|
55
|
+
todo_entry = self.class.get("/users/#{@github_creds[:username]}/gists",
|
56
|
+
{:basic_auth => @github_creds}).find do |gist|
|
57
|
+
gist && gist["files"].has_key?(GIST_FILE_NAME) && gist["description"] == GIST_DESCRIPTION
|
58
|
+
end
|
59
|
+
self.class.get("/gists/#{todo_entry["id"]}", {:basic_auth => @github_creds}) if todo_entry
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def post_gist(route, content)
|
65
|
+
@todo_gist = self.class.post(route, {:body => create_gist_json(content), :basic_auth => @github_creds})
|
66
|
+
@todo_id = @todo_gist["id"]
|
67
|
+
end
|
68
|
+
|
69
|
+
def append_todo_content(content)
|
70
|
+
@todo_gist.nil? ? content : get_todo_content + content
|
71
|
+
end
|
72
|
+
|
73
|
+
def create_gist_json(content)
|
74
|
+
{
|
75
|
+
:description => GIST_DESCRIPTION,
|
76
|
+
:public => false,
|
77
|
+
:files => {
|
78
|
+
GIST_FILE_NAME.to_sym => {
|
79
|
+
:content => content.to_yaml
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}.to_json
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/readme.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Hacker ToDo List
|
2
|
+
================
|
3
|
+
|
4
|
+
Hacker ToDo List is a command line to-do list, primarily for hackers who do not like to take their hands off the keyboard.
|
5
|
+
|
6
|
+
Features
|
7
|
+
--------
|
8
|
+
|
9
|
+
Hacker ToDo List is integrated with github and all your todo's are stored as private gists. So, you need not worry about your to-do's when you switch from your office machine to your home machine. Just provide your github credentials, your todo's will be synced.
|
10
|
+
|
11
|
+
Usage
|
12
|
+
-----
|
13
|
+
|
14
|
+
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hacker_todo_list
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Manjunath
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.9.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.9.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.7.5
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.7.5
|
46
|
+
description: ! "\n Hacker ToDo List is integrated with github and all your todo's
|
47
|
+
are stored as private gists. \n So, you need not worry about your to-do's when
|
48
|
+
you switch from your office machine to your home machine. \n Just provide your
|
49
|
+
github credentials, your todo's will be synced.\n "
|
50
|
+
email: manjunath.nm89@gmail.com
|
51
|
+
executables: []
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files: []
|
54
|
+
files:
|
55
|
+
- .gitignore
|
56
|
+
- hacker_todo_list.gemspec
|
57
|
+
- lib/hacker_todo_list.rb
|
58
|
+
- lib/hacker_todo_list/core_methods.rb
|
59
|
+
- lib/hacker_todo_list/extensions.rb
|
60
|
+
- lib/hacker_todo_list/setup.rb
|
61
|
+
- readme.md
|
62
|
+
homepage: https://github.com/manjunath-nm89/Hacker-ToDo-List
|
63
|
+
licenses: []
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.8.24
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: A command line To-Do list
|
86
|
+
test_files: []
|