cabi 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -0
  3. data/bin/cabi +24 -9
  4. data/cabi.gemspec +1 -1
  5. data/lib/data.rb +5 -2
  6. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a56f6e6e8ee48ba38ba8f60099907e4c1d9c700
4
- data.tar.gz: 484d80e55fc096a324dd0667b2f5d515e2b12af6
3
+ metadata.gz: ee85570e4d09d5212cdd2987e00f584522ce5a15
4
+ data.tar.gz: 720e2a6061641df78035b8bc576460fac1f0a52c
5
5
  SHA512:
6
- metadata.gz: 6eeedec5d3f8db0fdd66e428910225990acfda42f93f9281e29c732c5064da64b217b54c82bd67cf9d20d7c771959e011a6b2f83c3043786976e56833adfc911
7
- data.tar.gz: 9ab42f192d38f94e8b4fd5c0e33e6d4f0b7f0505e839d3234158926c8963ae560ab64ad60c0bfaf87597dd9134e20f261717c7ac56ceca926a56a7cf50454519
6
+ metadata.gz: 357e04fc69b7accafb5c53e7a8df59af0f7905a3526910db1f3d13c9001c872aa9de83b453ca170963cfb53b932aafad3bc419f21cd358dc7dbfc95d63e76b39
7
+ data.tar.gz: 60865bf4a8e4db0a4ec30d52080f92d1210108d125efa768ae806fe6de017fcd10182203aa375d49f847c18bdc8b00e982e14affb34ae85ede1645c5387bae07
data/README.md CHANGED
@@ -60,7 +60,9 @@ Cabi.read('**/*').length # 9
60
60
 
61
61
  # Selection within YAML files
62
62
  Cabi.read('pages:about:meta:foo:bar') # contents of ['foo']['bar'] in page/about/meta.yml hash
63
+ Cabi.read('pages:about:meta.yml:foo:bar') # same as above
63
64
  Cabi.read('info:foo:bar:baz') # contents of ['foo']['bar']['baz'] in info.yml hash
65
+ Cabi.read('info.yml:foo:bar:baz') # same as above
64
66
  ```
65
67
 
66
68
  ### Custom Data Directory
data/bin/cabi CHANGED
@@ -6,6 +6,9 @@ require File.join( File.expand_path("../..", __FILE__), "lib", "cabi")
6
6
 
7
7
  class CabiCLI < Thor
8
8
 
9
+ # -----------------------------------------------------------------------------------------------------------
10
+ # Init Task
11
+ # -----------------------------------------------------------------------------------------------------------
9
12
  desc "init", "Initialize Cabi data directory (use --mock to create fake data, use --target to specify your own directory)"
10
13
  method_options :mock => :boolean, :target => :string
11
14
  def init
@@ -18,22 +21,34 @@ class CabiCLI < Thor
18
21
  `tar -xf #{f} --strip-components=1 -C #{target}`
19
22
  end
20
23
 
21
- puts " ** Cabi data created in #{target}"
24
+ puts "** Cabi data created in #{target}"
22
25
  end
23
26
 
27
+ # -----------------------------------------------------------------------------------------------------------
28
+ # Clean Task
29
+ # -----------------------------------------------------------------------------------------------------------
24
30
  desc "clean", "Remove Cabi data directory"
25
31
  method_options :force => :boolean
26
32
  def clean
27
- if options[:force]
28
- begin
29
- FileUtils.rm_rf( Cabi.data_dir )
30
- FileUtils.rm_rf( Cabi::CABI_DATA_DIR)
31
- puts " ** Cleaned cabi data"
32
- rescue Exception => e
33
- end
33
+ puts "\n** Trying to clean Cabi data folder."
34
+
35
+ current_dir = File.expand_path(Dir.pwd) == Cabi.data_dir({ quiet: true })
36
+
37
+ if current_dir
38
+ puts "** Cabi data folder is the same as the current folder -- not cleaning!"
34
39
  else
35
- puts " ** Not cleaning cabi data folder without --force"
40
+ if options[:force]
41
+ begin
42
+ FileUtils.rm_rf( Cabi.data_dir )
43
+ puts " ** Cleaned cabi data"
44
+ rescue Exception => e
45
+ end
46
+ else
47
+ puts "** Not cleaning cabi data folder without --force"
48
+ end
36
49
  end
50
+
51
+
37
52
  end
38
53
 
39
54
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'cabi'
3
- s.version = '0.1.4'
3
+ s.version = '0.1.5'
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."
@@ -29,10 +29,13 @@ module Cabi
29
29
  end
30
30
 
31
31
  # Helpers for setting/getting data dir.
32
- def self.data_dir
32
+ def self.data_dir(opts={})
33
33
  dir = Data.user_data_dir || CABI_DATA_DIR
34
34
  @@data_dir = File.expand_path(dir)
35
- raise LoadError.new "Could not find cabi data folder!" unless File.exists? @@data_dir
35
+
36
+ return nil if !File.exists?(@@data_dir) and opts[:quiet]
37
+ raise LoadError.new "Could not find cabi data folder!" if !File.exists? @@data_dir
38
+
36
39
  @@data_dir
37
40
  end
38
41
 
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
4
+ version: 0.1.5
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-19 00:00:00.000000000 Z
11
+ date: 2013-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor