chars_count 0.1.2
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 +7 -0
- data/.byebug_history +16 -0
- data/.gitignore +8 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +20 -0
- data/README.md +57 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/chars_count.gemspec +40 -0
- data/lib/chars_count.rb +26 -0
- data/lib/chars_count/version.rb +3 -0
- metadata +81 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0af0372bec0b4f6e8a6d1731a357afcd6d893150760367754a7d0a37816be2df
|
|
4
|
+
data.tar.gz: 98932a243b86be7c87add4b5e9c5d52d2e165ba6bc4e2d0650d72879a808cd3e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5cf3ac762bbbce935683eb088502cc39af090d333e50661b0155345fc325e77a1f99481f01b51a95c30c69c34d9cdf678f38b29e2b4959eb7b0c26eb31d6c5fb
|
|
7
|
+
data.tar.gz: cd5511e441239360e9a0456fef3ebf3af15e8fe2d2bb5c9cb19f5071bc974b9f2fe0e2605bd596240b6f73ec3f369262f15e6e078a68ad512a461cb8c812c7a1
|
data/.byebug_history
ADDED
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# CharsCount
|
|
2
|
+
|
|
3
|
+
Welcome to CharsCount gem!.
|
|
4
|
+
By this Gem you can get a characters count in a string or paragraph
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Add this line to your application's Gemfile:
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
gem 'chars_count'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
And then execute:
|
|
15
|
+
|
|
16
|
+
$ bundle
|
|
17
|
+
|
|
18
|
+
Or install it yourself as:
|
|
19
|
+
|
|
20
|
+
$ gem install chars_count
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
obj = CharsCount::Chars.new
|
|
25
|
+
|
|
26
|
+
string_count = obj.count("example")
|
|
27
|
+
|
|
28
|
+
## Output for above example
|
|
29
|
+
|
|
30
|
+
it returns output as
|
|
31
|
+
|
|
32
|
+
string_count = [["a", 1], ["e", 2], ["l", 1], ["m", 1], ["p", 1], ["x", 1]]
|
|
33
|
+
|
|
34
|
+
or You can write code as
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
string_count.each do |key, value|
|
|
38
|
+
puts "#{key} is #{value}"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
output:
|
|
42
|
+
a is 1
|
|
43
|
+
e is 2
|
|
44
|
+
l is 1
|
|
45
|
+
m is 1
|
|
46
|
+
p is 1
|
|
47
|
+
x is 1
|
|
48
|
+
|
|
49
|
+
## Development
|
|
50
|
+
|
|
51
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
52
|
+
|
|
53
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
54
|
+
|
|
55
|
+
## Contributing
|
|
56
|
+
|
|
57
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/chars_count.
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "chars_count"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/chars_count.gemspec
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "chars_count/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "chars_count"
|
|
8
|
+
spec.version = CharsCount::VERSION
|
|
9
|
+
spec.authors = ["naveen goli"]
|
|
10
|
+
spec.email = ["naveengoli313@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{it counts each characters in a string}
|
|
13
|
+
spec.description = %q{it counts each characters in a string}
|
|
14
|
+
spec.homepage = "https://github.com/naveen80088/chars_count"
|
|
15
|
+
|
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
17
|
+
# # to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
18
|
+
# if spec.respond_to?(:metadata)
|
|
19
|
+
# spec.metadata["allowed_push_host"] = "https://rubygems.org/profiles/naveen80088"
|
|
20
|
+
|
|
21
|
+
# # spec.metadata["homepage_uri"] = spec.homepage
|
|
22
|
+
# # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
|
23
|
+
# # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
|
24
|
+
# else
|
|
25
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
|
26
|
+
# "public gem pushes."
|
|
27
|
+
# end
|
|
28
|
+
|
|
29
|
+
# Specify which files should be added to the gem when it is released.
|
|
30
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
31
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
32
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
33
|
+
end
|
|
34
|
+
spec.bindir = "exe"
|
|
35
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
36
|
+
spec.require_paths = ["lib"]
|
|
37
|
+
|
|
38
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
|
39
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
40
|
+
end
|
data/lib/chars_count.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require "chars_count/version"
|
|
2
|
+
|
|
3
|
+
module CharsCount
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Error < StandardError; end
|
|
7
|
+
|
|
8
|
+
class Chars
|
|
9
|
+
def count(string)
|
|
10
|
+
@string = string
|
|
11
|
+
charhash = Hash.new
|
|
12
|
+
count = 1
|
|
13
|
+
|
|
14
|
+
@string.split("").each do |i|
|
|
15
|
+
if (charhash.key?(i))
|
|
16
|
+
charhash[i] = charhash[i] + 1
|
|
17
|
+
else
|
|
18
|
+
charhash[i] = count
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
return charhash.sort
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: chars_count
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- naveen goli
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-02-27 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.17'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.17'
|
|
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
|
+
description: it counts each characters in a string
|
|
42
|
+
email:
|
|
43
|
+
- naveengoli313@gmail.com
|
|
44
|
+
executables: []
|
|
45
|
+
extensions: []
|
|
46
|
+
extra_rdoc_files: []
|
|
47
|
+
files:
|
|
48
|
+
- ".byebug_history"
|
|
49
|
+
- ".gitignore"
|
|
50
|
+
- Gemfile
|
|
51
|
+
- Gemfile.lock
|
|
52
|
+
- README.md
|
|
53
|
+
- Rakefile
|
|
54
|
+
- bin/console
|
|
55
|
+
- bin/setup
|
|
56
|
+
- chars_count.gemspec
|
|
57
|
+
- lib/chars_count.rb
|
|
58
|
+
- lib/chars_count/version.rb
|
|
59
|
+
homepage: https://github.com/naveen80088/chars_count
|
|
60
|
+
licenses: []
|
|
61
|
+
metadata: {}
|
|
62
|
+
post_install_message:
|
|
63
|
+
rdoc_options: []
|
|
64
|
+
require_paths:
|
|
65
|
+
- lib
|
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
|
+
requirements:
|
|
68
|
+
- - ">="
|
|
69
|
+
- !ruby/object:Gem::Version
|
|
70
|
+
version: '0'
|
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
requirements: []
|
|
77
|
+
rubygems_version: 3.0.3
|
|
78
|
+
signing_key:
|
|
79
|
+
specification_version: 4
|
|
80
|
+
summary: it counts each characters in a string
|
|
81
|
+
test_files: []
|