countr 0.1.0 → 1.1.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 +5 -5
- data/README.md +11 -17
- data/Rakefile +0 -5
- data/bin/countr +27 -18
- data/countr.gemspec +2 -2
- data/lib/countr/version.rb +1 -1
- metadata +13 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0111eaad31daf911e5387485c8efcdcfa118ed58200398f4f593066d5051581c
|
4
|
+
data.tar.gz: 76b02a366af95e8ebe4252421488f73b7afd611a2cff58bd6c74762f57fafffd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2574e4e07a77962a80949a2f9bfa3934deccf8d9e27570d09cc5a0c9688afe1053c19c3160ab052a8c95ff81da92e3a40cd7616a2553c8d930dcaa3d404c527b
|
7
|
+
data.tar.gz: a9968f743b4bb1b1b2a5c86d1de40a2c5dbe451f33eb3827ac79775c03dbb0bb9ae028e90724a9573803489eddff3d23666f07c0cd56a320dcfd8bc338ae4ab2
|
data/README.md
CHANGED
@@ -1,30 +1,24 @@
|
|
1
1
|
# Countr
|
2
2
|
|
3
|
-
|
3
|
+
[](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
|
-
```ruby
|
10
|
-
gem 'countr'
|
11
|
-
```
|
12
|
-
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ 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.
|
20
8
|
|
21
9
|
## Usage
|
22
10
|
|
23
|
-
`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.`
|
24
18
|
|
25
19
|
## Contributing
|
26
20
|
|
27
|
-
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.
|
28
22
|
|
29
23
|
## License
|
30
24
|
|
data/Rakefile
CHANGED
data/bin/countr
CHANGED
@@ -1,23 +1,30 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'optparse'
|
4
|
+
require_relative '../lib/countr/version'
|
4
5
|
|
5
6
|
BINARY_NAME = $PROGRAM_NAME.split('/').last
|
6
7
|
|
7
8
|
def parse_options
|
8
|
-
options = {
|
9
|
+
options = {
|
10
|
+
:oneline => false
|
11
|
+
}
|
9
12
|
|
10
13
|
optparse = OptionParser.new do |opts|
|
11
|
-
opts.banner = "
|
12
|
-
opts.banner += "usage: countr
|
13
|
-
opts.banner += "
|
14
|
-
|
14
|
+
opts.banner = "Displays the number of characters in a string\n"
|
15
|
+
opts.banner += "usage: countr STRING\n"
|
16
|
+
opts.banner += "NOTE: quotes and double-quotes will not be counted unless escaped with a \\"
|
17
|
+
|
15
18
|
opts.on('-v', '--version', 'Display version number and exit') do
|
16
|
-
puts "#{
|
19
|
+
puts "#{Countr::VERSION}"
|
17
20
|
exit
|
18
21
|
end
|
19
|
-
|
20
|
-
opts.on('-
|
22
|
+
|
23
|
+
opts.on('-n', '--no-line-break', 'No newline when returning count') do
|
24
|
+
options[:oneline] = true
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on('-h', '-?', '--help', 'Display this screen and exit') do
|
21
28
|
puts opts
|
22
29
|
exit
|
23
30
|
end
|
@@ -31,10 +38,9 @@ end
|
|
31
38
|
def print_error(error)
|
32
39
|
case error
|
33
40
|
when OptionParser::InvalidOption
|
34
|
-
puts "#{BINARY_NAME}: illegal option #{error.args.join(' ')}"
|
41
|
+
puts "#{BINARY_NAME} ERROR: illegal option #{error.args.join(' ')}"
|
35
42
|
else
|
36
|
-
puts "
|
37
|
-
puts " #{error}\n"
|
43
|
+
puts "#{BINARY_NAME} ERROR: #{error}"
|
38
44
|
end
|
39
45
|
end
|
40
46
|
|
@@ -42,14 +48,17 @@ begin
|
|
42
48
|
options = parse_options
|
43
49
|
|
44
50
|
count = 0
|
45
|
-
|
46
|
-
|
47
|
-
|
51
|
+
words = ARGV.join(" ")
|
52
|
+
|
53
|
+
for i in 0..words.length-1 do
|
54
|
+
count += words[i].length
|
55
|
+
end
|
56
|
+
|
57
|
+
if options[:oneline]
|
58
|
+
print count
|
59
|
+
else
|
60
|
+
puts count
|
48
61
|
end
|
49
|
-
|
50
|
-
count += ARGV.length-1
|
51
|
-
|
52
|
-
puts count
|
53
62
|
rescue => error
|
54
63
|
print_error(error)
|
55
64
|
exit(false)
|
data/countr.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
spec.license = 'MIT'
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 1
|
22
|
-
spec.add_development_dependency "rake", "~>
|
21
|
+
spec.add_development_dependency "bundler", "~> 2.1"
|
22
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
24
|
end
|
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:
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Chadwick
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '2.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '12.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '12.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,7 +77,7 @@ homepage: http://rubygems.org/gems/countr
|
|
77
77
|
licenses:
|
78
78
|
- MIT
|
79
79
|
metadata: {}
|
80
|
-
post_install_message:
|
80
|
+
post_install_message:
|
81
81
|
rdoc_options: []
|
82
82
|
require_paths:
|
83
83
|
- lib
|
@@ -92,9 +92,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
|
96
|
-
|
97
|
-
signing_key:
|
95
|
+
rubygems_version: 3.1.4
|
96
|
+
signing_key:
|
98
97
|
specification_version: 4
|
99
98
|
summary: Displays the number of character in a string
|
100
|
-
test_files:
|
99
|
+
test_files:
|
100
|
+
- spec/count_spec.rb
|
101
|
+
- spec/spec_helper.rb
|