sixarm_ruby_fab 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +1 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gemtest +0 -0
  5. data/CONTRIBUTING.md +28 -0
  6. data/README.md +91 -0
  7. data/Rakefile +8 -0
  8. data/VERSION +1 -0
  9. data/lib/sixarm_ruby_fab.rb +40 -0
  10. data/lib/sixarm_ruby_fab/agent.rb +20 -0
  11. data/lib/sixarm_ruby_fab/basic.rb +26 -0
  12. data/lib/sixarm_ruby_fab/company.rb +21 -0
  13. data/lib/sixarm_ruby_fab/date.rb +45 -0
  14. data/lib/sixarm_ruby_fab/datetime.rb +44 -0
  15. data/lib/sixarm_ruby_fab/email.rb +12 -0
  16. data/lib/sixarm_ruby_fab/files.rb +113 -0
  17. data/lib/sixarm_ruby_fab/forgery/geo.rb +56 -0
  18. data/lib/sixarm_ruby_fab/forgery/uri.rb +12 -0
  19. data/lib/sixarm_ruby_fab/geo.rb +21 -0
  20. data/lib/sixarm_ruby_fab/id.rb +28 -0
  21. data/lib/sixarm_ruby_fab/internet.rb +12 -0
  22. data/lib/sixarm_ruby_fab/locale.rb +34 -0
  23. data/lib/sixarm_ruby_fab/mime.rb +29 -0
  24. data/lib/sixarm_ruby_fab/names.rb +30 -0
  25. data/lib/sixarm_ruby_fab/password.rb +16 -0
  26. data/lib/sixarm_ruby_fab/phone.rb +12 -0
  27. data/lib/sixarm_ruby_fab/postal.rb +39 -0
  28. data/lib/sixarm_ruby_fab/text.rb +58 -0
  29. data/lib/sixarm_ruby_fab/time.rb +44 -0
  30. data/lib/sixarm_ruby_fab/twitter.rb +119 -0
  31. data/lib/sixarm_ruby_fab/username.rb +16 -0
  32. data/lib/sixarm_ruby_fab/uuid.rb +27 -0
  33. data/test/sixarm_ruby_fab_test.rb +32 -0
  34. data/test/sixarm_ruby_fab_test/agent_test.rb +40 -0
  35. data/test/sixarm_ruby_fab_test/basic_test.rb +35 -0
  36. data/test/sixarm_ruby_fab_test/company_test.rb +34 -0
  37. data/test/sixarm_ruby_fab_test/date_test.rb +67 -0
  38. data/test/sixarm_ruby_fab_test/datetime_test.rb +66 -0
  39. data/test/sixarm_ruby_fab_test/email_test.rb +22 -0
  40. data/test/sixarm_ruby_fab_test/files_test.rb +106 -0
  41. data/test/sixarm_ruby_fab_test/forgery/geo_test.rb +0 -0
  42. data/test/sixarm_ruby_fab_test/forgery/uri_test.rb +0 -0
  43. data/test/sixarm_ruby_fab_test/geo_test.rb +34 -0
  44. data/test/sixarm_ruby_fab_test/id_test.rb +34 -0
  45. data/test/sixarm_ruby_fab_test/internet_test.rb +23 -0
  46. data/test/sixarm_ruby_fab_test/locale_test.rb +51 -0
  47. data/test/sixarm_ruby_fab_test/mime_test.rb +41 -0
  48. data/test/sixarm_ruby_fab_test/names_test.rb +47 -0
  49. data/test/sixarm_ruby_fab_test/password_test.rb +26 -0
  50. data/test/sixarm_ruby_fab_test/phone_test.rb +22 -0
  51. data/test/sixarm_ruby_fab_test/postal_test.rb +58 -0
  52. data/test/sixarm_ruby_fab_test/text_test.rb +58 -0
  53. data/test/sixarm_ruby_fab_test/time_test.rb +66 -0
  54. data/test/sixarm_ruby_fab_test/twitter_test.rb +98 -0
  55. data/test/sixarm_ruby_fab_test/username_test.rb +58 -0
  56. data/test/sixarm_ruby_fab_test/uuid_test.rb +34 -0
  57. metadata +159 -0
  58. metadata.gz.sig +3 -0
@@ -0,0 +1,16 @@
1
+ class Fab
2
+
3
+ # Fab a username.
4
+ #
5
+ # Options:
6
+ #
7
+ # * chars: a..z
8
+ # * size: rand(10..30) [actual size may be less because we strip the string]
9
+ #
10
+ # @returns [String] a username
11
+ #
12
+ def username(options = {})
13
+ (options[:chars] || AZ).sample(options[:size] || rand(5..15)).join
14
+ end
15
+
16
+ end
@@ -0,0 +1,27 @@
1
+ class Fab
2
+
3
+ # Fab a random UUID.
4
+ #
5
+ # Options:
6
+ #
7
+ # * none
8
+ #
9
+ # @returns [String] a random UUID sting
10
+ #
11
+ def uuid(options = {})
12
+ SecureRandom.uuid
13
+ end
14
+
15
+ # Fab a list of random UUIDs.
16
+ #
17
+ # Options:
18
+ #
19
+ # * size: 3
20
+ #
21
+ # @returns [Array[String]] a list of random UUIDs
22
+ #
23
+ def uuids(options = {})
24
+ (options[:size] || 3).times.map{ uuid(options) }
25
+ end
26
+
27
+ end
@@ -0,0 +1,32 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'minitest/autorun'
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'sixarm_ruby_fab'
6
+
7
+ [
8
+ 'agent',
9
+ 'basic',
10
+ 'company',
11
+ 'date',
12
+ 'datetime',
13
+ 'email',
14
+ 'files',
15
+ 'geo',
16
+ 'id',
17
+ 'internet',
18
+ 'locale',
19
+ 'mime',
20
+ 'names',
21
+ 'password',
22
+ 'phone',
23
+ 'postal',
24
+ 'text',
25
+ 'time',
26
+ 'twitter',
27
+ 'username',
28
+ 'uuid'
29
+ ].each{|x|
30
+ require "sixarm_ruby_fab_test/#{x}_test.rb"
31
+ }
32
+
@@ -0,0 +1,40 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'minitest/autorun'
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+
6
+ describe Fab do
7
+
8
+ let(:fab){ Fab.new }
9
+
10
+ describe "#agent" do
11
+
12
+ before do
13
+ @x = fab.agent
14
+ end
15
+
16
+ it "returns a string" do
17
+ @x.must_be_kind_of String
18
+ end
19
+
20
+ it "is in the list" do
21
+ fab.agent_list.must_include @x
22
+ end
23
+
24
+ end
25
+
26
+ describe "#agent_list" do
27
+
28
+ before do
29
+ @x = [:a, :b, :c]
30
+ end
31
+
32
+ it "gets and sets" do
33
+ fab.agent_list = @x
34
+ fab.agent_list.must_equal @x
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+
@@ -0,0 +1,35 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'minitest/autorun'
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+
6
+ describe Fab do
7
+
8
+ let(:fab){ Fab.new }
9
+
10
+ describe "#boolean" do
11
+
12
+ before do
13
+ @x = fab.boolean
14
+ end
15
+
16
+ it "is true or false" do
17
+ [true, false].must_include @x
18
+ end
19
+
20
+ end
21
+
22
+ describe "#rating" do
23
+
24
+ before do
25
+ @x = fab.rating
26
+ end
27
+
28
+ it "is a number" do
29
+ @x.must_be_kind_of Fixnum
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+
@@ -0,0 +1,34 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'minitest/autorun'
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+
6
+ describe Fab do
7
+
8
+ let(:fab){ Fab.new }
9
+
10
+ describe "#company_name" do
11
+
12
+ before do
13
+ @x = fab.company_name
14
+ end
15
+
16
+ it "returns a string" do
17
+ @x.must_be_kind_of String
18
+ end
19
+
20
+ end
21
+
22
+ describe "#job_title" do
23
+
24
+ before do
25
+ @x = fab.job_title
26
+ end
27
+
28
+ it "returns a string" do
29
+ @x.must_be_kind_of String
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -0,0 +1,67 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'minitest/autorun'
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+
6
+ describe Fab do
7
+
8
+ let(:fab){ Fab.new }
9
+
10
+ describe "#date" do
11
+
12
+ before do
13
+ @x = fab.date
14
+ end
15
+
16
+ it "returns a date" do
17
+ @x.must_be_kind_of Date
18
+ end
19
+
20
+ end
21
+
22
+ describe "#start_date" do
23
+
24
+ before do
25
+ @x = fab.start_date
26
+ end
27
+
28
+ it "returns a date" do
29
+ @x.must_be_kind_of Date
30
+ end
31
+
32
+ end
33
+
34
+ describe "#stop_date" do
35
+
36
+ before do
37
+ @x = fab.stop_date
38
+ end
39
+
40
+ it "returns a date" do
41
+ @x.must_be_kind_of Date
42
+ end
43
+
44
+ end
45
+
46
+ describe "#start_date_and_stop_date" do
47
+
48
+ before do
49
+ @start, @stop = @x = fab.start_date_and_stop_date
50
+ end
51
+
52
+ it "is an array" do
53
+ @x.must_be_kind_of Array
54
+ end
55
+
56
+ it "contains a start date and stop date" do
57
+ @start.must_be_kind_of Date
58
+ @stop.must_be_kind_of Date
59
+ end
60
+
61
+ it "ensures start <= stop" do
62
+ @start.must_be :<=, @stop
63
+ end
64
+
65
+ end
66
+
67
+ end
@@ -0,0 +1,66 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'minitest/autorun'
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+
6
+ describe Fab do
7
+
8
+ let(:fab){ Fab.new }
9
+
10
+ describe "#datetime" do
11
+
12
+ before do
13
+ @x = fab.datetime
14
+ end
15
+
16
+ it "is a datetime" do
17
+ @x.must_be_kind_of DateTime
18
+ end
19
+ end
20
+
21
+ describe "#start_datetime" do
22
+
23
+ before do
24
+ @x = fab.start_datetime
25
+ end
26
+
27
+ it "is a datetime" do
28
+ @x.must_be_kind_of DateTime
29
+ end
30
+
31
+ end
32
+
33
+ describe "#stop_datetime" do
34
+
35
+ before do
36
+ @x = fab.stop_datetime
37
+ end
38
+
39
+ it "is a datetime" do
40
+ @x.must_be_kind_of DateTime
41
+ end
42
+
43
+ end
44
+
45
+ describe "#start_datetime_and_stop_datetime" do
46
+
47
+ before do
48
+ @start, @stop = @x = fab.start_datetime_and_stop_datetime
49
+ end
50
+
51
+ it "is an array" do
52
+ @x.must_be_kind_of Array
53
+ end
54
+
55
+ it "contains a start datetime and stop datetime" do
56
+ @start.must_be_kind_of DateTime
57
+ @stop.must_be_kind_of DateTime
58
+ end
59
+
60
+ it "ensures start <= stop" do
61
+ @start.must_be :<=, @stop
62
+ end
63
+
64
+ end
65
+
66
+ end
@@ -0,0 +1,22 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'minitest/autorun'
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+
6
+ describe Fab do
7
+
8
+ let(:fab){ Fab.new }
9
+
10
+ describe "#email_address" do
11
+
12
+ before do
13
+ @x = fab.email_address
14
+ end
15
+
16
+ it "is a string" do
17
+ @x.must_be_kind_of String
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,106 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'minitest/autorun'
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+
6
+ describe Fab do
7
+
8
+ let(:fab){ Fab.new }
9
+
10
+ describe "#path" do
11
+
12
+ before do
13
+ @x = fab.path
14
+ end
15
+
16
+ it "is a string" do
17
+ @x.must_be_kind_of String
18
+ end
19
+
20
+ end
21
+
22
+ describe "#basename" do
23
+
24
+ before do
25
+ @x = fab.basename
26
+ end
27
+
28
+ it "is a string" do
29
+ @x.must_be_kind_of String
30
+ end
31
+
32
+ end
33
+
34
+ describe "#basename_intension" do
35
+
36
+ before do
37
+ @x = fab.basename_intension
38
+ end
39
+
40
+ it "is a string" do
41
+ @x.must_be_kind_of String
42
+ end
43
+
44
+ end
45
+
46
+ describe "#basename_extension" do
47
+
48
+ before do
49
+ @x = fab.basename_extension
50
+ end
51
+
52
+ it "is a string" do
53
+ @x.must_be_kind_of String
54
+ end
55
+
56
+ end
57
+
58
+ describe "#dirname" do
59
+
60
+ before do
61
+ @x = fab.dirname
62
+ end
63
+
64
+ it "is a string" do
65
+ @x.must_be_kind_of String
66
+ end
67
+
68
+ end
69
+
70
+ describe "#dirname_part" do
71
+
72
+ before do
73
+ @x = fab.dirname_part
74
+ end
75
+
76
+ it "is a string" do
77
+ @x.must_be_kind_of String
78
+ end
79
+
80
+ end
81
+
82
+ describe "#file_extension" do
83
+
84
+ before do
85
+ @x = fab.file_extension
86
+ end
87
+
88
+ it "is a string" do
89
+ @x.must_be_kind_of String
90
+ end
91
+
92
+ end
93
+
94
+ describe "#file_path" do
95
+
96
+ before do
97
+ @x = fab.file_path
98
+ end
99
+
100
+ it "is a string" do
101
+ @x.must_be_kind_of String
102
+ end
103
+
104
+ end
105
+
106
+ end