ppl 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,14 @@ class Ppl::Adapter::Storage::Disk < Ppl::Adapter::Storage
10
10
  if !Dir.exists? path
11
11
  FileUtils.mkdir_p(path)
12
12
  end
13
- storage = self.new(path)
13
+ storage = self.new(Dir.new(path))
14
+
15
+ dot_ppl = File.join(path, ".ppl")
16
+ config = File.join(dot_ppl, "config")
17
+ FileUtils.mkdir_p(dot_ppl)
18
+ FileUtils.touch(config)
19
+
20
+ storage
14
21
  end
15
22
 
16
23
  def initialize(directory)
@@ -14,8 +14,12 @@ class Ppl::Adapter::Storage::Git < Ppl::Adapter::Storage
14
14
  end
15
15
 
16
16
  def self.create_address_book(path)
17
- disk = Ppl::Adapter::Storage::Disk.create_address_book(path)
18
17
  repo = Rugged::Repository.init_at(path, false)
18
+ disk = Ppl::Adapter::Storage::Disk.create_address_book(path)
19
+
20
+ git = self.new(disk)
21
+ git.add(".ppl/config")
22
+ git.commit("first commit")
19
23
  end
20
24
 
21
25
  def load_address_book
@@ -63,7 +67,6 @@ class Ppl::Adapter::Storage::Git < Ppl::Adapter::Storage
63
67
  @disk.delete_contact(contact)
64
68
  end
65
69
 
66
- private
67
70
 
68
71
  def add(file)
69
72
  @repository.index.add(file)
@@ -71,9 +74,22 @@ class Ppl::Adapter::Storage::Git < Ppl::Adapter::Storage
71
74
  end
72
75
 
73
76
  def commit(message)
74
- hash = @repository.index.write_tree
75
- tree = @repository.lookup hash
76
- parents = [ @repository.lookup( @repository.head.target ).oid ]
77
+ hash = @repository.index.write_tree
78
+ tree = @repository.lookup hash
79
+ head = nil
80
+
81
+ begin
82
+ head = @repository.head
83
+ rescue
84
+ end
85
+
86
+ if !head.nil?
87
+ parents = [ @repository.lookup( @repository.head.target ).oid ]
88
+ update_ref = "HEAD"
89
+ else
90
+ parents = []
91
+ update_ref = "HEAD"
92
+ end
77
93
 
78
94
  name = ENV['USER']
79
95
  host = Socket.gethostname
@@ -90,7 +106,7 @@ class Ppl::Adapter::Storage::Git < Ppl::Adapter::Storage
90
106
  :committer => author,
91
107
  :tree => tree,
92
108
  :parents => parents,
93
- :update_ref => "HEAD",
109
+ :update_ref => update_ref,
94
110
  }
95
111
 
96
112
  Rugged::Commit.create(@repository, data)
data/lib/ppl.rb CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Ppl
3
3
 
4
- Version = "1.0.5"
4
+ Version = "1.0.6"
5
5
 
6
6
  module Adapter
7
7
  end
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.0.5"
5
+ spec.version = "1.0.6"
6
6
  spec.date = "2012-12-20"
7
7
 
8
8
  spec.required_ruby_version = ">= 1.9.3"
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.0.5
4
+ version: 1.0.6
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: &7714400 !ruby/object:Gem::Requirement
16
+ requirement: &16103420 !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: *7714400
24
+ version_requirements: *16103420
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rugged
27
- requirement: &7713380 !ruby/object:Gem::Requirement
27
+ requirement: &16091980 !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: *7713380
35
+ version_requirements: *16091980
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: vpim
38
- requirement: &7712420 !ruby/object:Gem::Requirement
38
+ requirement: &16091260 !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: *7712420
46
+ version_requirements: *16091260
47
47
  description: CLI Address Book
48
48
  email: henry@henrysmith.org
49
49
  executables: