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.
@@ -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
@@ -0,0 +1,16 @@
1
+ n
2
+ nn
3
+ n
4
+ charhash[i] = charhash[i] + 1
5
+ i.to_s
6
+ n
7
+ charhash[i] = count
8
+ n
9
+ i = "n"
10
+ charhash[i] = charhash[i] + 1
11
+ charhash.key?(i)
12
+ i.to_s
13
+ charhash[i]
14
+ charhash[i] = count
15
+ n
16
+ @string.split("").each do |i|
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in chars_count.gemspec
6
+ gemspec
7
+
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ chars_count (0.1.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.5.0)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.17)
16
+ chars_count!
17
+ rake (~> 10.0)
18
+
19
+ BUNDLED WITH
20
+ 1.17.2
@@ -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.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -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__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -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
@@ -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
@@ -0,0 +1,3 @@
1
+ module CharsCount
2
+ VERSION = "0.1.2"
3
+ 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: []