wc 0.20.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/wc +2 -1
- data/lib/wc.rb +5 -1
- data/wc.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.21.0
|
data/bin/wc
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'lib/Wc'
|
3
3
|
require 'getoptlong'
|
4
4
|
require 'rdoc/usage'
|
5
|
+
require 'json'
|
5
6
|
|
6
7
|
opts = GetoptLong.new(
|
7
8
|
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
@@ -42,7 +43,7 @@ if output == 'text'
|
|
42
43
|
w.to_text
|
43
44
|
end
|
44
45
|
if output == 'json'
|
45
|
-
|
46
|
+
w.to_json
|
46
47
|
end
|
47
48
|
if output == 'xml'
|
48
49
|
puts 'xml support is coming soon...'
|
data/lib/wc.rb
CHANGED
@@ -14,11 +14,15 @@ class Wc
|
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
17
|
+
def to_json
|
18
|
+
puts @hash.to_json
|
19
|
+
end
|
20
|
+
|
17
21
|
private
|
18
22
|
|
19
23
|
def read()
|
20
24
|
hash = Hash.new { |h, k| h[k] = 0 }
|
21
|
-
File.open(
|
25
|
+
File.open(@filename, "r") { |f|
|
22
26
|
f.each_line { |line|
|
23
27
|
words = line.split
|
24
28
|
words.each { |w| hash[w] += 1 }
|
data/wc.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 75
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 21
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.21.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Paolo Perego
|