-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport.rb
81 lines (60 loc) · 1.49 KB
/
export.rb
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require 'rubygems'
require 'neo4j'
require 'neo4j-core'
require 'gexf'
graph = GEXF::Graph.new
graph.define_node_attribute(:name)
graph.define_node_attribute(:mail)
graph.define_node_attribute(:label)
graph.define_edge_attribute(:amount)
class String
# colorization
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def red
colorize(31)
end
def green
colorize(32)
end
def yellow
colorize(33)
end
def pink
colorize(35)
end
end
class Email
include Neo4j::ActiveNode
id_property :mail_id, on: :id
property :mailId, type:String
property :date, type:DateTime
property :subject, type:String
has_many :in, :sentmails, unique: true, model_class: "User"
has_many :out, :tomail, model_class: "User"
has_many :out, :ccusers, model_class: "User"
has_many :out, :bccusers, model_class: "User"
end
class User
include Neo4j::ActiveNode
id_property :mail_id, on: :mail
property :name, type:String
property :mail, type:String
has_many :out, :sentmails, unique: true, model_class: Email
has_many :in, :tomail, unique: true, model_class: Email
has_many :in, :ccusers, model_class: Email
has_many :in, :bccusers, model_class: Email
has_one :out, :domain, unique: true, model_class: "Domain"
end
class Domain
include Neo4j::ActiveNode
id_property :domain_id, on: :domain_id
property :domain, type:String
has_many :in, :users, unique: true, model_class: User
end
def userExport
User.all do |user|
puts user.name.pink
end
end