cabi 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/cabi.gemspec +1 -1
  3. data/lib/datafile.rb +11 -5
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 406c18b661c24a06904f1daeb757b3e0c053b822
4
- data.tar.gz: a1eed6752e778fff1add1d785ab75134f719ca7d
3
+ metadata.gz: 2a56f6e6e8ee48ba38ba8f60099907e4c1d9c700
4
+ data.tar.gz: 484d80e55fc096a324dd0667b2f5d515e2b12af6
5
5
  SHA512:
6
- metadata.gz: 73a054cca65bb89d43e28403292bb37c550edee56f7c9c11d576fe3ba29a03300bf089d7ee08b6a79bb812310159b1f1faac31c0e7122a27f52220aef90dc9eb
7
- data.tar.gz: d0ebd8aa1069c374f66085ddec30dbb5d9aff2909f1274750b8198c21d7d12a4a54906d82922129d751fe076fd2382e7ee0600152861d7e54984ed9d3be78078
6
+ metadata.gz: 6eeedec5d3f8db0fdd66e428910225990acfda42f93f9281e29c732c5064da64b217b54c82bd67cf9d20d7c771959e011a6b2f83c3043786976e56833adfc911
7
+ data.tar.gz: 9ab42f192d38f94e8b4fd5c0e33e6d4f0b7f0505e839d3234158926c8963ae560ab64ad60c0bfaf87597dd9134e20f261717c7ac56ceca926a56a7cf50454519
data/cabi.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'cabi'
3
- s.version = '0.1.3'
3
+ s.version = '0.1.4'
4
4
  s.summary = "A simple, flat-file datastore for Ruby."
5
5
 
6
6
  s.description = "Cabi is a flat-file datastore where data is stored by directory stucture and accessed by colon-delimited strings."
data/lib/datafile.rb CHANGED
@@ -4,8 +4,8 @@ module Cabi
4
4
 
5
5
  def self.contents(id)
6
6
  return self.bulk_selection(id) if self.bulk_selection?(id)
7
- return File.read( self.file(id) ) if self.file_exists?(id)
8
7
  return YAML.load(File.read( self.yaml_file(id) )) if self.yaml_exists?(id)
8
+ return File.read( self.file(id) ) if self.file_exists?(id)
9
9
  return File.read( self.non_extension_file(id) ) if self.non_extension_file(id)
10
10
  return self.sub_yaml(id)
11
11
  nil
@@ -27,8 +27,8 @@ module Cabi
27
27
 
28
28
  def self.file_yaml_or_non_extension_file(id)
29
29
  return self.bulk_selection(id, true) if self.bulk_selection?(id)
30
- return self.file(id) if self.file_exists?(id)
31
30
  return self.yaml_file(id) if self.yaml_exists?(id)
31
+ return self.file(id) if self.file_exists?(id)
32
32
  return self.non_extension_file(id) if self.non_extension_file(id)
33
33
  nil
34
34
  end
@@ -38,7 +38,12 @@ module Cabi
38
38
  end
39
39
 
40
40
  def self.yaml_file(id)
41
- File.join( self.file(id) + YAML_EXT )
41
+ path = self.has_yaml_ext?(id) ? self.file(id) : self.file(id) + YAML_EXT
42
+ File.join( path )
43
+ end
44
+
45
+ def self.has_yaml_ext?(id)
46
+ (id[-4..-1] == YAML_EXT)
42
47
  end
43
48
 
44
49
  def self.non_extension_file(id)
@@ -97,8 +102,9 @@ module Cabi
97
102
  id.each_with_index do |key, index|
98
103
  break if val
99
104
 
100
- a = [Cabi.data_dir] + id[0..index]
101
- a[ a.length - 1 ] = a[a.length - 1 ] + YAML_EXT
105
+ a = [Cabi.data_dir] + id[0..index]
106
+ last = a[a.length - 1]
107
+ a[ a.length - 1 ] = last + YAML_EXT if !self.has_yaml_ext?(last)
102
108
  f = File.join( *a )
103
109
 
104
110
  if File.exists? f
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cabi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Gonzalez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-18 00:00:00.000000000 Z
11
+ date: 2013-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor