nmax1000 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e652c38220f4fb5463551d5f3019edc262e3ea780c69fec0dd5d8b939bfaeee
4
- data.tar.gz: 7e5eaece9fa39e0f106597d8cf570cee3b6cbc1dd7219b96a87658b713b65c9e
3
+ metadata.gz: c18c7bdc942335a1fb7d101846ea1698a825bbd36363c3503333f8a185dd2f0a
4
+ data.tar.gz: 94fb6867287b8bb73d31741b49ced35abf94790e29a242a9ac2f3ad04fc982a3
5
5
  SHA512:
6
- metadata.gz: dce6f594562c9ebc8407a2e9fbf08571761601265f17ce79d23653dc3213de4f11f43d54d14c9b4d2e7894ec3505e1b2915360f75f481ceec79ea7a7962f50d0
7
- data.tar.gz: 101b0fe3d60b08ac21f21e7600980933035443d7336a1a4ae8e849edb5d7291bbbde1d1b5b6f927049c550aba2c93cf976020fee266a130e4510ad63ebba2d3c
6
+ metadata.gz: e94647407fccdd3ce2536b9495deb2cf9771748948427802c251aa0a30696701335b5b58adb9ff6935f4bc7ae54a49e8c596c5c31443a0302237d721feab38ba
7
+ data.tar.gz: ff6087918c1edf6e7f802fe0a70147b40808ddad2eb7d4ae353321af8661b80435a12efc3c2f6f53c1337491c45a6af20ff0e2a7aebaa4281fd59253492e4fe1
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 1.16.4
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 nmax1000.gemspec
6
+ gemspec
7
+ gem 'pry'
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Oleg Suchkov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # Nmax1000
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/nmax1000`. 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 'nmax1000'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install nmax1000
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. Then, run `rake test` to run the tests. 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]/nmax1000.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "nmax1000"
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,9 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH << './lib'
3
+
4
+ # (C) Oleg Suchkov (olgkv)
5
+ # MIT licence
6
+
7
+ require 'nmax1000'
8
+
9
+ Nmax1000::Nmax.new(ARGV[0].to_i)
@@ -0,0 +1,60 @@
1
+ require 'nmax1000/version'
2
+ require 'pp'
3
+
4
+ module Nmax1000
5
+ class Nmax
6
+ def initialize(amount_of_max_numbers)
7
+ exit 1 if amount_of_max_numbers < 0
8
+ @amount_of_max_numbers = amount_of_max_numbers
9
+ @max_numbers = []
10
+ @input = $stdin
11
+ result
12
+ end
13
+
14
+ def result
15
+ loop do
16
+ num = read_number
17
+ next if num.empty?
18
+
19
+ add_number_to_array(num)
20
+ @max_numbers.sort!.uniq!
21
+
22
+ break if @input.eof
23
+ end
24
+
25
+ print_result
26
+ exit 0
27
+ end
28
+
29
+ def read_number
30
+ number_string = ''
31
+ char = @input.getc
32
+ until /[^\d-]/.match? char
33
+ next if char.nil?
34
+
35
+ number_string += char
36
+ break if @input.eof
37
+
38
+ char = @input.getc
39
+ end
40
+ number_string
41
+ end
42
+
43
+ def add_number_to_array(num)
44
+ @max_numbers << num.to_i if @max_numbers.empty?
45
+
46
+ if @max_numbers.size == @amount_of_max_numbers
47
+ if @max_numbers.first < num.to_i
48
+ @max_numbers.shift
49
+ @max_numbers.unshift(num.to_i)
50
+ end
51
+ else
52
+ @max_numbers << num.to_i
53
+ end
54
+ end
55
+
56
+ def print_result
57
+ pp @max_numbers
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ module Nmax1000
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,38 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "nmax1000/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nmax1000"
8
+ spec.version = Nmax1000::VERSION
9
+ spec.authors = ["Oleg Suchkov"]
10
+ spec.email = ["2oleg.ru@gmail.com"]
11
+
12
+ spec.summary = 'It sorts whole integers from sdtin'
13
+ # spec.description = %q{TODO: Write a longer description or delete this line.}
14
+ spec.homepage = 'http://rubygems.org/gems/nmax1000'
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ # Specify which files should be added to the gem when it is released.
27
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
+ end
31
+ spec.bindir = "exe"
32
+ spec.executables = ['nmax1000']
33
+ spec.require_paths = ["lib"]
34
+
35
+ spec.add_development_dependency "bundler", "~> 1.16"
36
+ spec.add_development_dependency "rake", "~> 10.0"
37
+ spec.add_development_dependency "minitest", "~> 5.0"
38
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nmax1000
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Suchkov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-09 00:00:00.000000000 Z
11
+ date: 2018-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -25,40 +25,53 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.16'
27
27
  - !ruby/object:Gem::Dependency
28
- name: minitest
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '5.0'
33
+ version: '10.0'
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: '5.0'
40
+ version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '5.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '5.0'
55
55
  description:
56
56
  email:
57
57
  - 2oleg.ru@gmail.com
58
- executables: []
58
+ executables:
59
+ - nmax1000
59
60
  extensions: []
60
61
  extra_rdoc_files: []
61
- files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - exe/nmax1000
72
+ - lib/nmax1000.rb
73
+ - lib/nmax1000/version.rb
74
+ - nmax1000.gemspec
62
75
  homepage: http://rubygems.org/gems/nmax1000
63
76
  licenses:
64
77
  - MIT
@@ -82,5 +95,5 @@ rubyforge_project:
82
95
  rubygems_version: 2.7.6
83
96
  signing_key:
84
97
  specification_version: 4
85
- summary: Sort whole integers from sdtin
98
+ summary: It sorts whole integers from sdtin
86
99
  test_files: []