little_faker 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/fake.rb +71 -0
- data/lib/little_faker.rb +1 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MTgzMjg0MjUwMmRhOTA0NWUxNDAzNmI2MzM4MjcyMjgzNDhlNGI5Mw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ODFlYzI0NjExNjQ4NzJlMTdjMDJiNjI3MTg0Y2QyMDM1OTg5MThmYw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDFiNmNkY2EwNWI1MzEwMmVhOWQxYmRkMTExNWVkOTlkMTUzNjhiMTcyYzgw
|
10
|
+
NzhjMGZiMTYzYjNkOTkxNDMzZjFiODYwOTlkNDI2MzFlMmU2OWJjNTQ1NTA5
|
11
|
+
YjU5MGVlYzRlOTE2NmFhZTg0OWFkODliNjY5M2I1ODgyZTU1Mjc=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Y2ZiYjczZWI5Nzc2MjhlYTVhMTc3N2RhZWQ0MTQxNWJiNDFkYzg3MzJkNmNl
|
14
|
+
OWYyNjZkYzFjYmFiNGZmZWY5ZmUyZDNlNDMyMzY4MTdkMTRhODA4ZTZhZGM0
|
15
|
+
OTgwZjNkNTUwMzY2OWJkZTI0YWU1ZGU0NDhmMWI1OTc5NTg5NjQ=
|
data/lib/fake.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'faker'
|
2
|
+
#Exposes all Faker methods under to Fake class
|
3
|
+
# ie.
|
4
|
+
module Faker
|
5
|
+
module FakerMethodsDelegator
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def faker_method_modules
|
9
|
+
Faker.constants
|
10
|
+
.map{|c| Faker.const_get(c)}
|
11
|
+
.select{|const| const.is_a?(Class) && const.superclass == Faker::Base}
|
12
|
+
end
|
13
|
+
|
14
|
+
def faker_methods_hash
|
15
|
+
Hash[
|
16
|
+
*faker_method_modules.map do |faker_mod|
|
17
|
+
(faker_mod.methods - Faker::Base.methods).map do |method_name|
|
18
|
+
[method_name, faker_mod.method(method_name)]
|
19
|
+
end
|
20
|
+
end.flatten
|
21
|
+
]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.included(base)
|
26
|
+
base.class_eval do
|
27
|
+
@faker_methods_hash = FakerMethodsDelegator.faker_methods_hash
|
28
|
+
class << self
|
29
|
+
include ClassDelegationMethods
|
30
|
+
alias_method :respond_to_without_faker_methods?, :respond_to?
|
31
|
+
alias_method :respond_to?, :respond_to_with_faker_methods?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module ClassDelegationMethods
|
37
|
+
def respond_to_with_faker_methods?(method_name, include_all=false)
|
38
|
+
if @faker_methods_hash[method_name]
|
39
|
+
true
|
40
|
+
else
|
41
|
+
respond_to_without_faker_methods?(method_name, include_all)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def method_missing(method_name, *args, &block)
|
46
|
+
if (method = @faker_methods_hash[method_name])
|
47
|
+
method.call(*args, &block)
|
48
|
+
else
|
49
|
+
super
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def faker_methods
|
54
|
+
@faker_methods_hash.keys
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class Fake < Faker::Base
|
61
|
+
include Faker::FakerMethodsDelegator
|
62
|
+
|
63
|
+
class << self
|
64
|
+
def password_of_length(size=12)
|
65
|
+
words = []
|
66
|
+
words << word until words.inject(0){|len, a| len+a.size} >= size
|
67
|
+
words.join[0,size]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
data/lib/little_faker.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'fake'
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: little_faker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- R2dR
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faker
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.2.0
|
27
|
+
description: Call Faker methods from single module
|
28
|
+
email: github@r2dr.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/little_faker.rb
|
34
|
+
- lib/fake.rb
|
35
|
+
homepage: http://github.com/r2dr/little_faker
|
36
|
+
licenses: []
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.9'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements:
|
53
|
+
- faker, v1.2.0 or greater
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 2.0.6
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: Delegation interface for Faker gem
|
59
|
+
test_files: []
|