uber_config 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module UberConfig
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/uber_config.rb CHANGED
@@ -7,6 +7,7 @@ module UberConfig
7
7
 
8
8
  # First check for abt config
9
9
  if defined? $abt_config
10
+ puts "$abt_config found."
10
11
  @config = $abt_config
11
12
  return @config
12
13
  end
@@ -23,41 +24,36 @@ module UberConfig
23
24
  file = options[:file]
24
25
  end
25
26
 
26
- p Kernel.caller
27
+ #p Kernel.caller
27
28
  caller_file = caller[0][0...(caller[0].index(":in"))]
28
29
  caller_file = caller_file[0...(caller_file.rindex(":"))]
29
- p caller_file
30
+ #p caller_file
30
31
  caller_dir = File.dirname(caller_file)
31
- p caller_dir
32
+ #p caller_dir
32
33
  caller_dir_split = caller_dir.split("/")
33
- p caller_dir_split
34
+ #p caller_dir_split
34
35
  auto_dir_name = caller_dir_split.last
35
36
  if auto_dir_name == "test"
36
37
  caller_dir_split.pop
37
38
  auto_dir_name = caller_dir_split.last
38
39
  end
39
- p auto_dir_name
40
+ #p auto_dir_name
40
41
 
41
42
  # Now check near caller file
42
43
  dir_and_file = dir.nil? ? [] : dir.dup
43
44
  dir_and_file << file
44
- p dir_and_file
45
+ #p dir_and_file
45
46
  location = File.join(dir_and_file)
46
- p location
47
+ #p location
47
48
  cf = File.expand_path(location, caller_dir)
48
- puts "cf=" + cf.inspect
49
- if File.exist?(cf)
50
- @config = YAML::load_file(cf)
51
- return @config
52
- end
49
+ @config = load_from(cf)
50
+ return @config if @config
53
51
 
54
52
  # and working directory
55
53
  cf = File.expand_path(location)
56
- puts "cf=" + cf.inspect
57
- if File.exist?(cf)
58
- @config = YAML::load_file(cf)
59
- return @config
60
- end
54
+ @config = load_from(cf)
55
+ return @config if @config
56
+
61
57
 
62
58
  # Now check in Dropbox
63
59
  dropbox_folders = ["~", "Dropbox", "configs"]
@@ -68,16 +64,21 @@ module UberConfig
68
64
  end
69
65
  dropbox_folders << file
70
66
  cf = File.expand_path(File.join(dropbox_folders))
71
- puts "cf=" + cf.inspect
72
- if File.exist?(cf)
73
- @config = YAML::load_file(cf)
74
- return @config
75
- end
76
-
77
-
67
+ @config = load_from(cf)
68
+ return @config if @config
78
69
 
79
70
  # couldn't find it
71
+ puts "Could not find config file."
80
72
  return nil
81
73
 
82
74
  end
75
+
76
+ def load_from(cf)
77
+ puts "Checking for config file at #{cf}..."
78
+ if File.exist?(cf)
79
+ config = YAML::load_file(cf)
80
+ return config
81
+ end
82
+ nil
83
+ end
83
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uber_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-03 00:00:00.000000000 Z
12
+ date: 2012-06-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Loads configs from common locations.
15
15
  email:
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  version: '0'
46
46
  requirements: []
47
47
  rubyforge_project: uber_config
48
- rubygems_version: 1.8.21
48
+ rubygems_version: 1.8.24
49
49
  signing_key:
50
50
  specification_version: 3
51
51
  summary: Loads configs from common locations.