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 CHANGED
@@ -3,6 +3,7 @@
3
3
  git.bundle
4
4
  .geanyprj
5
5
  .rvmrc
6
+ /.switch_file
6
7
  .yardoc
7
8
  Gemfile.lock
8
9
  doc/*
@@ -0,0 +1,9 @@
1
+ 0.1.0 - 2012-04-10
2
+ -----------------
3
+
4
+ * [#1] Added prompt. No validation yet, but ready to use.
5
+
6
+ 0.0.1 - 2012-04-09
7
+ ------------------
8
+
9
+ * [#1] Initial commit.
@@ -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.prompt))
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
@@ -2,6 +2,7 @@ module SwitchFile
2
2
  # A type of file within the project
3
3
  class FileType < Valuable
4
4
  has_value :open_command
5
+ has_value :name
5
6
  has_value :path_regex
6
7
  has_value :shortcut
7
8
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module SwitchFile
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -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.1
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-09 00:00:00.000000000 Z
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: &69981220 !ruby/object:Gem::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: *69981220
24
+ version_requirements: *80765390
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &69980910 !ruby/object:Gem::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: *69980910
35
+ version_requirements: *80764340
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: valuable
38
- requirement: &69980370 !ruby/object:Gem::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: *69980370
46
+ version_requirements: *80763720
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard
49
- requirement: &69979850 !ruby/object:Gem::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: *69979850
57
+ version_requirements: *80763160
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: guard-rspec
60
- requirement: &69979400 !ruby/object:Gem::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: *69979400
68
+ version_requirements: *80781130
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry
71
- requirement: &69979100 !ruby/object:Gem::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: *69979100
79
+ version_requirements: *80780850
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rspec
82
- requirement: &69978770 !ruby/object:Gem::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: *69978770
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
- - .switch_file
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
- ]