test_my_gem 0.1.0

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: 66deab917873e2c785aee456a7367ecd26f61c3284fc6d1bdd281aadbd437efd
4
+ data.tar.gz: aa72b01f4ed7d17b04c117624960f984eaf80b7908745073b97a5bcff1cac659
5
+ SHA512:
6
+ metadata.gz: dcb2fe148697bcd8c1f3ddd06883e7401b2b5204a8b21b003c34f2e5d0cf3efffecbc895c6f0728778de5f1a9c6b597e1e27c0b7d09b58285a9f6017f5ee1f32
7
+ data.tar.gz: c98868a2a69379246e826fdb30fe4410bca5ad3f46a60a01dba10a2e59d36764a8c33a1001ff4c7c442762b678b0a78799ab6f39bf48fc28fc09d049041670ae
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ *.gem
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in test_my_gem.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
@@ -0,0 +1,34 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ test_my_gem (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.4.4)
10
+ rake (12.3.3)
11
+ rspec (3.9.0)
12
+ rspec-core (~> 3.9.0)
13
+ rspec-expectations (~> 3.9.0)
14
+ rspec-mocks (~> 3.9.0)
15
+ rspec-core (3.9.2)
16
+ rspec-support (~> 3.9.3)
17
+ rspec-expectations (3.9.2)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.9.0)
20
+ rspec-mocks (3.9.1)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.9.0)
23
+ rspec-support (3.9.3)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ rake (~> 12.0)
30
+ rspec (~> 3.0)
31
+ test_my_gem!
32
+
33
+ BUNDLED WITH
34
+ 2.1.4
@@ -0,0 +1,36 @@
1
+ # TestMyGem
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/test_my_gem`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'test_my_gem'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install test_my_gem
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/test_my_gem.
36
+
@@ -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 "test_my_gem"
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,7 @@
1
+ require "test_my_gem/version"
2
+ require "test_my_gem/game"
3
+
4
+ module TestMyGem
5
+ class Error < StandardError; end
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,73 @@
1
+ module Codebreaker
2
+ class Game
3
+ NUMBER_ATTEMPTS = 3
4
+ HINTS = 4
5
+
6
+ attr_reader :attempts,:hints,:secret_code
7
+
8
+ def initialize
9
+ @secret_code = random
10
+ @attempts = NUMBER_ATTEMPTS
11
+ @hints = HINTS
12
+ @exit = false
13
+ end
14
+
15
+ def random
16
+ [6,5,4,3]
17
+ end
18
+
19
+ def guess(code)
20
+ no_attempts
21
+ @code = code.split('').map(&:to_i)
22
+ @attempts -= 1
23
+ win
24
+ mark
25
+ end
26
+
27
+ def exit_with_status(message)
28
+ @exit = true
29
+ @status = message
30
+ end
31
+
32
+ def win
33
+ return exit_with_status('Congratulations, you win!') if @code == @secret_code
34
+ end
35
+
36
+ def no_attempts
37
+ return exit_with_status('Game over! You have no more attempts') if @attempts == 0
38
+ end
39
+
40
+ def hint
41
+ return "You don't have any hints." if @hints == 0
42
+ @hints -=1
43
+ @secret_code.sample
44
+ end
45
+
46
+ def mark
47
+ array_code = Array.new(@code)
48
+ array_secret_code = Array.new(@secret_code)
49
+ answer = []
50
+ array_code.zip(array_secret_code).each_with_index do |(code, secret_code), i|
51
+ next if code != secret_code
52
+ array_secret_code[i], array_code[i] = nil
53
+ answer << '+'
54
+ end
55
+ array_code.compact!
56
+ array_secret_code.compact!
57
+ array_code.map do |code|
58
+ index = code && array_secret_code.index(code)
59
+ next unless index
60
+ array_secret_code[index] = nil
61
+ answer << '-'
62
+ end
63
+ answer.join if @exit == false
64
+ end
65
+ def exit?
66
+ @exit
67
+ end
68
+ def statistik
69
+ "Status: #{@status}, Secret code: #{@secret_code}, attempts left: #{@attempts}, hints left: #{@hints}"
70
+ end
71
+ end
72
+ end
73
+
@@ -0,0 +1,3 @@
1
+ module TestMyGem
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,27 @@
1
+ require_relative 'lib/test_my_gem/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "test_my_gem"
5
+ spec.version = TestMyGem::VERSION
6
+ spec.authors = ["MaratMustafin"]
7
+ spec.email = ["sampplayer2@gmail.com"]
8
+
9
+ spec.summary = %q{Test gem}
10
+ spec.description = %q{A high level}
11
+ spec.homepage = "https://github.com/MaratMustafin/test_my_gem"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
15
+
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: test_my_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - MaratMustafin
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-07-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ description: A high level
28
+ email:
29
+ - sampplayer2@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - README.md
39
+ - Rakefile
40
+ - bin/console
41
+ - bin/setup
42
+ - lib/test_my_gem.rb
43
+ - lib/test_my_gem/game.rb
44
+ - lib/test_my_gem/version.rb
45
+ - test_my_gem.gemspec
46
+ homepage: https://github.com/MaratMustafin/test_my_gem
47
+ licenses: []
48
+ metadata:
49
+ allowed_push_host: https://rubygems.org
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 2.3.0
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubygems_version: 3.1.4
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Test gem
69
+ test_files: []