donald 0.1.8 → 2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,27 +12,17 @@ h2. Usage:
12
12
 
13
13
  <pre><code>donald</code></pre>
14
14
 
15
- h2. Options:
15
+ h2. Using a different editor:
16
16
 
17
- h3. -g or --gvim
17
+ You can use another editor sending its name as a parameter:
18
18
 
19
- Open files using gvim
19
+ <pre><code>donald gvim</code></pre>
20
20
 
21
- Example:
22
-
23
- <pre><code>donald -g</code></pre>
24
-
25
- h3. -m or --mvim
26
-
27
- Open files using mvim
28
-
29
- h3. --vim
30
-
31
- Open files using vim
21
+ Or
32
22
 
33
- h3. -t or --textmate
23
+ <pre><code>donald mate</code></pre>
34
24
 
35
- Open files using Textmate
25
+ If you inform more than one parameter donald will ignore it.
36
26
 
37
27
  h2. Setting up your default text editor
38
28
 
@@ -40,7 +30,7 @@ Set the $EDITOR variable in your ~/.bashrc file
40
30
 
41
31
  Example:
42
32
 
43
- <pre><code>export EDITOR="mate"</code></pre>
33
+ <pre><code>export EDITOR="gedit"</code></pre>
44
34
 
45
35
  h2. Searching for conflicts
46
36
 
@@ -1,2 +1 @@
1
1
  Dir.glob(File.dirname(__FILE__) + '/donald/*.rb').each { |file| require file }
2
-
@@ -2,12 +2,26 @@ module Donald
2
2
  class Editor
3
3
  DEFAULT_EDITOR = 'vim'
4
4
 
5
- def initialize(editor_name = nil)
6
- @editor_name = editor_name
5
+ def initialize(name = nil)
6
+ @name = name || Donald::Environment.editor_variable || DEFAULT_EDITOR
7
7
  end
8
8
 
9
- def to_s
10
- @editor_name || Donald::Environment.editor_variable || DEFAULT_EDITOR
9
+ def run(files)
10
+ Kernel.system "#{@name}#{arguments} #{files.join(' ')}"
11
+ end
12
+
13
+ private
14
+
15
+ def arguments
16
+ " #{tab_argument} #{search_argument}" if @name.include? 'vim'
17
+ end
18
+
19
+ def tab_argument
20
+ '-p'
21
+ end
22
+
23
+ def search_argument
24
+ '+/HEAD'
11
25
  end
12
26
  end
13
27
  end
@@ -2,7 +2,7 @@ module Donald
2
2
  class MergeTool
3
3
  def initialize(output, args = [])
4
4
  @printer = Donald::Printer.new output
5
- @options = parse_options args
5
+ @editor = Donald::Editor.new(editor_from(args))
6
6
  end
7
7
 
8
8
  def start
@@ -10,43 +10,16 @@ module Donald
10
10
 
11
11
  if files.any?
12
12
  @printer.print_files files
13
- call_editor files
13
+ @editor.run files
14
14
  else
15
15
  @printer.print_no_files_message
16
16
  end
17
17
  end
18
18
 
19
19
  private
20
-
21
- def call_editor(files)
22
- Kernel.system "#{editor}#{arguments(editor)} #{files.join(' ')}"
23
- end
24
20
 
25
- def editor
26
- @editor || @editor = Donald::Editor.new(@options[:editor])
27
- end
28
-
29
- def parse_options(args)
30
- options = {}
31
-
32
- options.merge! :editor => 'vim' if args.include?('--vim')
33
- options.merge! :editor => 'mvim' if args.include?('-m') || args.include?('--mvim')
34
- options.merge! :editor => 'gvim' if args.include?('-g') || args.include?('--gvim')
35
- options.merge! :editor => 'mate' if args.include?('-t') || args.include?('--textmate')
36
-
37
- options
38
- end
39
-
40
- def arguments(editor)
41
- " #{tab_argument} #{search_argument}" if editor.to_s.include? 'vim'
42
- end
43
-
44
- def tab_argument
45
- '-p'
46
- end
47
-
48
- def search_argument
49
- '+/HEAD'
21
+ def editor_from(args)
22
+ args.any? ? args.first : nil
50
23
  end
51
24
  end
52
25
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: donald
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
+ - 2
7
8
  - 0
8
- - 1
9
- - 8
10
- version: 0.1.8
9
+ version: "2.0"
11
10
  platform: ruby
12
11
  authors:
13
12
  - Bruno Grasselli
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-08-21 00:00:00 -03:00
17
+ date: 2010-08-22 00:00:00 -03:00
19
18
  default_executable: donald
20
19
  dependencies: []
21
20