pio 0.1.0 → 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 42e4ddeb113721d1515042c5b21242f7f5f49f76
4
+ data.tar.gz: 4d135571f99d94db9e3b0f534e8154669da4360d
5
+ SHA512:
6
+ metadata.gz: bae38aa9d987cfd6965b4657222e8713dc4e019d655bcc4fc2b81c1bdee8fa03d5b9795324b8915290e56d78ae4b8b93584d071b0cc65ab921b64da47b7cb61c
7
+ data.tar.gz: 0ff3e93fc9a7159807c3ed2bb01fb8ff045e948e34ee32a1956b6856fa9ec24c8734b2287bffd5fe77d66194e29c5e5d85f63db329495cfa480af23971e3bf9f
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+
3
+ script: "rake travis"
4
+
5
+ rvm:
6
+ - 1.9.3
7
+ - 2.0.0
8
+
9
+ branches:
10
+ only:
11
+ - master
12
+ - develop
data/Gemfile CHANGED
@@ -1,27 +1,28 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
 
4
- gem "bindata"
4
+ gemspec
5
5
 
6
6
 
7
7
  group :development do
8
- gem "cucumber", "~> 1.3.3"
9
- gem "flay", "~> 2.3.1"
8
+ gem "coveralls", "~> 0.6.7", :require => false
9
+ gem "flay", "~> 2.4.0"
10
10
  gem "flog", "~> 4.1.1"
11
- gem "guard", "~> 1.8.1"
11
+ gem "guard", "~> 1.8.2"
12
12
  gem "guard-bundler", "~> 1.0.0"
13
13
  gem "guard-rspec", "~> 3.0.2"
14
+ gem "json", "~> 1.8.0" if RUBY_VERSION < "1.9.0"
14
15
  gem "rake", "~> 10.1.0"
15
16
  gem "rb-fchange", "~> 0.0.6", :require => false
16
17
  gem "rb-fsevent", "~> 0.9.3", :require => false
17
- gem "rb-inotify", "~> 0.9.0", :require => false
18
+ gem "rb-inotify", "~> 0.9.1", :require => false
18
19
  gem "redcarpet", "~> 2.3.0" if RUBY_VERSION < "1.9.0"
19
20
  gem "redcarpet", "~> 3.0.0" if RUBY_VERSION >= "1.9.0"
20
- gem "reek", "~> 1.3.1"
21
+ gem "reek", "~> 1.3.3"
21
22
  gem "rspec", "~> 2.14.1"
22
23
  gem "rspec-instafail", "~> 0.2.4"
23
24
  gem "terminal-notifier-guard", "~> 1.5.3"
24
- gem "yard", "~> 0.8.6.2"
25
+ gem "yard", "~> 0.8.7"
25
26
  end
26
27
 
27
28
 
data/README.md CHANGED
@@ -1,4 +1,99 @@
1
- pio
1
+ Pio
2
2
  ===
3
+ [![Gem Version](https://badge.fury.io/rb/pio.png)](http://badge.fury.io/rb/pio)
4
+ [![Build Status](https://travis-ci.org/trema/pio.png?branch=develop)](https://travis-ci.org/trema/pio)
5
+ [![Code Climate](https://codeclimate.com/github/trema/pio.png)](https://codeclimate.com/github/trema/pio)
6
+ [![Coverage Status](https://coveralls.io/repos/trema/pio/badge.png?branch=develop)](https://coveralls.io/r/trema/pio)
7
+ [![Dependency Status](https://gemnasium.com/trema/pio.png)](https://gemnasium.com/trema/pio)
3
8
 
4
- Packet parser and generator
9
+ <a href="http://www.flickr.com/photos/mongogushi/4226014070/" title="pio pencil by mongo gushi, on Flickr"><img src="http://farm5.staticflickr.com/4022/4226014070_cdeb7c1e5d_n.jpg" width="320" height="290" alt="pio pencil"></a>
10
+
11
+ Pio is a ruby gem to easily parse and generate network packets. It supports the following packet formats:
12
+
13
+ * [LLDP](http://en.wikipedia.org/wiki/Link_Layer_Discovery_Protocol)
14
+ * (...currently there are just a few formats supported but I'm sure this list will grow)
15
+
16
+
17
+ Features Overview
18
+ -----------------
19
+
20
+ * Pure Ruby. No additional dependency on other external tools
21
+ to parse/generate packets.
22
+ * Multi-Platform. Runs on major operating systems (recent Windows,
23
+ Linux, and MacOSX), and supports all major version of Ruby (1.8.7,
24
+ 1.9.3, 2.0.0).
25
+ * Clean Code. Pio is built on
26
+ [BinData](https://github.com/dmendel/bindata)'s declarative binary
27
+ format DSL so that it is easy to read and debug by human beings.
28
+
29
+
30
+ Example
31
+ -------
32
+
33
+ Its usage is dead simple: to parse an LLDP frame for example, use the
34
+ API `Pio::Lldp.read` and you can access each field of the parsed LLDP
35
+ frame.
36
+
37
+ ```ruby
38
+ require "pio"
39
+
40
+ lldp = Pio::Lldp.read( binary_data )
41
+ lldp.ttl #=> 120
42
+ ```
43
+
44
+ Also you can use `Pio::Lldp#new` to generate an LLDP frame like below:
45
+
46
+ ```ruby
47
+ require "pio"
48
+
49
+ lldp = Pio::Lldp.new( 0x123, 12 ) # dpid and port_number
50
+ lldp.to_binary #=> LLDP frame in binary format.
51
+ ```
52
+
53
+
54
+ Installation
55
+ ------------
56
+
57
+ The simplest way to install Pio is to use [Bundler](http://gembundler.com/).
58
+
59
+ Add Pio to your `Gemfile`:
60
+
61
+ ```ruby
62
+ gem 'pio'
63
+ ```
64
+
65
+ and install it by running Bundler:
66
+
67
+ ```bash
68
+ $ bundle
69
+ ```
70
+
71
+
72
+ Documents
73
+ ---------
74
+
75
+ * [API document generated with YARD](http://rubydoc.info/github/trema/pio/frames/file/README.md)
76
+
77
+
78
+ ### Author
79
+
80
+ [Yasuhito Takamiya](https://github.com/yasuhito) ([@yasuhito](http://twitter.com/yasuhito))
81
+
82
+ ### Contributors
83
+
84
+ [https://github.com/trema/pio/contributors](https://github.com/trema/pio/contributors)
85
+
86
+
87
+ Alternatives
88
+ ------------
89
+
90
+ * PacketFu: https://github.com/todb/packetfu
91
+ * Racket: http://spoofed.org/files/racket/
92
+
93
+
94
+ License
95
+ -------
96
+
97
+ Trema is released under the GNU General Public License version 3.0:
98
+
99
+ * http://www.gnu.org/licenses/gpl.html
data/Rakefile CHANGED
@@ -17,22 +17,29 @@
17
17
 
18
18
 
19
19
  require "bundler/gem_tasks"
20
+ require "coveralls/rake/task"
20
21
  require "flay"
21
- require "rake/tasklib"
22
22
  require "flay_task"
23
23
  require "flog"
24
+ require "rake/tasklib"
24
25
  require "reek/rake/task"
25
26
  require "rspec/core"
26
27
  require "rspec/core/rake_task"
28
+ require "yaml"
27
29
  require "yard"
28
30
 
29
31
 
30
32
  $ruby_source = FileList[ "lib/**/*.rb" ]
31
33
 
32
34
 
35
+ task :default => :travis
36
+ task :travis => [ :spec, :quality, "coveralls:push" ]
33
37
  task :quality => [ :reek, :flog, :flay ]
34
38
 
35
39
 
40
+ Coveralls::RakeTask.new
41
+
42
+
36
43
  RSpec::Core::RakeTask.new do | task |
37
44
  task.rspec_opts = "--format documentation --color"
38
45
  end
@@ -51,7 +58,7 @@ desc "Analyze for code complexity"
51
58
  task :flog do
52
59
  flog = Flog.new( :continue => true )
53
60
  flog.flog( *$ruby_source )
54
- threshold = 10
61
+ threshold = 20
55
62
 
56
63
  bad_methods = flog.totals.select do | name, score |
57
64
  ( not ( /##{flog.no_method}$/=~ name ) ) and score > threshold
@@ -82,6 +89,31 @@ YARD::Rake::YardocTask.new do | t |
82
89
  end
83
90
 
84
91
 
92
+ def travis_yml
93
+ File.join File.dirname( __FILE__ ), ".travis.yml"
94
+ end
95
+
96
+
97
+ def rubies
98
+ ( [ "1.8.7" ] + YAML.load_file( travis_yml )[ "rvm" ] ).uniq.sort
99
+ end
100
+
101
+
102
+ desc "Run tests against multiple rubies"
103
+ task :portability
104
+
105
+ rubies.each do | each |
106
+ portability_task_name = "portability:#{ each }"
107
+ task :portability => portability_task_name
108
+
109
+ desc "Run tests against Ruby#{ each }"
110
+ task portability_task_name do
111
+ sh "rvm #{ each } exec bundle"
112
+ sh "rvm #{ each } exec bundle exec rake"
113
+ end
114
+ end
115
+
116
+
85
117
  ### Local variables:
86
118
  ### mode: Ruby
87
119
  ### coding: utf-8-unix
@@ -19,7 +19,7 @@
19
19
  # Base module.
20
20
  module Pio
21
21
  # gem version.
22
- VERSION = "0.1.0"
22
+ VERSION = "0.1.1"
23
23
  end
24
24
 
25
25
 
@@ -21,6 +21,8 @@ Gem::Specification.new do | gem |
21
21
 
22
22
  gem.extra_rdoc_files = [ "README.md" ]
23
23
  gem.test_files = `git ls-files -- {spec,features}/*`.split( "\n" )
24
+
25
+ gem.add_dependency "bindata", "~> 1.6.0"
24
26
  end
25
27
 
26
28
 
@@ -7,7 +7,7 @@ module Pio
7
7
  describe MacAddress do
8
8
  subject { MacAddress.new( "01:80:c2:00:00:0e" ) }
9
9
 
10
- its( :to_binary_s ) { should eq "\001\200\302\000\000\016" }
10
+ its( :to_binary_s ) { should eq [ 0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e ].pack( "C6" ) }
11
11
  end
12
12
  end
13
13
  end
@@ -1,5 +1,8 @@
1
1
  require "rubygems"
2
2
 
3
+ require "simplecov"
4
+ SimpleCov.start
5
+
3
6
  require "rspec"
4
7
  require "rspec/autorun"
5
8
 
@@ -11,6 +14,12 @@ Dir[ "#{ File.dirname( __FILE__ ) }/support/**/*.rb" ].each do | each |
11
14
  end
12
15
 
13
16
 
17
+ if ENV[ "TRAVIS" ]
18
+ require "coveralls"
19
+ Coveralls.wear!
20
+ end
21
+
22
+
14
23
  ### Local variables:
15
24
  ### mode: Ruby
16
25
  ### coding: utf-8-unix
metadata CHANGED
@@ -1,34 +1,39 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pio
3
- version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 0
10
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Yasuhito Takamiya
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-07-31 00:00:00 Z
19
- dependencies: []
20
-
11
+ date: 2013-09-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bindata
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.6.0
21
27
  description: Pure ruby packet parser and generator.
22
- email:
28
+ email:
23
29
  - yasuhito@gmail.com
24
30
  executables: []
25
-
26
31
  extensions: []
27
-
28
- extra_rdoc_files:
32
+ extra_rdoc_files:
29
33
  - README.md
30
- files:
34
+ files:
31
35
  - .gitignore
36
+ - .travis.yml
32
37
  - Gemfile
33
38
  - Guardfile
34
39
  - LICENSE
@@ -59,38 +64,37 @@ files:
59
64
  - spec/pio/lldp_spec.rb
60
65
  - spec/spec_helper.rb
61
66
  homepage: http://github.com/trema/pio
62
- licenses:
67
+ licenses:
63
68
  - GPL3
69
+ metadata: {}
64
70
  post_install_message:
65
71
  rdoc_options: []
66
-
67
- require_paths:
72
+ require_paths:
68
73
  - lib
69
- required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- hash: 3
75
- segments:
76
- - 0
77
- version: "0"
78
- required_rubygems_version: !ruby/object:Gem::Requirement
79
- none: false
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- hash: 3
84
- segments:
85
- - 0
86
- version: "0"
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
87
84
  requirements: []
88
-
89
85
  rubyforge_project:
90
- rubygems_version: 1.8.25
86
+ rubygems_version: 2.0.7
91
87
  signing_key:
92
- specification_version: 3
88
+ specification_version: 4
93
89
  summary: Packet parser and generator.
94
- test_files: []
95
-
90
+ test_files:
91
+ - spec/pio/lldp/chassis-id-tlv_spec.rb
92
+ - spec/pio/lldp/end-of-lldpdu-value_spec.rb
93
+ - spec/pio/lldp/frame_spec.rb
94
+ - spec/pio/lldp/mac-address_spec.rb
95
+ - spec/pio/lldp/optional-tlv_spec.rb
96
+ - spec/pio/lldp/port-id-tlv_spec.rb
97
+ - spec/pio/lldp/ttl-tlv_spec.rb
98
+ - spec/pio/lldp_spec.rb
99
+ - spec/spec_helper.rb
96
100
  has_rdoc: