Class: CamTool::ProvJSONParser

Inherits:
Object
  • Object
show all
Defined in:
lib/camtool/provjson_parser.rb

Instance Method Summary collapse

Instance Method Details

#activity(k, v) ⇒ Object



49
50
# File 'lib/camtool/provjson_parser.rb', line 49

def activity k, v
end

#agent(k, v) ⇒ Object



52
53
# File 'lib/camtool/provjson_parser.rb', line 52

def agent k, v
end

#entity(k, v) ⇒ Object



46
47
# File 'lib/camtool/provjson_parser.rb', line 46

def entity k, v
end

#parse_json(string) ⇒ Object



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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/camtool/provjson_parser.rb', line 55

def parse_json string
  begin
    json = JSON.parse(string)
  rescue JSON::ParserError => ex
    puts "Length: #{string.length}\n"
    abort "Error #{ex.class}, message: #{ex.message}"
  end

  json['prefix'].each do |k, v|
    self.prefix k, v
  end unless !json.key? 'prefix'

  json['entity'].each do |k, v|
    self.entity k, v
  end unless !json.key? 'entity'

  json['activity'].each do |k, v|
    self.activity k, v
  end unless !json.key? 'activity'

  json['agent'].each do |k, v|
    self.activity k, v
  end unless !json.key? 'agent'

  json['used'].each do |k, v|
    self.used k, v
  end unless !json.key? 'used'

  json['wasGeneratedBy'].each do |k, v|
    self.wasGeneratedBy k, v
  end unless !json.key? 'wasGeneratedBy'

  json['wasDerivedFrom'].each do |k, v|
    self.wasDerivedFrom k, v
  end unless !json.key? 'wasDerivedFrom'

  json['wasInformedBy'].each do |k, v|
    self.wasInformedBy k, v
  end unless !json.key? 'wasInformedBy'

  json['relation'].each do |k, v|
    self.relation k, v
  end unless !json.key? 'relation'

  json['wasAssociatedWith'].each do |k, v|
    self.wasAssociatedWith k, v
  end unless !json.key? 'wasAssociatedWith'
end

#prefix(k, v) ⇒ Object



43
44
# File 'lib/camtool/provjson_parser.rb', line 43

def prefix k, v
end

#read_json_file(filename) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/camtool/provjson_parser.rb', line 5

def read_json_file filename
  if filename != nil
    parse_json File.read(filename).gsub("\n", '') unless !File.file?(filename)
    print "File does not exist\n" unless File.file?(filename)
  end
  self
end

#read_log_file(filename) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/camtool/provjson_parser.rb', line 13

def read_log_file filename
  if filename != nil
    open(filename) do |file|
      file.each_line do |line|
        parse_json line.gsub("\n", '')
      end
    end unless !File.file?(filename)
    print "File does not exist\n" unless File.file?(filename)
  end
  self
end

#relation(k, v) ⇒ Object



40
41
# File 'lib/camtool/provjson_parser.rb', line 40

def relation k, v
end

#used(k, v) ⇒ Object



25
26
# File 'lib/camtool/provjson_parser.rb', line 25

def used k, v
end

#wasAssociatedWith(k, v) ⇒ Object



37
38
# File 'lib/camtool/provjson_parser.rb', line 37

def wasAssociatedWith k, v
end

#wasDerivedFrom(k, v) ⇒ Object



31
32
# File 'lib/camtool/provjson_parser.rb', line 31

def wasDerivedFrom k, v
end

#wasGeneratedBy(k, v) ⇒ Object



28
29
# File 'lib/camtool/provjson_parser.rb', line 28

def wasGeneratedBy k, v
end

#wasInformedBy(k, v) ⇒ Object



34
35
# File 'lib/camtool/provjson_parser.rb', line 34

def wasInformedBy k, v
end