codepath 0.0.2 → 0.0.3
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.
- data/README.textile +1 -2
- data/lib/codepath.rb +25 -1
- data/spec/codepath_spec.rb +26 -24
- metadata +2 -3
- data/lib/codepath/codepath.rb +0 -25
data/README.textile
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
This gem provides a tiny class for the codepath.vim plugin. Please take a look
|
2
|
-
at http://www.vim.org/scripts/script.php?script_id=3435.
|
1
|
+
This gem provides a tiny class for the codepath.vim plugin. Please take a look at the "plugin":http://www.vim.org/scripts/script.php?script_id=3435 page.
|
3
2
|
|
4
3
|
h2. copyright
|
5
4
|
|
data/lib/codepath.rb
CHANGED
@@ -1 +1,25 @@
|
|
1
|
-
|
1
|
+
class CodePath
|
2
|
+
|
3
|
+
VERSION='0.0.3'
|
4
|
+
|
5
|
+
def initialize(code_dir)
|
6
|
+
@code_dir = code_dir
|
7
|
+
end
|
8
|
+
|
9
|
+
def in_dir?(current_dir)
|
10
|
+
current_dir.include?(@code_dir)
|
11
|
+
end
|
12
|
+
|
13
|
+
def project_dir(current_dir)
|
14
|
+
in_dir?(current_dir) ? "#{@code_dir}/#{current_dir.split(File::Separator)[@code_dir.split(File::Separator).length]}" : current_dir
|
15
|
+
end
|
16
|
+
|
17
|
+
def subdirs(path)
|
18
|
+
Dir.glob(File.join(path,"**/*")).select { |f| File.directory?(f) }.join(",")
|
19
|
+
end
|
20
|
+
|
21
|
+
def project_name(current_file)
|
22
|
+
in_dir?(File.dirname(current_file)) ? project_dir(File.dirname(current_file)).split(File::Separator).last : ""
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/spec/codepath_spec.rb
CHANGED
@@ -2,42 +2,44 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe CodePath do
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
before(:all) do
|
6
|
+
@codepath = CodePath.new("/tmp/code")
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#in_dir?" do
|
10
|
+
|
11
|
+
it "returns true when passed a good dir" do
|
12
|
+
@codepath.in_dir?("/tmp/code/project").should be true
|
7
13
|
end
|
8
14
|
|
9
|
-
|
15
|
+
it "returns false when passed a bad dir" do
|
16
|
+
@codepath.in_dir?("/tmp/notcode/project").should be false
|
17
|
+
end
|
10
18
|
|
11
|
-
|
12
|
-
@codepath.in_dir?("/tmp/code/project").should be true
|
13
|
-
end
|
19
|
+
end
|
14
20
|
|
15
|
-
|
16
|
-
@codepath.in_dir?("/tmp/notcode/project").should be false
|
17
|
-
end
|
21
|
+
describe "#project_dir" do
|
18
22
|
|
23
|
+
it "returns the current root project dir" do
|
24
|
+
@codepath.project_dir("/tmp/code/project/awesome").should == "/tmp/code/project"
|
19
25
|
end
|
20
26
|
|
21
|
-
|
22
|
-
|
23
|
-
@codepath.project_dir("/tmp/code/project/awesome").should == "/tmp/code/project"
|
24
|
-
end
|
25
|
-
it "returns the dir itself" do
|
26
|
-
@codepath.project_dir("/tmp/notcode/project").should == "/tmp/notcode/project"
|
27
|
-
end
|
28
|
-
|
27
|
+
it "returns the dir itself" do
|
28
|
+
@codepath.project_dir("/tmp/notcode/project").should == "/tmp/notcode/project"
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
end
|
32
32
|
|
33
|
-
|
34
|
-
@codepath.project_name("/tmp/code/foo/file").should == "foo"
|
35
|
-
end
|
33
|
+
describe "#project_name" do
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
it "returns the project name for a file in codepath" do
|
36
|
+
@codepath.project_name("/tmp/code/foo/file").should == "foo"
|
37
|
+
end
|
40
38
|
|
39
|
+
it "returns an empty string for a file not in codepath" do
|
40
|
+
@codepath.project_name("/tmp/notcode/bar").should be_empty
|
41
41
|
end
|
42
42
|
|
43
|
+
end
|
44
|
+
|
43
45
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: codepath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- lucapette
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-09-01 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -41,7 +41,6 @@ files:
|
|
41
41
|
- Rakefile
|
42
42
|
- codepath.gemspec
|
43
43
|
- lib/codepath.rb
|
44
|
-
- lib/codepath/codepath.rb
|
45
44
|
- spec/codepath_spec.rb
|
46
45
|
- spec/spec_helper.rb
|
47
46
|
has_rdoc: true
|
data/lib/codepath/codepath.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
class CodePath
|
2
|
-
|
3
|
-
VERSION='0.0.2'
|
4
|
-
|
5
|
-
def initialize(code_dir)
|
6
|
-
@code_dir = code_dir
|
7
|
-
end
|
8
|
-
|
9
|
-
def in_dir?(current_dir)
|
10
|
-
current_dir.include?(@code_dir) && current_dir != @code_dir
|
11
|
-
end
|
12
|
-
|
13
|
-
def project_dir(current_dir)
|
14
|
-
in_dir?(current_dir) ? "#{@code_dir}/#{current_dir.split(File::Separator)[@code_dir.split(File::Separator).length]}" : current_dir
|
15
|
-
end
|
16
|
-
|
17
|
-
def subdirs(path)
|
18
|
-
Dir.glob(File.join(path,"**/*")).select { |f| File.directory?(f) }.join(",")
|
19
|
-
end
|
20
|
-
|
21
|
-
def project_name(current_file)
|
22
|
-
in_dir?(File.dirname(current_file)) ? project_dir(File.dirname(current_file)).split(File::Separator).last : ""
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|