ppl 1.4.1 → 1.5.0

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/lib/ppl.rb CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Ppl
3
3
 
4
- Version = "1.4.1"
4
+ Version = "1.5.0"
5
5
 
6
6
  module Adapter
7
7
  end
@@ -54,6 +54,7 @@ require "ppl/command/org"
54
54
  require "ppl/command/phone"
55
55
  require "ppl/command/mutt"
56
56
  require "ppl/command/post"
57
+ require "ppl/command/shell"
57
58
 
58
59
  require "ppl/entity/address_book"
59
60
  require "ppl/entity/contact"
@@ -17,6 +17,7 @@ class Ppl::Application::Bootstrap
17
17
  Ppl::Command::Org.new,
18
18
  Ppl::Command::Phone.new,
19
19
  Ppl::Command::Post.new,
20
+ Ppl::Command::Shell.new,
20
21
  ]
21
22
  commands.each do |command|
22
23
  command.storage = storage_adapter
@@ -0,0 +1,36 @@
1
+
2
+ require "readline"
3
+
4
+ class Ppl::Command::Shell < Ppl::Application::Command
5
+
6
+ attr_writer :format
7
+
8
+ def initialize
9
+ @name = "shell"
10
+ @description = "Interactive mode"
11
+ end
12
+
13
+ def options(parser, options)
14
+ parser.banner = "usage: ppl shell"
15
+ end
16
+
17
+ def execute(input, output)
18
+ begin
19
+ while line = Readline.readline("ppl> ", true)
20
+ break if line == "exit"
21
+ break if line == false
22
+ Kernel.system "#{$0} #{line}"
23
+ end
24
+ rescue SystemExit, Interrupt
25
+ output.line("")
26
+ return false
27
+ end
28
+
29
+ if $stdin.tty?
30
+ output.line("")
31
+ end
32
+ return true
33
+ end
34
+
35
+ end
36
+
data/ppl.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |spec|
3
3
 
4
4
  spec.name = "ppl"
5
- spec.version = "1.4.1"
5
+ spec.version = "1.5.0"
6
6
  spec.date = "2012-12-20"
7
7
 
8
8
  spec.required_ruby_version = ">= 1.9.3"
@@ -75,6 +75,9 @@ describe Ppl::Application::Bootstrap do
75
75
  it "should contain the 'help' command" do
76
76
  @bootstrap.command_suite.find_command("help").should_not be nil
77
77
  end
78
+ it "should contain the 'shell' command" do
79
+ @bootstrap.command_suite.find_command("shell").should_not be nil
80
+ end
78
81
  end
79
82
 
80
83
  describe "#configuration" do
@@ -0,0 +1,48 @@
1
+
2
+ describe Ppl::Command::Shell do
3
+
4
+ before(:each) do
5
+ @command = Ppl::Command::Shell.new
6
+ @input = Ppl::Application::Input.new
7
+ @output = double(Ppl::Application::Output)
8
+ end
9
+
10
+ describe "#name" do
11
+ it "should be 'shell'" do
12
+ @command.name.should eq "shell"
13
+ end
14
+ end
15
+
16
+ describe "#execute" do
17
+ before(:each) do
18
+ @output.should_receive(:line)
19
+ end
20
+ it "should read a line of input from stdin" do
21
+ Readline.should_receive(:readline)
22
+ @command.execute(@input, @output).should eq true
23
+ end
24
+ end
25
+
26
+ describe "#execute" do
27
+ before(:each) do
28
+ @output.should_receive(:line)
29
+ end
30
+
31
+ it "should make a system call with the input from stdin" do
32
+ Readline.should_receive(:readline).and_return("email fred")
33
+ Readline.should_receive(:readline).and_return(false)
34
+ Kernel.should_receive(:system) do |command|
35
+ command.should include "email fred"
36
+ end
37
+ @command.execute(@input, @output).should eq true
38
+ end
39
+
40
+ it "should exit on ctrl+c" do
41
+ Readline.should_receive(:readline).and_raise(Interrupt)
42
+ @command.execute(@input, @output).should eq false
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+
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: 1.4.1
4
+ version: 1.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: inifile
16
- requirement: &15422560 !ruby/object:Gem::Requirement
16
+ requirement: &5576920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.0.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *15422560
24
+ version_requirements: *5576920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rugged
27
- requirement: &15420820 !ruby/object:Gem::Requirement
27
+ requirement: &5576360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - =
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.17.0.b6
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *15420820
35
+ version_requirements: *5576360
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: vpim
38
- requirement: &15420120 !ruby/object:Gem::Requirement
38
+ requirement: &5563160 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - =
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0.695'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *15420120
46
+ version_requirements: *5563160
47
47
  description: CLI Address Book
48
48
  email: henry@henrysmith.org
49
49
  executables:
@@ -87,6 +87,7 @@ files:
87
87
  - lib/ppl/command/phone.rb
88
88
  - lib/ppl/command/post.rb
89
89
  - lib/ppl/command/rm.rb
90
+ - lib/ppl/command/shell.rb
90
91
  - lib/ppl/command/show.rb
91
92
  - lib/ppl/entity/address_book.rb
92
93
  - lib/ppl/entity/contact.rb
@@ -139,6 +140,7 @@ files:
139
140
  - spec/ppl/command/phone_spec.rb
140
141
  - spec/ppl/command/post_spec.rb
141
142
  - spec/ppl/command/rm_spec.rb
143
+ - spec/ppl/command/shell_spec.rb
142
144
  - spec/ppl/command/show_spec.rb
143
145
  - spec/ppl/entity/address_book_spec.rb
144
146
  - spec/ppl/entity/contact_spec.rb