wc 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/VERSION +1 -1
  2. data/bin/wc +2 -1
  3. data/lib/wc.rb +5 -1
  4. data/wc.gemspec +1 -1
  5. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.20.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
- puts 'json support is coming soon...'
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(ARGV[0], "r") { |f|
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wc}
8
- s.version = "0.20.0"
8
+ s.version = "0.21.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Paolo Perego"]
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: 79
4
+ hash: 75
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 20
8
+ - 21
9
9
  - 0
10
- version: 0.20.0
10
+ version: 0.21.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paolo Perego