elia 1.0.2 → 1.1.0

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.1.0
@@ -0,0 +1,12 @@
1
+ module ProcessExtensions
2
+ def exist?(pid)
3
+ kill(0, pid) rescue false
4
+ end
5
+ alias exists? exist?
6
+
7
+ def kill!(pid)
8
+ kill('KILL', pid)
9
+ end
10
+ end
11
+
12
+ Process.extend ProcessExtensions
@@ -0,0 +1,12 @@
1
+ module StringNibbles
2
+ def nibbles width = nil
3
+ s = self.unpack('H*').first.scan(/(..)/).flatten
4
+ if width
5
+ s.in_groups_of(width).map { |group| group.join(' ') }
6
+ else
7
+ s.join(' ')
8
+ end
9
+ end
10
+ end
11
+
12
+ String.send :include, StringNibbles
@@ -15,7 +15,7 @@ describe BitFields do
15
15
  field :frame_data_field_status, 'S' do
16
16
  bit_field :secondary_header_flag, 1
17
17
  bit_field :sync_flag, 1
18
- bit_field :packet_order_flag, 1
18
+ bit_field :packet_order, 1
19
19
  bit_field :segment_length_id, 2
20
20
  bit_field :first_header_pointer, 11
21
21
  end
@@ -51,6 +51,7 @@ describe BitFields do
51
51
  it 'should define question mark methods for bit fields of length 1' do
52
52
  @object.should respond_to(:sync_flag?)
53
53
  @object.should respond_to(:sync?)
54
+ @object.should respond_to(:packet_order?)
54
55
  @object.sync_flag?.should == false
55
56
  @object.should respond_to(:secondary_header?)
56
57
  @object.secondary_header?.should == true
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'process_extensions'
3
+
4
+ describe ProcessExtensions do
5
+ it 'should tell if a process exists' do
6
+ begin
7
+ pid = fork { sleep }
8
+ Process.should exist(pid)
9
+ ensure
10
+ Process.kill('KILL', pid)
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'string_nibbles'
3
+
4
+ describe StringNibbles do
5
+ it 'should represent a string as hex nibbles' do
6
+ s = "string"
7
+ s.should respond_to(:nibbles)
8
+ s.nibbles.should == s.unpack('H*').first.scan(/../).flatten.join(' ')
9
+ end
10
+ end
11
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elia
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elia Schito
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-26 00:00:00 +01:00
12
+ date: 2009-12-01 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -39,10 +39,14 @@ files:
39
39
  - lib/bit_fields.rb
40
40
  - lib/elia.rb
41
41
  - lib/path_operator.rb
42
+ - lib/process_extensions.rb
43
+ - lib/string_nibbles.rb
42
44
  - lib/world_logger.rb
43
45
  - spec/lib/bit_fields_spec.rb
44
46
  - spec/lib/elia_spec.rb
45
47
  - spec/lib/path_operator_spec.rb
48
+ - spec/lib/process_extensions_spec.rb
49
+ - spec/lib/string_nibbles_spec.rb
46
50
  - spec/spec.opts
47
51
  - spec/spec_helper.rb
48
52
  has_rdoc: true
@@ -77,4 +81,6 @@ test_files:
77
81
  - spec/lib/bit_fields_spec.rb
78
82
  - spec/lib/elia_spec.rb
79
83
  - spec/lib/path_operator_spec.rb
84
+ - spec/lib/process_extensions_spec.rb
85
+ - spec/lib/string_nibbles_spec.rb
80
86
  - spec/spec_helper.rb