water 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/water.rb +22 -6
  2. data/water.gemspec +1 -1
  3. metadata +1 -1
data/lib/water.rb CHANGED
@@ -1,16 +1,32 @@
1
1
  require 'coderay'
2
2
  require 'launchy'
3
3
 
4
- module Water
4
+ class Water
5
5
  DIFF_FILE_NAME = 'diff.html'
6
6
 
7
7
  def self.run
8
- # FIXME: Don't just write into the currend folder.
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(ARGF.read, :diff).page
25
+ file.write CodeRay.scan(@diff, :diff).page
11
26
  end
12
-
13
- url = "file://#{File.join Dir.pwd, DIFF_FILE_NAME}"
14
- Launchy.open url
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
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "water"
6
- s.version = '0.2'
6
+ s.version = '0.2.1'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Kornelius Kalnbach"]
9
9
  s.email = ["murphy@rubychan.de"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: water
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "0.2"
5
+ version: 0.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kornelius Kalnbach