countr 0.1.0
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 +31 -0
- data/Rakefile +6 -0
- data/bin/countr +56 -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 +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4e687aa8225f424a4371b8d1f2bdf1e97fe30932
|
4
|
+
data.tar.gz: c583606b40c14f2856f4e990a45195b46d975110
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ae4582c985ed922ecc58c3f728db811eb0fd0483d642c26f0e4e5f238eab565c616281a1fa4601d7214253d3b506ec2873bda3d2c6cd21348c3079dbdae432c2
|
7
|
+
data.tar.gz: 7eed54567bf931b875851d8a60fdd80161767ddb62174dee63e84fa07d3e5f4721dfb5430fc1be021c9022b24c60769ea4ae55146b32cbfd3bfe4b9c5e9586f6
|
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,31 @@
|
|
1
|
+
# Countr
|
2
|
+
|
3
|
+
Simple RubyGem that counts the number of characters in a string and displays it. 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.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
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
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
`countr string`
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/countr.
|
28
|
+
|
29
|
+
## License
|
30
|
+
|
31
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/countr
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
BINARY_NAME = $PROGRAM_NAME.split('/').last
|
6
|
+
|
7
|
+
def parse_options
|
8
|
+
options = {}
|
9
|
+
|
10
|
+
optparse = OptionParser.new do |opts|
|
11
|
+
opts.banner = "#{BINARY_NAME}: display the number of characters in a string\n"
|
12
|
+
opts.banner += "usage: countr string\n"
|
13
|
+
opts.banner += "Note: quotes and double-quotes will not be counted unless escaped with a \\"
|
14
|
+
|
15
|
+
opts.on('-v', '--version', 'Display version number and exit') do
|
16
|
+
puts "#{BINARY_NAME} v#{VERSION}"
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
|
20
|
+
opts.on('-h', '--help', 'Display this screen and exit') do
|
21
|
+
puts opts
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
optparse.parse!()
|
27
|
+
|
28
|
+
return options
|
29
|
+
end
|
30
|
+
|
31
|
+
def print_error(error)
|
32
|
+
case error
|
33
|
+
when OptionParser::InvalidOption
|
34
|
+
puts "#{BINARY_NAME}: illegal option #{error.args.join(' ')}"
|
35
|
+
else
|
36
|
+
puts "An unexpected error occurred while running #{BINARY_NAME}:"
|
37
|
+
puts " #{error}\n"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
begin
|
42
|
+
options = parse_options
|
43
|
+
|
44
|
+
count = 0
|
45
|
+
|
46
|
+
for i in 0..ARGV.length-1 do
|
47
|
+
count += ARGV[i].length
|
48
|
+
end
|
49
|
+
|
50
|
+
count += ARGV.length-1
|
51
|
+
|
52
|
+
puts count
|
53
|
+
rescue => error
|
54
|
+
print_error(error)
|
55
|
+
exit(false)
|
56
|
+
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", "~> 1.10"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
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,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: countr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Chadwick
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-29 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: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
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
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.4.6
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Displays the number of character in a string
|
100
|
+
test_files: []
|