basepath 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +5 -5
  2. data/VERSION +1 -1
  3. data/lib/basepath.rb +10 -5
  4. metadata +3 -3
data/Rakefile CHANGED
@@ -4,12 +4,12 @@ require 'rake'
4
4
  begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
- gem.name = "basepath"
8
- gem.summary = %Q{Define you application base path for easy requires and general access to files.}
7
+ gem.name = "basepath"
8
+ gem.summary = %Q{Define you application base path for easy requires and general access to files.}
9
9
  gem.description = %Q{By adding a .base file to your application base dir, helps you augment $LOAD_PATH, auto-require files, and set constants to important paths.}
10
- gem.email = "dev@caiochassot.com"
11
- gem.homepage = "http://github.com/kch/basepath"
12
- gem.authors = ["Caio Chassot"]
10
+ gem.email = "dev@caiochassot.com"
11
+ gem.homepage = "http://github.com/kch/basepath"
12
+ gem.authors = ["Caio Chassot"]
13
13
  gem.add_development_dependency "bacon", ">= 0"
14
14
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
15
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
@@ -1,4 +1,6 @@
1
+ # encoding: UTF-8
1
2
  require 'pathname'
3
+ require 'yaml'
2
4
 
3
5
  module Basepath
4
6
  DOT_BASE = '.base'
@@ -23,16 +25,19 @@ module Basepath
23
25
 
24
26
  def find_base!
25
27
  paths_tried = []
26
- index_of_require_line = caller.index { |line| line =~ /`require'$/ } \
27
- and caller_line_before_require = caller[index_of_require_line.succ]
28
- if index_of_require_line && caller_line_before_require
28
+ caller_line_before_require = caller.inject(false) do |was_in_require, line|
29
+ is_in_require = line.force_encoding(__ENCODING__) =~ /`(rescue in )?require'$/
30
+ break line if was_in_require && !is_in_require
31
+ is_in_require
32
+ end
33
+ if caller_line_before_require
29
34
  path_from_requirer = Pathname.new(path_from_caller_line(caller_line_before_require)).realpath.dirname
30
35
  base_from_requirer = find_base(path_from_requirer)
31
36
  return base_from_requirer if base_from_requirer
32
37
  paths_tried << path_from_requirer
33
38
  end
34
39
  path_from_pwd = Pathname.new(Dir.pwd).realpath
35
- pwd_path_parent_of_requirer_path = index_of_require_line && "#{path_from_requirer}/".index("#{path_from_pwd}/") == 0
40
+ pwd_path_parent_of_requirer_path = caller_line_before_require && "#{path_from_requirer}/".index("#{path_from_pwd}/") == 0
36
41
  if not pwd_path_parent_of_requirer_path
37
42
  base_from_pwd = find_base(path_from_pwd)
38
43
  return base_from_pwd if base_from_pwd
@@ -73,7 +78,7 @@ module Basepath
73
78
  $LOAD_PATH.unshift(*load_paths)
74
79
 
75
80
  # requires
76
- loaded = caller(0).map { |s| s[/\A(.+?)(?:\.rb)?:\d+(?::in `.*?')?\z/, 1] }.compact.uniq
81
+ loaded = caller(0).map { |s| s.force_encoding(__ENCODING__)[/\A(.+?)(?:\.rb)?:\d+(?::in `.*?')?\z/, 1] }.compact.uniq
77
82
  globs, names = base_conf[:requires].split("\n").partition { |s| s =~ /\*/ }
78
83
  names.map! { |s| const_expand! s, false }.concat \
79
84
  globs.map { |s| Dir[const_expand!(s).to_s + ".rb"] }\
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 4
7
+ - 5
8
8
  - 0
9
- version: 0.4.0
9
+ version: 0.5.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Caio Chassot
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-28 00:00:00 -03:00
17
+ date: 2010-08-02 00:00:00 -03:00
18
18
  default_executable: basepath-init
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency