countr 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -19
- data/Rakefile +0 -5
- data/bin/countr +15 -17
- data/lib/countr/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1ef959647b95149f6234b8f35885636436a8c89
|
4
|
+
data.tar.gz: 4d13a631e71e025be0ccb15310e68182cd6ca893
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4fde3c410a5c02ea57a1c609723404136be6fbe00c05de2318a6b3cbe5f584a5c47c68c9a089b2aeb6bbf8cd9e6428b1a04c87c0925a14c5f1bf974f7479706
|
7
|
+
data.tar.gz: 024b31e1b172c68fd8ba6d62800740473a457b5941f528ade0ad15e396ffe4c83d8fbf766a67920a89c97f88e78ab132261d8ad6d65af7e07c79e7e23d369913
|
data/README.md
CHANGED
@@ -1,32 +1,24 @@
|
|
1
1
|
# Countr
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/countr.svg)](http://badge.fury.io/rb/countr)
|
4
4
|
|
5
|
-
|
5
|
+
A simple RubyGem that counts the number of characters in a string and displays it.
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'countr'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install countr
|
7
|
+
*NOTE:* Make sure to escape any quotes (`\\'`) or double-quotes (`\\"`) (if'n your string has something quoted, for example) so that they are included in the overall count.
|
22
8
|
|
23
9
|
## Usage
|
24
10
|
|
25
|
-
`countr
|
11
|
+
`countr STRING`
|
12
|
+
|
13
|
+
Examples:
|
14
|
+
* Tweet length:
|
15
|
+
`$ countr \@username and then I said \"OMG this new rubygem called \'countr\' is super-cool!\"`
|
16
|
+
* Arbitrary sentence:
|
17
|
+
`$ countr Sundry items have a way of creeping into your subconscious, whether your mind lingered on them for long or not.`
|
26
18
|
|
27
19
|
## Contributing
|
28
20
|
|
29
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
21
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/michaelchadwick/countr.
|
30
22
|
|
31
23
|
## License
|
32
24
|
|
data/Rakefile
CHANGED
data/bin/countr
CHANGED
@@ -9,16 +9,16 @@ def parse_options
|
|
9
9
|
options = {}
|
10
10
|
|
11
11
|
optparse = OptionParser.new do |opts|
|
12
|
-
opts.banner = "
|
13
|
-
opts.banner += "usage: countr
|
14
|
-
opts.banner += "
|
15
|
-
|
12
|
+
opts.banner = "Displays the number of characters in a string\n"
|
13
|
+
opts.banner += "usage: countr STRING\n"
|
14
|
+
opts.banner += "NOTE: quotes and double-quotes will not be counted unless escaped with a \\"
|
15
|
+
|
16
16
|
opts.on('-v', '--version', 'Display version number and exit') do
|
17
|
-
puts "#{
|
17
|
+
puts "#{Countr::VERSION}"
|
18
18
|
exit
|
19
19
|
end
|
20
|
-
|
21
|
-
opts.on('-h', '--help', 'Display this screen and exit') do
|
20
|
+
|
21
|
+
opts.on('-h', '-?', '--help', 'Display this screen and exit') do
|
22
22
|
puts opts
|
23
23
|
exit
|
24
24
|
end
|
@@ -32,10 +32,9 @@ end
|
|
32
32
|
def print_error(error)
|
33
33
|
case error
|
34
34
|
when OptionParser::InvalidOption
|
35
|
-
puts "#{BINARY_NAME}: illegal option #{error.args.join(' ')}"
|
35
|
+
puts "#{BINARY_NAME} ERROR: illegal option #{error.args.join(' ')}"
|
36
36
|
else
|
37
|
-
puts "
|
38
|
-
puts " #{error}\n"
|
37
|
+
puts "#{BINARY_NAME} ERROR: #{error}"
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
@@ -43,14 +42,13 @@ begin
|
|
43
42
|
options = parse_options
|
44
43
|
|
45
44
|
count = 0
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
words = ARGV.join(" ")
|
46
|
+
|
47
|
+
for i in 0..words.length-1 do
|
48
|
+
count += words[i].length
|
49
49
|
end
|
50
|
-
|
51
|
-
count
|
52
|
-
|
53
|
-
puts count
|
50
|
+
|
51
|
+
print count
|
54
52
|
rescue => error
|
55
53
|
print_error(error)
|
56
54
|
exit(false)
|
data/lib/countr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: countr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Chadwick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
95
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.5.0
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Displays the number of character in a string
|