countr 0.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4e687aa8225f424a4371b8d1f2bdf1e97fe30932
4
- data.tar.gz: c583606b40c14f2856f4e990a45195b46d975110
2
+ SHA256:
3
+ metadata.gz: 0111eaad31daf911e5387485c8efcdcfa118ed58200398f4f593066d5051581c
4
+ data.tar.gz: 76b02a366af95e8ebe4252421488f73b7afd611a2cff58bd6c74762f57fafffd
5
5
  SHA512:
6
- metadata.gz: ae4582c985ed922ecc58c3f728db811eb0fd0483d642c26f0e4e5f238eab565c616281a1fa4601d7214253d3b506ec2873bda3d2c6cd21348c3079dbdae432c2
7
- data.tar.gz: 7eed54567bf931b875851d8a60fdd80161767ddb62174dee63e84fa07d3e5f4721dfb5430fc1be021c9022b24c60769ea4ae55146b32cbfd3bfe4b9c5e9586f6
6
+ metadata.gz: 2574e4e07a77962a80949a2f9bfa3934deccf8d9e27570d09cc5a0c9688afe1053c19c3160ab052a8c95ff81da92e3a40cd7616a2553c8d930dcaa3d404c527b
7
+ data.tar.gz: a9968f743b4bb1b1b2a5c86d1de40a2c5dbe451f33eb3827ac79775c03dbb0bb9ae028e90724a9573803489eddff3d23666f07c0cd56a320dcfd8bc338ae4ab2
data/README.md CHANGED
@@ -1,30 +1,24 @@
1
1
  # Countr
2
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.
3
+ [![Gem Version](https://badge.fury.io/rb/countr.svg)](http://badge.fury.io/rb/countr)
4
4
 
5
- ## Installation
5
+ A simple RubyGem that counts the number of characters in a string and displays it.
6
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
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 string`
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/[USERNAME]/countr.
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
@@ -1,6 +1 @@
1
1
  require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
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 = "#{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
-
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 "#{BINARY_NAME} v#{VERSION}"
19
+ puts "#{Countr::VERSION}"
17
20
  exit
18
21
  end
19
-
20
- opts.on('-h', '--help', 'Display this screen and exit') do
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 "An unexpected error occurred while running #{BINARY_NAME}:"
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
- for i in 0..ARGV.length-1 do
47
- count += ARGV[i].length
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)
@@ -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.10"
22
- spec.add_development_dependency "rake", "~> 10.0"
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
@@ -1,3 +1,3 @@
1
1
  module Countr
2
- VERSION = "0.1.0"
2
+ VERSION = '1.1.1'
3
3
  end
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.1.0
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: 2015-06-29 00:00:00.000000000 Z
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.10'
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.10'
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: '10.0'
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: '10.0'
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
- rubyforge_project:
96
- rubygems_version: 2.4.6
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