politokens 1.0.2

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
+ SHA1:
3
+ metadata.gz: 094a15565c6b15e13ded166fc5164f4ab533d579
4
+ data.tar.gz: 27c068a6fcf0c8200d63947f4e641bd88b94e335
5
+ SHA512:
6
+ metadata.gz: 6e99de99938ac0daa6136443771d9a06ea57ebf130470d5d9c1951206217a930aa889e11e88d6dde7da09c22b026353429d6c58e9be77d7bb943c7c7afff76b9
7
+ data.tar.gz: a36e7c7b146a2ffc94ed0f021ad9205217781dbfd14034153576eac05d03192fee345787e093d2c2191dada17fb4746be3c1f723b49460b739ff05de1f60ff5c
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ 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,16 @@
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
+ - 1.9.3
10
+
11
+ script: 'bundle exec rake'
12
+
13
+ notifications:
14
+ email:
15
+ on_failure: change
16
+ on_success: never
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in politokens.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2015 Max Fierke
2
+ Copyright (c) 2015 Usman Bashir
3
+
4
+ MIT License
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # Politokens
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/politokens.svg)](http://badge.fury.io/rb/politokens)
4
+ [![Build Status](https://travis-ci.org/maxfierke/politokens.svg?branch=master)](https://travis-ci.org/maxfierke/politokens)
5
+ [![Coverage Status](https://coveralls.io/repos/maxfierke/politokens/badge.svg)](https://coveralls.io/r/maxfierke/politokens)
6
+
7
+ Generate Heroku-like memorable random names to use in your apps or anywhere else, but with a geopolitical twist. Fork of [Haikunator](https://github.com/usmanbashir/haikunator)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'politokens'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install politokens
22
+
23
+ ## Usage
24
+
25
+ Politokens is pretty simple. There is nothing to configure and it only has a single method, `.politoke`:
26
+
27
+ ```ruby
28
+ Politokens.politoke # => "rough-snowflake-1142"
29
+
30
+ # Token range
31
+ Politokens.politoke(100) # => "nameless-star-13"
32
+
33
+ # Don't include the token
34
+ Politokens.politoke(0) # => "long-flower"
35
+
36
+ # Use a different delimiter
37
+ Politokens.politoke(9999, '.') # => "cool.leaf.6743"
38
+
39
+ # No token, no delimiter
40
+ Politokens.politoke(0, ' ') # => "green fire"
41
+ ```
42
+
43
+ ## Contributing
44
+
45
+ Everyone is encouraged to help improve this project. Here are a few ways you can help:
46
+
47
+ - [Report bugs](https://github.com/maxfierke/politokens/issues)
48
+ - Fix bugs and [submit pull requests](https://github.com/maxfierke/politokens/pulls)
49
+ - Write, clarify, or fix documentation
50
+ - Suggest or add new features
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,3 @@
1
+ module Politokens
2
+ VERSION = "1.0.2"
3
+ end
data/lib/politokens.rb ADDED
@@ -0,0 +1,106 @@
1
+ require "politokens/version"
2
+ require "securerandom"
3
+
4
+ module Politokens
5
+ class << self
6
+ def politoke(token_range = 9999, delimiter = "-")
7
+ seed = random_seed
8
+
9
+ build(seed, token_range, delimiter)
10
+ end
11
+
12
+ private
13
+
14
+ def build(seed, token_range, delimiter)
15
+ sections = [
16
+ adjectives[seed % adjectives.length],
17
+ nouns[seed % nouns.length],
18
+ token(token_range)
19
+ ]
20
+
21
+ sections.compact.join(delimiter)
22
+ end
23
+
24
+ def random_seed
25
+ SecureRandom.random_number(4096)
26
+ end
27
+
28
+ def token(range)
29
+ SecureRandom.random_number(range) if range > 0
30
+ end
31
+
32
+ def adjectives
33
+ %w(
34
+ adaptable adventurous affable affectionate agreeable
35
+ ambitious amiable amicable amusing brave bright
36
+ broad-minded calm careful charming communicative
37
+ compassionate conscientious considerate convivial
38
+ courageous courteous creative decisive determined
39
+ diligent diplomatic discreet dynamic easygoing
40
+ emotional energetic enthusiastic exuberant fair-minded
41
+ faithful fearless forceful frank friendly funny
42
+ generous gentle good gregarious hard-working helpful
43
+ honest humorous imaginative impartial independent
44
+ intellectual intelligent intuitive inventive kind
45
+ loving loyal modest neat nice optimistic passionate
46
+ patient persistent pioneering philosophical placid
47
+ plucky polite powerful practical pro-active
48
+ quick-witted quiet rational reliable reserved
49
+ resourceful romantic self-confident self-disciplined
50
+ sensible sensitive shy sincere sociable straightforward
51
+ sympathetic thoughtful tidy tough unassuming
52
+ understanding versatile warmhearted willing witty
53
+ )
54
+ end
55
+
56
+ def nouns
57
+ %w(
58
+ afghanistan aland-islands albania algeria american-samoa
59
+ andorra angola anguilla antarctica antigua-and-barbuda
60
+ argentina armenia aruba australia austria azerbaijan bahamas
61
+ bahrain bangladesh barbados belarus belgium belize benin
62
+ bermuda bhutan bolivia bosnia-and-herzegovina botswana
63
+ bouvet-island brazil british-indian-ocean-territory
64
+ brunei-darussalam bulgaria burkina-faso burundi cambodia
65
+ cameroon canada cape-verde cayman-islands
66
+ central-african-republic chad chile china christmas-island
67
+ cocos-islands colombia comoros congo dr-congo cook-islands
68
+ costa-rica cote-d'ivoire croatia cuba cyprus czech-republic
69
+ denmark djibouti dominica dominican-republic ecuador egypt
70
+ el-salvador equatorial-guinea eritrea estonia ethiopia
71
+ falkland-islands-(malvinas) faroe-islands fiji finland
72
+ france french-guiana french-polynesia
73
+ french-southern-territories gabon gambia georgia germany
74
+ ghana gibraltar greece greenland grenada guadeloupe guam
75
+ guatemala guernsey guinea guinea-bissau guyana haiti
76
+ heard-island-and-mcdonald-islands holy-see honduras
77
+ hong-kong hungary iceland india indonesia iran iraq
78
+ ireland isle-of-man israel italy jamaica japan jersey
79
+ jordan kazakhstan kenya kiribati north-korea south-korea
80
+ kuwait kyrgyzstan laos latvia lebanon lesotho liberia
81
+ libya liechtenstein lithuania luxembourg macao macedonia
82
+ madagascar malawi malaysia maldives mali malta
83
+ marshall-islands martinique mauritania mauritius mayotte
84
+ mexico micronesia moldova monaco mongolia montenegro
85
+ montserrat morocco mozambique myanmar namibia nauru nepal
86
+ netherlands netherlands-antilles new-caledonia new-zealand
87
+ nicaragua niger nigeria niue norfolk-island
88
+ northern-mariana-islands norway oman pakistan palau
89
+ palestine panama papua-new-guinea paraguay peru philippines
90
+ pitcairn poland portugal puerto-rico qatar reunion romania
91
+ russia rwanda saint-helena saint-kitts-and-nevis saint-lucia
92
+ saint-pierre-and-miquelon saint-vincent-and-the-grenadines
93
+ samoa san-marino sao-tome-and-principe saudi-arabia senegal
94
+ serbia seychelles sierra-leone singapore slovakia slovenia
95
+ solomon-islands somalia south-africa spain sri-lanka sudan
96
+ suriname swaziland sweden switzerland syria taiwan
97
+ tajikistan tanzania thailand timor-leste togo tokelau tonga
98
+ trinidad-and-tobago tunisia turkey turkmenistan
99
+ turks-and-caicos-islands tuvalu uganda ukraine
100
+ united-arab-emirates united-kingdom united-states uruguay
101
+ uzbekistan vanuatu venezuela viet-nam virgin-islands
102
+ wallis-and-futuna western-sahara yemen zambia zimbabwe
103
+ )
104
+ end
105
+ end
106
+ end
@@ -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 "politokens/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "politokens"
8
+ spec.version = Politokens::VERSION
9
+ spec.authors = ["Max Fierke", "Usman Bashir"]
10
+ spec.email = ["max@maxfierke.com"]
11
+ spec.summary = "Heroku-like random name generator with geopolitcal twist"
12
+ spec.description = "Generate memorable random names to use in your apps"\
13
+ " or anywhere else. Fork of Haikunator with a gepolitical twist"
14
+ spec.homepage = "https://github.com/maxfierke/politokens"
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,40 @@
1
+ require_relative "../spec_helper"
2
+
3
+ describe Politokens do
4
+ it "generates a name like still-silence-5012" do
5
+ name = Politokens.politoke
6
+
7
+ expect(name).to match(/\A[\w\-]+-+[\w\-]+-+\d{1,4}\z/)
8
+ end
9
+
10
+ it "won't return the same name for subsequent calls" do
11
+ name1 = Politokens.politoke
12
+ name2 = Politokens.politoke
13
+
14
+ expect(name1).not_to eql(name2)
15
+ end
16
+
17
+ it "permits optional configuration of the token range" do
18
+ name = Politokens.politoke(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 = Politokens.politoke(0)
25
+
26
+ expect(name).to match(/\A[\w\-]+-[\w\-]+\z/)
27
+ end
28
+
29
+ it "permits optional configuration of the delimiter" do
30
+ name = Politokens.politoke(9999, ".")
31
+
32
+ expect(name).to match(/\A[\w\-]+\.[\w\-]+\.\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 = Politokens.politoke(0, " ")
37
+
38
+ expect(name).to match(/\A[\w\-]+ [\w\-]+\z/)
39
+ end
40
+ end
@@ -0,0 +1,23 @@
1
+ require "coveralls"
2
+ Coveralls.wear!
3
+
4
+ require "politokens"
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,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: politokens
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Max Fierke
8
+ - Usman Bashir
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-06-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rspec
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: coveralls
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description: Generate memorable random names to use in your apps or anywhere else.
57
+ Fork of Haikunator with a gepolitical twist
58
+ email:
59
+ - max@maxfierke.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".coveralls.yml"
65
+ - ".gitignore"
66
+ - ".rspec"
67
+ - ".rubocop.yml"
68
+ - ".travis.yml"
69
+ - Gemfile
70
+ - LICENSE.txt
71
+ - README.md
72
+ - Rakefile
73
+ - lib/politokens.rb
74
+ - lib/politokens/version.rb
75
+ - politokens.gemspec
76
+ - spec/lib/politokens_spec.rb
77
+ - spec/spec_helper.rb
78
+ homepage: https://github.com/maxfierke/politokens
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.4.5
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: Heroku-like random name generator with geopolitcal twist
102
+ test_files:
103
+ - spec/lib/politokens_spec.rb
104
+ - spec/spec_helper.rb