cabi 0.1.6 → 0.1.7

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: 35527186595b9556478c37edc3d06266f9450e03
4
- data.tar.gz: 3aa8a7e939c43613b9c97bb8273ab8209078fbe2
3
+ metadata.gz: 0b09ee246dba02249981cbb0f0c42274da912aac
4
+ data.tar.gz: 17a4990844a94d7a72d0d929c26daba3c0c242b4
5
5
  SHA512:
6
- metadata.gz: f223bc853cdfd1ff9dbd1ef91188dc9931348b0d127386c3f99e6f3519b28e451699a4c0369ad96906c43118c5a3d9ba999a3b894b4ce84119d3b551f8db161e
7
- data.tar.gz: bf8ab692fa122a0cffafd624907579227a4c3533b0bdc7a86a5dd42b716fc557bba44bc2b9b5cbde788c992a7ae457213ec890b36407b637f3a2db939d9b2563
6
+ metadata.gz: aa15f5e116ac640f3a90a7de36ca1bc732ea74b4dc0d4c2e758730255f9793291252f5cca4c923956c4f1c1be64483f2f86d1bef8a8e7ce16a22c317957819f3
7
+ data.tar.gz: 5d93f37b690435ab11f4eb1c1154f20b97edafc04096bbf6b1db02135e599fdfc63dd38926ee88fd7b892e8664ee95d73f4417459a64883033a031fda52bfcb0
data/Rakefile CHANGED
@@ -5,4 +5,41 @@ Rake::TestTask.new do |t|
5
5
  end
6
6
 
7
7
  desc "Run tests"
8
- task :default => :test
8
+ task :default => :test
9
+
10
+ namespace :gem do
11
+
12
+ desc "build"
13
+ task :build do
14
+ puts %x[rm -rf *.gem]
15
+ puts %x[gem build *.gemspec]
16
+ end
17
+
18
+ desc "install"
19
+ task :install do
20
+ puts %x[gem install *.gem]
21
+ puts %x[rm -rf *.gem]
22
+ end
23
+
24
+ desc "release"
25
+ task :release do
26
+ gems = Dir.glob("*.gem").length
27
+ puts gems
28
+ raise "0 or > 1 gem in directory; aborting!" if gems != 1
29
+ puts %x[gem push *.gem]
30
+ puts %x[rm -rf *.gem]
31
+ end
32
+
33
+ desc "build & install"
34
+ task :build_and_install do
35
+ Rake::Task["gem:build"].invoke
36
+ Rake::Task["gem:install"].invoke
37
+ end
38
+
39
+ desc "build & release"
40
+ task :build_and_release do
41
+ Rake::Task["gem:build"].invoke
42
+ Rake::Task["gem:release"].invoke
43
+ end
44
+
45
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'cabi'
3
- s.version = '0.1.6'
3
+ s.version = '0.1.7'
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."
@@ -21,8 +21,12 @@ module Cabi
21
21
  Data.write(id, content)
22
22
  end
23
23
 
24
- def self.file(id)
24
+ def self.file(id, opts={})
25
25
  DataFile.file_yaml_or_non_extension_file(id)
26
26
  end
27
27
 
28
+ def self.list(id)
29
+ Cabi::List.list(id)
30
+ end
31
+
28
32
  end
@@ -10,10 +10,6 @@ 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
-
17
13
  def self.user_data_dir
18
14
  dir = false
19
15
 
@@ -28,7 +24,7 @@ module Cabi
28
24
 
29
25
  end
30
26
 
31
- # Helpers for setting/getting data dir.
27
+ # Helpers for setting/getting data directory.
32
28
  def self.data_dir(opts={})
33
29
  dir = Data.user_data_dir || CABI_DATA_DIR
34
30
  @@data_dir = File.expand_path(dir)
@@ -25,11 +25,11 @@ module Cabi
25
25
  File.open( file, 'w') {|f| f.write(content) }
26
26
  end
27
27
 
28
- def self.file_yaml_or_non_extension_file(id)
29
- return self.bulk_selection(id, true) if self.bulk_selection?(id)
30
- return self.yaml_file(id) if self.yaml_exists?(id)
31
- return self.file(id) if self.file_exists?(id)
32
- return self.non_extension_file(id) if self.non_extension_file(id)
28
+ def self.file_yaml_or_non_extension_file(id, opts={})
29
+ return self.bulk_selection(id, only_file: true) if self.bulk_selection?(id)
30
+ return self.yaml_file(id) if self.yaml_exists?(id)
31
+ return self.file(id) if self.file_exists?(id)
32
+ return self.non_extension_file(id) if self.non_extension_file(id)
33
33
  nil
34
34
  end
35
35
 
@@ -58,13 +58,14 @@ module Cabi
58
58
  file
59
59
  end
60
60
 
61
- def self.bulk_selection(id, only_file=false)
61
+ def self.bulk_selection(id, opts={})
62
62
  contents = []
63
63
 
64
+ opts[:only_file] ||= false
65
+
64
66
  Dir.glob( File.join( *self.id_array(id) ) ).each do |f|
65
67
  next if f == '.' or f == '..' or File.directory?(f)
66
-
67
- contents << (only_file ? f : File.read(f)) if File.exists?(f)
68
+ contents << (opts[:only_file] ? f : File.read(f)) if File.exists?(f)
68
69
  end
69
70
 
70
71
  contents
@@ -0,0 +1,16 @@
1
+ module Cabi
2
+ class List
3
+
4
+ def self.list(id, opts={})
5
+ ls = []
6
+
7
+ Dir.glob( "#{Cabi.data_dir}/#{id}") do |item|
8
+ next if item == '.' or item == '..'
9
+ ls << [ item, File.directory?(item) ? "dir" : "file" ]
10
+ end
11
+
12
+ ls
13
+ end
14
+
15
+ end
16
+ end
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.6
4
+ version: 0.1.7
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-26 00:00:00.000000000 Z
11
+ date: 2013-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -46,6 +46,7 @@ files:
46
46
  - lib/data.rb
47
47
  - lib/datafile.rb
48
48
  - lib/hash.rb
49
+ - lib/list.rb
49
50
  - data/cabi-data.tar.gz
50
51
  - data/cabi.svg
51
52
  homepage: http://github.com/briangonzalez/cabi-gem