ppl 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/README.md +61 -14
- data/lib/ppl/address_book.rb +42 -0
- data/lib/ppl/cli.rb +7 -1
- data/lib/ppl/command/base.rb +13 -0
- data/lib/ppl/command/birthdays.rb +27 -0
- data/lib/ppl/command/help.rb +29 -0
- data/lib/ppl/command/list.rb +11 -18
- data/lib/ppl/command/show.rb +25 -0
- data/lib/ppl/command.rb +3 -0
- data/lib/ppl/contact.rb +38 -0
- data/lib/ppl.rb +3 -0
- data/ppl.gemspec +2 -2
- metadata +7 -3
- /data/{COPYING.txt → COPYING} +0 -0
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
_____ _____ __
|
2
2
|
| _ || _ || |
|
3
|
-
| __|| __|| |
|
3
|
+
| __|| __|| |__
|
4
4
|
|__| |__| |_____|
|
5
5
|
|
6
6
|
|
@@ -11,23 +11,70 @@ like "people". You might be interested in ppl if:
|
|
11
11
|
* You want ownership of your address book data back from the cloud
|
12
12
|
* You prefer to keep your data stored in an open format
|
13
13
|
|
14
|
-
The Plan
|
15
|
-
--------
|
16
14
|
|
17
|
-
|
15
|
+
Usage
|
16
|
+
-----
|
18
17
|
|
18
|
+
### List all contacts
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
```bash
|
21
|
+
$ ppl list
|
22
|
+
fred Fred Smith fred.smith@example.org
|
23
|
+
dave Dave Jones dave.jones@example.org
|
24
|
+
joe Joe Bloggs joe.bloggs@example.org
|
25
|
+
```
|
24
26
|
|
25
|
-
|
27
|
+
### Show a single contact
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
```bash
|
30
|
+
$ ppl show fred
|
31
|
+
Fred Smith
|
32
|
+
fred.simth@example.org
|
30
33
|
|
31
|
-
|
32
|
-
|
34
|
+
Birthday 1980-01-01
|
35
|
+
Cellphone 01189998819991197253
|
36
|
+
````
|
33
37
|
|
38
|
+
### List upcoming birthdays
|
39
|
+
|
40
|
+
```bash
|
41
|
+
$ ppl birthdays
|
42
|
+
fred Fred Smith 1980-01-01 99 days
|
43
|
+
dave Dave Jones 1980-01-02 100 days
|
44
|
+
joe Joe Bloggs 1980-01-03 101 days
|
45
|
+
```
|
46
|
+
|
47
|
+
Roadmap
|
48
|
+
-------
|
49
|
+
|
50
|
+
Support for the following commands is planned.
|
51
|
+
|
52
|
+
### Add a contact
|
53
|
+
```bash
|
54
|
+
$ ppl add adam --email=adam.brown@example.org --birthday=1980-01-04
|
55
|
+
```
|
56
|
+
|
57
|
+
### Update a contact
|
58
|
+
```bash
|
59
|
+
$ ppl set adam --email=adam.brown@example.com
|
60
|
+
```
|
61
|
+
|
62
|
+
### Rename a contact
|
63
|
+
```bash
|
64
|
+
$ ppl mv adam workadam
|
65
|
+
```
|
66
|
+
|
67
|
+
### Delete a contact
|
68
|
+
```bash
|
69
|
+
$ ppl rm workadam
|
70
|
+
```
|
71
|
+
|
72
|
+
In a highly optimistic version of the future, I plan to integrate Git.
|
73
|
+
Any commands that modify the address book will also commit their changes.
|
74
|
+
Then this will be posisble:
|
75
|
+
```bash
|
76
|
+
$ ppl sync
|
77
|
+
Pulling latest changes from all remotes...
|
78
|
+
Pushing local changes to all remotes...
|
79
|
+
Done
|
80
|
+
```
|
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
require "vpim/vcard"
|
3
|
+
require "enumerator"
|
4
|
+
|
5
|
+
class Ppl::Address_Book
|
6
|
+
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
def initialize(path)
|
10
|
+
@path = path
|
11
|
+
end
|
12
|
+
|
13
|
+
def contact(id)
|
14
|
+
filename = File.join @path, id + ".vcard"
|
15
|
+
vcard = IO.read filename
|
16
|
+
vcard = Vpim::Vcard.decode(vcard).first
|
17
|
+
contact = Ppl::Contact.new(id, vcard)
|
18
|
+
end
|
19
|
+
|
20
|
+
def contacts
|
21
|
+
pattern = File.join @path, "*.vcard"
|
22
|
+
filenames = Dir.glob pattern
|
23
|
+
contacts = []
|
24
|
+
|
25
|
+
filenames.each do |filename|
|
26
|
+
id = File.basename(filename).slice(0..-7)
|
27
|
+
contacts.push self.contact(id);
|
28
|
+
end
|
29
|
+
contacts
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def each
|
34
|
+
self.contacts.each { |c| yield c }
|
35
|
+
end
|
36
|
+
|
37
|
+
def with_birthday
|
38
|
+
self.find_all { |contact| contact.birthday.nil? == false }
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
data/lib/ppl/cli.rb
CHANGED
@@ -5,7 +5,13 @@ require "ppl/command"
|
|
5
5
|
class Ppl::CLI
|
6
6
|
|
7
7
|
def self.start(*args)
|
8
|
-
|
8
|
+
|
9
|
+
command = args.shift
|
10
|
+
if command
|
11
|
+
command = command.strip
|
12
|
+
else
|
13
|
+
command = "help"
|
14
|
+
end
|
9
15
|
|
10
16
|
Ppl::Command.load
|
11
17
|
Ppl::Command.run(command, args)
|
data/lib/ppl/command/base.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
|
2
|
+
require "vpim/vcard"
|
3
|
+
require "colored"
|
4
|
+
|
5
|
+
|
2
6
|
class Ppl::Command::Base
|
3
7
|
|
4
8
|
|
@@ -9,8 +13,17 @@ class Ppl::Command::Base
|
|
9
13
|
def initialize(arguments=[], options={})
|
10
14
|
@arguments = arguments
|
11
15
|
@options = options
|
16
|
+
|
17
|
+
@address_book = Ppl::Address_Book.new(@options[:path])
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def name
|
12
22
|
end
|
13
23
|
|
14
24
|
|
25
|
+
def summary
|
26
|
+
end
|
27
|
+
|
15
28
|
end
|
16
29
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
class Ppl::Command::Birthdays < Ppl::Command::Base
|
3
|
+
|
4
|
+
def name
|
5
|
+
"birthdays"
|
6
|
+
end
|
7
|
+
|
8
|
+
def summary
|
9
|
+
"Show a list of upcoming birthdays"
|
10
|
+
end
|
11
|
+
|
12
|
+
def index
|
13
|
+
today = Date.today
|
14
|
+
|
15
|
+
@address_book.with_birthday.each do |contact|
|
16
|
+
puts(
|
17
|
+
sprintf("%-20s", contact.id) +
|
18
|
+
sprintf("%-20s", contact.name) +
|
19
|
+
sprintf("%-20s", contact.birthday) +
|
20
|
+
sprintf("%d days", contact.until_birthday(today))
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
class Ppl::Command::Help < Ppl::Command::Base
|
3
|
+
|
4
|
+
def name
|
5
|
+
"help"
|
6
|
+
end
|
7
|
+
|
8
|
+
def summary
|
9
|
+
"Show a list of available commands"
|
10
|
+
end
|
11
|
+
|
12
|
+
def index
|
13
|
+
|
14
|
+
puts
|
15
|
+
Ppl::Command.constants.each do |constant|
|
16
|
+
if constant.to_s != "Base"
|
17
|
+
command = Ppl::Command.const_get(constant).new(@arguments, @options)
|
18
|
+
puts(
|
19
|
+
sprintf(" %-10s", command.name) +
|
20
|
+
sprintf("%s", command.summary)
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
puts
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
data/lib/ppl/command/list.rb
CHANGED
@@ -1,29 +1,22 @@
|
|
1
1
|
|
2
|
-
require "vpim/vcard"
|
3
|
-
require "colored"
|
4
|
-
|
5
2
|
class Ppl::Command::List < Ppl::Command::Base
|
6
3
|
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
contacts = Dir.glob pattern
|
11
|
-
|
12
|
-
contacts.each do |filename|
|
13
|
-
|
14
|
-
id = File.basename(filename).slice(0..-7)
|
4
|
+
def name
|
5
|
+
"list"
|
6
|
+
end
|
15
7
|
|
16
|
-
|
17
|
-
|
8
|
+
def summary
|
9
|
+
"Show a list of all contacts"
|
10
|
+
end
|
18
11
|
|
12
|
+
def index
|
13
|
+
@address_book.each do |contact|
|
19
14
|
puts(
|
20
|
-
sprintf("%-20s", id).red +
|
21
|
-
sprintf("%-20s",
|
22
|
-
sprintf("%-20s",
|
15
|
+
sprintf("%-20s", contact.id).red +
|
16
|
+
sprintf("%-20s", contact.name).yellow +
|
17
|
+
sprintf("%-20s", contact.email).blue
|
23
18
|
)
|
24
|
-
|
25
19
|
end
|
26
|
-
|
27
20
|
end
|
28
21
|
|
29
22
|
end
|
data/lib/ppl/command/show.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
require "ppl/command/base"
|
3
|
+
|
4
|
+
class Ppl::Command::Show < Ppl::Command::Base
|
5
|
+
|
6
|
+
def name
|
7
|
+
"show"
|
8
|
+
end
|
9
|
+
|
10
|
+
def summary
|
11
|
+
"Show full details of a single contact"
|
12
|
+
end
|
13
|
+
|
14
|
+
def index
|
15
|
+
contact = @address_book.contact @arguments.first
|
16
|
+
|
17
|
+
puts contact.name.yellow
|
18
|
+
contact.emails.each do |email|
|
19
|
+
puts email.blue
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
data/lib/ppl/command.rb
CHANGED
data/lib/ppl/contact.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
require "active_support/core_ext/time/calculations.rb"
|
3
|
+
|
4
|
+
class Ppl::Contact
|
5
|
+
|
6
|
+
attr_reader :id
|
7
|
+
|
8
|
+
def initialize(id, vcard)
|
9
|
+
@id = id
|
10
|
+
@vcard = vcard
|
11
|
+
end
|
12
|
+
|
13
|
+
def birthday
|
14
|
+
@vcard.birthday
|
15
|
+
end
|
16
|
+
|
17
|
+
def until_birthday(now)
|
18
|
+
birthday = self.birthday.dup
|
19
|
+
while birthday < now
|
20
|
+
birthday = birthday.advance :years => 1
|
21
|
+
end
|
22
|
+
birthday - now
|
23
|
+
end
|
24
|
+
|
25
|
+
def email
|
26
|
+
@vcard.emails.first
|
27
|
+
end
|
28
|
+
|
29
|
+
def emails
|
30
|
+
@vcard.emails
|
31
|
+
end
|
32
|
+
|
33
|
+
def name
|
34
|
+
@vcard.name.fullname
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
data/lib/ppl.rb
CHANGED
data/ppl.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ppl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-11 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Command-line driven address book
|
15
15
|
email: henry@henrysmith.org
|
@@ -18,17 +18,21 @@ executables:
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
- COPYING
|
21
|
+
- COPYING
|
22
22
|
- Gemfile
|
23
23
|
- Gemfile.lock
|
24
24
|
- README.md
|
25
25
|
- bin/ppl
|
26
26
|
- lib/ppl.rb
|
27
|
+
- lib/ppl/address_book.rb
|
27
28
|
- lib/ppl/cli.rb
|
28
29
|
- lib/ppl/command.rb
|
29
30
|
- lib/ppl/command/base.rb
|
31
|
+
- lib/ppl/command/birthdays.rb
|
32
|
+
- lib/ppl/command/help.rb
|
30
33
|
- lib/ppl/command/list.rb
|
31
34
|
- lib/ppl/command/show.rb
|
35
|
+
- lib/ppl/contact.rb
|
32
36
|
- lib/ppl/ppl.rb
|
33
37
|
- ppl.gemspec
|
34
38
|
homepage: https://github.com/h2s/ppl
|
/data/{COPYING.txt → COPYING}
RENAMED
File without changes
|