nice_uuid 0.0.6

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/lib/nice_uuid.rb ADDED
@@ -0,0 +1,28 @@
1
+ require "nice_uuid/version"
2
+
3
+ module NiceUuid
4
+ DEFAULT_NUMBER_OF_WORDS = 4
5
+ DICTIONARY_PATH = File.dirname(__FILE__) + '/length_ordered_sanitized_dictionary.txt'
6
+
7
+ def self.generate(maximum=36)
8
+ 10000.times do
9
+ @solution = possible_nice_uuid
10
+ break if @solution.length <= maximum
11
+ end
12
+ @solution
13
+ end
14
+
15
+ private
16
+
17
+ def self.possible_nice_uuid
18
+ bundle_of_words.map(&:strip).shuffle.join('-')
19
+ end
20
+
21
+ def self.bundle_of_words
22
+ array_of_all_words.sample(DEFAULT_NUMBER_OF_WORDS)
23
+ end
24
+
25
+ def self.array_of_all_words
26
+ @array_of_all_words ||= File.readlines(DICTIONARY_PATH)
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module NiceUuid
2
+ VERSION = "0.0.6"
3
+ end
data/nice_uuid.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nice_uuid/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nice_uuid"
8
+ spec.version = NiceUuid::VERSION
9
+ spec.authors = ["Alex Gessner"]
10
+ spec.email = ["alex.gessner@gmail.com"]
11
+ spec.description = 'nice and easy uuids'
12
+ spec.summary = 'NiceUuid.generate(36) for a nice uuid with 4, dash-separated, readable words'
13
+ spec.homepage = "https://github.com/xgess/nice_uuid"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "rspec"
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ end
@@ -0,0 +1,19 @@
1
+ require_relative '../../lib/nice_uuid'
2
+
3
+ describe NiceUuid do
4
+ describe 'generate' do
5
+ before { @nice_uuid = NiceUuid::generate }
6
+
7
+ it 'is a string' do
8
+ @nice_uuid.should be_an_instance_of(String)
9
+ end
10
+
11
+ it 'is has 1 fewer dashes than number of words' do
12
+ @nice_uuid.count('-').should == (NiceUuid::DEFAULT_NUMBER_OF_WORDS - 1)
13
+ end
14
+
15
+ it 'eventually yields a solution for an obnoxious request' do
16
+ NiceUuid::generate(27).length.should <= 27
17
+ end
18
+ end
19
+ end
File without changes
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nice_uuid
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ platform: ruby
6
+ authors:
7
+ - Alex Gessner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
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: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
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: nice and easy uuids
56
+ email:
57
+ - alex.gessner@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/length_ordered_sanitized_dictionary.txt
68
+ - lib/nice_uuid.rb
69
+ - lib/nice_uuid/version.rb
70
+ - nice_uuid.gemspec
71
+ - spec/lib/nice_uuid_spec.rb
72
+ - spec/spec_helper.rb
73
+ homepage: https://github.com/xgess/nice_uuid
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.6
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: NiceUuid.generate(36) for a nice uuid with 4, dash-separated, readable words
97
+ test_files:
98
+ - spec/lib/nice_uuid_spec.rb
99
+ - spec/spec_helper.rb