countr 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +25 -0
- data/Rakefile +1 -0
- data/bin/countr +65 -0
- data/countr.gemspec +24 -0
- data/lib/countr.rb +4 -0
- data/lib/countr/version.rb +3 -0
- data/spec/count_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0111eaad31daf911e5387485c8efcdcfa118ed58200398f4f593066d5051581c
|
4
|
+
data.tar.gz: 76b02a366af95e8ebe4252421488f73b7afd611a2cff58bd6c74762f57fafffd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2574e4e07a77962a80949a2f9bfa3934deccf8d9e27570d09cc5a0c9688afe1053c19c3160ab052a8c95ff81da92e3a40cd7616a2553c8d930dcaa3d404c527b
|
7
|
+
data.tar.gz: a9968f743b4bb1b1b2a5c86d1de40a2c5dbe451f33eb3827ac79775c03dbb0bb9ae028e90724a9573803489eddff3d23666f07c0cd56a320dcfd8bc338ae4ab2
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Michael Chadwick
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Countr
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/countr.svg)](http://badge.fury.io/rb/countr)
|
4
|
+
|
5
|
+
A simple RubyGem that counts the number of characters in a string and displays it.
|
6
|
+
|
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.
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
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.`
|
18
|
+
|
19
|
+
## Contributing
|
20
|
+
|
21
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/michaelchadwick/countr.
|
22
|
+
|
23
|
+
## License
|
24
|
+
|
25
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/countr
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require_relative '../lib/countr/version'
|
5
|
+
|
6
|
+
BINARY_NAME = $PROGRAM_NAME.split('/').last
|
7
|
+
|
8
|
+
def parse_options
|
9
|
+
options = {
|
10
|
+
:oneline => false
|
11
|
+
}
|
12
|
+
|
13
|
+
optparse = OptionParser.new do |opts|
|
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
|
+
|
18
|
+
opts.on('-v', '--version', 'Display version number and exit') do
|
19
|
+
puts "#{Countr::VERSION}"
|
20
|
+
exit
|
21
|
+
end
|
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
|
28
|
+
puts opts
|
29
|
+
exit
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
optparse.parse!()
|
34
|
+
|
35
|
+
return options
|
36
|
+
end
|
37
|
+
|
38
|
+
def print_error(error)
|
39
|
+
case error
|
40
|
+
when OptionParser::InvalidOption
|
41
|
+
puts "#{BINARY_NAME} ERROR: illegal option #{error.args.join(' ')}"
|
42
|
+
else
|
43
|
+
puts "#{BINARY_NAME} ERROR: #{error}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
begin
|
48
|
+
options = parse_options
|
49
|
+
|
50
|
+
count = 0
|
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
|
61
|
+
end
|
62
|
+
rescue => error
|
63
|
+
print_error(error)
|
64
|
+
exit(false)
|
65
|
+
end
|
data/countr.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'countr/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "countr"
|
8
|
+
spec.version = Countr::VERSION
|
9
|
+
spec.authors = ["Michael Chadwick"]
|
10
|
+
spec.email = ["michael.chadwick@gmail.com"]
|
11
|
+
spec.homepage = 'http://rubygems.org/gems/countr'
|
12
|
+
spec.summary = 'Displays the number of character in a string'
|
13
|
+
spec.description = 'Simple RubyGem that takes a string and displays the number of characters'
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split("\n")
|
16
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
spec.license = 'MIT'
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 2.1"
|
22
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
data/lib/countr.rb
ADDED
data/spec/count_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: countr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Chadwick
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.1'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '12.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '12.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Simple RubyGem that takes a string and displays the number of characters
|
56
|
+
email:
|
57
|
+
- michael.chadwick@gmail.com
|
58
|
+
executables:
|
59
|
+
- countr
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/countr
|
71
|
+
- countr.gemspec
|
72
|
+
- lib/countr.rb
|
73
|
+
- lib/countr/version.rb
|
74
|
+
- spec/count_spec.rb
|
75
|
+
- spec/spec_helper.rb
|
76
|
+
homepage: http://rubygems.org/gems/countr
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubygems_version: 3.1.4
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Displays the number of character in a string
|
99
|
+
test_files:
|
100
|
+
- spec/count_spec.rb
|
101
|
+
- spec/spec_helper.rb
|