word_counter 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/word_counter.rb +15 -2
- data/lib/word_counter/version.rb +1 -1
- data/spec/word_counter_spec.rb +13 -15
- data/word_counter.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad4762dc1f1983b67b2402185ce23df5426e3235
|
4
|
+
data.tar.gz: 49f3dc0d1daa4de2966a90bee9eade7aa0073f63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
[](http://travis-ci.org/wulftone/word_counter)
|
6
|
+
[](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
|
-
|
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
|
|
data/lib/word_counter/version.rb
CHANGED
data/spec/word_counter_spec.rb
CHANGED
@@ -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
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.
|
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-
|
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
|