Class: Encapsulator::ProvJSONParser

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

Direct Known Subclasses

RJSONParser

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



5
6
7
# File 'lib/encapsulator/provjson_parser.rb', line 5

def filename
  @filename
end

Instance Method Details

#activity(k, v) ⇒ Object



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

def activity k, v
end

#agent(k, v) ⇒ Object



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

def agent k, v
end

#entity(k, v) ⇒ Object



46
47
# File 'lib/encapsulator/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
# File 'lib/encapsulator/provjson_parser.rb', line 55

def parse_json string
  begin
    json = JSON.parse(string)
  rescue JSON::ParserError
    puts 'Failed parsing.'
    abort
  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['wasAssociatedWith'].each do |k, v|
    self.wasAssociatedWith k, v
  end unless !json.key? 'wasAssociatedWith'
end

#prefix(k, v) ⇒ Object



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

def prefix k, v
end

#read_json_file(filename) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/encapsulator/provjson_parser.rb', line 7

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

#read_log_file(filename) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/encapsulator/provjson_parser.rb', line 16

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

#used(k, v) ⇒ Object



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

def used k, v
end

#wasAssociatedWith(k, v) ⇒ Object



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

def wasAssociatedWith k, v
end

#wasDerivedFrom(k, v) ⇒ Object



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

def wasDerivedFrom k, v
end

#wasGeneratedBy(k, v) ⇒ Object



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

def wasGeneratedBy k, v
end

#wasInformedBy(k, v) ⇒ Object



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

def wasInformedBy k, v
end