water 0.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/water.rb +22 -6
- data/water.gemspec +1 -1
- metadata +1 -1
data/lib/water.rb
CHANGED
@@ -1,16 +1,32 @@
|
|
1
1
|
require 'coderay'
|
2
2
|
require 'launchy'
|
3
3
|
|
4
|
-
|
4
|
+
class Water
|
5
5
|
DIFF_FILE_NAME = 'diff.html'
|
6
6
|
|
7
7
|
def self.run
|
8
|
-
|
8
|
+
new.run
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
@diff = ARGF.read
|
13
|
+
|
14
|
+
if @diff.chomp.empty?
|
15
|
+
puts 'Your diff is empty.'
|
16
|
+
else
|
17
|
+
write_diff_file
|
18
|
+
open_diff_file
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def write_diff_file
|
23
|
+
# FIXME: Don't just write into the current folder.
|
9
24
|
File.open DIFF_FILE_NAME, 'w' do |file|
|
10
|
-
file.write CodeRay.scan(
|
25
|
+
file.write CodeRay.scan(@diff, :diff).page
|
11
26
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
27
|
+
end
|
28
|
+
|
29
|
+
def open_diff_file
|
30
|
+
Launchy.open "file://#{File.join Dir.pwd, DIFF_FILE_NAME}"
|
15
31
|
end
|
16
32
|
end
|
data/water.gemspec
CHANGED