dohroot 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ module Doh
2
+ extend self
3
+
4
+ def findup(start_directory, filename, max_tries = 20)
5
+ curr_directory = start_directory
6
+ max_tries.times do
7
+ path = File.expand_path(File.join(curr_directory, filename))
8
+ return path if File.exist?(path)
9
+ return nil if (path == '/')
10
+ curr_directory = File.join(curr_directory, '..')
11
+ end
12
+ nil
13
+ end
14
+
15
+ end # module Doh
File without changes
data/lib/dohroot.rb ADDED
@@ -0,0 +1,46 @@
1
+ require 'dohroot/findup'
2
+
3
+ module Doh
4
+ extend self
5
+
6
+ class DohRootNotFoundException < Exception
7
+ end
8
+
9
+ def root
10
+ @root
11
+ end
12
+
13
+ def root=(directory)
14
+ @root = directory
15
+ libdir = File.join(@root, 'lib')
16
+ $LOAD_PATH.push(libdir) if libdir
17
+ end
18
+
19
+ def find_root(start_directory, filename = 'dohroot', max_tries = 20)
20
+ rootfile = Doh.findup(start_directory, filename, max_tries)
21
+ if rootfile
22
+ Doh.root = File.dirname(rootfile)
23
+ end
24
+ end
25
+
26
+ def find_root_from_file(filepath = nil)
27
+ Doh.find_root(File.dirname(filepath || caller[0]))
28
+ end
29
+
30
+ def find_root_from_path(path)
31
+ if File.directory?(path)
32
+ Doh.find_root(path)
33
+ else
34
+ Doh.find_root(File.dirname(path))
35
+ end
36
+ end
37
+
38
+ def find_root_from_prog
39
+ Doh.find_root(File.dirname($PROGRAM_NAME))
40
+ end
41
+
42
+ def find_root_from_pwd
43
+ Doh.find_root(Dir.pwd)
44
+ end
45
+
46
+ end # module Doh
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dohroot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-09-20 00:00:00.000000000 Z
13
+ date: 2013-05-22 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Implements the notion of dohroot that enables most other doh stuff.
16
16
  email:
@@ -20,9 +20,9 @@ extensions: []
20
20
  extra_rdoc_files:
21
21
  - MIT-LICENSE
22
22
  files:
23
- - lib/doh/findup.rb
24
- - lib/doh/options.rb
25
- - lib/doh/root.rb
23
+ - lib/dohroot/findup.rb
24
+ - lib/dohroot/options.rb
25
+ - lib/dohroot.rb
26
26
  - MIT-LICENSE
27
27
  homepage: https://github.com/atpsoft/dohroot
28
28
  licenses:
@@ -36,7 +36,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ! '>='
38
38
  - !ruby/object:Gem::Version
39
- version: 1.9.2
39
+ version: 1.9.3
40
40
  required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
@@ -45,9 +45,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  version: '0'
46
46
  requirements: []
47
47
  rubyforge_project:
48
- rubygems_version: 1.8.24
48
+ rubygems_version: 1.8.25
49
49
  signing_key:
50
50
  specification_version: 3
51
51
  summary: tiniest root of doh stuff
52
52
  test_files: []
53
- has_rdoc:
data/lib/doh/findup.rb DELETED
@@ -1,12 +0,0 @@
1
- module Doh
2
- def self.findup(start_directory, filename, max_tries = 20)
3
- curr_directory = start_directory
4
- max_tries.times do
5
- path = File.expand_path(File.join(curr_directory, filename))
6
- return path if File.exist?(path)
7
- return nil if (path == '/')
8
- curr_directory = File.join(curr_directory, '..')
9
- end
10
- nil
11
- end
12
- end
data/lib/doh/root.rb DELETED
@@ -1,42 +0,0 @@
1
- require 'doh/findup'
2
-
3
- module Doh
4
- class DohRootNotFoundException < Exception
5
- end
6
- def self.root
7
- @root
8
- end
9
-
10
- def self.root=(directory)
11
- @root = directory
12
- libdir = File.join(@root, 'lib')
13
- $LOAD_PATH.push(libdir) if libdir
14
- end
15
-
16
- def self.find_root(start_directory, filename = 'dohroot', max_tries = 20)
17
- rootfile = Doh::findup(start_directory, filename, max_tries)
18
- if rootfile
19
- Doh::root = File.dirname(rootfile)
20
- end
21
- end
22
-
23
- def self.find_root_from_file(filepath = nil)
24
- Doh::find_root(File.dirname(filepath || caller[0]))
25
- end
26
-
27
- def self.find_root_from_path(path)
28
- if File.directory?(path)
29
- Doh::find_root(path)
30
- else
31
- Doh::find_root(File.dirname(path))
32
- end
33
- end
34
-
35
- def self.find_root_from_prog
36
- Doh::find_root(File.dirname($PROGRAM_NAME))
37
- end
38
-
39
- def self.find_root_from_pwd
40
- Doh::find_root(Dir.pwd)
41
- end
42
- end