haikunator_ru 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 455d991f5a484625b8664ad117b1e7bfdb3638f6d31ca3101112518c97ceff33
4
+ data.tar.gz: ca377f48ab22503ca9a12a3a74cc5c10889701a814cbcbb03ee87474a9134acd
5
+ SHA512:
6
+ metadata.gz: 8e5ee8dcbe7703cddef477b4f91d2466c14c8687a8b4ce24279bf3598a834dea89446dab72b41e4d06c8e2d6c4279a6cb60a98d65c029c870d4d5398e32e29ce
7
+ data.tar.gz: d70691e36e9d1b76f62f4f0edd9a01d63310b7981ec44ae22002e844f952789a0e937df913b3e241ebedc9c7f4fba7fe0e81d33bf7378b6a424acdd6865e30d7
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ .tool-versions
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ *.bundle
20
+ *.so
21
+ *.o
22
+ *.a
23
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,14 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Documentation:
8
+ Enabled: false
9
+
10
+ Style/RegexpLiteral:
11
+ Enabled: false
12
+
13
+ Metrics/LineLength:
14
+ Max: 90
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+ cache: bundler
3
+
4
+ rvm:
5
+ - 2.2.0
6
+ - 2.1.2
7
+ - 2.1.0
8
+ - 2.0.0
9
+
10
+ script: 'bundle exec rake'
11
+
12
+ notifications:
13
+ email:
14
+ on_failure: change
15
+ on_success: never
16
+ slack:
17
+ secure: j0pMnM5JiBxiNsFf1n4DtsNSSkmaSW6w8KRy9D5V0ArxPEr7GdlAVfmsgqFIsOCEnm7CvREvUDGEQqx2Y9oIUxjxtnKYhQgru+DG+dONZQIEtOyRGL4UQKYDms/843DnXKuHuFUVeAu7alL9sKFTXFqaVT/r+YRk79cGt4vdfYg=
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in haikunator.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Usman Bashir
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # HaikunatorRu
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/haikunator_ru.svg)](http://badge.fury.io/rb/haikunator_ru)
4
+
5
+ Generate Heroku-like memorable random names to use in your apps or anywhere else.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'haikunator_ru'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install haikunator_ru
20
+
21
+ ## Usage
22
+
23
+ HaikunatorRu is pretty simple. There is nothing to configure and it only has a single method, `.haikunate`:
24
+
25
+ ```ruby
26
+ HaikunatorRu.haikunate # => "грубая-снежинка-1142"
27
+
28
+ # Token range
29
+ HaikunatorRu.haikunate(100) # => "безымянная-звезда-13"
30
+
31
+ # Don't include the token
32
+ HaikunatorRu.haikunate(0) # => "длинный-цветок"
33
+
34
+ # Use a different delimiter
35
+ HaikunatorRu.haikunate(9999, '.') # => "свежий.лист.6743"
36
+
37
+ # No token, no delimiter
38
+ HaikunatorRu.haikunate(0, ' ') # => "зелёный огонь"
39
+ ```
40
+
41
+ ## Contributing
42
+
43
+ Everyone is encouraged to help improve this project.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "rake"
2
+ require "bundler/gem_tasks"
3
+
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "haikunator_ru/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "haikunator_ru"
8
+ spec.version = HaikunatorRu::VERSION
9
+ spec.authors = ["HorteWolf01", "Usman Bashir"]
10
+ spec.email = ["me@usmanbashir.com"]
11
+ spec.summary = "Heroku-like random name generator."
12
+ spec.description = "Generate memorable random names to use in your apps"\
13
+ " or anywhere else."
14
+ spec.homepage = "https://github.com/hortewolf01/haikunator_ru"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "coveralls"
25
+ end
@@ -0,0 +1,3 @@
1
+ module HaikunatorRu
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,88 @@
1
+ require "haikunator_ru/version"
2
+ require "securerandom"
3
+
4
+ module HaikunatorRu
5
+ class << self
6
+ def haikunate(token_range = 9999, delimiter = "-")
7
+ build(token_range, delimiter)
8
+ end
9
+
10
+ private
11
+
12
+ def build(token_range, delimiter)
13
+ nouns_all = nouns.values.flatten
14
+ noun = nouns_all[random_seed % nouns_all.length]
15
+ gender = nouns.find{_2.include?(noun)}[0]
16
+ sections = [
17
+ adjectives[gender][random_seed % adjectives[gender].length],
18
+ noun,
19
+ token(token_range)
20
+ ]
21
+
22
+ sections.compact.join(delimiter)
23
+ end
24
+
25
+ def random_seed
26
+ SecureRandom.random_number(4096)
27
+ end
28
+
29
+ def token(range)
30
+ SecureRandom.random_number(range) if range > 0
31
+ end
32
+
33
+ def nouns
34
+ {
35
+ m: %w(
36
+ водопад бриз дождь ветер снег закат лист рассвет блеск лес холм луг
37
+ ручей куст огонь цветок светлячок пруд звук прибой гром резонанс туман
38
+ мороз голос дым
39
+ ),
40
+ f: %w(
41
+ река луна сосна тень поляна птица бабочка роса пыль трава дымка гора
42
+ ночь темнота снежинка тишина форма фиалка вода волна мечта вишня
43
+ бумага жаба звезда пустота
44
+ ),
45
+ n: %w(
46
+ море утро озеро облако солнце поле перо небо растение бревно дерево
47
+ )
48
+ }
49
+ end
50
+
51
+ def adjectives
52
+ {
53
+ m: %w(
54
+ осенний скрытый горький туманный тихий пустой сухой тёмный летний
55
+ ледяной деликатный спокойный белый свежий весенний зимний терпеливый
56
+ сумеречный багровый тонкий голубой волнистый сломанный холодный
57
+ влажный падающий морозный зелёный длинный поздний долгий смелый
58
+ маленький утренний грязный старый красный грубый чистый небольшой
59
+ искрящийся громогласный скромный блуждающий дикий чёрный молодой
60
+ святой одинокий ароматный снежный гордый цветочный неспокойный
61
+ божественный полированный древний пурпурный живой безымянный цветной
62
+ золотой
63
+ ),
64
+ f: %w(
65
+ осенняя скрытая горькая туманныя тихая пустая сухая тёмная летняя
66
+ ледяная деликатная спокойная белая свежая весенняя зимняя терпеливая
67
+ сумеречная багровая тонкая голубая волнистая сломанная холодная
68
+ влажная падающая морозная зелёная длинная поздняя долгая смелая
69
+ маленькая утренняя грязная старая красная грубая чистая небольшая
70
+ искрящаяся громогласная скромная блуждающая дикая чёрная молодая
71
+ святая одинокая ароматная снежная гордая цветочная неспокойная
72
+ бжественная полированная древняя пурпурная живая безымянная цветная
73
+ золотая
74
+ ),
75
+ n: %w(
76
+ осенее скрытое горькое туманное тихое пустое сухое тёмное летнее
77
+ ледяное деликатное спокойное белое свежее весеннее зимнее терпеливое
78
+ сумеречное багровое тонкое голубое волнистое сломанное холодное
79
+ маленькое утреннее грязное старое красное грубое чистое небольшое
80
+ искрящееся громогласное скромное блуждающее дикое чёрное молодое
81
+ святое одинокое ароматное снежное гордое цветочное неспокойное
82
+ божественное полированное древнее пурпурное живое безымянное цветное
83
+ золотое
84
+ )
85
+ }
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,40 @@
1
+ require_relative "../spec_helper"
2
+
3
+ describe HaikunatorRu do
4
+ it "generates a name like still-silence-5012" do
5
+ name = HaikunatorRu.haikunate
6
+
7
+ expect(name).to match(/\A\p{Letter}+-\p{Letter}+-\d{1,4}\z/)
8
+ end
9
+
10
+ it "won't return the same name for subsequent calls" do
11
+ name1 = HaikunatorRu.haikunate
12
+ name2 = HaikunatorRu.haikunate
13
+
14
+ expect(name1).not_to eql(name2)
15
+ end
16
+
17
+ it "permits optional configuration of the token range" do
18
+ name = HaikunatorRu.haikunate(9)
19
+
20
+ expect(name).to match(/-\d{1}\z/)
21
+ end
22
+
23
+ it "drops the token if token range is 0" do
24
+ name = HaikunatorRu.haikunate(0)
25
+
26
+ expect(name).to match(/\A\p{Letter}+-\p{Letter}+\z/)
27
+ end
28
+
29
+ it "permits optional configuration of the delimiter" do
30
+ name = HaikunatorRu.haikunate(9999, ".")
31
+
32
+ expect(name).to match(/\A\p{Letter}+\.\p{Letter}+\.\d{1,4}\z/)
33
+ end
34
+
35
+ it "drops the token and delimiter if token range is 0 and delimiter empty space" do
36
+ name = HaikunatorRu.haikunate(0, " ")
37
+
38
+ expect(name).to match(/\A\p{Letter}+ \p{Letter}+\z/)
39
+ end
40
+ end
@@ -0,0 +1,23 @@
1
+ require "coveralls"
2
+ Coveralls.wear!
3
+
4
+ require "haikunator_ru"
5
+
6
+ RSpec.configure do |config|
7
+ config.expect_with :rspec do |expectations|
8
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
9
+ end
10
+
11
+ config.mock_with :rspec do |mocks|
12
+ mocks.verify_partial_doubles = true
13
+ end
14
+
15
+ # Use the specified formatter
16
+ config.formatter = :documentation
17
+
18
+ # Print top 2 slowest examples
19
+ config.profile_examples = 2
20
+
21
+ # Run specs in random order
22
+ config.order = :random
23
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: haikunator_ru
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - HorteWolf01
8
+ - Usman Bashir
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 1980-01-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Generate memorable random names to use in your apps or anywhere else.
56
+ email:
57
+ - me@usmanbashir.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".coveralls.yml"
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".rubocop.yml"
66
+ - ".travis.yml"
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - haikunator_ru.gemspec
72
+ - lib/haikunator_ru.rb
73
+ - lib/haikunator_ru/version.rb
74
+ - spec/lib/haikunator_ru_spec.rb
75
+ - spec/spec_helper.rb
76
+ homepage: https://github.com/hortewolf01/haikunator_ru
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubygems_version: 3.7.1
95
+ specification_version: 4
96
+ summary: Heroku-like random name generator.
97
+ test_files:
98
+ - spec/lib/haikunator_ru_spec.rb
99
+ - spec/spec_helper.rb