ppl 1.12.0 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/ppl.rb +2 -1
- data/lib/ppl/adapter/storage.rb +4 -0
- data/lib/ppl/adapter/storage/disk.rb +4 -0
- data/lib/ppl/adapter/storage/git.rb +4 -0
- data/lib/ppl/application/bootstrap.rb +15 -6
- data/lib/ppl/application/shell.rb +1 -1
- data/lib/ppl/command/execute.rb +19 -0
- data/ppl.gemspec +2 -2
- data/spec/ppl/adapter/storage/disk_spec.rb +6 -0
- data/spec/ppl/adapter/storage/git_spec.rb +7 -0
- data/spec/ppl/adapter/storage_spec.rb +6 -0
- data/spec/ppl/application/bootstrap_spec.rb +12 -0
- data/spec/ppl/application/shell_spec.rb +8 -0
- data/spec/ppl/command/execute_spec.rb +38 -0
- metadata +4 -2
data/README.md
CHANGED
@@ -13,7 +13,7 @@ ppl if:
|
|
13
13
|
* You prefer to keep your data stored in an open format
|
14
14
|
|
15
15
|
[![Build Status](https://secure.travis-ci.org/h2s/ppl.png)](http://travis-ci.org/h2s/ppl)
|
16
|
-
[![Code Climate](https://codeclimate.com/
|
16
|
+
[![Code Climate](https://codeclimate.com/github/h2s/ppl.png)](https://codeclimate.com/github/h2s/ppl)
|
17
17
|
|
18
18
|
Installation
|
19
19
|
------------
|
data/lib/ppl.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
module Ppl
|
3
3
|
|
4
|
-
Version = "1.
|
4
|
+
Version = "1.13.0"
|
5
5
|
|
6
6
|
module Adapter
|
7
7
|
end
|
@@ -60,6 +60,7 @@ require "ppl/command/post"
|
|
60
60
|
require "ppl/command/shell"
|
61
61
|
require "ppl/command/url"
|
62
62
|
require "ppl/command/version"
|
63
|
+
require "ppl/command/execute"
|
63
64
|
|
64
65
|
require "ppl/entity/address_book"
|
65
66
|
require "ppl/entity/contact"
|
data/lib/ppl/adapter/storage.rb
CHANGED
@@ -3,26 +3,27 @@ class Ppl::Application::Bootstrap
|
|
3
3
|
|
4
4
|
def commands
|
5
5
|
commands = [
|
6
|
-
Ppl::Command::
|
6
|
+
Ppl::Command::Add.new,
|
7
|
+
Ppl::Command::Age.new,
|
7
8
|
Ppl::Command::Bday.new,
|
9
|
+
Ppl::Command::Email.new,
|
8
10
|
Ppl::Command::Help.new,
|
9
|
-
Ppl::Command::
|
10
|
-
Ppl::Command::Rm.new,
|
11
|
+
Ppl::Command::Init.new,
|
11
12
|
Ppl::Command::Ls.new,
|
12
13
|
Ppl::Command::Mutt.new,
|
13
14
|
Ppl::Command::Mv.new,
|
14
|
-
Ppl::Command::Show.new,
|
15
15
|
Ppl::Command::Name.new,
|
16
16
|
Ppl::Command::Nick.new,
|
17
|
-
Ppl::Command::Email.new,
|
18
17
|
Ppl::Command::Org.new,
|
19
18
|
Ppl::Command::Phone.new,
|
20
19
|
Ppl::Command::Post.new,
|
20
|
+
Ppl::Command::Rm.new,
|
21
21
|
Ppl::Command::Shell.new,
|
22
|
+
Ppl::Command::Show.new,
|
22
23
|
Ppl::Command::Url.new,
|
23
24
|
Ppl::Command::Version.new,
|
24
|
-
Ppl::Command::Age.new,
|
25
25
|
]
|
26
|
+
commands += git_commands
|
26
27
|
commands.each do |command|
|
27
28
|
command.storage = storage_adapter
|
28
29
|
end
|
@@ -43,6 +44,14 @@ class Ppl::Application::Bootstrap
|
|
43
44
|
return config
|
44
45
|
end
|
45
46
|
|
47
|
+
def git_commands
|
48
|
+
[
|
49
|
+
Ppl::Command::Execute.new("pull", "git pull", "Execute 'git pull' in the address book directory"),
|
50
|
+
Ppl::Command::Execute.new("push", "git push", "Execute 'git push' in the address book directory"),
|
51
|
+
Ppl::Command::Execute.new("remote", "git remote", "Execute 'git remote' in the address book directory"),
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
46
55
|
def input
|
47
56
|
input = Ppl::Application::Input.new(ARGV.dup)
|
48
57
|
return input
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
class Ppl::Command::Execute < Ppl::Application::Command
|
3
|
+
|
4
|
+
def initialize(name, command, description)
|
5
|
+
@name = name
|
6
|
+
@command = command
|
7
|
+
@description = description
|
8
|
+
end
|
9
|
+
|
10
|
+
def execute(input, output)
|
11
|
+
if !input.arguments.empty?
|
12
|
+
@command += " " + input.arguments.join(" ")
|
13
|
+
end
|
14
|
+
Dir.chdir(@storage.path)
|
15
|
+
Kernel.exec(@command)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
data/ppl.gemspec
CHANGED
@@ -69,6 +69,12 @@ describe Ppl::Adapter::Storage::Disk do
|
|
69
69
|
FakeFS.deactivate!
|
70
70
|
end
|
71
71
|
|
72
|
+
describe "#path" do
|
73
|
+
it "should return the path of the directory" do
|
74
|
+
@storage.path.should eq "/contacts"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
72
78
|
describe "#load_address_book" do
|
73
79
|
|
74
80
|
it "should return a Ppl::Entity::AddressBook" do
|
@@ -16,6 +16,7 @@ describe Ppl::Adapter::Storage::Git do
|
|
16
16
|
Rugged::Repository.stub(:new).and_return(@repo)
|
17
17
|
|
18
18
|
@disk.stub(:directory).and_return(Dir.new("/contacts"))
|
19
|
+
@disk.stub(:path).and_return("/contacts")
|
19
20
|
@contact.stub(:id).and_return("test")
|
20
21
|
|
21
22
|
@git = Ppl::Adapter::Storage::Git.new(@disk)
|
@@ -27,6 +28,12 @@ describe Ppl::Adapter::Storage::Git do
|
|
27
28
|
FakeFS.deactivate!
|
28
29
|
end
|
29
30
|
|
31
|
+
describe "#path" do
|
32
|
+
it "should return the path of the repository" do
|
33
|
+
@git.path.should eq "/contacts"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
30
37
|
describe "#initialize" do
|
31
38
|
it "should accept a disk storage adapter" do
|
32
39
|
@git.disk.should be @disk
|
@@ -92,6 +92,18 @@ describe Ppl::Application::Bootstrap do
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
+
describe "#git_commands" do
|
96
|
+
it "should contain the 'pull' command" do
|
97
|
+
@bootstrap.git_commands[0].name.should eq "pull"
|
98
|
+
end
|
99
|
+
it "should contain the 'push' command" do
|
100
|
+
@bootstrap.git_commands[1].name.should eq "push"
|
101
|
+
end
|
102
|
+
it "should contain the 'remote' command" do
|
103
|
+
@bootstrap.git_commands[2].name.should eq "remote"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
95
107
|
describe "#configuration" do
|
96
108
|
it "should return a Ppl::Application::Configuration" do
|
97
109
|
@bootstrap.configuration.should be_a(Ppl::Application::Configuration)
|
@@ -67,6 +67,14 @@ describe Ppl::Application::Shell do
|
|
67
67
|
@shell.run(@input, @output)
|
68
68
|
end
|
69
69
|
|
70
|
+
it "should not do any option parsing for Ppl::Command::Execute instances" do
|
71
|
+
execute = Ppl::Command::Execute.new("ls", "ls", "List directory contents")
|
72
|
+
execute.stub(:execute).and_return(true)
|
73
|
+
@shell.should_receive(:select_command).and_return(execute)
|
74
|
+
execute.should_not_receive(:options)
|
75
|
+
@shell.run(@input, @output)
|
76
|
+
end
|
77
|
+
|
70
78
|
it "should send exception messages to stderr" do
|
71
79
|
@command.should_receive(:options)
|
72
80
|
@command.should_receive(:execute) { raise "Pool's Closed" }
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Command::Execute do
|
3
|
+
|
4
|
+
before(:each) do
|
5
|
+
@command = Ppl::Command::Execute.new("remote", "git remote", "Execute 'git remote' in the address book directory")
|
6
|
+
@input = Ppl::Application::Input.new
|
7
|
+
@output = double(Ppl::Application::Output)
|
8
|
+
@storage = double(Ppl::Adapter::Storage)
|
9
|
+
|
10
|
+
@storage.stub(:path).and_return("/contacts")
|
11
|
+
@command.storage = @storage
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#execute" do
|
15
|
+
|
16
|
+
it "should chdir to the location of the address book on disk" do
|
17
|
+
Dir.should_receive(:chdir).with("/contacts")
|
18
|
+
Kernel.stub(:exec)
|
19
|
+
@command.execute(@input, @output)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should run the specified command" do
|
23
|
+
Dir.stub(:chdir)
|
24
|
+
Kernel.should_receive(:exec).with("git remote")
|
25
|
+
@command.execute(@input, @output)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should pass arguments through to the command" do
|
29
|
+
@input.arguments = ["--help"]
|
30
|
+
Dir.stub(:chdir)
|
31
|
+
Kernel.should_receive(:exec).with("git remote --help")
|
32
|
+
@command.execute(@input, @output)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
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
|
+
version: 1.13.0
|
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: 2013-02-
|
12
|
+
date: 2013-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: inifile
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- lib/ppl/command/attribute.rb
|
95
95
|
- lib/ppl/command/bday.rb
|
96
96
|
- lib/ppl/command/email.rb
|
97
|
+
- lib/ppl/command/execute.rb
|
97
98
|
- lib/ppl/command/help.rb
|
98
99
|
- lib/ppl/command/init.rb
|
99
100
|
- lib/ppl/command/ls.rb
|
@@ -160,6 +161,7 @@ files:
|
|
160
161
|
- spec/ppl/command/attribute_spec.rb
|
161
162
|
- spec/ppl/command/bday_spec.rb
|
162
163
|
- spec/ppl/command/email_spec.rb
|
164
|
+
- spec/ppl/command/execute_spec.rb
|
163
165
|
- spec/ppl/command/help_spec.rb
|
164
166
|
- spec/ppl/command/init_spec.rb
|
165
167
|
- spec/ppl/command/ls_spec.rb
|