README.md in rasn1-0.3.1 vs README.md in rasn1-0.4.0

- old
+ new

@@ -1,6 +1,7 @@ [![Gem Version](https://badge.fury.io/rb/rasn1.svg)](https://badge.fury.io/rb/rasn1) +[![Build Status](https://travis-ci.org/sdaubert/rasn1.svg?branch=master)](https://travis-ci.org/sdaubert/rasn1) # Rasn1 Rasn1 will be a ruby ASN.1 library to encode, parse and decode ASN.1 data in DER format. @@ -27,13 +28,19 @@ Record ::= SEQUENCE { id INTEGER, room [0] INTEGER OPTIONAL, house [1] INTEGER DEFAULT 0 } + +ComplexRecord ::= SEQUENCE { + bool BOOLEAN, + data [0] EXPLICIT OCTET STRING, + a_record Record +} ``` -## Create a ASN.1 model +### Create a ASN.1 model ```ruby class Record < RASN1::Model sequence :record, content: [integer(:id), @@ -46,16 +53,16 @@ ```ruby class ComplexRecord < RASN1::Model sequence :cplx_record, content: [boolean(:bool), - octet_string(:data, explicit: 0), - model(:a_record, Record)] + octet_string(:data, explicit: 0), + model(:a_record, Record)] end ``` -## Parse a DER-encoded string +### Parse a DER-encoded string ```ruby record = Record.parse(der_string) record[:id] # => RASN1::Types::Integer record[:id].value # => Integer record[:id].to_i # => Integer @@ -64,13 +71,20 @@ record[:id].default # => nil record[:room].optional # => true record[:house].default # => 0 record[:id].to_der # => String + +cplx_record = ComplexRecord.parse(der_string) +cplx_record[:bool] # => RASN1::Types::Boolean +cplx_record[:bool].value # => TrueClass/FalseClass +cplx_record[:data].value # => String +cplx_record[:data].explicit? # => true +cplx_record[:a_record] # => Record ``` -## Generate a DER-encoded string +### Generate a DER-encoded string ```ruby record = Record.new(id: 12) record[:id].to_i # => 12 record[:room] # => nil record[:house] # => 0 @@ -83,9 +97,12 @@ record.set id: 124, house: 155 record.to_der # => String ``` +### More information + +see https://github.com/sdaubert/rasn1/wiki + ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/sdaubert/rasn1. -