codepath 0.0.1
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/.gitignore +4 -0
- data/.rspec +3 -0
- data/Gemfile +3 -0
- data/README.textile +10 -0
- data/Rakefile +10 -0
- data/codepath.gemspec +23 -0
- data/lib/codepath/codepath.rb +23 -0
- data/lib/codepath/version.rb +3 -0
- data/lib/codepath.rb +1 -0
- data/spec/codepath_spec.rb +43 -0
- data/spec/spec_helper.rb +1 -0
- metadata +77 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/README.textile
ADDED
@@ -0,0 +1,10 @@
|
|
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.
|
3
|
+
|
4
|
+
h2. copyright
|
5
|
+
|
6
|
+
This program is free software. It comes without any warranty,
|
7
|
+
to the extent permitted by applicable law. You can redistribute
|
8
|
+
it and/or modify it under the terms of the Do What The Fuck You
|
9
|
+
Want To Public License, Version 2, as published by Sam Hocevar.
|
10
|
+
See http://sam.zoy.org/wtfpl/COPYING for more details.
|
data/Rakefile
ADDED
data/codepath.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "codepath/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "codepath"
|
7
|
+
s.version = Codepath::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["lucapette"]
|
10
|
+
s.email = ["lucapette@gmail.com"]
|
11
|
+
s.homepage = "https://github.com/lucapette/codepath"
|
12
|
+
s.summary = %q{Utility for the codepath.vim plugin}
|
13
|
+
s.description = %q{This gem is provides the tiny class used by the plugin codepath.vim. Please take a look at http://www.vim.org/scripts/script.php?script_id=3435}
|
14
|
+
|
15
|
+
s.rubyforge_project = "codepath"
|
16
|
+
|
17
|
+
s.add_development_dependency "rspec-rails", ">= 2.5.0"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CodePath
|
2
|
+
|
3
|
+
def initialize(code_dir)
|
4
|
+
@code_dir = code_dir
|
5
|
+
end
|
6
|
+
|
7
|
+
def in_dir?(current_dir)
|
8
|
+
current_dir.include?(@code_dir) && current_dir != @code_dir
|
9
|
+
end
|
10
|
+
|
11
|
+
def project_dir(current_dir)
|
12
|
+
in_dir?(current_dir) ? "#{@code_dir}/#{current_dir.split(File::Separator)[@code_dir.split(File::Separator).length]}" : current_dir
|
13
|
+
end
|
14
|
+
|
15
|
+
def subdirs(path)
|
16
|
+
Dir.glob(File.join(path,"**/*")).select { |f| File.directory?(f) }.join(",")
|
17
|
+
end
|
18
|
+
|
19
|
+
def project_name(current_file)
|
20
|
+
in_dir?(File.dirname(current_file)) ? project_dir(File.dirname(current_file)).split(File::Separator).last : ""
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/codepath.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "codepath/codepath"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CodePath do
|
4
|
+
|
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
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns false when passed a bad dir" do
|
16
|
+
@codepath.in_dir?("/tmp/notcode/project").should be false
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#codedir" do
|
22
|
+
it "returns the current root project dir" do
|
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
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#project_name" do
|
32
|
+
|
33
|
+
it "returns the project name for a file in codepath" do
|
34
|
+
@codepath.project_name("/tmp/code/foo/file").should == "foo"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns an empty string for a file not in codepath" do
|
38
|
+
@codepath.project_name("/tmp/notcode/bar").should be_empty
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../lib/codepath")
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: codepath
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- lucapette
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-02 00:00:00 +02:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rspec-rails
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 2.5.0
|
25
|
+
type: :development
|
26
|
+
version_requirements: *id001
|
27
|
+
description: This gem is provides the tiny class used by the plugin codepath.vim. Please take a look at http://www.vim.org/scripts/script.php?script_id=3435
|
28
|
+
email:
|
29
|
+
- lucapette@gmail.com
|
30
|
+
executables: []
|
31
|
+
|
32
|
+
extensions: []
|
33
|
+
|
34
|
+
extra_rdoc_files: []
|
35
|
+
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- .rspec
|
39
|
+
- Gemfile
|
40
|
+
- README.textile
|
41
|
+
- Rakefile
|
42
|
+
- codepath.gemspec
|
43
|
+
- lib/codepath.rb
|
44
|
+
- lib/codepath/codepath.rb
|
45
|
+
- lib/codepath/version.rb
|
46
|
+
- spec/codepath_spec.rb
|
47
|
+
- spec/spec_helper.rb
|
48
|
+
has_rdoc: true
|
49
|
+
homepage: https://github.com/lucapette/codepath
|
50
|
+
licenses: []
|
51
|
+
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project: codepath
|
72
|
+
rubygems_version: 1.6.2
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Utility for the codepath.vim plugin
|
76
|
+
test_files: []
|
77
|
+
|