dirge 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/README.rdoc +17 -1
  2. data/VERSION +1 -1
  3. data/lib/dirge.rb +6 -0
  4. data/spec/dirge_spec.rb +5 -1
  5. metadata +2 -2
@@ -4,7 +4,7 @@
4
4
 
5
5
  require 'dirge'
6
6
  require_relative '../to_my_file'
7
-
7
+
8
8
  Or, the much simpler notation
9
9
 
10
10
  require ~'../to_my_file'
@@ -24,3 +24,19 @@ Again, this could be
24
24
  All of this is powered by the new function:
25
25
 
26
26
  __DIR__
27
+
28
+ which takes a single line off of <tt>Kernel.caller</tt> and give you back the relative path. Calling __DIR__(caller.first) for instance, will give you the relative path to whoever called you.
29
+
30
+ There is also a more explicit, and probably, more readable version.
31
+
32
+ File.relative(path)
33
+
34
+ This will convert your path into a relative directory from wherever you are.
35
+
36
+ require_relative 'to/my/file'
37
+
38
+ and
39
+
40
+ require File.relative('to/my/file')
41
+
42
+ should be identical.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -31,4 +31,10 @@ class String
31
31
  File.expand_path(File.join(__DIR_REL__(caller.first), self))
32
32
  end
33
33
  end
34
+ end
35
+
36
+ class File
37
+ def self.relative(path)
38
+ File.expand_path(File.join(__DIR_REL__(caller.first), path))
39
+ end
34
40
  end
@@ -1,8 +1,12 @@
1
1
  describe 'Dirge' do
2
- it "should resolve a path" do
2
+ it "should resolve a path through String#~" do
3
3
  (~'test:2test/test').should == File.expand_path(File.join(File.dirname(__FILE__), 'test:2test', 'test'))
4
4
  end
5
5
 
6
+ it "should resolve a path through File#relative" do
7
+ File.relative('test:2test/test').should == File.expand_path(File.join(File.dirname(__FILE__), 'test:2test', 'test'))
8
+ end
9
+
6
10
  it 'should require a relative path' do
7
11
  proc {
8
12
  require_relative 'test:2test/test'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dirge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Hull
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-21 00:00:00 -08:00
12
+ date: 2010-01-24 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15