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 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/badge.png)](https://codeclimate.com/github/h2s/ppl)
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.12.0"
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"
@@ -29,5 +29,9 @@ class Ppl::Adapter::Storage
29
29
  raise NotImplementedError
30
30
  end
31
31
 
32
+ def path
33
+ raise NotImplementedError
34
+ end
35
+
32
36
  end
33
37
 
@@ -73,5 +73,9 @@ class Ppl::Adapter::Storage::Disk < Ppl::Adapter::Storage
73
73
  File.join(@directory.path, id + ".vcf")
74
74
  end
75
75
 
76
+ def path
77
+ @directory.path
78
+ end
79
+
76
80
  end
77
81
 
@@ -113,5 +113,9 @@ class Ppl::Adapter::Storage::Git < Ppl::Adapter::Storage
113
113
  true
114
114
  end
115
115
 
116
+ def path
117
+ @disk.path
118
+ end
119
+
116
120
  end
117
121
 
@@ -3,26 +3,27 @@ class Ppl::Application::Bootstrap
3
3
 
4
4
  def commands
5
5
  commands = [
6
- Ppl::Command::Init.new,
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::Add.new,
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
@@ -31,7 +31,7 @@ class Ppl::Application::Shell
31
31
  end
32
32
 
33
33
  def prepare_command(command, input)
34
- if !command.nil?
34
+ if !command.nil? && !command.is_a?(Ppl::Command::Execute)
35
35
  @optparse = OptionParser.new do |parser|
36
36
  command.options(parser, input.options)
37
37
  end
@@ -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
@@ -2,8 +2,8 @@
2
2
  Gem::Specification.new do |spec|
3
3
 
4
4
  spec.name = "ppl"
5
- spec.version = "1.12.0"
6
- spec.date = "2013-02-16"
5
+ spec.version = "1.13.0"
6
+ spec.date = "2013-02-17"
7
7
 
8
8
  spec.required_ruby_version = ">= 1.9.3"
9
9
 
@@ -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
@@ -48,5 +48,11 @@ describe Ppl::Adapter::Storage do
48
48
  end
49
49
  end
50
50
 
51
+ describe "#path" do
52
+ it "should raise not implemented error" do
53
+ expect{@storage.path}.to raise_error(NotImplementedError)
54
+ end
55
+ end
56
+
51
57
  end
52
58
 
@@ -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.12.0
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-16 00:00:00.000000000 Z
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