hold_the_fort 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d071eb5c72d6915cac91b35d8eacf0cc0d6c13ce1aa4b998bec2cddbe1bc5fc4
4
+ data.tar.gz: 470bcf9a58d7fef1c31f4ad7319c2560eaa16290259160456b99857f145e9d2b
5
+ SHA512:
6
+ metadata.gz: 8f60e554183aaf8b464014b5d164106335d0429aea9fa0e377b181c27befbbbca0bcafd53f54840c7a8995f94cb4fecf3140a6c70b71ba56262a28caa602cf07
7
+ data.tar.gz: bd155e9057c78035b07efa8118f9917636a6aee6f6f82e7599d2b3c60fe0d6b07ae1e89ab8a8920071988701f530113a44fa50fc4f366e3c34e7f1609718e23b
@@ -0,0 +1,5 @@
1
+ class HoldTheFort
2
+ end
3
+
4
+ require 'hold_the_fort/hash'
5
+ require 'hold_the_fort/mocker'
@@ -0,0 +1,25 @@
1
+ class Hash
2
+ def mock(number = 1, mocker = Mocker.new)
3
+ hashes = []
4
+ (0...number).each do |i|
5
+ hash = {}
6
+ self.each do |key, value|
7
+ value = case value.class.to_s
8
+ when 'Integer'
9
+ mocker.int
10
+ when 'Hash'
11
+ value.mock
12
+ when 'String'
13
+ mocker.string
14
+ when 'Float'
15
+ mocker.float
16
+ else
17
+ 'Nothing'
18
+ end
19
+ hash[key] = value
20
+ end
21
+ hashes.append(hash)
22
+ end
23
+ hashes
24
+ end
25
+ end
@@ -0,0 +1,34 @@
1
+ class Mocker
2
+ attr_accessor :min_int,
3
+ :max_int,
4
+ :min_float,
5
+ :max_float,
6
+ :words,
7
+ :number_of_words
8
+
9
+ def initialize(min_int = 0,
10
+ max_int = 100,
11
+ min_float = 0.0,
12
+ max_float = 100.0,
13
+ words = 'lorem ipsum dolor sit amet consectetur adipiscing elit'.split(),
14
+ number_of_words = 1)
15
+ @min_int = min_int
16
+ @max_int = max_int
17
+ @min_float = min_float
18
+ @max_float = max_float
19
+ @words = words
20
+ @number_of_words = number_of_words
21
+ end
22
+
23
+ def int
24
+ @int ||= Random.new.rand(min_int..max_int)
25
+ end
26
+
27
+ def float
28
+ @float ||= Random.new.rand(min_float..max_float)
29
+ end
30
+
31
+ def string
32
+ @string ||= words.sample(number_of_words)
33
+ end
34
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hold_the_fort
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Michał Dziardziel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-11-17 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Generates hashes with sample data
14
+ email: mdziardziel@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/hold_the_fort.rb
20
+ - lib/hold_the_fort/hash.rb
21
+ - lib/hold_the_fort/mocker.rb
22
+ homepage: http://rubygems.org/gems/hold_the_fort
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.7.6
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Hold the fort!
46
+ test_files: []