flat_hash 0.0.1 → 0.0.2

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.
@@ -23,7 +23,7 @@ class FlatHash::Directory
23
23
  return unless File.exist?(@path)
24
24
  Dir.foreach(@path) do |path|
25
25
  basename = File.basename(path)
26
- yield basename unless ['.','..'].include?(basename)
26
+ yield self[basename] unless ['.','..'].include?(basename)
27
27
  end
28
28
  end
29
29
 
@@ -35,6 +35,10 @@ class FlatHash::Directory
35
35
  write entry.name, entry.content
36
36
  end
37
37
 
38
+ def exist? key
39
+ File.exist?(File.join(@path,key))
40
+ end
41
+
38
42
  def read key
39
43
  File.open(File.join(@path,key)) {|io| add_key(@serialiser.read(io), key) }
40
44
  end
@@ -3,16 +3,29 @@ require 'flat_hash/directory'
3
3
  require 'flat_hash/git'
4
4
  require 'flat_hash/hg'
5
5
 
6
- module FlatHash
7
- class Repository < Directory
8
- extend Forwardable
9
- def_delegators :@vcs, :changesets
6
+ class FlatHash::Repository < FlatHash::Directory
7
+ extend Forwardable
8
+ def_delegators :@vcs, :changesets, :addremovecommit
10
9
 
11
- def initialize serialiser, path
12
- super
13
- @vcs = Git.new if File.exist?('.git')
14
- @vcs = Hg.new if File.exist?('.hg')
15
- raise "could not determine repository type" unless @vcs
16
- end
10
+ def initialize serialiser, path
11
+ super
12
+ @vcs = FlatHash::Git.new if File.exist?('.git')
13
+ @vcs = FlatHash::Hg.new if File.exist?('.hg')
14
+ end
15
+
16
+ def vcs_supported?
17
+ !@vcs.nil?
18
+ end
19
+
20
+ def history key=nil
21
+ return [] unless vcs_supported?
22
+ path = key ? File.join(@path, key) : @path
23
+ @vcs.changesets(path).map {|cs| @vcs.changeset cs }
24
+ end
25
+
26
+ def element_at changeset, key
27
+ return {} unless vcs_supported?
28
+ content = @vcs.content_at(File.join(@path, key),changeset)
29
+ @serialiser.read StringIO.new(content)
17
30
  end
18
31
  end
@@ -1,3 +1,5 @@
1
+ require 'yaml'
2
+
1
3
  module FlatHash; end
2
4
 
3
5
  class FlatHash::Serialiser
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flat_hash
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 27
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 1
9
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Mark Ryall
@@ -14,30 +15,34 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-08-15 00:00:00 +10:00
18
+ date: 2010-08-21 00:00:00 +10:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: grit
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - "="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 7
27
30
  segments:
28
31
  - 2
29
- - 1
32
+ - 2
30
33
  - 0
31
- version: 2.1.0
34
+ version: 2.2.0
32
35
  type: :runtime
33
36
  version_requirements: *id001
34
37
  - !ruby/object:Gem::Dependency
35
38
  name: rake
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - "="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 49
41
46
  segments:
42
47
  - 0
43
48
  - 8
@@ -49,9 +54,11 @@ dependencies:
49
54
  name: rspec
50
55
  prerelease: false
51
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
52
58
  requirements:
53
59
  - - "="
54
60
  - !ruby/object:Gem::Version
61
+ hash: 27
55
62
  segments:
56
63
  - 1
57
64
  - 3
@@ -63,9 +70,11 @@ dependencies:
63
70
  name: gemesis
64
71
  prerelease: false
65
72
  requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
66
74
  requirements:
67
75
  - - "="
68
76
  - !ruby/object:Gem::Version
77
+ hash: 25
69
78
  segments:
70
79
  - 0
71
80
  - 0
@@ -74,7 +83,7 @@ dependencies:
74
83
  type: :development
75
84
  version_requirements: *id004
76
85
  description: |
77
- Hash serialisation that writes key/value pairs in a predicatable order
86
+ Hash serialisation that writes key/value pairs in a predictable order
78
87
 
79
88
  email: mark@ryall.name
80
89
  executables: []
@@ -106,23 +115,27 @@ rdoc_options: []
106
115
  require_paths:
107
116
  - lib
108
117
  required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
109
119
  requirements:
110
120
  - - ">="
111
121
  - !ruby/object:Gem::Version
122
+ hash: 3
112
123
  segments:
113
124
  - 0
114
125
  version: "0"
115
126
  required_rubygems_version: !ruby/object:Gem::Requirement
127
+ none: false
116
128
  requirements:
117
129
  - - ">="
118
130
  - !ruby/object:Gem::Version
131
+ hash: 3
119
132
  segments:
120
133
  - 0
121
134
  version: "0"
122
135
  requirements: []
123
136
 
124
137
  rubyforge_project:
125
- rubygems_version: 1.3.6
138
+ rubygems_version: 1.3.7
126
139
  signing_key:
127
140
  specification_version: 3
128
141
  summary: trivial but predictable serialisation for hashes