-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathThorfile
More file actions
51 lines (47 loc) · 1.44 KB
/
Thorfile
File metadata and controls
51 lines (47 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require 'open-uri'
Bundler.require
require 'faker/japanese'
require 'romaji'
require_relative './core'
class Default < Thor
desc 'cleanup_db', 'cleanup database'
def cleanup_db
::Mongoid.purge!
::Mongoid::Clients.default.database.drop
end
desc 'load_random_data', 'load random data'
def load_random_data
doc = Nokogiri::HTML(open("https://pinboard.in/u:youpy").read)
tags = doc.search('#tag_cloud a.tag').map {|x| x.text }
users = []
1.upto(200) do |i|
first_name = Faker::Japanese::Name.first_name
last_name = Faker::Japanese::Name.last_name
uid = [
Romaji.kana2romaji(first_name.yomi),
Romaji.kana2romaji(last_name.yomi)
].join('.') + "@gmail.com"
users << User.create!(
uid: uid,
provider: "saml",
screen_name: "#{last_name} #{first_name}",
name: uid,
tags: [tags.sample, tags.sample, tags.sample],
)
end
url = "https://raw.githubusercontent.com/tily/domoraen/master/data/tools.json"
items = JSON.parse(open(url).read)['originals']
1.upto(200) do |i|
Work.create!(
title: items.pop,
date: Random.rand(Time.parse("1983/09/27")..Time.parse("2017/12/15")),
links_text: [
"http://www.google.com",
"http://www.google.com",
].join("\n"),
tags: [tags.sample, tags.sample, tags.sample],
users: [users.sample, users.sample, users.sample],
)
end
end
end