spicy-proton 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d5b82dd948e56edbb58d997e133c9d280d4f269
4
- data.tar.gz: f88ee4e26bdc9d6ab4572e1731df0beb67beabb5
3
+ metadata.gz: 40ebf7df25dfb926d8a332c8e207becd9df787c2
4
+ data.tar.gz: a8943410443bb9614db6a1627c7d209d9da64738
5
5
  SHA512:
6
- metadata.gz: 6846f219c69ec864dcb872373f0a247734df8b2e0acca86e2568443a46ceec9580222f40c0b1cee2cf9a6482f8c321e0ac6443e2c5011becd41a6251b4dd5038
7
- data.tar.gz: 60497c63be6c65376fe9920bd0013b51ecc4187f18de9275df608eba5b0396eb8bce66ba546fb3b96b697b88129a2b3d0c2be78cc9e91d6f1e0ab1b68f285bb9
6
+ metadata.gz: 57bb1914e746fc42c1ada4e994ef1e691488785ed7fef21085e3153e9fc52711c45504e6bf5ed877b7903e12d977e0cd446aa0dcf200db7bd7138622e8cc412d
7
+ data.tar.gz: 5675ab127bfb8cf9c377fcd6dd1dd2a7d4d2b5a2c79ce3955ed83cff890c505cb7e9a2b5445d47e7dcda1f8d282aa80b0d7bd65b65697fb0bfd96e9a7934dbbc
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Spicy::Proton
2
- Generate a random adjective-noun pair.
2
+ Generate a random adjective-noun word pair. Works with Ruby 1.9.x and newer.
3
3
 
4
4
  ## Quick Start
5
5
 
@@ -21,19 +21,18 @@ require 'spicy-proton'
21
21
 
22
22
  Spicy::Proton.adjective # => "extreme"
23
23
  Spicy::Proton.noun # => "loan"
24
- Spicy::Proton.color # => "burgundy"
25
24
  Spicy::Proton.pair # => "opportune-spacesuit"
26
25
  Spicy::Proton.pair(':') # => "hip:squash"
27
26
  Spicy::Proton.format('%a/%c/%n') # => "slippery/ultramarine/rattler"
28
27
 
29
28
  # With length constraints.
30
- Spicy::Proton.adjective(max: 5) # => "foamy"
31
29
  Spicy::Proton.noun(min: 10) # => "translucence"
32
- Spicy::Proton.color(min: 5, max: 7) # => "indigo"
33
- Spicy::Proton.noun(length: 8) # => "morality"
30
+ Spicy::Proton.adjective(max: 5) # => "foamy"
31
+ Spicy::Proton.noun(min: 5, max: 7) # => "target"
32
+ Spicy::Proton.adjective(length: 8) # => "medieval"
34
33
  ```
35
34
 
36
- When generating multiple specimens, instance methods are faster. The instance keeps the word corpus in memory. The instance methods are the same as their static counterparts.
35
+ When generating multiple specimens, instance methods are faster. The instance keeps the word corpus in memory. The instance methods are the same as their class method counterparts.
37
36
 
38
37
  ```ruby
39
38
  require 'spicy-proton'
@@ -42,9 +41,8 @@ generator = Spicy::Proton.new
42
41
  1000.times do
43
42
  generator.adjective
44
43
  generator.noun(min: 7)
45
- generator.color(length: 4)
46
44
  generator.pair
47
- generator.pair(':')
45
+ generator.pair('.')
48
46
  generator.format('%a-%c-%n')
49
47
  end
50
48
  ```
@@ -54,7 +52,6 @@ Instances give you access to the raw word lists as well:
54
52
  ```ruby
55
53
  generator.adjectives # => ["dreadful", "methodist", "necessary", "tough", ...]
56
54
  generator.nouns # => ["rustling", "fiance", "infield", "chatter", ...]
57
- generator.colors # => ["alizarin", "amaranth", "amber", "amethyst", ...]
58
55
  ```
59
56
 
60
57
  ## License
@@ -18,10 +18,6 @@ module Spicy::Disk
18
18
  def self.nouns
19
19
  @@nouns ||= File.join(dir, 'nouns.bin')
20
20
  end
21
-
22
- def self.colors
23
- @@colors ||= File.join(dir, 'colors.bin')
24
- end
25
21
  end
26
22
 
27
23
  class Header < BinData::Record
@@ -87,10 +83,6 @@ module Spicy::Disk
87
83
  generate(:nouns, *args)
88
84
  end
89
85
 
90
- def color(*args)
91
- generate(:colors, *args)
92
- end
93
-
94
86
  private
95
87
 
96
88
  def generate(type, *args)
@@ -17,10 +17,6 @@ module Spicy::Memory
17
17
  def self.nouns
18
18
  @@nouns ||= File.join(dir, 'nouns.yaml')
19
19
  end
20
-
21
- def self.colors
22
- @@colors ||= File.join(dir, 'colors.yaml')
23
- end
24
20
  end
25
21
 
26
22
  class WordList
@@ -49,7 +45,6 @@ module Spicy::Memory
49
45
  dir = File.dirname(__FILE__)
50
46
  @adjectives = WordList.new(Files.adjectives)
51
47
  @nouns = WordList.new(Files.nouns)
52
- @colors = WordList.new(Files.colors)
53
48
  end
54
49
 
55
50
  def adjective(*args)
@@ -60,10 +55,6 @@ module Spicy::Memory
60
55
  @nouns.word(*args)
61
56
  end
62
57
 
63
- def color(*args)
64
- @colors.word(*args)
65
- end
66
-
67
58
  def pair(separator = '-')
68
59
  "#{self.adjective}#{separator}#{self.noun}"
69
60
  end
@@ -2,7 +2,9 @@ require 'securerandom'
2
2
 
3
3
  module Spicy
4
4
  module Seek
5
- def seek(min: nil, max: nil, length: nil, &found)
5
+ def seek(opts = {}, &found)
6
+ min, max, length = opts[:min], opts[:max], opts[:length]
7
+
6
8
  if !length.nil? && (!min.nil? || !max.nil?)
7
9
  raise ArgumentError.new('length cannot be specified if min or max are specified.')
8
10
  end
@@ -16,7 +18,9 @@ module Spicy
16
18
 
17
19
  rand_min = @cumulative[min - 1] || 0
18
20
  rand_max = @cumulative[max] || @cumulative[@max]
19
- index = SecureRandom.random_number(rand_min...rand_max)
21
+
22
+ range = rand_max - rand_min + 1
23
+ index = rand_min + SecureRandom.random_number(range)
20
24
 
21
25
  min.upto(max) do |len|
22
26
  if @cumulative[len] > index
@@ -22,12 +22,6 @@ module Spicy
22
22
  end
23
23
  end
24
24
 
25
- def self.color(*args)
26
- Disk::Corpus.use do |c|
27
- c.color(*args)
28
- end
29
- end
30
-
31
25
  def self.pair(separator = '-')
32
26
  Disk::Corpus.use do |c|
33
27
  "#{c.adjective}#{separator}#{c.noun}"
@@ -44,7 +38,7 @@ module Spicy
44
38
  self.class.format_with(self, format)
45
39
  end
46
40
 
47
- def_delegators :@corpus, :adjective, :noun, :color, :pair, :adjectives, :nouns, :colors
41
+ def_delegators :@corpus, :adjective, :noun, :pair, :adjectives, :nouns
48
42
 
49
43
  private
50
44
 
@@ -55,8 +49,6 @@ module Spicy
55
49
  source.adjective
56
50
  when 'n'
57
51
  source.noun
58
- when 'c'
59
- source.color
60
52
  when '%'
61
53
  '%'
62
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spicy-proton
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schmich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-30 00:00:00.000000000 Z
11
+ date: 2017-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bindata
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5.10'
41
- description: Generate a random adjective-noun pair.
41
+ description: ''
42
42
  email: schmch@gmail.com
43
43
  executables: []
44
44
  extensions: []
@@ -48,8 +48,6 @@ files:
48
48
  - README.md
49
49
  - lib/corpus/adjectives.bin
50
50
  - lib/corpus/adjectives.yaml
51
- - lib/corpus/colors.bin
52
- - lib/corpus/colors.yaml
53
51
  - lib/corpus/nouns.bin
54
52
  - lib/corpus/nouns.yaml
55
53
  - lib/disk-corpus.rb
@@ -68,7 +66,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
66
  requirements:
69
67
  - - ">="
70
68
  - !ruby/object:Gem::Version
71
- version: 2.0.0
69
+ version: 1.9.1
72
70
  required_rubygems_version: !ruby/object:Gem::Requirement
73
71
  requirements:
74
72
  - - ">="
@@ -79,5 +77,5 @@ rubyforge_project:
79
77
  rubygems_version: 2.6.8
80
78
  signing_key:
81
79
  specification_version: 4
82
- summary: Generate a random adjective-noun pair.
80
+ summary: Generate a random adjective-noun word pair.
83
81
  test_files: []
Binary file
@@ -1,157 +0,0 @@
1
- ---
2
- cumulative:
3
- 3: 3
4
- 4: 28
5
- 5: 56
6
- 6: 78
7
- 7: 95
8
- 8: 115
9
- 9: 128
10
- 10: 135
11
- 11: 136
12
- words:
13
- 3:
14
- - red
15
- - sky
16
- - tan
17
- 4:
18
- - aqua
19
- - blue
20
- - buff
21
- - corn
22
- - cyan
23
- - ecru
24
- - fern
25
- - flax
26
- - gold
27
- - gray
28
- - jade
29
- - lime
30
- - mint
31
- - moss
32
- - navy
33
- - pear
34
- - pine
35
- - pink
36
- - plum
37
- - puce
38
- - rose
39
- - ruby
40
- - rust
41
- - sand
42
- - teal
43
- 5:
44
- - amber
45
- - azure
46
- - beige
47
- - black
48
- - brass
49
- - brown
50
- - coral
51
- - cream
52
- - denim
53
- - green
54
- - ivory
55
- - khaki
56
- - lemon
57
- - lilac
58
- - linen
59
- - mauve
60
- - ochre
61
- - olive
62
- - peach
63
- - sepia
64
- - slate
65
- - smalt
66
- - steel
67
- - taupe
68
- - tawny
69
- - umber
70
- - wheat
71
- - white
72
- 6:
73
- - auburn
74
- - bistre
75
- - bronze
76
- - carrot
77
- - cerise
78
- - cherry
79
- - cobalt
80
- - copper
81
- - forest
82
- - indigo
83
- - maroon
84
- - myrtle
85
- - orange
86
- - orchid
87
- - purple
88
- - russet
89
- - salmon
90
- - sienna
91
- - silver
92
- - tomato
93
- - violet
94
- - yellow
95
- 7:
96
- - apricot
97
- - carmine
98
- - celadon
99
- - crimson
100
- - emerald
101
- - fuchsia
102
- - gamboge
103
- - magenta
104
- - mustard
105
- - olivine
106
- - pumpkin
107
- - saffron
108
- - sangria
109
- - scarlet
110
- - thistle
111
- - xanthic
112
- - zucchin
113
- 8:
114
- - alizarin
115
- - amaranth
116
- - amethyst
117
- - burgundy
118
- - cardinal
119
- - cerulean
120
- - charcoal
121
- - chestnut
122
- - cinnabar
123
- - cinnamon
124
- - eggplant
125
- - lavender
126
- - magnolia
127
- - midnight
128
- - platinum
129
- - sapphire
130
- - seashell
131
- - titanium
132
- - viridian
133
- - wisteria
134
- 9:
135
- - asparagus
136
- - champagne
137
- - chocolate
138
- - dandelion
139
- - firebrick
140
- - goldenrod
141
- - harlequin
142
- - malachite
143
- - persimmon
144
- - sea green
145
- - tangerine
146
- - turquoise
147
- - vermilion
148
- 10:
149
- - aquamarine
150
- - camouflage
151
- - chartreuse
152
- - cornflower
153
- - heliotrope
154
- - periwinkle
155
- - terracotta
156
- 11:
157
- - ultramarine