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 +4 -4
- data/Rakefile +38 -1
- data/cabi.gemspec +1 -1
- data/lib/cabi.rb +5 -1
- data/lib/data.rb +1 -5
- data/lib/datafile.rb +9 -8
- data/lib/list.rb +16 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b09ee246dba02249981cbb0f0c42274da912aac
|
4
|
+
data.tar.gz: 17a4990844a94d7a72d0d929c26daba3c0c242b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
+
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."
|
data/lib/cabi.rb
CHANGED
data/lib/data.rb
CHANGED
@@ -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
|
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)
|
data/lib/datafile.rb
CHANGED
@@ -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)
|
30
|
-
return self.yaml_file(id)
|
31
|
-
return self.file(id)
|
32
|
-
return 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,
|
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
|
data/lib/list.rb
ADDED
@@ -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.
|
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-
|
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
|