haiku_name 0.0.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.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .rvmrc
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in haiku_name.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Brendon Murphy
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,45 @@
1
+ # HaikuName
2
+
3
+ HaikuName: Generate pleasing random name strings.
4
+
5
+ For example, crimson-wave-3450, dawn-snowflake-f6f1, or little-morning-65f6.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'haiku_name'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install haiku_name
20
+
21
+ ## Usage
22
+
23
+ HaikuName is not configuration and has 1 simple method, `.generate`
24
+
25
+ ```ruby
26
+ HaikuName.generate # => 'delicate-dust-2a74'
27
+ # Configure the token length
28
+ HaikuName.generate(8) # => 'still-sun-1a841af9'
29
+ # Don't include a token
30
+ HaikuName.generate(0) # => 'aged-river'
31
+ ```
32
+
33
+ ## Configuration
34
+
35
+ In the interest of saying simple, HaikuName does not currently have
36
+ word configurations, it just uses internal frozen lists in the code
37
+ itself. This could evolve to allow config, but should stay simple.
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new(:spec) do |t|
6
+ t.libs.push "lib"
7
+ t.test_files = FileList['spec/*_spec.rb']
8
+ t.verbose = true
9
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/haiku_name/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Brendon Murphy"]
6
+ gem.email = ["xternal1+github@gmail.com"]
7
+ gem.summary = %q{Generate pleasing random name strings}
8
+ gem.description = gem.summary
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "haiku_name"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = HaikuName::VERSION
17
+
18
+ gem.add_development_dependency "minitest"
19
+ end
@@ -0,0 +1,3 @@
1
+ module HaikuName
2
+ VERSION = "0.0.1"
3
+ end
data/lib/haiku_name.rb ADDED
@@ -0,0 +1,129 @@
1
+ require "haiku_name/version"
2
+ require "securerandom"
3
+
4
+ module HaikuName
5
+ DELIMITER = '-'.freeze
6
+
7
+ # Return a randomly generate haiku name string
8
+ #
9
+ # @param [Integer] token_length optional length of token to use. 0 to omit
10
+ # @return [String]
11
+ def self.generate(token_length = 4)
12
+ parts = [ADJECTIVES.sample, NOUNS.sample]
13
+
14
+ if token_length.to_i > 0
15
+ token = SecureRandom.hex(token_length)[0, token_length]
16
+ parts << token
17
+ end
18
+
19
+ parts.join(DELIMITER)
20
+ end
21
+
22
+ ADJECTIVES = %w[
23
+ aged
24
+ ancient
25
+ autumn
26
+ billowing
27
+ bitter
28
+ blue
29
+ bold
30
+ broken
31
+ cold
32
+ cool
33
+ crimson
34
+ dark
35
+ dawn
36
+ delicate
37
+ empty
38
+ falling
39
+ floral
40
+ frosty
41
+ green
42
+ hidden
43
+ icy
44
+ late
45
+ little
46
+ lively
47
+ long
48
+ misty
49
+ morning
50
+ patient
51
+ polished
52
+ purple
53
+ quiet
54
+ red
55
+ silent
56
+ small
57
+ snowy
58
+ solitary
59
+ sparkling
60
+ still
61
+ summer
62
+ twilight
63
+ wandering
64
+ weathered
65
+ white
66
+ winter
67
+ ].freeze
68
+
69
+ NOUNS = %w[
70
+ bird
71
+ breeze
72
+ brook
73
+ butterfly
74
+ cloud
75
+ darkness
76
+ dawn
77
+ dew
78
+ dream
79
+ dust
80
+ feather
81
+ field
82
+ fire
83
+ firefly
84
+ flower
85
+ fog
86
+ forest
87
+ frog
88
+ frost
89
+ glade
90
+ glitter
91
+ grass
92
+ haze
93
+ hill
94
+ lake
95
+ leaf
96
+ meadow
97
+ moon
98
+ morning
99
+ mountain
100
+ night
101
+ paper
102
+ pine
103
+ pond
104
+ rain
105
+ river
106
+ sea
107
+ shadow
108
+ silence
109
+ sky
110
+ smoke
111
+ snow
112
+ snowflake
113
+ star
114
+ sun
115
+ sun
116
+ sunset
117
+ surf
118
+ thunder
119
+ tree
120
+ violet
121
+ voice
122
+ water
123
+ waterfall
124
+ wave
125
+ wildflower
126
+ wind
127
+ wood
128
+ ].freeze
129
+ end
@@ -0,0 +1,28 @@
1
+ require "minitest/spec"
2
+ require "minitest/autorun"
3
+ require "haiku_name"
4
+
5
+ describe HaikuName, '.generate' do
6
+ it "returns a name like adjective-noun-af12" do
7
+ name = HaikuName.generate
8
+ name.must_match /\A\w+-\w+-[a-f0-9]{4}\z/
9
+ end
10
+
11
+ it "won't return the same name for subsequent calls" do
12
+ name1 = HaikuName.generate
13
+ name2 = HaikuName.generate
14
+ name1.wont_equal name2
15
+ end
16
+
17
+ it "permits optional configuration of the token length" do
18
+ name = HaikuName.generate(8)
19
+ name.must_match /-[a-f0-9]{8}\z/
20
+ name = HaikuName.generate(9)
21
+ name.must_match /-[a-f0-9]{9}\z/
22
+ end
23
+
24
+ it "drops the token if token length is 0" do
25
+ name = HaikuName.generate(0)
26
+ name.must_match /\A\w+-\w+\z/
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: haiku_name
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Brendon Murphy
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: minitest
16
+ requirement: &2152405500 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *2152405500
25
+ description: Generate pleasing random name strings
26
+ email:
27
+ - xternal1+github@gmail.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - haiku_name.gemspec
38
+ - lib/haiku_name.rb
39
+ - lib/haiku_name/version.rb
40
+ - spec/haiku_name_spec.rb
41
+ homepage: ''
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 1.8.15
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Generate pleasing random name strings
65
+ test_files:
66
+ - spec/haiku_name_spec.rb