monkey_sort 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2c876082f349600cc2f6ecfd59407467da7091c95aca155c38ed742defec6ca7
4
+ data.tar.gz: 7a68a5ed4c2f345371312d48faa854263119eb11faf5b7453af837bda1eacccf
5
+ SHA512:
6
+ metadata.gz: 7eb22df6eaada4749eb7fee5af7970454b6b5576a8c5de009bf2931aa91c903f45ef2f7dccd44f95cfdf80994d7a2e849e2d1948eec9a560c9980bf5dfeab893
7
+ data.tar.gz: 930d75c51dc5ea05283006d9695d48010d04dc3af62eb9ab6e5e27813d5b9b25f6d31c7addd59ad6980416e0c05dcce67137866abaa31615973fdfd9d4ea5b22
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ Gemfile
3
+ Gemfile.lock
4
+ doc
5
+ pkg
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/MIT-LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2018 megosparta
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # MonkeySort
2
+
3
+ ## Installation
4
+
5
+ ``` gem install monkey_sort ```
6
+
7
+ ## Usage
8
+
9
+ ```ruby
10
+ 'simple'.mokey_sort #=> 'eilmps'
11
+ ['s', 'i', 'm', 'p', 'l', 'e'].mokey_sort #=> ['e', 'i', 'l', 'm', 'p', 's']
12
+ ```
13
+
14
+ ## Author
15
+
16
+ megosparta (megosparta)
17
+
18
+ ## License
19
+
20
+ Copyright (c) 2018 megosparta
21
+
22
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
23
+ this software and associated documentation files (the "Software"), to deal in
24
+ the Software without restriction, including without limitation the rights to
25
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
26
+ the Software, and to permit persons to whom the Software is furnished to do so,
27
+ subject to the following conditions:
28
+
29
+ The above copyright notice and this permission notice shall be included in all
30
+ copies or substantial portions of the Software.
31
+
32
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
34
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
35
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
36
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
37
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler/gem_tasks'
2
+ task default: :spec
@@ -0,0 +1,2 @@
1
+ require_relative 'monkey_sort/array'
2
+ require_relative 'monkey_sort/string'
@@ -0,0 +1,14 @@
1
+ class Array
2
+ def sorted?
3
+ (self.length - 1).times { |i| return false if self[i] > self[i+1] }
4
+ true
5
+ end
6
+
7
+ def monkey_sort
8
+ loop do
9
+ break if sorted?
10
+ self.shuffle!
11
+ end
12
+ self
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ class String
2
+ def monkey_sort
3
+ self.split('').monkey_sort.join
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ module MonkeySort
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ TINY = 1
6
+ BUILD = nil
7
+ STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ require File.expand_path("../lib/monkey_sort/version", __FILE__)
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.authors = ['Mario_Sparta']
5
+ spec.email = ['megosparta@mail.ru']
6
+ spec.description = 'Lucky sort'
7
+ spec.summary = 'Lucky sort'
8
+ spec.homepage = "http://github.com/megosparta@mail.ru/monkey_sort"
9
+ spec.license = 'MIT'
10
+ spec.platform = Gem::Platform::RUBY
11
+
12
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
13
+ f.match(%r{^(test|spec|features)/})
14
+ end
15
+ spec.name = "monkey_sort"
16
+ spec.require_paths = ['lib']
17
+
18
+ spec.version = MonkeySort::Version::STRING
19
+ spec.add_development_dependency 'bundler', '~> 1.16', '>= 1.16.1'
20
+ spec.add_development_dependency 'rake', '~> 10.5'
21
+ spec.add_development_dependency 'rspec', '~> 3.7'
22
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: monkey_sort
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mario_Sparta
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-12-17 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.16'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.16.1
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.16'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.16.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '10.5'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '10.5'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.7'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.7'
61
+ description: Lucky sort
62
+ email:
63
+ - megosparta@mail.ru
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - ".gitignore"
69
+ - ".rspec"
70
+ - MIT-LICENSE
71
+ - README.md
72
+ - Rakefile
73
+ - lib/monkey_sort.rb
74
+ - lib/monkey_sort/array.rb
75
+ - lib/monkey_sort/string.rb
76
+ - lib/monkey_sort/version.rb
77
+ - monkey_sort.gemspec
78
+ homepage: http://github.com/megosparta@mail.ru/monkey_sort
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.7.8
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: Lucky sort
102
+ test_files: []