nilio 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.travis.yml +6 -0
- data/Gemfile +1 -0
- data/MIT-LICENSE +20 -0
- data/README.md +39 -0
- data/lib/nilio.rb +17 -0
- data/nilio.gemspec +17 -0
- data/test/nilio_test.rb +23 -0
- metadata +54 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gemspec
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Morgan Brown
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# NilIO [![Build Status](https://secure.travis-ci.org/discom4rt/nilio.png)](http://travis-ci.org/discom4rt/nilio)
|
2
|
+
|
3
|
+
NilIO emulates a null device
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
gem install nilio
|
8
|
+
|
9
|
+
## Use
|
10
|
+
|
11
|
+
Make sure you got it:
|
12
|
+
|
13
|
+
>> require "nilio"
|
14
|
+
=> true
|
15
|
+
|
16
|
+
Create a NilIO:
|
17
|
+
|
18
|
+
>> null_device = NilIO.new
|
19
|
+
=> #<NilIO: ... >
|
20
|
+
|
21
|
+
Write to it:
|
22
|
+
|
23
|
+
>> null_device.write("It's so nil")
|
24
|
+
=> 11
|
25
|
+
|
26
|
+
Read from it:
|
27
|
+
|
28
|
+
>> null_device.read(1)
|
29
|
+
=>
|
30
|
+
|
31
|
+
It's always EOF:
|
32
|
+
|
33
|
+
>> null_device.eof?
|
34
|
+
=> true
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
data/lib/nilio.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
|
3
|
+
# NilIO emulates a null device (like /dev/null).
|
4
|
+
class NilIO < StringIO
|
5
|
+
|
6
|
+
# Write to the null device. Ignores the
|
7
|
+
# string parameter, just returning its byte length
|
8
|
+
def write(string)
|
9
|
+
string.to_s.bytesize
|
10
|
+
end
|
11
|
+
|
12
|
+
# Read form the null device. Always returns nil.
|
13
|
+
def read(length=nil, buffer=nil)
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/nilio.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "nilio"
|
6
|
+
s.version = "0.0.1"
|
7
|
+
s.authors = "Morgan Brown"
|
8
|
+
s.email = "brown.mhg@gmail.com"
|
9
|
+
s.homepage = "http://github.com/discom4rt/nilio"
|
10
|
+
s.summary = %q{NilIO emulates a null device}
|
11
|
+
s.description = %q{NilIO emulates a null device}
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
end
|
data/test/nilio_test.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'nilio'
|
5
|
+
|
6
|
+
class NilIOTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@null_device = NilIO.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_should_discard_any_data_written
|
12
|
+
@null_device.write("I am writing something")
|
13
|
+
assert_equal @null_device.readlines.length, 0
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_should_provide_no_data_when_read
|
17
|
+
assert_equal @null_device.read(200), nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_should_report_eof
|
21
|
+
assert @null_device.eof?
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nilio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Morgan Brown
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-08 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: NilIO emulates a null device
|
15
|
+
email: brown.mhg@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- .gitignore
|
21
|
+
- .travis.yml
|
22
|
+
- Gemfile
|
23
|
+
- MIT-LICENSE
|
24
|
+
- README.md
|
25
|
+
- lib/nilio.rb
|
26
|
+
- nilio.gemspec
|
27
|
+
- test/nilio_test.rb
|
28
|
+
homepage: http://github.com/discom4rt/nilio
|
29
|
+
licenses: []
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 1.8.21
|
49
|
+
signing_key:
|
50
|
+
specification_version: 3
|
51
|
+
summary: NilIO emulates a null device
|
52
|
+
test_files:
|
53
|
+
- test/nilio_test.rb
|
54
|
+
has_rdoc:
|