Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/844196/log_parser
https://github.com/844196/log_parser
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/844196/log_parser
- Owner: 844196
- License: mit
- Created: 2016-01-11T17:49:16.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-16T15:28:35.000Z (almost 9 years ago)
- Last Synced: 2023-08-02T04:55:10.657Z (over 1 year ago)
- Language: Ruby
- Size: 36.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LogParser
[![Required Ruby](https://img.shields.io/badge/ruby-%3E%3D%202.2.4-red.svg)](#)
[![Travis branch](https://img.shields.io/travis/844196/log_parser.svg)](https://travis-ci.org/844196/log_parser)
[![Coveralls branch](https://img.shields.io/coveralls/844196/log_parser/master.svg)](https://coveralls.io/github/844196/log_parser)
[![Code Climate](https://img.shields.io/codeclimate/github/844196/log_parser.svg)](https://codeclimate.com/github/844196/log_parser)## Usage
```ruby
require 'log_parser'
require 'csv'LogParser.yaml_load :file_obj => DATA
csv = <<-EOS
PC00101,ak1111054,2000/01/01,0:00:00,0:01:00
PC00203,sushi_tabetai,2000/01/01,12:34:56,15:31:58
EOSrecords = []
CSV.parse(csv) do |client_id, user_id, use_date, startup_time, shutdown_time|
records << LogParser::Record.parse({
:client_id => client_id,
:user_id => user_id,
:use_date => Date.parse(use_date),
:startup_time => Time.parse("#{use_date} #{startup_time}"),
:shutdown_time => Time.parse("#{use_date} #{shutdown_time}")
})
endrecords[0].pc.place #=> "1F"
records[0].user.department #=> "keiei_keizai"
records[1].user.student? #=> false
records[1].use_date_time.uptime #=> 10622__END__
:faculty:
keizai:
- ak
hoken:
- ah:department:
keiei_keizai:
- 11
- 12
hoken_fukushi:
- 61
- 62:place:
1F: !ruby/regexp /PC001../
2F: !ruby/regexp /PC002../:student_id:
:legal_pattern:
!ruby/regexp /\A(?\w{2})(?\d{1,2})(?\d{2})(?\d{3})\z/
```