regulos 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. data/CHANGELOG.md +5 -0
  2. data/README.md +22 -0
  3. data/lib/regulos.rb +5 -0
  4. data/lib/regulos/combat_log/event.rb +9 -0
  5. data/lib/regulos/combat_log/event/affliction.rb +8 -0
  6. data/lib/regulos/combat_log/event/attack_hit.rb +8 -0
  7. data/lib/regulos/combat_log/event/attack_miss.rb +8 -0
  8. data/lib/regulos/combat_log/event/base.rb +109 -0
  9. data/lib/regulos/combat_log/event/begin_cast.rb +8 -0
  10. data/lib/regulos/combat_log/event/buff_fade.rb +8 -0
  11. data/lib/regulos/combat_log/event/buff_gain.rb +8 -0
  12. data/lib/regulos/combat_log/event/critical_heal.rb +8 -0
  13. data/lib/regulos/combat_log/event/critical_hit.rb +8 -0
  14. data/lib/regulos/combat_log/event/damage.rb +8 -0
  15. data/lib/regulos/combat_log/event/damage_over_time.rb +8 -0
  16. data/lib/regulos/combat_log/event/death.rb +8 -0
  17. data/lib/regulos/combat_log/event/dissipate.rb +8 -0
  18. data/lib/regulos/combat_log/event/dodge.rb +8 -0
  19. data/lib/regulos/combat_log/event/end_cast.rb +8 -0
  20. data/lib/regulos/combat_log/event/fall_damage.rb +8 -0
  21. data/lib/regulos/combat_log/event/heal.rb +8 -0
  22. data/lib/regulos/combat_log/event/immune.rb +8 -0
  23. data/lib/regulos/combat_log/event/interrupt.rb +8 -0
  24. data/lib/regulos/combat_log/event/mana_gain.rb +8 -0
  25. data/lib/regulos/combat_log/event/miss.rb +0 -0
  26. data/lib/regulos/combat_log/event/parry.rb +8 -0
  27. data/lib/regulos/combat_log/event/resist.rb +8 -0
  28. data/lib/regulos/combat_log/event/unknown.rb +8 -0
  29. data/lib/regulos/combat_log/event/unknown_death.rb +8 -0
  30. data/lib/regulos/combat_log/file.rb +29 -0
  31. data/lib/regulos/version.rb +7 -0
  32. metadata +109 -0
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ #### v0.1.1
2
+ * Add more tests
3
+ * Fix event determination for deaths
4
+ #### v0.1.0
5
+ * Initial parser
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # Regulos
2
+
3
+ ### 'Rift - Planes of Telera' combat log parser
4
+
5
+
6
+ #### How to Install
7
+
8
+ * gem install regulos
9
+
10
+
11
+ #### Usage
12
+
13
+ * require 'regulos'
14
+ * log = Regulos::CombatLog.parse "/path/to/combatlog.txt"
15
+ * log.events
16
+
17
+
18
+ #### Methods on Event
19
+ time, action_code, origin, target, origin_name, target_name, output, spell_id, spell_name, full_message
20
+
21
+
22
+
data/lib/regulos.rb ADDED
@@ -0,0 +1,5 @@
1
+ lib = File.expand_path('../', __FILE__)
2
+ $:.unshift lib unless $:.include?(lib)
3
+
4
+ require "regulos/combat_log/file.rb"
5
+ require "regulos/combat_log/event.rb"
@@ -0,0 +1,9 @@
1
+ lib = File.expand_path('../', __FILE__)
2
+ $:.unshift lib unless $:.include?(lib)
3
+ require "event/base"
4
+
5
+ event_path = File.join(lib, "event" )
6
+ glob_pattern = event_path + "/**/*.rb"
7
+ Dir.glob( glob_pattern ).each do |file|
8
+ require file
9
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class Affliction < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class AttackHit < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class AttackMiss < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,109 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ CODES = {
5
+ :Unknown => "-1",
6
+ :BeginCast => "1",
7
+ :Interrupt => "2",
8
+ :AttackHit => "3",
9
+ :DamageOverTime => "4",
10
+ :Heal => "5",
11
+ :BuffGain => "6",
12
+ :BuffFade => "7",
13
+ :Affliction => "8",
14
+ :Dissipate => "9",
15
+ :AttackMiss => "10",
16
+ :Death => "11",
17
+ :UnknownDeath => "12",
18
+ :FallDamage => "14",
19
+ :Dodge => "15",
20
+ :Parry => "16",
21
+ :CriticalHit => "23",
22
+ :Immune => "26",
23
+ :ManaGain => "27",
24
+ :CriticalHeal => "28"
25
+ }
26
+ def Event.handle row
27
+ Base.which(row)
28
+ end
29
+
30
+ # An event represents a row in the combat log.
31
+ class Base
32
+ def initialize(attributes)
33
+ process attributes
34
+ end
35
+
36
+ def inspect
37
+ "<#{self.class}>"
38
+ end
39
+
40
+ def code
41
+ CODES.invert[ action_code ]
42
+ end
43
+
44
+ def heal?
45
+ full_message =~ /heals/
46
+ end
47
+
48
+ def overheal?
49
+ full_message =~ /\d\soverheal/
50
+ end
51
+
52
+ def buff?
53
+ code == :BuffGain
54
+ end
55
+
56
+ def debuff?
57
+ code == :Affliction
58
+ end
59
+
60
+ def process attributes
61
+ attributes.each_pair{|k,v| self.class.send(:attr_reader, k); instance_variable_set("@#{k}", v) }
62
+ end
63
+
64
+ protected
65
+
66
+ class << self
67
+ def which(row)
68
+ require "strscan"
69
+ s = StringScanner.new row
70
+ #03:53:35: ( 15 , T=N#R=O#9223372038886130583 , T=N#R=O#9223372043800556153 , T=X#R=X#224054081475471412 , T=X#R=X#0 , Lesser Earth Elemental , Eternal Servant , 0 , 75533189 , Thud ) Eternal Servant dodges Lesser Earth Elemental's Thud.
71
+ entity_regex = /\s[A-Z]=[A-Z]#[A-Z]=[A-Z]#\d+?\s,/
72
+ e = {}
73
+ e[:time] = s.scan(/\d{2}:\d{2}:\d{2}:\s\(/) # Time of action
74
+ e[:action_code] = s.scan(/\s\d+?\s,/) # 15 (dodge)
75
+ e[:origin] = s.scan entity_regex
76
+ e[:target] = s.scan entity_regex
77
+ e[:pet_origin] = s.scan entity_regex # Your pet did something
78
+ e[:pet_target] = s.scan entity_regex # Your pet is receiving damage, heal, etc
79
+ e[:origin_name] = s.scan /\s[A-Za-z\s\-]+?\s,/
80
+ e[:target_name] = s.scan /\s[A-Za-z\s\-]+?\s,/
81
+ e[:output] = s.scan /\s\d+?\s,/ # Damage or healing output
82
+ e[:spell_id] = s.scan /\s\d+?\s,/ # Spell ID
83
+ e[:spell_name] = s.scan /\s[A-Za-z\-\s]+?\s\)/ # Spell name
84
+ e[:full_message] = s.scan /\s(.*)+\Z/ # Full log message
85
+ e = sanitize(e)
86
+ determine_event_type(e).new e
87
+ end
88
+
89
+ def sanitize hash
90
+ hash.each_pair do |k,v|
91
+ v.to_s.strip! # Remove leading space
92
+ v.to_s.gsub! /[,\(\)]\Z/, '' # Then remove leading comma or parenthesis
93
+ v.to_s.gsub! /\A[,\(\)]/, '' # Then remove trailing comma or parenthesis
94
+ v.to_s.strip! # Then remove trailing space
95
+ hash[k] = v
96
+ end
97
+
98
+ hash
99
+ end
100
+
101
+ def determine_event_type hash
102
+ kind = CODES.invert.fetch(hash[:action_code]){ "Unknown" }
103
+ Regulos::CombatLog::Event.const_get "#{kind}"
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class BeginCast < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class BuffFade < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class BuffGain < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class CriticalHeal < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class CriticalHit < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class AttackHit < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class DamageOverTime < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class Death < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class Dissipate < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class Dodge < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class EndCast < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class FallDamage < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class Heal < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class Immune < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class Interrupt < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class ManaGain < Base
5
+ end
6
+ end
7
+ end
8
+ end
File without changes
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class Parry < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class Resist < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class Unknown < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Regulos
2
+ module CombatLog
3
+ module Event
4
+ class UnknownDeath < Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,29 @@
1
+ module Regulos
2
+ module CombatLog
3
+ class FileNotFoundError < RuntimeError; end
4
+ # Helper for .new
5
+ def CombatLog.parse(path)
6
+ log = File.new( :path => path )
7
+ log.parse
8
+ log
9
+ end
10
+
11
+ class File
12
+
13
+ attr_reader :path, :events
14
+ def initialize(options={})
15
+ @path = ::File.exist?( options[:path] ) ? options[:path] : raise(FileNotFoundError, "The specified combat log does not exist.")
16
+ @events = []
17
+ end
18
+
19
+ def parse
20
+ data = ::File.readlines path
21
+ data.each{|row| @events << Event.handle(row) }
22
+ end
23
+
24
+ def inspect
25
+ "<Regulos::CombatLog::File path=#{@path}>"
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,7 @@
1
+ module Regulos
2
+ MAJOR_VERSION = "0"
3
+ MINOR_VERSION = "1"
4
+ BUG_VERSION = "1"
5
+
6
+ VERSION = [ MAJOR_VERSION, MINOR_VERSION, BUG_VERSION ].join "."
7
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: regulos
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 1
9
+ version: 0.1.1
10
+ platform: ruby
11
+ authors:
12
+ - James Cook
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-27 00:00:00 -06:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :development
32
+ version_requirements: *id001
33
+ description: Regulos parses combat logs for reporting & statistics.
34
+ email:
35
+ - james@isotope11.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files: []
41
+
42
+ files:
43
+ - lib/regulos/combat_log/event/affliction.rb
44
+ - lib/regulos/combat_log/event/attack_hit.rb
45
+ - lib/regulos/combat_log/event/attack_miss.rb
46
+ - lib/regulos/combat_log/event/base.rb
47
+ - lib/regulos/combat_log/event/begin_cast.rb
48
+ - lib/regulos/combat_log/event/buff_fade.rb
49
+ - lib/regulos/combat_log/event/buff_gain.rb
50
+ - lib/regulos/combat_log/event/critical_heal.rb
51
+ - lib/regulos/combat_log/event/critical_hit.rb
52
+ - lib/regulos/combat_log/event/damage.rb
53
+ - lib/regulos/combat_log/event/damage_over_time.rb
54
+ - lib/regulos/combat_log/event/death.rb
55
+ - lib/regulos/combat_log/event/dissipate.rb
56
+ - lib/regulos/combat_log/event/dodge.rb
57
+ - lib/regulos/combat_log/event/end_cast.rb
58
+ - lib/regulos/combat_log/event/fall_damage.rb
59
+ - lib/regulos/combat_log/event/heal.rb
60
+ - lib/regulos/combat_log/event/immune.rb
61
+ - lib/regulos/combat_log/event/interrupt.rb
62
+ - lib/regulos/combat_log/event/mana_gain.rb
63
+ - lib/regulos/combat_log/event/miss.rb
64
+ - lib/regulos/combat_log/event/parry.rb
65
+ - lib/regulos/combat_log/event/resist.rb
66
+ - lib/regulos/combat_log/event/unknown.rb
67
+ - lib/regulos/combat_log/event/unknown_death.rb
68
+ - lib/regulos/combat_log/event.rb
69
+ - lib/regulos/combat_log/file.rb
70
+ - lib/regulos/version.rb
71
+ - lib/regulos.rb
72
+ - README.md
73
+ - CHANGELOG.md
74
+ has_rdoc: true
75
+ homepage: http://github.com/jamecook/regulos
76
+ licenses: []
77
+
78
+ post_install_message:
79
+ rdoc_options: []
80
+
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ segments:
97
+ - 1
98
+ - 3
99
+ - 6
100
+ version: 1.3.6
101
+ requirements: []
102
+
103
+ rubyforge_project:
104
+ rubygems_version: 1.3.7
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: "'Rift - Planes of Telera' combat log parser"
108
+ test_files: []
109
+