word_counter 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 369c75efe673d26c303a3a337ec9ac52374f224a
4
- data.tar.gz: 8851cd6e31789b9ffce17a9e202ed168a8e6ffcc
3
+ metadata.gz: ad4762dc1f1983b67b2402185ce23df5426e3235
4
+ data.tar.gz: 49f3dc0d1daa4de2966a90bee9eade7aa0073f63
5
5
  SHA512:
6
- metadata.gz: e4a8b6d8b6347e2389f9da6f2d380094663f65e57a6e364fd7c5b52fb2c08ef4595202ff04c879426a9886e23bd562d46701ba8da432993e4059406bb45522ae
7
- data.tar.gz: 8b808a9111151250694eb470ff8472cc9cf5203c101b090e76eeb6dfbe3f4f601b5c6a48a32b42f7c9b946822f3ed48670c71ae1d8ab9e4bb78d7fe12415ac77
6
+ metadata.gz: 71af26195753cad0a620098d190da7ee48dffd8e124d2419bab04b2d7052a963af100db7f09f64f345c5d3b37fda601b8eb966672f940ea0c2385b5f8c49eaff
7
+ data.tar.gz: a9ab076b9c4533f53d5ade730c13bbbfbba9127c16e19f530070b1a0b09a3e364c464b04c70d7fae58ec9a88cfc4dd9caf52ed23bc0b1b701eb3dc33328d1158
data/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  Counts words from either a file or a website, and prints a report to stdout.
4
4
 
5
5
  [![Build Status](https://api.travis-ci.org/wulftone/word_counter.svg?branch=master)](http://travis-ci.org/wulftone/word_counter)
6
+ [![Gem Version](https://badge.fury.io/rb/word_counter.svg)](http://badge.fury.io/rb/word_counter)
6
7
 
7
8
  ## Installation
8
9
 
data/lib/word_counter.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "word_counter/version"
2
2
  require "net/http"
3
3
  require 'nokogiri'
4
+ require 'colorize'
4
5
 
5
6
  class NoFileError < StandardError; end
6
7
  class NoWebsiteError < StandardError; end
@@ -34,6 +35,11 @@ class WordCounter
34
35
  end
35
36
 
36
37
 
38
+ def colorize str
39
+ str.to_s.green.bold
40
+ end
41
+
42
+
37
43
  ##
38
44
  # Prints a report to stdout
39
45
  def report
@@ -46,8 +52,15 @@ class WordCounter
46
52
  }
47
53
 
48
54
  sorted_hash.each do |word, data|
49
- puts "#{data[:count]} #{word}"
50
- puts " #{data[:lines].join("\n ")}" if show_sentences?
55
+ puts colorize "#{data[:count]} #{word}"
56
+
57
+ i = 0
58
+ lines = data[:lines].map { |l|
59
+ i += 1
60
+ "#{i.to_s.red}: #{l}"
61
+ }.join("\n ")
62
+
63
+ puts " #{lines}" if show_sentences?
51
64
  end
52
65
  end
53
66
 
@@ -1,3 +1,3 @@
1
1
  class WordCounter
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -40,22 +40,22 @@ describe WordCounter do
40
40
  wc.report
41
41
  end
42
42
 
43
- printed.should eq "4 woof
44
- bark woof woof snort
45
- honk woof bark
46
- snort bark woof
43
+ printed.uncolorize.should eq "4 woof
44
+ 1: bark woof woof snort
45
+ 2: honk woof bark
46
+ 3: snort bark woof
47
47
  3 bark
48
- bark woof woof snort
49
- honk woof bark
50
- snort bark woof
48
+ 1: bark woof woof snort
49
+ 2: honk woof bark
50
+ 3: snort bark woof
51
51
  2 honk
52
- honk woof bark
53
- sniff sniff honk
52
+ 1: honk woof bark
53
+ 2: sniff sniff honk
54
54
  2 sniff
55
- sniff sniff honk
55
+ 1: sniff sniff honk
56
56
  2 snort
57
- bark woof woof snort
58
- snort bark woof
57
+ 1: bark woof woof snort
58
+ 2: snort bark woof
59
59
  "
60
60
  end
61
61
 
@@ -67,7 +67,7 @@ describe WordCounter do
67
67
  wc.report
68
68
  end
69
69
 
70
- printed.should eq "2 Domain
70
+ printed.uncolorize.should eq "2 Domain
71
71
  2 Example
72
72
  2 domain
73
73
  2 examples
@@ -105,6 +105,4 @@ describe WordCounter do
105
105
  url = WordCounter.urlize 'http://example.com'
106
106
  url.should eq 'http://example.com'
107
107
  end
108
-
109
-
110
108
  end
data/word_counter.gemspec CHANGED
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "pry-debugger"
26
26
 
27
27
  spec.add_dependency "nokogiri"
28
+ spec.add_dependency "colorize"
28
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: word_counter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - trevor bortins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-26 00:00:00.000000000 Z
11
+ date: 2014-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: colorize
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: Counts words in a file and prints them out in interesting ways.
98
112
  email:
99
113
  - trevor.bortins@gmail.com