Module: Faker::Webhookdb
- Defined in:
- lib/webhookdb/fixtures/faker.rb
Class Method Summary collapse
- .image_url(opts = {}) ⇒ Object
- .pg_connection(user: nil, password: nil, host: nil, port: nil, dbname: nil) ⇒ Object
- .s3_url(opts = {}) ⇒ Object
- .us_phone ⇒ Object
Class Method Details
.image_url(opts = {}) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/webhookdb/fixtures/faker.rb', line 13 def image_url(opts={}) opts[:protocol] ||= ["https", "http"].sample opts[:host] ||= ["facebook.com", "flickr.com", "mysite.com"].sample opts[:path] ||= "fld" opts[:filename] ||= Faker::Lorem.word opts[:ext] ||= ["png", "jpg", "jpeg"].sample return "#{opts[:protocol]}://#{opts[:host]}/#{opts[:path]}/#{opts[:filename]}.#{opts[:ext]}" end |
.pg_connection(user: nil, password: nil, host: nil, port: nil, dbname: nil) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/webhookdb/fixtures/faker.rb', line 32 def pg_connection(user: nil, password: nil, host: nil, port: nil, dbname: nil) user ||= Faker::Internet.username password ||= Faker::Internet.password host ||= Faker::Internet.ip_v4_address port ||= Faker::Number.between(from: 2000, to: 50_000) dbname ||= Faker::Lorem.word return "postgres://#{user}:#{password}@#{host}:#{port}/#{dbname}" end |
.s3_url(opts = {}) ⇒ Object
7 8 9 10 11 |
# File 'lib/webhookdb/fixtures/faker.rb', line 7 def s3_url(opts={}) opts[:region] ||= ["us-east-2.", ""].sample host = "potato.s3.#{opts[:region]}amazonaws.com" return self.image_url(host:) end |
.us_phone ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/webhookdb/fixtures/faker.rb', line 22 def us_phone s = +"1" # First char is never 0 in US area codes s << Faker::Number.between(from: 1, to: 9).to_s Array.new(9) do s << Faker::Number.between(from: 0, to: 9).to_s end return s end |