factory-helper 1.7.3 → 1.7.4

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: b6da63f932142e44ce11edd71bab598badb64c53
4
- data.tar.gz: 04493c963464eaf1cdcdf9c2cd875d4bb9bfc35e
3
+ metadata.gz: e5e6b076114e219a3dd4625abfa1d936794c39ad
4
+ data.tar.gz: d079896356804bea22a8f4239d4282ffa3000a23
5
5
  SHA512:
6
- metadata.gz: 17a27de292ae66e4dffb5d75611acad4d150cc3e596100a7417870405aa51733896bd6d5c708626bb5e29b011817031be77e883fb14c72eb2189ca09a072680c
7
- data.tar.gz: caee66faea0cf88d53a03c6193c6e15c2a026303d02726c122501208dd059bc65ccd10110ca43f263885c4326367ca9fd4e0da35f8f27a92c5b4063c2dcaa9aa
6
+ metadata.gz: 333083f0720a6398e5abe06d9cfca8eca5ae1dd3b59c8375bf9f08cb3f40e194fc5ea881bc240563b1070df60d0c21959cbf76f16eab5d152015650df2437ebe
7
+ data.tar.gz: 9ac9cecc1fb4a74768f72886883bd7124203b0b60ac605f973c705a77ef0218e651a2307a59e24784798ad2854fed1bfce7e9e15842dfdc9b0c6ab9bf39c5ecb
data/README.md CHANGED
@@ -1,10 +1,8 @@
1
1
  factory-helper
2
2
  =====
3
- **This is currently considered a _pre-release_ version by the authors.**
4
-
5
3
  This gem began life as a fork of [stympy's Faker](https://github.com/stympy/faker). While the usage examples below use the `FactoryHelper` name, the `Faker` constant remains available. For example, `Faker::Name.name`.
6
4
 
7
- FactoryHelper's purpose is to facilitate software testing by allowing factories to have a solid source of random data with defined characteristics, but the gem can be used for many other purposes as well as in production code.
5
+ **FactoryHelper's purpose is to facilitate software testing** by allowing factories to have a solid source of random data with defined characteristics, but the gem can be used for many other purposes as well as in production code.
8
6
 
9
7
  Its main use-case is slightly different than Faker's and will evolve in that direction, with a primary focus on software testing and only a secondary focus on real-looking data. New features will also be added, some based on PRs submitted to the original repo, some based on things we've needed ourselves, and some based on incoming pull requests.
10
8
 
@@ -20,7 +18,7 @@ gem install factory-helper
20
18
 
21
19
  or in your Gemfile
22
20
  ```ruby
23
- gem 'factory-helper'
21
+ gem 'factory-helper', '~> 1.7'
24
22
  ```
25
23
 
26
24
  ##Usage
@@ -57,7 +55,7 @@ FactoryHelper::Company.bs #=> "revolutionize plug-and-play architectures"
57
55
  Random UTF-8 string with optional nested length arguments.
58
56
 
59
57
  ```ruby
60
- FactoryHelper::String.random #=> "3 뇦\u0017&y\u{3A109}$8^4* 녹豿4좘툢ꔾ쉙6ɉ\uA6F8TN畀챵|\"3쇤Ŵ"
58
+ FactoryHelper::String.random #=> "3 뇦\u0017&y\u{3A109}$8^4* 녹豿4좘툢ꔾ쉙6ɉ\uA6 8TN畀챵|\"3쇤Ŵ"
61
59
  FactoryHelper::String.random(4) #=> "⼨%0*"
62
60
  FactoryHelper::String.random(3..12) #=> "\u{69FDC};秨툫"
63
61
  FactoryHelper::String.random([0, 6]) #=> "I轤𣴒P溟L"
@@ -84,41 +82,23 @@ FactoryHelper::MySQL.mediumint #=> 7456451
84
82
 
85
83
  ```ruby
86
84
  FactoryHelper::Address.city #=> "Imogeneborough"
87
-
88
85
  FactoryHelper::Address.street_name #=> "Larkin Fork"
89
-
90
86
  FactoryHelper::Address.street_address #=> "282 Kevin Brook"
91
-
92
87
  FactoryHelper::Address.secondary_address #=> "Apt. 672"
93
-
94
88
  FactoryHelper::Address.building_number #=> "7304"
95
-
96
89
  FactoryHelper::Address.zip_code #=> "58517"
97
-
98
90
  FactoryHelper::Address.zip #=> "58517"
99
-
100
91
  FactoryHelper::Address.postcode #=> "58517"
101
-
102
92
  FactoryHelper::Address.time_zone #=> "Asia/Yakutsk"
103
-
104
93
  FactoryHelper::Address.street_suffix #=> "Street"
105
-
106
94
  FactoryHelper::Address.city_suffix #=> "fort"
107
-
108
95
  FactoryHelper::Address.city_prefix #=> "Lake"
109
-
110
96
  FactoryHelper::Address.state_abbr #=> "AP"
111
-
112
97
  FactoryHelper::Address.state #=> "California"
113
-
114
98
  FactoryHelper::Address.state_abbr #=> "AP"
115
-
116
99
  FactoryHelper::Address.country #=> "French Guiana"
117
-
118
100
  FactoryHelper::Address.country_code #=> "IT"
119
-
120
101
  FactoryHelper::Address.latitude #=> "-58.17256227443719"
121
-
122
102
  FactoryHelper::Address.longitude #=> "-156.65548382095133"
123
103
  ```
124
104
 
@@ -127,7 +107,6 @@ FactoryHelper::Address.longitude #=> "-156.65548382095133"
127
107
 
128
108
  ```ruby
129
109
  FactoryHelper::Bitcoin.address #=> "1HUoGjmgChmnxxYhz87YytV4gVjfPaExmh"
130
-
131
110
  FactoryHelper::Bitcoin.testnet_address #=> "msHGunDvoEwmVFXvd2Bub1SNw5RP1YHJaf"
132
111
  ```
133
112
 
@@ -136,9 +115,7 @@ FactoryHelper::Bitcoin.testnet_address #=> "msHGunDvoEwmVFXvd2Bub1SNw5RP1YHJaf"
136
115
 
137
116
  ```ruby
138
117
  FactoryHelper::Business.credit_card_number #=> "1228-1221-1221-1431"
139
-
140
118
  FactoryHelper::Business.credit_card_expiry_date #=> <Date: 2015-11-11 ((2457338j,0s,0n),+0s,2299161j)>
141
-
142
119
  FactoryHelper::Business.credit_card_type #=> "visa"
143
120
  ```
144
121
 
@@ -147,7 +124,6 @@ FactoryHelper::Business.credit_card_type #=> "visa"
147
124
 
148
125
  ```ruby
149
126
  FactoryHelper::Code.isbn #=> "759021701-8"
150
-
151
127
  FactoryHelper::Code.ean #=> "4600051000057"
152
128
  ```
153
129
 
@@ -301,19 +277,12 @@ FactoryHelper::Lorem.paragraphs(1, true) #=> #<Array:0x00000002b7fc58: #<String:
301
277
 
302
278
  ```ruby
303
279
  FactoryHelper::Name.name #=> "Tyshawn Johns Sr."
304
-
305
280
  FactoryHelper::Name.first_name #=> "Kaci"
306
-
307
281
  FactoryHelper::Name.last_name #=> "Ernser"
308
-
309
282
  FactoryHelper::Name.prefix #=> "Mr."
310
-
311
283
  FactoryHelper::Name.suffix #=> "IV"
312
-
313
284
  FactoryHelper::Name.title #=> "Legacy Creative Director"
314
-
315
285
  FactoryHelper::Name.female_name #=> "Marissa"
316
-
317
286
  FactoryHelper::Name.male_name #=> "Brian"
318
287
  ```
319
288
 
@@ -436,9 +405,7 @@ FactoryHelper::Hacker.ingverb #=> "synthesizing"
436
405
 
437
406
  ```ruby
438
407
  FactoryHelper::App.name #=> "Treeflex"
439
-
440
408
  FactoryHelper::App.version #=> "0.7.9"
441
-
442
409
  FactoryHelper::App.author #=> "Daphne Swift"
443
410
  ```
444
411
 
@@ -2,7 +2,7 @@ module FactoryHelper
2
2
  class String
3
3
  class << self
4
4
  def random(length= 32)
5
- utf8string select_a length
5
+ utf8string select_a length
6
6
  end
7
7
 
8
8
  private
@@ -16,7 +16,22 @@ module FactoryHelper
16
16
  end
17
17
 
18
18
  def utf8string(length)
19
- (1..length.to_i).map{ utf8character }.join
19
+ ratio= char_space_ratio
20
+ (1..length.to_i).map do
21
+ space_or_utf8_char ratio
22
+ end.join
23
+ end
24
+
25
+ def space_or_utf8_char ratio
26
+ [
27
+ 32.chr(Encoding::UTF_8), [utf8character]* ratio
28
+ ].flatten.sample(:random => FactoryHelper::Config.random)
29
+ end
30
+
31
+ def char_space_ratio
32
+ [
33
+ 2, [3]*5, [5]*17, [7]*11, 11, 191,
34
+ ].flatten.sample(:random => FactoryHelper::Config.random)
20
35
  end
21
36
 
22
37
  def utf8character
@@ -1,3 +1,3 @@
1
1
  module FactoryHelper #:nodoc:
2
- VERSION = "1.7.3"
2
+ VERSION = '1.7.4'
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory-helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.3
4
+ version: 1.7.4
5
5
  platform: ruby
6
6
  authors:
7
- - Nikita Avvakumov
8
7
  - Brian Giaraffa
8
+ - Nikita Avvakumov
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-20 00:00:00.000000000 Z
12
+ date: 2015-09-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler