rbsrt 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 599cf261c097f42b0af1f6ee17958cb2b86766d52bc5bc19a89cea55b25957ea
4
- data.tar.gz: 2be8be4acc737eec46c0360140a4896c713a5094508b0b5bba41ef1168c38037
3
+ metadata.gz: 0da76924878f6409bea03b2a05c5e97c27e9c070ae628d28b5048570ba0186ca
4
+ data.tar.gz: 8110b5167ea390acc8b6ae80a69cc300e20791e9ddd3ed0bd16a3e9f4fa724ac
5
5
  SHA512:
6
- metadata.gz: d9798f96042f668e129e16e2082cf386e7b77084e772b6c90d0db2b6063f2081fb6e29dc33b57b67e02c38ae3f5b9bab8ea952808ba7663794324434359f2069
7
- data.tar.gz: 37b7bbc0f9e934ab7236993c2adb6b6751bc930d1dbc84aff1c6b2cdb44aa0169d2c90800d9add67dde0f28db8a39e6b91c45f6ae468bf7d558b416ec99e6fe5
6
+ metadata.gz: ec80de0f349a045e02957118dd5cddd49041c96843f485df1f106c615278783462dd48901bcb1fbad2c73362b9fc82527edfca4e1f6cd197d0dd6443fa1af4ea
7
+ data.tar.gz: bbdeda3540c5e88c6ab5c4926bea4d5f70777351fcf2cfe630efcb69ba11c37d792131d0e30cd5a736852891a2b9137bdb84968920d20ec208c4af503a042d9e
data/Rakefile CHANGED
@@ -16,7 +16,10 @@ task :default => :test
16
16
  # sh "make"
17
17
  # end
18
18
 
19
- require 'rake/extensiontask'
19
+ desc "Open an irb session with rbsrt library"
20
+ task :console do
21
+ sh "irb -r ./lib/rbsrt.rb"
22
+ end
20
23
 
21
24
  Rake::ExtensionTask.new 'rbsrt' do |ext|
22
25
  ext.lib_dir = "lib/rbsrt"
@@ -2,24 +2,24 @@ require 'mkmf'
2
2
 
3
3
  extension_name = 'rbsrt/rbsrt'
4
4
 
5
- RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
5
+ # RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
6
6
 
7
- # LIBDIR = CONFIG['libdir']
8
- # INCLUDEDIR = CONFIG['includedir']
7
+ LIBDIR = CONFIG['libdir']
8
+ INCLUDEDIR = CONFIG['includedir']
9
9
 
10
- # HEADER_DIRS = []
11
- # HEADER_DIRS << '/opt/local/include' if File.directory?('/opt/local/include')
12
- # HEADER_DIRS << '/usr/local/include' if File.directory?('/usr/local/include')
13
- # HEADER_DIRS << INCLUDEDIR
14
- # HEADER_DIRS << '/usr/include' if File.directory?('/usr/include')
10
+ HEADER_DIRS = []
11
+ HEADER_DIRS << '/opt/local/include' if File.directory?('/opt/local/include')
12
+ HEADER_DIRS << '/usr/local/include' if File.directory?('/usr/local/include')
13
+ HEADER_DIRS << INCLUDEDIR
14
+ HEADER_DIRS << '/usr/include' if File.directory?('/usr/include')
15
15
 
16
- # LIB_DIRS = []
17
- # LIB_DIRS << '/opt/local/lib' if File.directory?('/opt/local/lib')
18
- # LIB_DIRS << '/usr/local/lib' if File.directory?('/usr/local/lib')
19
- # LIB_DIRS << LIBDIR
20
- # LIB_DIRS << '/usr/lib' if File.directory?('/usr/lib')
16
+ LIB_DIRS = []
17
+ LIB_DIRS << '/opt/local/lib' if File.directory?('/opt/local/lib')
18
+ LIB_DIRS << '/usr/local/lib' if File.directory?('/usr/local/lib')
19
+ LIB_DIRS << LIBDIR
20
+ LIB_DIRS << '/usr/lib' if File.directory?('/usr/lib')
21
21
 
22
- dir_config('srt')
22
+ dir_config('srt', HEADER_DIRS, LIB_DIRS)
23
23
  # dir_config('srt', HEADER_DIRS, LIB_DIRS)
24
24
  # dir_config('c++', HEADER_DIRS, LIB_DIRS)
25
25
 
Binary file
@@ -58,6 +58,23 @@ module SRT
58
58
  streamid + vars.join(",")
59
59
  end
60
60
 
61
+ def to_h
62
+ h = {}
63
+
64
+ @extra.each do |key, value|
65
+ h[key] = value
66
+ end
67
+
68
+ h[:resource_name] = resource_name if resource_name
69
+ h[:user_name] = user_name if user_name
70
+ h[:mode] = mode if mode
71
+ h[:host_name] = host_name if host_name
72
+ h[:type] = type if type
73
+ h[:sessionid] = sessionid if sessionid
74
+
75
+ return h
76
+ end
77
+
61
78
  def method_missing(name, *args)
62
79
  return extra[name.to_s] if extra.key? name.to_s
63
80
  match = name.to_s.match(/^(.*?)(=?)$/)
@@ -1,3 +1,3 @@
1
1
  module SRT
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -277,5 +277,41 @@ describe SRT::StreamIDComponents do
277
277
  s.baz.must_equal "bar"
278
278
  end
279
279
  end
280
+
281
+ describe "#to_h" do
282
+ let(:streamid) { "#!::r=foobar,u=admin,h=stream.recce.nl,s=12345,t=stream,m=publish,foo=bar" }
283
+
284
+ let(:parser) {
285
+ SRT::StreamIDComponents.new(streamid)
286
+ }
287
+
288
+ it "stores the 'r' as the :resource_name" do
289
+ parser.to_h[:resource_name].must_equal "foobar"
290
+ end
291
+
292
+ it "stores the 'u' var to :user_name" do
293
+ parser.to_h[:user_name].must_equal "admin"
294
+ end
295
+
296
+ it "stores the 'm' var to :mode" do
297
+ parser.to_h[:mode].must_equal :publish
298
+ end
299
+
300
+ it "stores the 'h' to :host_name" do
301
+ parser.to_h[:host_name].must_equal "stream.recce.nl"
302
+ end
303
+
304
+ it "stores the 't' var to :type" do
305
+ parser.to_h[:type].must_equal :stream
306
+ end
307
+
308
+ it "stores the 's' var to :sessionid" do
309
+ parser.to_h[:sessionid].must_equal "12345"
310
+ end
311
+
312
+ it "stores extra attributes when available" do
313
+ parser.to_h["foo"].must_equal "bar"
314
+ end
315
+ end
280
316
  end
281
317
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbsrt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Klaas Speller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-20 00:00:00.000000000 Z
11
+ date: 2019-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler