donald 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/lib/donald/editor.rb CHANGED
@@ -7,14 +7,7 @@ module Donald
7
7
  end
8
8
 
9
9
  def to_s
10
- @editor_name || system_editor_variable || DEFAULT_EDITOR
11
- end
12
-
13
- private
14
-
15
- def system_editor_variable
16
- editor = `echo $EDITOR`
17
- editor.chomp.size.zero? ? nil : editor
10
+ @editor_name || Donald::Environment.editor_variable || DEFAULT_EDITOR
18
11
  end
19
12
  end
20
13
  end
@@ -0,0 +1,14 @@
1
+ module Donald
2
+ class Environment
3
+ def self.editor_variable
4
+ editor = system_variable('EDITOR').chomp
5
+ editor.size.zero? ? nil : editor
6
+ end
7
+
8
+ private
9
+
10
+ def self.system_variable(name)
11
+ `echo $#{name}`
12
+ end
13
+ end
14
+ end
@@ -1,7 +1,7 @@
1
1
  module Donald
2
2
  class MergeTool
3
3
  def initialize(output, args = [])
4
- @output = output
4
+ @printer = Donald::Printer.new output
5
5
  @options = parse_options args
6
6
  end
7
7
 
@@ -9,16 +9,16 @@ module Donald
9
9
  files = Donald::Git.new.unmerged_files
10
10
 
11
11
  if files.any?
12
- print_files files
13
- call_vim files
12
+ @printer.print_files files
13
+ call_editor files
14
14
  else
15
- print_no_files_message
15
+ @printer.print_no_files_message
16
16
  end
17
17
  end
18
18
 
19
19
  private
20
20
 
21
- def call_vim(files)
21
+ def call_editor(files)
22
22
  Kernel.system "#{editor}#{arguments(editor)} #{files.join(' ')}"
23
23
  end
24
24
 
@@ -26,26 +26,6 @@ module Donald
26
26
  @editor || @editor = Donald::Editor.new(@options[:editor])
27
27
  end
28
28
 
29
- def print_files(files)
30
- print_delimiter
31
-
32
- files.each {|f| @output.puts f}
33
-
34
- print_delimiter
35
- end
36
-
37
- def print_no_files_message
38
- print_delimiter
39
-
40
- @output.puts 'No unmerged files found'
41
-
42
- print_delimiter
43
- end
44
-
45
- def print_delimiter
46
- @output.puts '*' * 30
47
- end
48
-
49
29
  def parse_options(args)
50
30
  options = {}
51
31
 
@@ -0,0 +1,33 @@
1
+ module Donald
2
+ class Printer
3
+ def initialize(output)
4
+ @output = output
5
+ end
6
+
7
+ def print_files(files)
8
+ print_delimiter do
9
+ files.each {|f| @output.puts f}
10
+ end
11
+ end
12
+
13
+ def print_no_files_message
14
+ print_delimiter do
15
+ @output.puts 'No unmerged files found'
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def print_delimiter
22
+ print_single_delimiter
23
+ if block_given?
24
+ yield
25
+ print_single_delimiter
26
+ end
27
+ end
28
+
29
+ def print_single_delimiter
30
+ @output.puts '*' * 30
31
+ end
32
+ end
33
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: donald
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 7
10
- version: 0.1.7
9
+ - 8
10
+ version: 0.1.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bruno Grasselli
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-18 00:00:00 -03:00
18
+ date: 2010-08-21 00:00:00 -03:00
19
19
  default_executable: donald
20
20
  dependencies: []
21
21
 
@@ -33,6 +33,8 @@ files:
33
33
  - lib/donald.rb
34
34
  - lib/donald/git.rb
35
35
  - lib/donald/editor.rb
36
+ - lib/donald/printer.rb
37
+ - lib/donald/environment.rb
36
38
  - lib/donald/merge_tool.rb
37
39
  has_rdoc: true
38
40
  homepage: http://brunograsselli.com.br