switch_file 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG.markdown +9 -0
- data/lib/switch_file/app.rb +1 -1
- data/lib/switch_file/file_type.rb +1 -0
- data/lib/switch_file/source_path.rb +8 -0
- data/lib/switch_file/version.rb +1 -1
- data/spec/lib/switch_file/source_path_spec.rb +22 -0
- metadata +17 -17
- data/.switch_file +0 -13
data/.gitignore
CHANGED
data/CHANGELOG.markdown
ADDED
data/lib/switch_file/app.rb
CHANGED
@@ -15,7 +15,7 @@ module SwitchFile
|
|
15
15
|
def execute(source_path)
|
16
16
|
SwitchFile.config_path = options['config']
|
17
17
|
sp = SourcePath.new(value: source_path)
|
18
|
-
shortcut = FileTypeShortcut.new(value: options['shortcut'] || ask(sp.
|
18
|
+
shortcut = FileTypeShortcut.new(value: options['shortcut'] || ask(sp.prompt_message))
|
19
19
|
target_command = shortcut.file_type.generate_open_command(sp)
|
20
20
|
`#{target_command}`
|
21
21
|
end
|
@@ -10,5 +10,13 @@ module SwitchFile
|
|
10
10
|
def file_type
|
11
11
|
FileType.all.detect{|file_type| value =~ file_type.path_regex }
|
12
12
|
end
|
13
|
+
|
14
|
+
def prompt_message
|
15
|
+
file_type_options = FileType.all.map{|file_type|
|
16
|
+
"[#{file_type.shortcut}] #{file_type.name}: #{file_type.generate_open_command(self)}"
|
17
|
+
}
|
18
|
+
|
19
|
+
"Enter the shortcut of the file you want to open:\n\n#{file_type_options.join("\n")}\n\n"
|
20
|
+
end
|
13
21
|
end
|
14
22
|
end
|
data/lib/switch_file/version.rb
CHANGED
@@ -19,4 +19,26 @@ describe SwitchFile::SourcePath do
|
|
19
19
|
source_path.file_type.should == file_type
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
describe "#prompt_message" do
|
24
|
+
it "be the message to display if the user want to jump to file related to the source path" do
|
25
|
+
FileType.all = [
|
26
|
+
FileType.new(
|
27
|
+
name: :spec,
|
28
|
+
shortcut: :s,
|
29
|
+
open_command: lambda {|class_name| "geany spec/lib/#{class_name}_spec.rb"},
|
30
|
+
path_regex: %r{spec/lib/(.*)_spec.rb}
|
31
|
+
),
|
32
|
+
FileType.new(
|
33
|
+
name: :lib,
|
34
|
+
shortcut: :l,
|
35
|
+
open_command: lambda {|class_name| "geany lib/#{class_name}.rb"},
|
36
|
+
path_regex: %r{lib/(.*).rb}
|
37
|
+
)
|
38
|
+
]
|
39
|
+
|
40
|
+
source_path = SourcePath.new(value: '/home/user/project/lib/project/some_class.rb')
|
41
|
+
source_path.prompt_message.should == "Enter the shortcut of the file you want to open:\n\n[s] spec: geany spec/lib/project/some_class_spec.rb\n[l] lib: geany lib/project/some_class.rb\n\n"
|
42
|
+
end
|
43
|
+
end
|
22
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: switch_file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pow
|
16
|
-
requirement: &
|
16
|
+
requirement: &80765390 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *80765390
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: thor
|
27
|
-
requirement: &
|
27
|
+
requirement: &80764340 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *80764340
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: valuable
|
38
|
-
requirement: &
|
38
|
+
requirement: &80763720 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *80763720
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: guard
|
49
|
-
requirement: &
|
49
|
+
requirement: &80763160 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *80763160
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: guard-rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &80781130 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *80781130
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry
|
71
|
-
requirement: &
|
71
|
+
requirement: &80780850 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *80780850
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &80780560 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *80780560
|
91
91
|
description: A configurable utility for jumping across files
|
92
92
|
email:
|
93
93
|
- gsmendoza@gmail.com
|
@@ -97,7 +97,7 @@ extensions: []
|
|
97
97
|
extra_rdoc_files: []
|
98
98
|
files:
|
99
99
|
- .gitignore
|
100
|
-
- .
|
100
|
+
- CHANGELOG.markdown
|
101
101
|
- Gemfile
|
102
102
|
- Guardfile
|
103
103
|
- Rakefile
|
data/.switch_file
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
[
|
2
|
-
{
|
3
|
-
shortcut: :s,
|
4
|
-
open_command: lambda {|class_name| "geany spec/lib/#{class_name}_spec.rb"},
|
5
|
-
path_regex: %r{spec/lib/(.*)_spec.rb}
|
6
|
-
},
|
7
|
-
|
8
|
-
{
|
9
|
-
shortcut: :l,
|
10
|
-
open_command: lambda {|class_name| "geany lib/#{class_name}.rb"},
|
11
|
-
path_regex: %r{lib/(.*).rb}
|
12
|
-
}
|
13
|
-
]
|