cabi 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cec2656830ddd4ae65fba64c3821363be983765b
4
- data.tar.gz: 25638dce3ba1f2f014f2629e190cf9ca9a7af450
3
+ metadata.gz: 406c18b661c24a06904f1daeb757b3e0c053b822
4
+ data.tar.gz: a1eed6752e778fff1add1d785ab75134f719ca7d
5
5
  SHA512:
6
- metadata.gz: 5ebf6f96dd020f6ac2149ce3b6a2c47a584270d0a3e031d5b239ddbe197b1be4c1401884c9c75841ecb7f37269ebe7fc415d880ff1c27ac754c157992f4a3f28
7
- data.tar.gz: ba777a2f2eaa0f25048341d9c72ef93fbe360782b015c51954f6add362bc3667e66232aae71cb8dcf9d1bf368003df2b570b29ba049276db36304ceb46090c9a
6
+ metadata.gz: 73a054cca65bb89d43e28403292bb37c550edee56f7c9c11d576fe3ba29a03300bf089d7ee08b6a79bb812310159b1f1faac31c0e7122a27f52220aef90dc9eb
7
+ data.tar.gz: d0ebd8aa1069c374f66085ddec30dbb5d9aff2909f1274750b8198c21d7d12a4a54906d82922129d751fe076fd2382e7ee0600152861d7e54984ed9d3be78078
data/README.md CHANGED
@@ -56,6 +56,7 @@ Cabi.read('posts:some-article:index.html') # contents of posts/some-article/i
56
56
  Cabi.read('pages:about:*') # an array of body.html and meta.yml contents
57
57
  Cabi.read('pages:about:person-*') # an array of all person-* html files
58
58
  Cabi.read('**/*') # an array of all files in data
59
+ Cabi.read('**/*').length # 9
59
60
 
60
61
  # Selection within YAML files
61
62
  Cabi.read('pages:about:meta:foo:bar') # contents of ['foo']['bar'] in page/about/meta.yml hash
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.2'
3
+ s.version = '0.1.3'
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/cabi.rb CHANGED
@@ -21,4 +21,8 @@ module Cabi
21
21
  Data.write(id, content)
22
22
  end
23
23
 
24
+ def self.file(id)
25
+ DataFile.file_yaml_or_non_extension_file(id)
26
+ end
27
+
24
28
  end
data/lib/data.rb CHANGED
@@ -10,6 +10,10 @@ module Cabi
10
10
  file = DataFile.write(id, content)
11
11
  end
12
12
 
13
+ def self.file(id)
14
+ file = DataFile.write(id, content)
15
+ end
16
+
13
17
  def self.user_data_dir
14
18
  dir = false
15
19
 
data/lib/datafile.rb CHANGED
@@ -8,6 +8,7 @@ module Cabi
8
8
  return YAML.load(File.read( self.yaml_file(id) )) if self.yaml_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
+ nil
11
12
  end
12
13
 
13
14
  def self.write(id, content)
@@ -25,9 +26,10 @@ module Cabi
25
26
  end
26
27
 
27
28
  def self.file_yaml_or_non_extension_file(id)
28
- return self.file(id) if self.file_exists?(id)
29
- return self.yaml_file(id) if self.yaml_exists?(id)
30
- return self.non_extension_file(id) if self.non_extension_file(id)
29
+ return self.bulk_selection(id, true) if self.bulk_selection?(id)
30
+ return self.file(id) if self.file_exists?(id)
31
+ return self.yaml_file(id) if self.yaml_exists?(id)
32
+ return self.non_extension_file(id) if self.non_extension_file(id)
31
33
  nil
32
34
  end
33
35
 
@@ -51,12 +53,13 @@ module Cabi
51
53
  file
52
54
  end
53
55
 
54
- def self.bulk_selection(id)
56
+ def self.bulk_selection(id, only_file=false)
55
57
  contents = []
56
58
 
57
59
  Dir.glob( File.join( *self.id_array(id) ) ).each do |f|
58
60
  next if f == '.' or f == '..' or File.directory?(f)
59
- contents << File.read(f) if File.exists?(f)
61
+
62
+ contents << (only_file ? f : File.read(f)) if File.exists?(f)
60
63
  end
61
64
 
62
65
  contents
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.2
4
+ version: 0.1.3
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-17 00:00:00.000000000 Z
11
+ date: 2013-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor