zfaker 0.0.4 → 0.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68c9c37aba4c5cb2fe5ffd91408e54d2c43d1c54
4
- data.tar.gz: 01fd70a58053c8f72deee2cc24ea7bd767dfda09
3
+ metadata.gz: 791827cda577cc07822834d7c855f25b76b3bf88
4
+ data.tar.gz: 7081a38021838e873e25ed95586057d7f4a2570c
5
5
  SHA512:
6
- metadata.gz: 26ec4152c5de2667355fc079ceb4ac6b0933f40d3de4ce0ea45254820bca84cb6a54e5306b0827239b28743cdd3e0ec84223b4cebc770521a2f442b1e69889a9
7
- data.tar.gz: c1f91f6d595840d3401de60d653848dab34327a9f066e9b88c31704cd530bd73e820b93cbaff63ad869a8c10586a3f1910abd701eced5f15d104108ff81f307a
6
+ metadata.gz: 038a633d64114abf2df5dc547ec90d913132bba3bb1e81d9a5dfb917fe04469088b42adf1531a416adc4b85618511f2fab2bf8bc843de7f9c7530c73e62b3e8f
7
+ data.tar.gz: d5a170d6d358f8ba904c0d876c93d3d5757710a6ff77869dcf49789b8d1010fa2f327c6ea57023876bae933a2783b0077a16921c343c6ef21669dff841bfc6b3
@@ -31,6 +31,26 @@ module ZFaker
31
31
  end
32
32
  end
33
33
 
34
+ def build_const(const_name, file)
35
+ data_path = file
36
+ reader = k File.read(data_path).split("\n")
37
+ arrout = []
38
+ reader.each do |x|
39
+ cut = x.split(' ')
40
+ if cut.size > 1 && cut[0].integer?
41
+ weight = cut[0].to_i
42
+ element = cut[1..-1].join(' ')
43
+ element = '' if element == '<blank>'
44
+ else
45
+ weight = 1
46
+ element = cut[0..-1].join(' ')
47
+ end
48
+ weight.times { arrout.push(element) }
49
+ end
50
+ const_set const_name, arrout
51
+ arrout
52
+ end
53
+
34
54
  def underscore(string)
35
55
  string.gsub(/::/, '/')
36
56
  .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
data/bin/zfaker.rb CHANGED
@@ -5,10 +5,8 @@ module ZFaker
5
5
 
6
6
  extend ModuleUtils
7
7
 
8
- #BASE_LIB_PATH = File.expand_path('..', __FILE__)
9
8
  BASE_LIB_PATH = File.expand_path('../zfaker/lib')
10
9
 
11
-
12
10
  LETTERS = [*'a'..'z']
13
11
 
14
12
  HEX = %w(0 1 2 3 4 5 6 7 8 9 A B C D E F)
@@ -29,17 +27,13 @@ module ZFaker
29
27
  letterify(numerify(masks))
30
28
  end
31
29
 
30
+ def add(file)
31
+ extn = File.extname file
32
+ name = File.basename file, extn
33
+ build_const(name, file)
34
+ end
32
35
 
33
36
 
34
- absolute_path = File.expand_path('../zfaker/lib/custom')
35
-
36
- load("#{absolute_path}.rb") if File.exist?("#{absolute_path}.rb")
37
-
38
- if File.directory? absolute_path
39
- Dir[File.join(absolute_path, '**', '*.rb')].sort.each do |file|
40
- load file
41
- end
42
- end
43
37
  end
44
38
 
45
39
 
data/lib/config.rb ADDED
@@ -0,0 +1,7 @@
1
+ Dir["#{File.dirname(File.absolute_path(__FILE__))}/custom/**/*.rb"].each do |file|
2
+ require_relative file
3
+ end
4
+
5
+ Dir["#{File.dirname(File.absolute_path(__FILE__))}/data/**/*.rb"].each do |file|
6
+ ZFaker.add(file)
7
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zfaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Mackie
@@ -19,6 +19,7 @@ files:
19
19
  - bin/utils/array_utils.rb
20
20
  - bin/utils/module_utils.rb
21
21
  - bin/zfaker.rb
22
+ - lib/config.rb
22
23
  - lib/custom/internet.rb
23
24
  - lib/custom/name.rb
24
25
  - lib/data/internet/hosts