ppl 0.0.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/.gitignore +2 -0
  2. data/.rspec +3 -0
  3. data/.travis.yml +5 -0
  4. data/Gemfile +7 -3
  5. data/Gemfile.lock +15 -7
  6. data/README.md +47 -34
  7. data/bin/ppl +7 -6
  8. data/lib/ppl/adapter/storage/disk.rb +40 -0
  9. data/lib/ppl/adapter/storage.rb +28 -0
  10. data/lib/ppl/adapter/vcard/vpim.rb +45 -0
  11. data/lib/ppl/adapter/vcard.rb +13 -0
  12. data/lib/ppl/application/bootstrap.rb +62 -0
  13. data/lib/ppl/application/command.rb +13 -0
  14. data/lib/ppl/application/command_suite.rb +25 -0
  15. data/lib/ppl/application/input.rb +13 -0
  16. data/lib/ppl/application/output.rb +21 -0
  17. data/lib/ppl/application/router.rb +19 -0
  18. data/lib/ppl/application/shell.rb +34 -0
  19. data/lib/ppl/command/command_list.rb +21 -0
  20. data/lib/ppl/command/contact_add.rb +26 -0
  21. data/lib/ppl/command/contact_delete.rb +16 -0
  22. data/lib/ppl/command/contact_list.rb +24 -0
  23. data/lib/ppl/command/contact_rename.rb +23 -0
  24. data/lib/ppl/command/contact_show.rb +20 -0
  25. data/lib/ppl/entity/address_book.rb +21 -0
  26. data/lib/ppl/entity/contact.rb +10 -0
  27. data/lib/ppl/error/contact_not_found.rb +4 -0
  28. data/lib/ppl/error/incorrect_usage.rb +4 -0
  29. data/lib/ppl.rb +51 -11
  30. data/ppl.gemspec +3 -3
  31. data/spec/ppl/adapter/output_spec.rb +43 -0
  32. data/spec/ppl/adapter/storage/disk_spec.rb +83 -0
  33. data/spec/ppl/adapter/storage_spec.rb +46 -0
  34. data/spec/ppl/adapter/vcard/vpim_spec.rb +77 -0
  35. data/spec/ppl/adapter/vcard_spec.rb +24 -0
  36. data/spec/ppl/application/bootstrap_spec.rb +88 -0
  37. data/spec/ppl/application/command_spec.rb +19 -0
  38. data/spec/ppl/application/command_suite_spec.rb +44 -0
  39. data/spec/ppl/application/input_spec.rb +21 -0
  40. data/spec/ppl/application/router_spec.rb +43 -0
  41. data/spec/ppl/application/shell_spec.rb +79 -0
  42. data/spec/ppl/command/command_list_spec.rb +37 -0
  43. data/spec/ppl/command/contact_add_spec.rb +41 -0
  44. data/spec/ppl/command/contact_delete_spec.rb +31 -0
  45. data/spec/ppl/command/contact_list_spec.rb +15 -0
  46. data/spec/ppl/command/contact_rename_spec.rb +42 -0
  47. data/spec/ppl/command/contact_show_spec.rb +35 -0
  48. data/spec/ppl/entity/address_book_spec.rb +26 -0
  49. data/spec/ppl/entity/contact_spec.rb +34 -0
  50. data/spec/spec_helper.rb +9 -0
  51. metadata +47 -14
  52. data/lib/ppl/address_book.rb +0 -74
  53. data/lib/ppl/cli.rb +0 -49
  54. data/lib/ppl/command/add.rb +0 -40
  55. data/lib/ppl/command/birthdays.rb +0 -34
  56. data/lib/ppl/command/help.rb +0 -32
  57. data/lib/ppl/command/list.rb +0 -31
  58. data/lib/ppl/command/rm.rb +0 -38
  59. data/lib/ppl/command/set.rb +0 -49
  60. data/lib/ppl/command/show.rb +0 -43
  61. data/lib/ppl/command.rb +0 -55
  62. data/lib/ppl/contact.rb +0 -43
@@ -1,49 +0,0 @@
1
-
2
- class Ppl::Command::Set < Ppl::Command
3
-
4
- def name
5
- "set"
6
- end
7
-
8
- def summary
9
- "Change the details of a contact"
10
- end
11
-
12
- def banner
13
- "Usage: ppl set <contact> [options]"
14
- end
15
-
16
- def options(parser)
17
- parser.on("-e", "--email <email>", "Email address") do |email|
18
- @options[:email] = email
19
- end
20
- end
21
-
22
- def execute(argv, options)
23
-
24
- contact_id = argv.first
25
-
26
- if contact_id.nil?
27
- $stderr.puts @option_parser
28
- return false
29
- end
30
-
31
- contact = @address_book.contact contact_id
32
- if contact.nil?
33
- raise "contact '#{contact_id}' not found"
34
- end
35
-
36
- contact.vcard.make do |maker|
37
- maker.name do |name|
38
- name.fullname = 's'
39
- end
40
- puts maker
41
- end
42
-
43
- if !options[:email].nil?
44
- #contact.vcard.add_email options[:email]
45
- end
46
- end
47
-
48
- end
49
-
@@ -1,43 +0,0 @@
1
-
2
- class Ppl::Command::Show < Ppl::Command
3
-
4
- def name
5
- "show"
6
- end
7
-
8
- def summary
9
- "Show full details of a single contact"
10
- end
11
-
12
- def banner
13
- "Usage: ppl show <contact>"
14
- end
15
-
16
- def options(parser)
17
- end
18
-
19
- def execute(argv, options)
20
-
21
- contact_id = argv.first
22
-
23
- if contact_id.nil?
24
- $stderr.puts @option_parser
25
- return false
26
- end
27
-
28
- contact = @address_book.contact contact_id
29
- if contact.nil?
30
- raise "contact '#{contact_id}' not found"
31
- end
32
-
33
-
34
- puts contact.name
35
- contact.emails.each do |email|
36
- puts email
37
- end
38
-
39
- return true
40
- end
41
-
42
- end
43
-
data/lib/ppl/command.rb DELETED
@@ -1,55 +0,0 @@
1
-
2
- class Ppl::Command
3
-
4
- attr_accessor :address_book
5
- attr_accessor :commands
6
-
7
- def initialize
8
- @option_parser = OptionParser.new do |parser|
9
- parser.banner = self.banner
10
- self.options parser
11
- end
12
- end
13
-
14
- def name
15
- raise NotImplementedError
16
- end
17
-
18
- def summary
19
- raise NotImplementedError
20
- end
21
-
22
- def banner
23
- raise NotImplementedError
24
- end
25
-
26
- def options(parser)
27
- raise NotImplementedError
28
- end
29
-
30
- def run(argv)
31
-
32
- @options = {}
33
- begin
34
- @option_parser.parse! ARGV
35
- rescue OptionParser::ParseError
36
- $stderr.puts $!
37
- $stderr.puts @option_parser
38
- return false
39
- end
40
-
41
- begin
42
- status = self.execute argv, @options
43
- rescue RuntimeError
44
- $stderr.puts "ppl: " + $!.to_s
45
- end
46
-
47
- return status
48
- end
49
-
50
- def execute(argv, options)
51
- raise NotImplementedError
52
- end
53
-
54
- end
55
-
data/lib/ppl/contact.rb DELETED
@@ -1,43 +0,0 @@
1
-
2
- require "active_support/core_ext/time/calculations.rb"
3
-
4
- class Ppl::Contact
5
-
6
- attr_reader :id
7
- attr_reader :vcard
8
-
9
- def initialize(id, vcard)
10
- @id = id
11
- @vcard = vcard
12
- end
13
-
14
- def birthday
15
- @vcard.birthday
16
- end
17
-
18
- def until_birthday(now)
19
- birthday = self.birthday.dup
20
- while birthday < now
21
- birthday = birthday.advance :years => 1
22
- end
23
- birthday - now
24
- end
25
-
26
- def email
27
- @vcard.emails.first
28
- end
29
-
30
- def emails
31
- @vcard.emails
32
- end
33
-
34
- def name
35
- @vcard.name.fullname
36
- end
37
-
38
- def to_s
39
- @vcard.to_s
40
- end
41
-
42
- end
43
-