quickdata_generator 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 72577396f7adc7609ba4b5ced16e2e61cc7b04c1
4
+ data.tar.gz: f1f1ca1d275fd019a5bae1515305da7f377a7f1f
5
+ SHA512:
6
+ metadata.gz: 48ddda3b026090f178dfb64edbd677f5c3aafdffc633679bacfcfa8de96668152dc0cb2a650b42228f830cdc6ccfcc0d8cd21802133ed8e5b397ba7631d5c986
7
+ data.tar.gz: ab280f3e1bb0139790eb5ef21be3ca5204a8184bf2987bd5b8179eac24bfd6a08b4c2ed4f169f9c3b704cd48a7278202156dc7ae59e46173907ef3486f20d578
@@ -0,0 +1 @@
1
+ �2>�>IV���E��VΩٌ���LM�� byr�p2A2�{*j�)��,FH�O�5�t���
Binary file
@@ -0,0 +1,51 @@
1
+ # file: quickdata_generator.rb
2
+ # desc: Generators random data from a simple_config format
3
+
4
+ require 'simple-config'
5
+
6
+
7
+ class QuickDataGenerator
8
+
9
+ attr_reader :to_a
10
+
11
+ def initialize(s, rows: 3)
12
+
13
+ entries = SimpleConfig.new(s).to_h
14
+ @to_a = rows.times.map { generate_value(entries) }
15
+
16
+ end
17
+
18
+
19
+ private
20
+
21
+ def generate_value(entries)
22
+
23
+ entries.inject({}) do |r, x|
24
+
25
+ key, s = x
26
+
27
+ val = if /^(?<x1>\d+)\.\.(?<x2>\d+)$/ =~ s then
28
+
29
+ Range.new(x1.to_i,x2.to_i).to_a.sample
30
+
31
+ elsif /^(?<x1>\d+)\.(?<i>\d+)\.\.(?<x2>\d+(?:\.\d+)?)$/ =~ s then
32
+
33
+ range = Range.new(x1.to_i,x2.to_i)
34
+ a = []
35
+ increment = 1 / 10.0 ** i.length
36
+
37
+ sum = "#{x1}.#{i}".to_f
38
+ (sum += increment; a << sum) until sum >= x2.to_i
39
+ a.map{|x| x.round(i.length)}.to_a.sample
40
+
41
+ else
42
+ s.split(/\s*,\s*/).sample
43
+ end
44
+
45
+ r.merge(key => val)
46
+ end
47
+
48
+ end
49
+
50
+ end
51
+
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quickdata_generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
+ YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
+ 8ixkARkWAmV1MB4XDTE2MDkxMTE1MDU0N1oXDTE3MDkxMTE1MDU0N1owSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
+ ggEBAMrtRaK3sO9t6QR9L+IQYcseLUf9pN46PL+BXiLFiumjzSxAktdZUX8lfYNJ
19
+ raURAX07yjJxq3IAkUMgnGogybTnnP2KrS3DOcyGlZuiSqIl30yHIlg4abB4m0i8
20
+ jgZ4UgTP8NlvewKbFxtOeeEGRG0Ksh9sKyhplKpxe4CqRNlcSimJB2AwBS/7UVUr
21
+ 8K6oOqR6J2MqCZmwJyEGqLxhcNWDN0dVYLy/VVcNgxoSJXyddbzAZQAwN6dwXzNa
22
+ 44Ph/mjdOHP7k5Bn7m0boxFGDUmpK6j0jtAOE3Oq9y8/tY+yIgOWHeI30kPxsCap
23
+ pn9ckywppv73jowV9efBzk8vShsCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQU8yNR+yeI7TxHtAdzC+pP6s9RtAwwJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAcgOqfjdT
27
+ seDb5jGp4NqKgazdL4QnNbM5sVRB8QFKK8/mqf5rX5nQOfdhbVwg5tBc3l3ZRfoU
28
+ fpqNhhGzIZ9sYdTLsIS6dlvkk5T1zmQ5vid2HP9Va0jCi6qV9+qpdqVNejAg2yxQ
29
+ j0DrZFDQZyfy4DJ6OKyInh/Igi3RJWyAdZirgiMjS0CBJnZX086RL4ZjlZgi3LeA
30
+ 3cMAaGGrr27AWC9pYpSbM73kL9Rol55CSwvA0EvAXiIVMx5RvDyTs2Brm0JZvcKN
31
+ KIMzSAT8BjhbJH6sXUxJ+a4+p3GfLUikdDO7qQ/ulQMMJYCaT22ycrm6KbLwRGIy
32
+ 1sL9hi2IEM5N/g==
33
+ -----END CERTIFICATE-----
34
+ date: 2016-09-11 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: simple-config
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.6'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.6.1
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.6'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.6.1
56
+ description:
57
+ email: james@r0bertson.co.uk
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/quickdata_generator.rb
63
+ homepage: https://github.com/jrobertson/quickdata_generator
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.5.1
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Generates data from a simple-config format.
87
+ test_files: []
Binary file