Permalink
Browse files

draft

  • Loading branch information...
kachick committed Jul 1, 2012
0 parents commit 2e47ee3f402728c127d21a16560ffefd98513c91
@@ -0,0 +1,26 @@
+*.gem
+*.rbc
+.bundle
+.config
+coverage
+coverage.data
+InstalledFiles
+lib/bundler/man
+pkg
+rdoc
+spec/reports
+test/tmp
+test/version_tmp
+tmp
+
+# YARD artifacts
+.yardoc
+_yardoc
+doc/
+
+# tmp-old
+.old
+
+# editor
+*~
+.redcar
674 COPYING

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,3 @@
+2010 ~ 2012
+
+ * 0.0.1
@@ -0,0 +1,11 @@
+README.rdoc
+COPYING
+Manifest.txt
+Rakefile
+History.txt
+lib/ovo_templatelogfile_summarizer.rb
+lib/ovo_templatelogfile_summarizer/csvformatter.rb
+lib/openviewoperations/template.rb
+lib/openviewoperations/template/parser.rb
+lib/openviewoperations/template/parser/logfile.rb
+bin/ovo_template-logfile_summarizer
@@ -0,0 +1,45 @@
+= ovo_template-logfile_summarizer
+
+code :: https://github.com/kachick/ovo_template-logfile_summarizer
+bugs :: https://github.com/kachick/ovo_template-logfile_summarizer/issues
+gem :: https://rubygems.org/gems/ovo_template-logfile_summarizer
+
+== Description
+
+An utility for the OVO(OpenViewOperations).
+"logfile.dat(syslog templates)" to some CSV files.
+
+== Feutures
+
+* Supportting formatted version is "5".
+ See the header of "logfile.dat"
+
+ > head logfile.dat
+
+* Author is just a user of OVO, Of course "No Warranty" :)
+
+== Usage
+
+ > ovo_template-logfile_summarizer logfile.dat [*logfile.dat]
+
+== Requirements
+
+* Ruby 1.9.3
+
+ Focusing
+
+ * 1.9.3-p194
+
+* striuct - 0.3.0
+
+== Installation
+
+* gem install ovo_template-logfile_summarizer
+
+== License
+
+GPL 3.0
+
+Copyright (c) 2010-2012 Kenichi Kamiya
+
+See the file COPYING for further details.
@@ -0,0 +1,16 @@
+gem 'hoe', '~> 3.0.6'
+require 'hoe'
+require 'fileutils'
+
+Hoe.plugin :newgem
+
+$hoe = Hoe.spec 'ovo_template-logfile_summarizer' do
+ developer 'Kenichi Kamiya', 'kachick1+ruby@gmail.com'
+ self.rubyforge_name = name
+ require_ruby_version '>= 1.9.3'
+ dependency 'striuct', '~> 0.3.0', :runtime
+ dependency 'yard', '>= 0.8.2', :development
+end
+
+require 'newgem/tasks'
+Dir['tasks/**/*.rake'].each {|t|load t}
@@ -0,0 +1,10 @@
+#!/usr/local/bin/ruby -w
+# Copyright (C) 2012 Kenichi Kamiya
+
+require_relative '../lib/ovo_templatelogfile_summarizer'
+
+unless ARGV.length >= 1
+ abort "usage: #{$PROGRAM_NAME} logfile.dat [*logfile.dat]"
+end
+
+OVO_TemplateLogfile_Summarizer.run ARGV
@@ -0,0 +1,61 @@
+# Copyright (C) 2011 Kenichi Kamiya
+
+require 'forwardable'
+require 'striuct'
+
+module OpenViewOperations
+
+ class Templates < Striuct
+ extend Forwardable
+
+ SYNTAX_VERSION = '5'.freeze
+
+ Condition = Striuct.define do
+ member :mode, AND(Symbol, /\A[^\n]+\z/)
+ member :description, AND(String, /\A[^\n]+\z/)
+ member :supp_dupl_ident, OR(CAN(:each_pair), nil)
+ member :supp_dupl_ident_output_msg, OR(CAN(:each_pair), nil)
+ member :condition_id, AND(Symbol, /\A[^\n]+\z/)
+ member :core, ->v{v.class.name.slice(/([^:]+)\z/, 1) == 'Core'}
+ member :set, CAN(:each_pair)
+ end
+
+ Node = Striuct.define do
+ member :ipaddress, AND(String, /\A(?:\d{1,3}\.){3}\d{1,3}\z/)
+ member :hostname, AND(String, /\A\S+\z/)
+
+ def inspect
+ "IP: #{ipaddress} - Hostname: #{hostname}"
+ end
+ end
+
+ member :name, AND(String, /\A[^\n]+\z/)
+ member :description, AND(String, /\A[^\n]+\z/)
+ member :set, CAN(:each_pair)
+ member :conditions, GENERICS(Condition)
+ close
+
+ class << self
+ def parse(str, type)
+ instance_eval("self::Parser::#{type}").parse str
+ end
+
+ def load(path)
+ str = File.read path
+
+ if /\ASYNTAX_VERSION \d+\n+(?<type>\w+) "/ =~ str
+ parse str, type
+ else
+ raise ArgumentError, 'Unknown format'
+ end
+ end
+ end
+
+ def_delegators :conditions, :each, :each_with_index
+
+ def each_with_ovo_index
+ each_with_index {|v, i|yield v, i + 1}
+ end
+ end
+
+end
Oops, something went wrong.

0 comments on commit 2e47ee3

Please sign in to comment.