countr 0.1.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -19
  3. data/Rakefile +0 -5
  4. data/bin/countr +15 -17
  5. data/lib/countr/version.rb +1 -1
  6. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bba26f804ea70fa13931bca5a8a42dbfa41bfe2c
4
- data.tar.gz: fef768d6e9e2be0ec02029b54898dd5fe900d503
3
+ metadata.gz: c1ef959647b95149f6234b8f35885636436a8c89
4
+ data.tar.gz: 4d13a631e71e025be0ccb15310e68182cd6ca893
5
5
  SHA512:
6
- metadata.gz: 173235c3a69d00d086ea22ee5eb3029c67e061b4bbe625fbec77aa93e072e8260003bb7234b144dccb713763f1dc6772c3382b240828577ce22c220bfa101087
7
- data.tar.gz: 9b3c0e43d5917add99191224df9e2f283792e56216adbbe23371bfdd7633403789f40f2b8b3537f00199b7bdd59e57e52749d6b7bbf3d138c466f96b188b9cd6
6
+ metadata.gz: b4fde3c410a5c02ea57a1c609723404136be6fbe00c05de2318a6b3cbe5f584a5c47c68c9a089b2aeb6bbf8cd9e6428b1a04c87c0925a14c5f1bf974f7479706
7
+ data.tar.gz: 024b31e1b172c68fd8ba6d62800740473a457b5941f528ade0ad15e396ffe4c83d8fbf766a67920a89c97f88e78ab132261d8ad6d65af7e07c79e7e23d369913
data/README.md CHANGED
@@ -1,32 +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
- Example usage (for checking tweet length): `countr \@username and then I said \"OMG this new rubygem called \'countr\' is super-cool!\"`
5
+ A simple RubyGem that counts the number of characters in a string and displays it.
6
6
 
7
- ## Installation
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 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.`
26
18
 
27
19
  ## Contributing
28
20
 
29
- 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.
30
22
 
31
23
  ## License
32
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
@@ -9,16 +9,16 @@ def parse_options
9
9
  options = {}
10
10
 
11
11
  optparse = OptionParser.new do |opts|
12
- opts.banner = "#{BINARY_NAME}: display 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
-
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 "#{BINARY_NAME} v#{Countr::VERSION}"
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 "An unexpected error occurred while running #{BINARY_NAME}:"
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
- for i in 0..ARGV.length-1 do
48
- count += ARGV[i].length
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 += ARGV.length-1
52
-
53
- puts count
50
+
51
+ print count
54
52
  rescue => error
55
53
  print_error(error)
56
54
  exit(false)
@@ -1,3 +1,3 @@
1
1
  module Countr
2
- VERSION = '0.1.2'
2
+ VERSION = '1.0.0'
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.2
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-08-18 00:00:00.000000000 Z
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.4.8
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